Decodeur commited on
Commit
411f088
·
verified ·
1 Parent(s): 0a183a5

application web de gestion des établissement scolaire secondaire avec toutes les fonctionnalités pour fonctionner en temps réel - Follow Up Deployment

Browse files
Files changed (1) hide show
  1. index.html +206 -7
index.html CHANGED
@@ -6,6 +6,7 @@
6
  <title>EduManage - Gestion des Établissements Scolaires</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
 
9
  <style>
10
  .dashboard-grid {
11
  display: grid;
@@ -123,8 +124,25 @@
123
  <!-- Main Content -->
124
  <div class="p-4 md:p-8">
125
  <header class="mb-8">
126
- <h2 class="text-2xl font-bold text-gray-800">Tableau de bord</h2>
127
- <p class="text-gray-600">Bienvenue dans le système de gestion des établissements scolaires</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  </header>
129
 
130
  <!-- Stats Cards -->
@@ -286,11 +304,23 @@
286
 
287
  <!-- School List -->
288
  <div class="bg-white p-6 rounded-lg shadow">
289
- <div class="flex justify-between items-center mb-4">
290
- <h3 class="text-lg font-semibold">Établissements scolaires</h3>
291
- <button class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition">
292
- <i class="fas fa-plus mr-1"></i> Ajouter
293
- </button>
 
 
 
 
 
 
 
 
 
 
 
 
294
  </div>
295
 
296
  <div class="overflow-x-auto">
@@ -406,6 +436,43 @@
406
  </div>
407
 
408
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  // Mobile menu toggle
410
  const mobileMenuButton = document.getElementById('mobileMenuButton');
411
  const sidebar = document.getElementById('sidebar');
@@ -420,6 +487,138 @@
420
  console.log('Dashboard loaded');
421
  });
422
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
423
  // Sample function to show a notification
424
  function showNotification(message, type = 'info') {
425
  const colors = {
 
6
  <title>EduManage - Gestion des Établissements Scolaires</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <script src="https://cdn.jsdelivr.net/npm/socket.io-client@4.7.2/dist/socket.io.min.js"></script>
10
  <style>
11
  .dashboard-grid {
12
  display: grid;
 
124
  <!-- Main Content -->
125
  <div class="p-4 md:p-8">
126
  <header class="mb-8">
127
+ <div class="flex justify-between items-start">
128
+ <div>
129
+ <h2 class="text-2xl font-bold text-gray-800">Tableau de bord</h2>
130
+ <p class="text-gray-600">Bienvenue dans le système de gestion des établissements scolaires</p>
131
+ </div>
132
+ <div class="flex items-center">
133
+ <div id="connectionStatus" class="flex items-center mr-4">
134
+ <span class="relative flex h-3 w-3 mr-2">
135
+ <span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-gray-400 opacity-75"></span>
136
+ <span class="relative inline-flex rounded-full h-3 w-3 bg-gray-500"></span>
137
+ </span>
138
+ <span class="text-sm text-gray-600">Connexion...</span>
139
+ </div>
140
+ <div id="notificationBell" class="relative cursor-pointer text-gray-500 hover:text-blue-600">
141
+ <i class="fas fa-bell text-xl"></i>
142
+ <span id="notificationCount" class="absolute -top-2 -right-2 bg-red-500 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center hidden">0</span>
143
+ </div>
144
+ </div>
145
+ </div>
146
  </header>
147
 
148
  <!-- Stats Cards -->
 
304
 
305
  <!-- School List -->
306
  <div class="bg-white p-6 rounded-lg shadow">
307
+ <div class="flex flex-col md:flex-row md:justify-between md:items-center mb-4 gap-4">
308
+ <h3 class="text-lg font-semibold">Établissements secondaires</h3>
309
+ <div class="flex flex-col sm:flex-row gap-3 w-full md:w-auto">
310
+ <div class="relative flex-grow">
311
+ <input type="text" id="schoolSearch" placeholder="Rechercher un établissement..." class="w-full pl-10 pr-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
312
+ <i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
313
+ </div>
314
+ <select id="schoolTypeFilter" class="border rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
315
+ <option value="all">Tous les types</option>
316
+ <option value="lycee">Lycée</option>
317
+ <option value="college">Collège</option>
318
+ <option value="lycee_pro">Lycée Professionnel</option>
319
+ </select>
320
+ <button id="addSchoolBtn" class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition whitespace-nowrap">
321
+ <i class="fas fa-plus mr-1"></i> Ajouter
322
+ </button>
323
+ </div>
324
  </div>
325
 
326
  <div class="overflow-x-auto">
 
436
  </div>
437
 
438
  <script>
439
+ // Connexion WebSocket
440
+ const socket = io('https://votre-serveur-socket.io', {
441
+ reconnectionAttempts: 5,
442
+ reconnectionDelay: 1000,
443
+ transports: ['websocket']
444
+ });
445
+
446
+ // Gestion de la connexion temps réel
447
+ socket.on('connect', () => {
448
+ updateConnectionStatus('connected', 'Connecté en temps réel');
449
+ });
450
+
451
+ socket.on('disconnect', () => {
452
+ updateConnectionStatus('disconnected', 'Déconnecté - Tentative de reconnexion...');
453
+ });
454
+
455
+ socket.on('connect_error', () => {
456
+ updateConnectionStatus('error', 'Erreur de connexion');
457
+ });
458
+
459
+ function updateConnectionStatus(status, message) {
460
+ const statusElement = document.getElementById('connectionStatus');
461
+ const dot = statusElement.querySelector('span:first-child span:last-child');
462
+
463
+ statusElement.querySelector('span:last-child').textContent = message;
464
+
465
+ dot.className = 'relative inline-flex rounded-full h-3 w-3 ' +
466
+ (status === 'connected' ? 'bg-green-500' :
467
+ status === 'disconnected' ? 'bg-yellow-500' : 'bg-red-500');
468
+ }
469
+
470
+ // Écoute des mises à jour des établissements
471
+ socket.on('schoolUpdate', (data) => {
472
+ showNotification(`Mise à jour: ${data.message}`, 'info');
473
+ refreshSchoolList();
474
+ });
475
+
476
  // Mobile menu toggle
477
  const mobileMenuButton = document.getElementById('mobileMenuButton');
478
  const sidebar = document.getElementById('sidebar');
 
487
  console.log('Dashboard loaded');
488
  });
489
 
490
+ // Gestion des établissements
491
+ async function refreshSchoolList() {
492
+ try {
493
+ const response = await fetch('/api/schools');
494
+ const schools = await response.json();
495
+ renderSchoolList(schools);
496
+ } catch (error) {
497
+ console.error('Erreur lors du chargement des établissements:', error);
498
+ showNotification('Erreur de chargement des établissements', 'error');
499
+ }
500
+ }
501
+
502
+ function renderSchoolList(schools) {
503
+ const tableBody = document.querySelector('tbody');
504
+ tableBody.innerHTML = schools.map(school => `
505
+ <tr data-school-id="${school.id}" data-type="${school.type}">
506
+ <td class="px-6 py-4 whitespace-nowrap">
507
+ <div class="flex items-center">
508
+ <div class="flex-shrink-0 h-10 w-10 ${getSchoolColorClass(school.type)} rounded-full flex items-center justify-center">
509
+ <i class="fas fa-school"></i>
510
+ </div>
511
+ <div class="ml-4">
512
+ <div class="text-sm font-medium text-gray-900">${school.name}</div>
513
+ <div class="text-sm text-gray-500">Code: ${school.code}</div>
514
+ </div>
515
+ </div>
516
+ </td>
517
+ <td class="px-6 py-4 whitespace-nowrap">
518
+ <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${getSchoolBadgeClass(school.type)}">
519
+ ${getSchoolTypeLabel(school.type)}
520
+ </span>
521
+ </td>
522
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${school.location}</td>
523
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${school.studentsCount}</td>
524
+ <td class="px-6 py-4 whitespace-nowrap">
525
+ <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${getStatusClass(school.status)}">
526
+ ${school.status}
527
+ </span>
528
+ </td>
529
+ <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
530
+ <button onclick="viewSchool('${school.id}')" class="text-blue-600 hover:text-blue-900 mr-3"><i class="fas fa-eye"></i></button>
531
+ <button onclick="editSchool('${school.id}')" class="text-yellow-600 hover:text-yellow-900 mr-3"><i class="fas fa-edit"></i></button>
532
+ <button onclick="deleteSchool('${school.id}')" class="text-red-600 hover:text-red-900"><i class="fas fa-trash"></i></button>
533
+ </td>
534
+ </tr>
535
+ `).join('');
536
+ }
537
+
538
+ function getSchoolColorClass(type) {
539
+ return {
540
+ 'lycee': 'bg-blue-100 text-blue-600',
541
+ 'college': 'bg-green-100 text-green-600',
542
+ 'lycee_pro': 'bg-purple-100 text-purple-600'
543
+ }[type] || 'bg-gray-100 text-gray-600';
544
+ }
545
+
546
+ function getSchoolBadgeClass(type) {
547
+ return {
548
+ 'lycee': 'bg-blue-100 text-blue-800',
549
+ 'college': 'bg-green-100 text-green-800',
550
+ 'lycee_pro': 'bg-purple-100 text-purple-800'
551
+ }[type] || 'bg-gray-100 text-gray-800';
552
+ }
553
+
554
+ function getSchoolTypeLabel(type) {
555
+ return {
556
+ 'lycee': 'Lycée',
557
+ 'college': 'Collège',
558
+ 'lycee_pro': 'Lycée Pro'
559
+ }[type] || type;
560
+ }
561
+
562
+ function getStatusClass(status) {
563
+ return {
564
+ 'Actif': 'bg-green-100 text-green-800',
565
+ 'Maintenance': 'bg-yellow-100 text-yellow-800',
566
+ 'Inactif': 'bg-red-100 text-red-800'
567
+ }[status] || 'bg-gray-100 text-gray-800';
568
+ }
569
+
570
+ // Fonctions de gestion
571
+ function viewSchool(id) {
572
+ console.log('Voir établissement:', id);
573
+ // Implémentez la logique d'affichage
574
+ }
575
+
576
+ function editSchool(id) {
577
+ console.log('Modifier établissement:', id);
578
+ // Implémentez la logique d'édition
579
+ }
580
+
581
+ async function deleteSchool(id) {
582
+ if (confirm('Êtes-vous sûr de vouloir supprimer cet établissement ?')) {
583
+ try {
584
+ const response = await fetch(`/api/schools/${id}`, { method: 'DELETE' });
585
+ if (response.ok) {
586
+ showNotification('Établissement supprimé avec succès', 'success');
587
+ refreshSchoolList();
588
+ }
589
+ } catch (error) {
590
+ console.error('Erreur lors de la suppression:', error);
591
+ showNotification('Erreur lors de la suppression', 'error');
592
+ }
593
+ }
594
+ }
595
+
596
+ // Initialisation
597
+ document.addEventListener('DOMContentLoaded', () => {
598
+ refreshSchoolList();
599
+
600
+ // Filtre de recherche
601
+ document.getElementById('schoolSearch').addEventListener('input', (e) => {
602
+ const searchTerm = e.target.value.toLowerCase();
603
+ document.querySelectorAll('tbody tr').forEach(row => {
604
+ const schoolName = row.querySelector('td:first-child div:first-child div:first-child').textContent.toLowerCase();
605
+ row.style.display = schoolName.includes(searchTerm) ? '' : 'none';
606
+ });
607
+ });
608
+
609
+ // Filtre par type
610
+ document.getElementById('schoolTypeFilter').addEventListener('change', (e) => {
611
+ const type = e.target.value;
612
+ document.querySelectorAll('tbody tr').forEach(row => {
613
+ if (type === 'all') {
614
+ row.style.display = '';
615
+ } else {
616
+ row.style.display = row.dataset.type === type ? '' : 'none';
617
+ }
618
+ });
619
+ });
620
+ });
621
+
622
  // Sample function to show a notification
623
  function showNotification(message, type = 'info') {
624
  const colors = {