diff --git a/templates/admin.html b/templates/admin.html
index 739ddc0..2feb59d 100644
--- a/templates/admin.html
+++ b/templates/admin.html
@@ -203,8 +203,8 @@
{{ photo.iso }} |
{{ photo.width }}x{{ photo.height }} |
-
-
+
+
|
{% endfor %}
@@ -241,8 +241,11 @@
@@ -335,11 +338,38 @@
}
}
+ document.getElementById('delete-btn').addEventListener('click', deletePhoto);
+ document.getElementById('save-btn').addEventListener('click', saveChanges);
+
+ document.getElementById('profile_image_upload').addEventListener('change', async (e) => {
+ const file = e.target.files[0];
+ if (!file) return;
+
+ const formData = new FormData();
+ formData.append('profile_image', file);
+
+ try {
+ const response = await fetch('/admin/upload_profile', {
+ method: 'POST',
+ body: formData
+ });
+
+ const result = await response.json();
+ if (result.success) {
+ document.getElementById('profile-preview').src = '/static/profile.jpeg?' + new Date().getTime();
+ } else {
+ alert('Error uploading profile image: ' + result.error);
+ }
+ } catch (error) {
+ alert('Error uploading profile image: ' + error);
+ }
+ });
+
document.getElementById('configForm').addEventListener('submit', async (e) => {
e.preventDefault();
const formData = {};
- const inputs = e.target.querySelectorAll('input, textarea');
+ const inputs = e.target.querySelectorAll('input:not([type="file"]), textarea');
inputs.forEach(input => {
formData[input.name] = input.value;