-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_employee.html
More file actions
65 lines (59 loc) · 2.33 KB
/
edit_employee.html
File metadata and controls
65 lines (59 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{% extends "base.html" %}
{% block content %}
<div class="card">
<h2 style="text-align: center; margin-bottom: 30px;">✏️ Edit {{ employee_name }}</h2>
<div style="margin-bottom: 30px;">
<h3>Photos</h3>
<div id="photos-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; margin-top: 20px;">
Loading photos...
</div>
</div>
<div style="text-align: center;">
<a href="/employees" class="btn">← Back to Employees</a>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
const employeeName = "{{ employee_name }}";
function loadPhotos() {
fetch('/api/employees')
.then(r => r.json())
.then(data => {
if (data.success) {
const employee = data.employees.find(emp => emp.name === employeeName);
if (employee && employee.images) {
let html = '';
employee.images.forEach(image => {
html += `
<div style="text-align: center; border: 1px solid #ddd; border-radius: 8px; padding: 10px;">
<img src="/api/employee_photo/${employeeName}/${image}"
style="width: 100%; height: 120px; object-fit: cover; border-radius: 8px; margin-bottom: 10px;">
<button class="btn btn-danger" style="font-size: 12px; padding: 6px 12px;"
onclick="deletePhoto('${image}')">🗑️ Delete</button>
</div>
`;
});
document.getElementById('photos-grid').innerHTML = html;
} else {
document.getElementById('photos-grid').innerHTML = '<p>No photos found</p>';
}
}
});
}
function deletePhoto(filename) {
if (confirm('Delete this photo?')) {
fetch(`/api/delete_employee_photo/${employeeName}/${filename}`, { method: 'DELETE' })
.then(r => r.json())
.then(data => {
if (data.success) {
loadPhotos();
} else {
alert('Error: ' + data.message);
}
});
}
}
loadPhotos();
</script>
{% endblock %}