File size: 29,535 Bytes
424e972
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Centre de Gestion - Admin</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js" defer></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: {
                            50: '#eff6ff',
                            500: '#3b82f6',
                            600: '#2563eb',
                            700: '#1d4ed8',
                        }
                    }
                }
            }
        }
    </script>
</head>
<body class="bg-gray-50 min-h-screen">
    <div x-data="adminApp()" class="min-h-screen">
        <!-- Header -->
        <header class="bg-white shadow-sm border-b border-gray-200">
            <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
                <div class="flex justify-between items-center h-16">
                    <div class="flex items-center">
                        <i class="fas fa-cogs text-primary-600 text-2xl mr-3"></i>
                        <h1 class="text-xl font-semibold text-gray-900">Centre de Gestion</h1>
                    </div>
                    <div class="flex items-center space-x-4">
                        <button @click="refreshData()" 
                                class="inline-flex items-center px-3 py-2 border border-gray-300 shadow-sm text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
                            <i class="fas fa-sync-alt mr-2" :class="{'animate-spin': loading}"></i>
                            Actualiser
                        </button>
                        <a href="/" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
                            <i class="fas fa-home mr-2"></i>
                            Retour à l'accueil
                        </a>
                    </div>
                </div>
            </div>
        </header>

        <!-- Dashboard Stats -->
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
                <!-- Total Tasks -->
                <div class="bg-white overflow-hidden shadow rounded-lg">
                    <div class="p-5">
                        <div class="flex items-center">
                            <div class="flex-shrink-0">
                                <i class="fas fa-tasks text-primary-600 text-2xl"></i>
                            </div>
                            <div class="ml-5 w-0 flex-1">
                                <dl>
                                    <dt class="text-sm font-medium text-gray-500 truncate">Total des tâches</dt>
                                    <dd class="text-lg font-medium text-gray-900" x-text="stats.total_tasks"></dd>
                                </dl>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Completed Tasks -->
                <div class="bg-white overflow-hidden shadow rounded-lg">
                    <div class="p-5">
                        <div class="flex items-center">
                            <div class="flex-shrink-0">
                                <i class="fas fa-check-circle text-green-600 text-2xl"></i>
                            </div>
                            <div class="ml-5 w-0 flex-1">
                                <dl>
                                    <dt class="text-sm font-medium text-gray-500 truncate">Tâches terminées</dt>
                                    <dd class="text-lg font-medium text-gray-900" x-text="stats.completed_tasks"></dd>
                                </dl>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Error Tasks -->
                <div class="bg-white overflow-hidden shadow rounded-lg">
                    <div class="p-5">
                        <div class="flex items-center">
                            <div class="flex-shrink-0">
                                <i class="fas fa-exclamation-triangle text-red-600 text-2xl"></i>
                            </div>
                            <div class="ml-5 w-0 flex-1">
                                <dl>
                                    <dt class="text-sm font-medium text-gray-500 truncate">Tâches en erreur</dt>
                                    <dd class="text-lg font-medium text-gray-900" x-text="stats.error_tasks"></dd>
                                </dl>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- PDF Files -->
                <div class="bg-white overflow-hidden shadow rounded-lg">
                    <div class="p-5">
                        <div class="flex items-center">
                            <div class="flex-shrink-0">
                                <i class="fas fa-file-pdf text-red-600 text-2xl"></i>
                            </div>
                            <div class="ml-5 w-0 flex-1">
                                <dl>
                                    <dt class="text-sm font-medium text-gray-500 truncate">Fichiers PDF</dt>
                                    <dd class="text-lg font-medium text-gray-900" x-text="stats.pdf_files"></dd>
                                </dl>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- System Status -->
            <div class="bg-white shadow rounded-lg mb-8">
                <div class="px-4 py-5 sm:p-6">
                    <h3 class="text-lg leading-6 font-medium text-gray-900 mb-4">
                        <i class="fas fa-server mr-2"></i>
                        État du système
                    </h3>
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                        <div class="flex items-center">
                            <div class="flex-shrink-0">
                                <div class="w-3 h-3 rounded-full" :class="stats.latex_installed ? 'bg-green-400' : 'bg-red-400'"></div>
                            </div>
                            <div class="ml-3">
                                <p class="text-sm font-medium text-gray-900">LaTeX</p>
                                <p class="text-sm text-gray-500" x-text="stats.latex_installed ? 'Installé' : 'Non installé'"></p>
                            </div>
                        </div>
                        <div class="flex items-center">
                            <div class="flex-shrink-0">
                                <i class="fas fa-images text-blue-600"></i>
                            </div>
                            <div class="ml-3">
                                <p class="text-sm font-medium text-gray-900">Images utilisateur</p>
                                <p class="text-sm text-gray-500" x-text="stats.user_images + ' fichiers'"></p>
                            </div>
                        </div>
                        <div class="flex items-center">
                            <div class="flex-shrink-0">
                                <i class="fas fa-clock text-yellow-600"></i>
                            </div>
                            <div class="ml-3">
                                <p class="text-sm font-medium text-gray-900">Tâches en cours</p>
                                <p class="text-sm text-gray-500" x-text="stats.pending_tasks + ' actives'"></p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Tasks Table -->
            <div class="bg-white shadow rounded-lg">
                <div class="px-4 py-5 sm:p-6">
                    <div class="flex justify-between items-center mb-4">
                        <h3 class="text-lg leading-6 font-medium text-gray-900">
                            <i class="fas fa-list mr-2"></i>
                            Gestion des tâches
                        </h3>
                        <div class="flex items-center space-x-2">
                            <select x-model="statusFilter" class="block w-40 pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm rounded-md">
                                <option value="">Tous les statuts</option>
                                <option value="completed">Terminées</option>
                                <option value="error">En erreur</option>
                                <option value="processing">En cours</option>
                                <option value="pending">En attente</option>
                            </select>
                        </div>
                    </div>

                    <!-- Loading state -->
                    <div x-show="loading" class="flex justify-center items-center py-8">
                        <div class="animate-spin rounded-full h-8 w-8 border-b-2 border-primary-600"></div>
                        <span class="ml-2 text-gray-600">Chargement...</span>
                    </div>

                    <!-- Tasks table -->
                    <div x-show="!loading" class="overflow-hidden">
                        <template x-if="filteredTasks.length === 0">
                            <div class="text-center py-8">
                                <i class="fas fa-inbox text-gray-400 text-4xl mb-4"></i>
                                <p class="text-gray-500">Aucune tâche trouvée</p>
                            </div>
                        </template>

                        <div x-show="filteredTasks.length > 0" class="overflow-x-auto">
                            <table class="min-w-full divide-y divide-gray-200">
                                <thead class="bg-gray-50">
                                    <tr>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                            Tâche
                                        </th>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                            Statut
                                        </th>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                            Style
                                        </th>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                            Fichiers
                                        </th>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                            Date
                                        </th>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                            Actions
                                        </th>
                                    </tr>
                                </thead>
                                <tbody class="bg-white divide-y divide-gray-200">
                                    <template x-for="task in filteredTasks" :key="task.id">
                                        <tr class="hover:bg-gray-50">
                                            <td class="px-6 py-4 whitespace-nowrap">
                                                <div class="flex items-center">
                                                    <div class="flex-shrink-0 h-10 w-10">
                                                        <div class="h-10 w-10 rounded-full bg-gray-300 flex items-center justify-center">
                                                            <i class="fas fa-file-alt text-gray-600"></i>
                                                        </div>
                                                    </div>
                                                    <div class="ml-4">
                                                        <div class="text-sm font-medium text-gray-900" x-text="task.id.substring(0, 8) + '...'"></div>
                                                        <div class="text-sm text-gray-500" x-text="task.first_filename"></div>
                                                    </div>
                                                </div>
                                            </td>
                                            <td class="px-6 py-4 whitespace-nowrap">
                                                <span class="inline-flex px-2 py-1 text-xs font-semibold rounded-full"
                                                      :class="{
                                                          'bg-green-100 text-green-800': task.status === 'completed',
                                                          'bg-red-100 text-red-800': task.status === 'error',
                                                          'bg-yellow-100 text-yellow-800': task.status === 'processing',
                                                          'bg-gray-100 text-gray-800': task.status === 'pending'
                                                      }">
                                                    <template x-if="task.status === 'completed'">
                                                        <span><i class="fas fa-check mr-1"></i>Terminée</span>
                                                    </template>
                                                    <template x-if="task.status === 'error'">
                                                        <span><i class="fas fa-exclamation-triangle mr-1"></i>Erreur</span>
                                                    </template>
                                                    <template x-if="task.status === 'processing'">
                                                        <span><i class="fas fa-spinner fa-spin mr-1"></i>En cours</span>
                                                    </template>
                                                    <template x-if="task.status === 'pending'">
                                                        <span><i class="fas fa-clock mr-1"></i>En attente</span>
                                                    </template>
                                                </span>
                                            </td>
                                            <td class="px-6 py-4 whitespace-nowrap">
                                                <span class="inline-flex px-2 py-1 text-xs font-medium rounded-md"
                                                      :class="{
                                                          'bg-purple-100 text-purple-800': task.style === 'colorful',
                                                          'bg-blue-100 text-blue-800': task.style === 'light'
                                                      }"
                                                      x-text="task.style === 'colorful' ? 'Coloré' : 'Léger'">
                                                </span>
                                            </td>
                                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
                                                <div class="flex items-center space-x-2">
                                                    <span x-show="task.file_count.images > 0" class="inline-flex items-center px-2 py-1 rounded-md text-xs font-medium bg-blue-100 text-blue-800">
                                                        <i class="fas fa-image mr-1"></i>
                                                        <span x-text="task.file_count.images"></span>
                                                    </span>
                                                    <span x-show="task.file_count.pdfs > 0" class="inline-flex items-center px-2 py-1 rounded-md text-xs font-medium bg-red-100 text-red-800">
                                                        <i class="fas fa-file-pdf mr-1"></i>
                                                        <span x-text="task.file_count.pdfs"></span>
                                                    </span>
                                                </div>
                                            </td>
                                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                                                <span x-text="task.time_started_formatted"></span>
                                            </td>
                                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                                                <div class="flex items-center space-x-2">
                                                    <template x-if="task.status === 'completed' && task.pdf_filename">
                                                        <a :href="'/download/' + task.id" 
                                                           class="text-primary-600 hover:text-primary-900 flex items-center">
                                                            <i class="fas fa-download mr-1"></i>
                                                            PDF
                                                        </a>
                                                    </template>
                                                    <button @click="showTaskDetails(task)" 
                                                            class="text-indigo-600 hover:text-indigo-900 flex items-center">
                                                        <i class="fas fa-eye mr-1"></i>
                                                        Détails
                                                    </button>
                                                    <button @click="deleteTask(task.id)" 
                                                            class="text-red-600 hover:text-red-900 flex items-center">
                                                        <i class="fas fa-trash mr-1"></i>
                                                        Supprimer
                                                    </button>
                                                </div>
                                            </td>
                                        </tr>
                                    </template>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Task Details Modal -->
        <div x-show="showModal" 
             class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50"
             x-transition:enter="ease-out duration-300"
             x-transition:enter-start="opacity-0"
             x-transition:enter-end="opacity-100"
             x-transition:leave="ease-in duration-200"
             x-transition:leave-start="opacity-100"
             x-transition:leave-end="opacity-0">
            <div class="relative top-20 mx-auto p-5 border w-11/12 md:w-3/4 lg:w-1/2 shadow-lg rounded-md bg-white">
                <div class="mt-3">
                    <div class="flex justify-between items-center mb-4">
                        <h3 class="text-lg font-medium text-gray-900">Détails de la tâche</h3>
                        <button @click="showModal = false" 
                                class="text-gray-400 hover:text-gray-600">
                            <i class="fas fa-times text-xl"></i>
                        </button>
                    </div>
                    
                    <template x-if="selectedTask">
                        <div class="space-y-4">
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">ID de la tâche</label>
                                    <p class="text-sm text-gray-900 font-mono bg-gray-100 p-2 rounded" x-text="selectedTask.id"></p>
                                </div>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">Statut</label>
                                    <span class="inline-flex px-2 py-1 text-sm font-semibold rounded-full"
                                          :class="{
                                              'bg-green-100 text-green-800': selectedTask.status === 'completed',
                                              'bg-red-100 text-red-800': selectedTask.status === 'error',
                                              'bg-yellow-100 text-yellow-800': selectedTask.status === 'processing',
                                              'bg-gray-100 text-gray-800': selectedTask.status === 'pending'
                                          }"
                                          x-text="selectedTask.status">
                                    </span>
                                </div>
                            </div>
                            
                            <div x-show="selectedTask.error" class="p-4 bg-red-50 border border-red-200 rounded-md">
                                <label class="block text-sm font-medium text-red-700 mb-1">Message d'erreur</label>
                                <p class="text-sm text-red-600" x-text="selectedTask.error"></p>
                            </div>
                            
                            <div x-show="selectedTask.response" class="p-4 bg-gray-50 border border-gray-200 rounded-md">
                                <label class="block text-sm font-medium text-gray-700 mb-1">Réponse</label>
                                <p class="text-sm text-gray-600" x-text="selectedTask.response"></p>
                            </div>
                            
                            <div x-show="selectedTask.user_images && selectedTask.user_images.length > 0">
                                <label class="block text-sm font-medium text-gray-700 mb-2">Images utilisateur</label>
                                <div class="grid grid-cols-2 md:grid-cols-4 gap-2">
                                    <template x-for="image in selectedTask.user_images" :key="image">
                                        <div class="relative group">
                                            <img :src="'/user_images/' + image" 
                                                 :alt="image"
                                                 class="w-full h-24 object-cover rounded-md border border-gray-300">
                                            <div class="absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-30 transition-opacity rounded-md"></div>
                                        </div>
                                    </template>
                                </div>
                            </div>
                        </div>
                    </template>
                </div>
            </div>
        </div>

        <!-- Delete Confirmation Modal -->
        <div x-show="showDeleteModal" 
             class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50"
             x-transition:enter="ease-out duration-300"
             x-transition:enter-start="opacity-0"
             x-transition:enter-end="opacity-100"
             x-transition:leave="ease-in duration-200"
             x-transition:leave-start="opacity-100"
             x-transition:leave-end="opacity-0">
            <div class="relative top-32 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white">
                <div class="mt-3 text-center">
                    <div class="mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-red-100">
                        <i class="fas fa-exclamation-triangle text-red-600"></i>
                    </div>
                    <h3 class="text-lg font-medium text-gray-900 mt-2">Supprimer la tâche</h3>
                    <div class="mt-2 px-7 py-3">
                        <p class="text-sm text-gray-500">
                            Êtes-vous sûr de vouloir supprimer cette tâche ? Cette action supprimera tous les fichiers associés et ne peut pas être annulée.
                        </p>
                    </div>
                    <div class="flex justify-center space-x-3 mt-4">
                        <button @click="showDeleteModal = false" 
                                class="px-4 py-2 bg-gray-300 text-gray-700 rounded-md hover:bg-gray-400 transition-colors">
                            Annuler
                        </button>
                        <button @click="confirmDeleteTask()" 
                                class="px-4 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 transition-colors">
                            Supprimer
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        function adminApp() {
            return {
                tasks: [],
                stats: {
                    total_tasks: 0,
                    completed_tasks: 0,
                    error_tasks: 0,
                    pending_tasks: 0,
                    pdf_files: 0,
                    user_images: 0,
                    latex_installed: false
                },
                loading: true,
                showModal: false,
                showDeleteModal: false,
                selectedTask: null,
                taskToDelete: null,
                statusFilter: '',

                async init() {
                    await this.refreshData();
                    // Auto-refresh every 30 seconds
                    setInterval(() => {
                        this.refreshData(false);
                    }, 30000);
                },

                async refreshData(showLoading = true) {
                    if (showLoading) this.loading = true;
                    
                    try {
                        const [tasksResponse, statsResponse] = await Promise.all([
                            fetch('/admin/api/tasks'),
                            fetch('/admin/api/stats')
                        ]);
                        
                        this.tasks = await tasksResponse.json();
                        this.stats = await statsResponse.json();
                    } catch (error) {
                        console.error('Erreur lors du rafraîchissement des données:', error);
                    } finally {
                        if (showLoading) this.loading = false;
                    }
                },

                showTaskDetails(task) {
                    this.selectedTask = task;
                    this.showModal = true;
                },

                deleteTask(taskId) {
                    this.taskToDelete = taskId;
                    this.showDeleteModal = true;
                },

                async confirmDeleteTask() {
                    if (!this.taskToDelete) return;
                    
                    try {
                        const response = await fetch(`/admin/delete_task/${this.taskToDelete}`, {
                            method: 'POST'
                        });
                        
                        if (response.ok) {
                            await this.refreshData();
                            this.showDeleteModal = false;
                            this.taskToDelete = null;
                        } else {
                            const error = await response.json();
                            alert('Erreur lors de la suppression: ' + error.error);
                        }
                    } catch (error) {
                        console.error('Erreur lors de la suppression:', error);
                        alert('Erreur lors de la suppression de la tâche');
                    }
                },

                get filteredTasks() {
                    if (!this.statusFilter) return this.tasks;
                    return this.tasks.filter(task => task.status === this.statusFilter);
                }
            };
        }
    </script>
</body>
</html>