EHDEM commited on
Commit
ecfb4d2
·
verified ·
1 Parent(s): 85c23b9

add another part in admin dashboard which is to add and remove students, make it when i pick the form and class and put in the students name it will be entered into the name list database. for remove student, make it when i pick form and class and the students name based on the name list in the attendence forms it will remove the students name in the list, add a part to remove or add classes. and lastly add something to entirly change the schools students list be entering a file

Browse files
Files changed (1) hide show
  1. admin-dashboard.html +302 -3
admin-dashboard.html CHANGED
@@ -5,8 +5,202 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>WASTE-LESS - Admin Dashboard</title>
7
  <link rel="stylesheet" href="style.css">
8
- <script src="https://cdn.tailwindcss.com"></script>
9
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
11
  </head>
12
  <body class="bg-gray-100 min-h-screen">
@@ -128,8 +322,113 @@
128
  </div>
129
  </div>
130
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  <!-- Charts and Recent Activity -->
132
- <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
133
  <!-- Attendance Trend -->
134
  <div class="bg-white rounded-lg shadow-md p-6">
135
  <h2 class="text-xl font-semibold mb-4 text-gray-800">Attendance Trend</h2>
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>WASTE-LESS - Admin Dashboard</title>
7
  <link rel="stylesheet" href="style.css">
8
+ <script src="https://cdn.tailwindcss.com">
9
+ </script>
10
+ <script>
11
+ // Student Management Functions
12
+ function showManagementMessage(message, isSuccess = true) {
13
+ const element = isSuccess ?
14
+ document.getElementById('management-success') :
15
+ document.getElementById('management-error');
16
+
17
+ element.textContent = message;
18
+ element.classList.remove('hidden');
19
+
20
+ setTimeout(() => {
21
+ element.classList.add('hidden');
22
+ }, 3000);
23
+ }
24
+
25
+ // Load students for removal dropdown
26
+ function loadStudentsForRemoval() {
27
+ const classVal = document.getElementById('remove-class-select').value;
28
+ const formVal = document.getElementById('remove-form-select').value;
29
+ const studentSelect = document.getElementById('student-to-remove');
30
+
31
+ studentSelect.innerHTML = '<option value="">Select Student</option>';
32
+ studentSelect.disabled = true;
33
+
34
+ if (classVal && formVal) {
35
+ const key = `${classVal}-${formVal}`;
36
+ if (students[key] && students[key].length > 0) {
37
+ students[key].forEach(student => {
38
+ const option = document.createElement('option');
39
+ option.value = student;
40
+ option.textContent = student;
41
+ studentSelect.appendChild(option);
42
+ });
43
+ studentSelect.disabled = false;
44
+ }
45
+ }
46
+ }
47
+
48
+ // Add student
49
+ document.getElementById('add-student-btn').addEventListener('click', function() {
50
+ const classVal = document.getElementById('add-class-select').value;
51
+ const formVal = document.getElementById('add-form-select').value;
52
+ const studentName = document.getElementById('new-student-name').value.trim();
53
+
54
+ if (!classVal || !formVal || !studentName) {
55
+ showManagementMessage('Please fill all fields', false);
56
+ return;
57
+ }
58
+
59
+ const key = `${classVal}-${formVal}`;
60
+ if (!students[key]) {
61
+ students[key] = [];
62
+ }
63
+
64
+ if (students[key].includes(studentName)) {
65
+ showManagementMessage('Student already exists', false);
66
+ return;
67
+ }
68
+
69
+ students[key].push(studentName);
70
+ localStorage.setItem('studentData', JSON.stringify(students));
71
+
72
+ document.getElementById('new-student-name').value = '';
73
+ showManagementMessage('Student added successfully!');
74
+ });
75
+
76
+ // Remove student
77
+ document.getElementById('remove-student-btn').addEventListener('click', function() {
78
+ const classVal = document.getElementById('remove-class-select').value;
79
+ const formVal = document.getElementById('remove-form-select').value;
80
+ const studentName = document.getElementById('student-to-remove').value;
81
+
82
+ if (!classVal || !formVal || !studentName) {
83
+ showManagementMessage('Please select all fields', false);
84
+ return;
85
+ }
86
+
87
+ const key = `${classVal}-${formVal}`;
88
+ if (students[key]) {
89
+ students[key] = students[key].filter(name => name !== studentName);
90
+ localStorage.setItem('studentData', JSON.stringify(students));
91
+
92
+ loadStudentsForRemoval();
93
+ showManagementMessage('Student removed successfully!');
94
+ }
95
+ });
96
+
97
+ // Add class
98
+ document.getElementById('add-class-btn').addEventListener('click', function() {
99
+ const className = document.getElementById('new-class-name').value.trim().toUpperCase();
100
+
101
+ if (!className) {
102
+ showManagementMessage('Please enter a class name', false);
103
+ return;
104
+ }
105
+
106
+ if (['BUDI', 'USAHA', 'MAJU', 'JAYA'].includes(className)) {
107
+ showManagementMessage('Class already exists', false);
108
+ return;
109
+ }
110
+
111
+ // Add to class dropdowns
112
+ const classSelects = [
113
+ document.getElementById('add-class-select'),
114
+ document.getElementById('remove-class-select'),
115
+ document.getElementById('class-to-remove')
116
+ ];
117
+
118
+ classSelects.forEach(select => {
119
+ const option = document.createElement('option');
120
+ option.value = className;
121
+ option.textContent = className;
122
+ select.appendChild(option);
123
+ });
124
+
125
+ document.getElementById('new-class-name').value = '';
126
+ showManagementMessage('Class added successfully!');
127
+ });
128
+
129
+ // Remove class
130
+ document.getElementById('remove-class-btn').addEventListener('click', function() {
131
+ const className = document.getElementById('class-to-remove').value;
132
+
133
+ if (!className) {
134
+ showManagementMessage('Please select a class', false);
135
+ return;
136
+ }
137
+
138
+ // Remove from dropdowns
139
+ document.querySelectorAll(`option[value="${className}"]`).forEach(option => {
140
+ option.remove();
141
+ });
142
+
143
+ // Remove student data for this class
144
+ for (const key in students) {
145
+ if (key.startsWith(className)) {
146
+ delete students[key];
147
+ }
148
+ }
149
+
150
+ localStorage.setItem('studentData', JSON.stringify(students));
151
+ showManagementMessage('Class removed successfully!');
152
+ });
153
+
154
+ // Bulk import students from CSV
155
+ document.getElementById('import-btn').addEventListener('click', function() {
156
+ const fileInput = document.getElementById('student-csv');
157
+ const file = fileInput.files[0];
158
+
159
+ if (!file) {
160
+ showManagementMessage('Please select a file', false);
161
+ return;
162
+ }
163
+
164
+ const reader = new FileReader();
165
+ reader.onload = function(e) {
166
+ const content = e.target.result;
167
+ const lines = content.split('\n');
168
+
169
+ let imported = 0;
170
+ let skipped = 0;
171
+
172
+ lines.forEach(line => {
173
+ if (!line.trim()) return;
174
+
175
+ const [classVal, formVal, ...nameParts] = line.split(',');
176
+ const studentName = nameParts.join(',').trim();
177
+
178
+ if (!classVal || !formVal || !studentName) {
179
+ skipped++;
180
+ return;
181
+ }
182
+
183
+ const key = `${classVal.trim().toUpperCase()}-${formVal.trim()}`;
184
+ if (!students[key]) {
185
+ students[key] = [];
186
+ }
187
+
188
+ if (!students[key].includes(studentName)) {
189
+ students[key].push(studentName);
190
+ imported++;
191
+ } else {
192
+ skipped++;
193
+ }
194
+ });
195
+
196
+ localStorage.setItem('studentData', JSON.stringify(students));
197
+ showManagementMessage(`Imported ${imported} students (${skipped} skipped)`);
198
+ fileInput.value = '';
199
+ };
200
+
201
+ reader.readAsText(file);
202
+ });
203
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
204
  <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
205
  </head>
206
  <body class="bg-gray-100 min-h-screen">
 
322
  </div>
323
  </div>
324
  </div>
325
+ <!-- Student Management Section -->
326
+ <div class="bg-white rounded-lg shadow-md p-6 mb-8">
327
+ <h2 class="text-xl font-semibold mb-4 text-gray-800">Student Management</h2>
328
+
329
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
330
+ <!-- Add Student -->
331
+ <div class="bg-gray-50 p-4 rounded-lg">
332
+ <h3 class="text-lg font-medium mb-3">Add Student</h3>
333
+ <div class="space-y-3">
334
+ <select id="add-class-select" class="w-full px-3 py-2 border rounded">
335
+ <option value="">Select Class</option>
336
+ <option value="BUDI">BUDI</option>
337
+ <option value="USAHA">USAHA</option>
338
+ <option value="MAJU">MAJU</option>
339
+ <option value="JAYA">JAYA</option>
340
+ </select>
341
+ <select id="add-form-select" class="w-full px-3 py-2 border rounded">
342
+ <option value="">Select Form</option>
343
+ <option value="1">Form 1</option>
344
+ <option value="2">Form 2</option>
345
+ <option value="3">Form 3</option>
346
+ <option value="4">Form 4</option>
347
+ <option value="5">Form 5</option>
348
+ </select>
349
+ <input type="text" id="new-student-name" placeholder="Student Full Name" class="w-full px-3 py-2 border rounded">
350
+ <button id="add-student-btn" class="w-full bg-green-600 hover:bg-green-700 text-white py-2 rounded">
351
+ Add Student
352
+ </button>
353
+ </div>
354
+ </div>
355
+
356
+ <!-- Remove Student -->
357
+ <div class="bg-gray-50 p-4 rounded-lg">
358
+ <h3 class="text-lg font-medium mb-3">Remove Student</h3>
359
+ <div class="space-y-3">
360
+ <select id="remove-class-select" class="w-full px-3 py-2 border rounded" onchange="loadStudentsForRemoval()">
361
+ <option value="">Select Class</option>
362
+ <option value="BUDI">BUDI</option>
363
+ <option value="USAHA">USAHA</option>
364
+ <option value="MAJU">MAJU</option>
365
+ <option value="JAYA">JAYA</option>
366
+ </select>
367
+ <select id="remove-form-select" class="w-full px-3 py-2 border rounded" onchange="loadStudentsForRemoval()">
368
+ <option value="">Select Form</option>
369
+ <option value="1">Form 1</option>
370
+ <option value="2">Form 2</option>
371
+ <option value="3">Form 3</option>
372
+ <option value="4">Form 4</option>
373
+ <option value="5">Form 5</option>
374
+ </select>
375
+ <select id="student-to-remove" class="w-full px-3 py-2 border rounded" disabled>
376
+ <option value="">Select Student</option>
377
+ </select>
378
+ <button id="remove-student-btn" class="w-full bg-red-600 hover:bg-red-700 text-white py-2 rounded">
379
+ Remove Student
380
+ </button>
381
+ </div>
382
+ </div>
383
+
384
+ <!-- Bulk Import -->
385
+ <div class="bg-gray-50 p-4 rounded-lg">
386
+ <h3 class="text-lg font-medium mb-3">Bulk Import</h3>
387
+ <div class="space-y-3">
388
+ <input type="file" id="student-csv" accept=".csv" class="w-full">
389
+ <button id="import-btn" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 rounded">
390
+ Import Students
391
+ </button>
392
+ <p class="text-xs text-gray-500">CSV format: Class,Form,StudentName (one per line)</p>
393
+ </div>
394
+ </div>
395
+ </div>
396
+
397
+ <!-- Add/Remove Class -->
398
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
399
+ <div class="bg-gray-50 p-4 rounded-lg">
400
+ <h3 class="text-lg font-medium mb-3">Add Class</h3>
401
+ <div class="flex space-x-2">
402
+ <input type="text" id="new-class-name" placeholder="New Class Name" class="flex-1 px-3 py-2 border rounded">
403
+ <button id="add-class-btn" class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded">
404
+ Add
405
+ </button>
406
+ </div>
407
+ </div>
408
+ <div class="bg-gray-50 p-4 rounded-lg">
409
+ <h3 class="text-lg font-medium mb-3">Remove Class</h3>
410
+ <div class="flex space-x-2">
411
+ <select id="class-to-remove" class="flex-1 px-3 py-2 border rounded">
412
+ <option value="">Select Class</option>
413
+ <option value="BUDI">BUDI</option>
414
+ <option value="USAHA">USAHA</option>
415
+ <option value="MAJU">MAJU</option>
416
+ <option value="JAYA">JAYA</option>
417
+ </select>
418
+ <button id="remove-class-btn" class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded">
419
+ Remove
420
+ </button>
421
+ </div>
422
+ </div>
423
+ </div>
424
+ </div>
425
+
426
+ <!-- Management Messages -->
427
+ <div id="management-success" class="hidden fixed top-4 right-4 bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded"></div>
428
+ <div id="management-error" class="hidden fixed top-4 right-4 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded"></div>
429
+
430
  <!-- Charts and Recent Activity -->
431
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
432
  <!-- Attendance Trend -->
433
  <div class="bg-white rounded-lg shadow-md p-6">
434
  <h2 class="text-xl font-semibold mb-4 text-gray-800">Attendance Trend</h2>