-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.html
More file actions
1863 lines (1725 loc) · 103 KB
/
dashboard.html
File metadata and controls
1863 lines (1725 loc) · 103 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
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
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sandbox Monitor</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
colors: {
gray: {
900: '#0f172a',
800: '#1e293b',
700: '#334155',
600: '#475569',
}
}
}
}
}
</script>
<style>
.worker-card {
transition: all 0.3s ease;
}
.worker-card.busy {
background-color: rgba(239, 68, 68, 0.1);
border-color: rgba(239, 68, 68, 0.5);
box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}
.worker-card.idle {
background-color: rgba(34, 197, 94, 0.1);
border-color: rgba(34, 197, 94, 0.5);
}
[v-cloak] {
display: none;
}
/* Network Flow Animation */
@keyframes flowRight {
0% { left: 0; opacity: 1; }
100% { left: calc(100% - 12px); opacity: 1; }
}
@keyframes flowLeft {
0% { left: calc(100% - 12px); opacity: 1; }
100% { left: 0; opacity: 1; }
}
.flow-particle {
position: absolute;
width: 12px;
height: 12px;
border-radius: 50%;
pointer-events: none;
z-index: 100;
opacity: 1;
}
.flow-particle.request {
left: 0;
background: #3b82f6;
box-shadow: 0 0 8px #3b82f6, 0 0 16px #3b82f6, 0 0 24px #60a5fa;
animation: flowRight 1.2s ease-in-out forwards;
}
.flow-particle.response {
left: calc(100% - 12px);
background: #22c55e;
box-shadow: 0 0 8px #22c55e, 0 0 16px #22c55e, 0 0 24px #4ade80;
animation: flowLeft 1.2s ease-in-out forwards;
}
.flow-particle.error {
left: calc(100% - 12px);
background: #ef4444;
box-shadow: 0 0 8px #ef4444, 0 0 16px #ef4444, 0 0 24px #f87171;
animation: flowLeft 1.2s ease-in-out forwards;
}
/* Particle trail effect */
.flow-particle::after {
content: '';
position: absolute;
width: 40px;
height: 4px;
top: 50%;
transform: translateY(-50%);
border-radius: 2px;
opacity: 0.6;
}
.flow-particle.request::after {
right: 100%;
background: linear-gradient(to left, #3b82f6, transparent);
}
.flow-particle.response::after,
.flow-particle.error::after {
left: 100%;
background: linear-gradient(to right, currentColor, transparent);
}
.flow-particle.response::after {
background: linear-gradient(to right, #22c55e, transparent);
}
.flow-particle.error::after {
background: linear-gradient(to right, #ef4444, transparent);
}
.network-node {
transition: all 0.3s ease;
}
.network-node.active {
transform: scale(1.05);
box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}
</style>
</head>
<body class="bg-gray-900 text-slate-200 min-h-screen font-sans">
<div id="app" class="container mx-auto px-4 py-8 max-w-7xl" v-cloak>
<!-- Header -->
<header class="flex flex-col md:flex-row justify-between items-center mb-10 gap-4">
<div>
<h1
class="text-4xl font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-blue-400 to-cyan-300">
Sandbox Monitor
</h1>
<p class="text-slate-400 mt-2 flex items-center gap-2">
<span class="w-2 h-2 rounded-full"
:class="isConnected ? 'bg-green-500 shadow-[0_0_8px_rgba(34,197,94,0.6)]' : 'bg-red-500'"></span>
{{ isConnected ? 'System Online' : 'Reconnecting...' }}
<span v-if="lastUpdated" class="text-xs text-slate-600 ml-2">Last update: {{ lastUpdated }}</span>
</p>
</div>
<div class="flex items-center gap-6">
<!-- API Key 設定按鈕 -->
<button @click="openApiKeyModal"
class="px-3 py-2 rounded-lg font-bold text-xs transition-all border"
:class="apiKey ? 'bg-green-600/20 border-green-600/50 text-green-400 hover:bg-green-600/30' : 'bg-red-600/20 border-red-600/50 text-red-400 hover:bg-red-600/30 animate-pulse'">
🔑 {{ apiKey ? 'API Key ✓' : 'Set API Key' }}
</button>
<div class="text-right hidden md:block">
<div class="text-3xl font-mono font-bold text-white flex items-center justify-end gap-2">
{{ stats.queue_size || 0 }}
<span v-if="stats.queue_paused" class="text-xs bg-yellow-500 text-black px-2 py-1 rounded font-bold">PAUSED</span>
</div>
<div class="text-xs text-slate-500 uppercase tracking-wider font-semibold">Queue Size</div>
</div>
<div class="flex flex-col gap-2">
<div class="flex gap-2">
<button @click="toggleQueue" :disabled="!isConnected || !apiKey"
class="px-4 py-2 rounded-lg font-bold text-xs transition-all border"
:class="stats.queue_paused ? 'bg-green-600 hover:bg-green-500 border-green-500 text-white' : 'bg-yellow-600 hover:bg-yellow-500 border-yellow-500 text-white'">
{{ stats.queue_paused ? '▶ Resume Queue' : '⏸ Pause Queue' }}
</button>
<button @click="clearQueue" :disabled="!isConnected || !apiKey || (stats.queue_size || 0) === 0"
class="px-4 py-2 rounded-lg font-bold text-xs transition-all bg-red-600 hover:bg-red-500 border border-red-500 text-white disabled:opacity-50 disabled:cursor-not-allowed">
🗑 Clear Queue
</button>
</div>
<button @click="runBatchTest" :disabled="isTesting || !isConnected"
class="relative overflow-hidden group bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-500 hover:to-blue-500 disabled:from-slate-700 disabled:to-slate-700 disabled:cursor-not-allowed text-white px-8 py-2 rounded-xl font-bold transition-all shadow-lg hover:shadow-purple-500/30 active:scale-95 text-sm">
<div class="flex items-center gap-2 justify-center">
<span v-if="isTesting" class="animate-spin">⟳</span>
<span v-else>🚀</span>
<span>{{ isTesting ? batchTestProgress.message : 'Run Batch Test' }}</span>
</div>
</button>
</div>
</div>
</header>
<!-- Batch Test Progress Bar -->
<div v-if="batchTestProgress.running" class="mb-6 bg-gray-800 rounded-xl p-4 border border-gray-700">
<div class="flex justify-between items-center mb-2">
<span class="text-sm font-bold text-slate-300">{{ batchTestProgress.message }}</span>
<button @click="abortBatchTest" class="text-xs bg-red-600 hover:bg-red-500 text-white px-3 py-1 rounded">
⏹ Abort
</button>
</div>
<div class="w-full bg-gray-700 h-3 rounded-full overflow-hidden">
<div class="h-full transition-all duration-300 flex">
<div class="bg-green-500" :style="{ width: (batchTestProgress.success / batchTestProgress.total * 100) + '%' }"></div>
<div class="bg-red-500" :style="{ width: (batchTestProgress.failed / batchTestProgress.total * 100) + '%' }"></div>
</div>
</div>
<div class="flex justify-between text-xs text-slate-500 mt-1">
<span>✓ {{ batchTestProgress.success }} success</span>
<span>✗ {{ batchTestProgress.failed }} failed</span>
<span>{{ batchTestProgress.current }} / {{ batchTestProgress.total }}</span>
</div>
</div>
<!-- Tabs -->
<div class="flex space-x-1 bg-gray-800/50 p-1 rounded-xl mb-8 w-fit border border-gray-700">
<button @click="currentTab = 'monitor'"
:class="['px-6 py-2 rounded-lg font-bold transition-all duration-200 flex items-center gap-2', currentTab === 'monitor' ? 'bg-blue-600 text-white shadow-lg shadow-blue-500/30' : 'text-slate-400 hover:text-white hover:bg-gray-700']">
<span>📊</span> System Monitor
</button>
<button @click="currentTab = 'history'"
:class="['px-6 py-2 rounded-lg font-bold transition-all duration-200 flex items-center gap-2', currentTab === 'history' ? 'bg-blue-600 text-white shadow-lg shadow-blue-500/30' : 'text-slate-400 hover:text-white hover:bg-gray-700']">
<span>📜</span> Detailed History
</button>
<button @click="currentTab = 'resources'; fetchResources()"
:class="['px-6 py-2 rounded-lg font-bold transition-all duration-200 flex items-center gap-2', currentTab === 'resources' ? 'bg-blue-600 text-white shadow-lg shadow-blue-500/30' : 'text-slate-400 hover:text-white hover:bg-gray-700']">
<span>📦</span> Resources
</button>
<button @click="currentTab = 'security'"
:class="['px-6 py-2 rounded-lg font-bold transition-all duration-200 flex items-center gap-2', currentTab === 'security' ? 'bg-blue-600 text-white shadow-lg shadow-blue-500/30' : 'text-slate-400 hover:text-white hover:bg-gray-700']">
<span>🔒</span> Security Logs
</button>
</div>
<!-- Monitor Tab -->
<div v-show="currentTab === 'monitor'" class="animate-fade-in">
<!-- Metrics Grid -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-10">
<!-- Total Workers -->
<div class="bg-gray-800 rounded-2xl p-6 border border-gray-700 shadow-xl relative overflow-hidden">
<div class="absolute top-0 right-0 p-4 opacity-10 text-6xl">🤖</div>
<div class="text-slate-400 text-sm font-bold uppercase tracking-wider mb-1">Total Workers</div>
<div class="text-5xl font-mono font-bold text-white">{{ stats.workers?.total_workers || 0 }}</div>
</div>
<!-- Active Workers -->
<div class="bg-gray-800 rounded-2xl p-6 border border-gray-700 shadow-xl relative overflow-hidden">
<div class="absolute top-0 right-0 p-4 opacity-10 text-6xl">🔥</div>
<div class="text-slate-400 text-sm font-bold uppercase tracking-wider mb-1">Active</div>
<div class="text-5xl font-mono font-bold text-red-400">{{ stats.workers?.active_workers || 0 }}</div>
<div class="w-full bg-gray-700 h-1 mt-4 rounded-full overflow-hidden">
<div class="bg-red-500 h-full transition-all duration-500"
:style="{ width: ((stats.workers?.active_workers || 0) / (stats.workers?.total_workers || 1) * 100) + '%' }">
</div>
</div>
</div>
<!-- Idle Workers -->
<div class="bg-gray-800 rounded-2xl p-6 border border-gray-700 shadow-xl relative overflow-hidden">
<div class="absolute top-0 right-0 p-4 opacity-10 text-6xl">💤</div>
<div class="text-slate-400 text-sm font-bold uppercase tracking-wider mb-1">Idle</div>
<div class="text-5xl font-mono font-bold text-green-400">{{ stats.workers?.idle_workers || 0 }}</div>
<div class="w-full bg-gray-700 h-1 mt-4 rounded-full overflow-hidden">
<div class="bg-green-500 h-full transition-all duration-500"
:style="{ width: ((stats.workers?.idle_workers || 0) / (stats.workers?.total_workers || 1) * 100) + '%' }">
</div>
</div>
</div>
</div>
<!-- System Resources -->
<div class="mb-10">
<h2 class="text-2xl font-bold text-white mb-6 flex items-center gap-3">
<span class="bg-green-500 w-1 h-8 rounded-full"></span>
System Resources
</h2>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="bg-gray-800 rounded-2xl p-6 border border-gray-700 shadow-xl">
<h3 class="text-lg font-bold text-slate-300 mb-4">CPU Usage (%)</h3>
<div id="cpuChart" class="w-full h-64"></div>
</div>
<div class="bg-gray-800 rounded-2xl p-6 border border-gray-700 shadow-xl">
<h3 class="text-lg font-bold text-slate-300 mb-4">Memory Usage (MB)</h3>
<div id="memoryChart" class="w-full h-64"></div>
</div>
</div>
</div>
<!-- Network Traffic Visualization -->
<div class="mb-10">
<h2 class="text-2xl font-bold text-white mb-6 flex items-center gap-3">
<span class="bg-cyan-500 w-1 h-8 rounded-full"></span>
Live Network Traffic
<span class="text-xs font-normal text-slate-500 ml-2">Real-time API connections</span>
</h2>
<div class="bg-gray-800 rounded-2xl p-6 border border-gray-700 shadow-xl">
<div class="relative flex items-center justify-between h-48">
<!-- Client Side -->
<div class="network-node w-40 h-32 bg-gradient-to-br from-blue-600/20 to-blue-800/20 rounded-xl border-2 border-blue-500/50 flex flex-col items-center justify-center z-20"
:class="{ 'active': networkFlow.clientActive }">
<div class="text-4xl mb-2">🌐</div>
<div class="text-sm font-bold text-blue-400">Clients</div>
<div class="text-xs text-slate-500 mt-1">{{ networkFlow.uniqueClients }} connected</div>
</div>
<!-- Connection Lines Container -->
<div class="absolute left-40 right-40 h-full overflow-hidden" style="z-index: 10; position: absolute;">
<!-- Static connection lines -->
<svg class="w-full h-full" style="position: absolute; left: 0; top: 0;" preserveAspectRatio="none">
<defs>
<linearGradient id="lineGradient" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:#3b82f6;stop-opacity:0.3" />
<stop offset="50%" style="stop-color:#22d3ee;stop-opacity:0.5" />
<stop offset="100%" style="stop-color:#22c55e;stop-opacity:0.3" />
</linearGradient>
</defs>
<!-- Multiple lanes -->
<line x1="0" y1="35%" x2="100%" y2="35%" stroke="url(#lineGradient)" stroke-width="2" stroke-dasharray="5,5" />
<line x1="0" y1="50%" x2="100%" y2="50%" stroke="url(#lineGradient)" stroke-width="3" />
<line x1="0" y1="65%" x2="100%" y2="65%" stroke="url(#lineGradient)" stroke-width="2" stroke-dasharray="5,5" />
</svg>
<!-- Flow particles -->
<div v-for="particle in networkFlow.particles" :key="particle.id"
class="flow-particle"
:class="particle.type"
:style="{ top: 'calc(' + particle.lane + '% - 6px)' }">
</div>
</div>
<!-- Server Side -->
<div class="network-node w-40 h-32 bg-gradient-to-br from-green-600/20 to-green-800/20 rounded-xl border-2 border-green-500/50 flex flex-col items-center justify-center z-20"
:class="{ 'active': networkFlow.serverActive }">
<div class="text-4xl mb-2">🖥️</div>
<div class="text-sm font-bold text-green-400">Sandbox</div>
<div class="text-xs text-slate-500 mt-1">{{ stats.workers?.active_workers || 0 }} processing</div>
</div>
</div>
<!-- Traffic Stats -->
<div class="grid grid-cols-5 gap-4 mt-6 pt-6 border-t border-gray-700">
<div class="text-center">
<div class="text-2xl font-bold text-blue-400">{{ networkFlow.requestCount }}</div>
<div class="text-xs text-slate-500">Requests (1min)</div>
</div>
<div class="text-center">
<div class="text-2xl font-bold text-green-400">{{ networkFlow.successCount }}</div>
<div class="text-xs text-slate-500">Success</div>
</div>
<div class="text-center">
<div class="text-2xl font-bold text-red-400">{{ networkFlow.errorCount }}</div>
<div class="text-xs text-slate-500">Errors</div>
</div>
<div class="text-center">
<div class="text-2xl font-bold text-cyan-400">{{ networkFlow.avgLatency }}ms</div>
<div class="text-xs text-slate-500">Avg Latency</div>
</div>
<div class="text-center">
<button @click="testParticle()"
class="px-3 py-2 bg-purple-600 hover:bg-purple-500 text-white text-xs rounded-lg transition-colors">
🧪 Test Particle
</button>
</div>
</div>
<!-- Recent Connections Log -->
<div class="mt-6 pt-6 border-t border-gray-700">
<div class="text-sm font-bold text-slate-400 mb-3">Recent Connections</div>
<div class="space-y-2 max-h-32 overflow-y-auto">
<div v-for="conn in networkFlow.recentConnections" :key="conn.id"
class="flex items-center justify-between text-xs bg-gray-900/50 rounded px-3 py-2">
<div class="flex items-center gap-3">
<span :class="conn.type === 'request' ? 'text-blue-400' : (conn.success ? 'text-green-400' : 'text-red-400')">
{{ conn.type === 'request' ? '→' : '←' }}
</span>
<span class="font-mono text-slate-400">{{ conn.ip }}</span>
<span class="text-slate-500">{{ conn.method }}</span>
<span class="text-slate-300 truncate max-w-xs">{{ conn.path }}</span>
</div>
<div class="flex items-center gap-3">
<span :class="conn.status < 300 ? 'text-green-400' : (conn.status < 500 ? 'text-yellow-400' : 'text-red-400')">
{{ conn.status }}
</span>
<span class="text-slate-500">{{ conn.time }}</span>
</div>
</div>
<div v-if="!networkFlow.recentConnections.length" class="text-slate-500 text-center py-4">
No recent connections
</div>
</div>
</div>
</div>
</div>
<!-- Worker Grid -->
<div class="mb-10">
<h2 class="text-2xl font-bold text-white mb-6 flex items-center gap-3">
<span class="bg-blue-500 w-1 h-8 rounded-full"></span>
Worker Nodes
</h2>
<div class="grid grid-cols-2 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-8 gap-4">
<div v-for="worker in stats.workers?.workers_details" :key="worker.id"
class="worker-card rounded-xl p-4 border border-gray-700 bg-gray-800 flex flex-col justify-between h-24 relative overflow-hidden"
:class="worker.busy ? 'busy' : 'idle'">
<div class="flex justify-between items-start z-10">
<span class="font-mono text-xs text-slate-400">#{{ worker.id }}</span>
<span class="w-2 h-2 rounded-full"
:class="worker.busy ? 'bg-red-500 animate-pulse' : 'bg-green-500'"></span>
</div>
<div class="z-10 mt-2">
<div v-if="worker.busy" class="text-xs font-mono text-red-300 truncate font-bold"
:title="worker.current_job">
{{ worker.current_job }}
</div>
<div v-else class="text-xs font-mono text-green-400/70 font-bold">
IDLE
</div>
</div>
<!-- Background Pulse Effect -->
<div v-if="worker.busy" class="absolute inset-0 bg-red-500/5 animate-pulse"></div>
</div>
</div>
</div>
</div>
<!-- History Tab -->
<div v-show="currentTab === 'history'" class="animate-fade-in">
<h2 class="text-2xl font-bold text-white mb-6 flex items-center gap-3 justify-between">
<div class="flex items-center gap-3">
<span class="bg-purple-500 w-1 h-8 rounded-full"></span>
Submission History
</div>
<div class="flex gap-2">
<button @click="isPaused = !isPaused" class="text-xs px-3 py-1.5 rounded transition-colors border border-gray-600 flex items-center gap-2" :class="isPaused ? 'bg-yellow-600 hover:bg-yellow-500 text-white' : 'bg-gray-700 hover:bg-gray-600 text-slate-300'">
<span>{{ isPaused ? '▶ Resume' : '⏸ Pause' }}</span>
</button>
<button @click="fetchHistory(100)" class="text-xs bg-gray-700 hover:bg-gray-600 text-white px-3 py-1.5 rounded transition-colors border border-gray-600">
Latest 100
</button>
<button @click="fetchHistory(1000)" class="text-xs bg-gray-700 hover:bg-gray-600 text-white px-3 py-1.5 rounded transition-colors border border-gray-600">
Latest 1k
</button>
<button @click="fetchHistory(-1)" class="text-xs bg-purple-600 hover:bg-purple-500 text-white px-3 py-1.5 rounded transition-colors shadow-lg shadow-purple-500/20">
Load All (Caution)
</button>
</div>
</h2>
<div class="bg-gray-800 rounded-2xl border border-gray-700 overflow-hidden shadow-xl">
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse">
<thead>
<tr class="bg-gray-900/50 text-slate-400 text-xs uppercase tracking-wider border-b border-gray-700">
<th class="p-4">ID / Time</th>
<th class="p-4">Problem / Lang</th>
<th class="p-4">Status</th>
<th class="p-4">Metrics</th>
<th class="p-4">Features</th>
<th class="p-4">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-700">
<tr v-for="job in sortedHistory" :key="job.submission_id" class="hover:bg-gray-700/50 transition-colors">
<td class="p-4">
<div class="font-mono text-sm text-blue-300 font-bold">{{ job.submission_id }}</div>
<div class="text-xs text-slate-500 mt-1">{{ new Date(job.timestamp * 1000).toLocaleString() }}</div>
</td>
<td class="p-4">
<div class="text-sm text-white font-semibold">{{ job.problem_id }}</div>
<div class="text-xs text-slate-400 mt-1 uppercase bg-gray-700 px-2 py-0.5 rounded w-fit">{{ job.language || 'N/A' }}</div>
</td>
<td class="p-4">
<span class="px-3 py-1 rounded-full text-xs font-bold border" :class="{
'bg-green-500/10 text-green-400 border-green-500/30': job.status === 'OK' || job.status === 'AC',
'bg-red-500/10 text-red-400 border-red-500/30': ['WA', 'RE', 'TLE', 'XX', 'CE'].includes(job.status)
}">
{{ job.status || (job.success ? 'OK' : 'FAIL') }}
</span>
</td>
<td class="p-4">
<div class="flex flex-col gap-1 text-xs font-mono">
<span class="text-slate-300">⏱ {{ job.time !== null ? job.time + 's' : '-' }}</span>
<span class="text-slate-300">💾 {{ job.memory !== null ? job.memory + 'KB' : '-' }}</span>
</div>
</td>
<td class="p-4">
<div class="flex gap-2 flex-wrap">
<span v-if="job.source_code" class="text-xs bg-green-500/20 text-green-300 px-2 py-1 rounded border border-green-500/30" title="Source Code Available">📄 Code</span>
<span v-if="job.network_log" class="text-xs bg-blue-500/20 text-blue-300 px-2 py-1 rounded border border-blue-500/30" title="Network Access">🌐 Net</span>
<span v-if="job.static_analysis" class="text-xs bg-yellow-500/20 text-yellow-300 px-2 py-1 rounded border border-yellow-500/30" title="Static Analysis">🔍 SA</span>
</div>
</td>
<td class="p-4 flex gap-2">
<button @click="showDetails(job)" class="text-sm bg-gray-700 hover:bg-gray-600 text-white px-3 py-1.5 rounded transition-colors border border-gray-600">
View Details
</button>
<button @click="downloadSourceCode(job)"
:disabled="!job.source_code"
:class="job.source_code ? 'bg-green-600/20 hover:bg-green-600 text-green-300 hover:text-white border-green-600/30' : 'bg-gray-600/20 text-gray-500 border-gray-600/30 cursor-not-allowed'"
class="text-sm px-3 py-1.5 rounded transition-colors border"
title="Download Source Code">
📄 Code
</button>
<button @click="downloadOriginalRequest(job)"
:disabled="!job.original_request"
:class="job.original_request ? 'bg-purple-600/20 hover:bg-purple-600 text-purple-300 hover:text-white border-purple-600/30' : 'bg-gray-600/20 text-gray-500 border-gray-600/30 cursor-not-allowed'"
class="text-sm px-3 py-1.5 rounded transition-colors border"
title="Download Original POST Request">
📨 Request
</button>
<button @click="downloadCallback(job)" class="text-sm bg-blue-600/20 hover:bg-blue-600 text-blue-300 hover:text-white px-3 py-1.5 rounded transition-colors border border-blue-600/30" title="Download Callback JSON">
⬇ Callback
</button>
</td>
</tr>
<tr v-if="!stats.workers?.history?.length">
<td colspan="6" class="p-8 text-center text-slate-500 italic">
No history available
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- Security Tab -->
<div v-show="currentTab === 'security'" class="animate-fade-in">
<h2 class="text-2xl font-bold text-white mb-6 flex items-center gap-3">
<span class="bg-red-500 w-1 h-8 rounded-full"></span>
Authentication Failures
</h2>
<div class="bg-gray-800 rounded-2xl border border-gray-700 overflow-hidden shadow-xl">
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse">
<thead>
<tr class="bg-gray-900/50 text-slate-400 text-xs uppercase tracking-wider border-b border-gray-700">
<th class="p-4">Time</th>
<th class="p-4">IP Address</th>
<th class="p-4">Method / Path</th>
<th class="p-4">Provided Key</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-700">
<tr v-for="(log, index) in authHistory" :key="index" class="hover:bg-gray-700/50 transition-colors">
<td class="p-4">
<div class="text-sm text-slate-300">{{ new Date(log.timestamp * 1000).toLocaleString() }}</div>
</td>
<td class="p-4">
<div class="font-mono text-sm text-red-300 font-bold">{{ log.ip }}</div>
</td>
<td class="p-4">
<div class="text-sm text-white font-semibold">{{ log.method }} {{ log.path }}</div>
</td>
<td class="p-4">
<div class="font-mono text-xs text-slate-500 bg-black/30 px-2 py-1 rounded w-fit">{{ log.provided_key }}</div>
</td>
</tr>
<tr v-if="!authHistory.length">
<td colspan="4" class="p-8 text-center text-slate-500 italic">
No security incidents recorded
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- Resources Tab (Checkers & Problems) -->
<div v-show="currentTab === 'resources'" class="animate-fade-in">
<!-- Checkers Section -->
<div class="mb-10">
<h2 class="text-2xl font-bold text-white mb-6 flex items-center gap-3 justify-between">
<div class="flex items-center gap-3">
<span class="bg-cyan-500 w-1 h-8 rounded-full"></span>
Checkers
<span class="text-sm font-normal text-slate-400">({{ checkers.length }} items)</span>
</div>
<button @click="fetchResources" class="text-xs bg-gray-700 hover:bg-gray-600 text-white px-3 py-1.5 rounded transition-colors border border-gray-600">
🔄 Refresh
</button>
</h2>
<div class="bg-gray-800 rounded-2xl border border-gray-700 overflow-hidden shadow-xl">
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse">
<thead>
<tr class="bg-gray-900/50 text-slate-400 text-xs uppercase tracking-wider border-b border-gray-700">
<th class="p-4">Name</th>
<th class="p-4">Type</th>
<th class="p-4">Size</th>
<th class="p-4">Modified</th>
<th class="p-4">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-700">
<tr v-for="checker in checkers" :key="checker.name" class="hover:bg-gray-700/50 transition-colors">
<td class="p-4">
<div class="font-mono text-sm text-cyan-300 font-bold">{{ checker.name }}</div>
</td>
<td class="p-4">
<span class="px-2 py-1 rounded text-xs font-bold" :class="{
'bg-yellow-500/20 text-yellow-300 border border-yellow-500/30': checker.type === 'python',
'bg-blue-500/20 text-blue-300 border border-blue-500/30': checker.type === 'binary',
'bg-gray-500/20 text-gray-300 border border-gray-500/30': checker.type === 'unknown'
}">
{{ checker.type === 'python' ? '🐍 Python' : checker.type === 'binary' ? '⚙️ Binary' : '❓ Unknown' }}
</span>
</td>
<td class="p-4">
<div class="text-sm text-slate-300 font-mono">{{ formatSize(checker.size) }}</div>
</td>
<td class="p-4">
<div class="text-sm text-slate-400">{{ new Date(checker.modified * 1000).toLocaleString() }}</div>
</td>
<td class="p-4 flex gap-2">
<button @click="downloadChecker(checker.name)" class="text-xs bg-cyan-600/20 hover:bg-cyan-600 text-cyan-300 hover:text-white px-3 py-1.5 rounded transition-colors border border-cyan-600/30">
⬇ Download
</button>
<button @click="deleteChecker(checker.name)" class="text-xs bg-red-600/20 hover:bg-red-600 text-red-300 hover:text-white px-3 py-1.5 rounded transition-colors border border-red-600/30">
🗑 Delete
</button>
</td>
</tr>
<tr v-if="!checkers.length">
<td colspan="5" class="p-8 text-center text-slate-500 italic">
No checkers uploaded
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- Problems Section -->
<div>
<h2 class="text-2xl font-bold text-white mb-6 flex items-center gap-3">
<span class="bg-green-500 w-1 h-8 rounded-full"></span>
Problem Packages
<span class="text-sm font-normal text-slate-400">({{ problems.length }} items)</span>
</h2>
<div class="bg-gray-800 rounded-2xl border border-gray-700 overflow-hidden shadow-xl">
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse">
<thead>
<tr class="bg-gray-900/50 text-slate-400 text-xs uppercase tracking-wider border-b border-gray-700">
<th class="p-4">Problem ID</th>
<th class="p-4">Testcases</th>
<th class="p-4">Checker</th>
<th class="p-4">Checksum</th>
<th class="p-4">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-700">
<tr v-for="problem in problems" :key="problem.problem_id" class="hover:bg-gray-700/50 transition-colors">
<td class="p-4">
<div class="font-mono text-sm text-green-300 font-bold">{{ problem.problem_id }}</div>
</td>
<td class="p-4">
<div class="text-sm text-white font-semibold">{{ problem.testcase_count }} cases</div>
</td>
<td class="p-4">
<span v-if="problem.has_checker" class="px-2 py-1 rounded text-xs font-bold bg-green-500/20 text-green-300 border border-green-500/30">
✓ Custom
</span>
<span v-else class="px-2 py-1 rounded text-xs font-bold bg-gray-500/20 text-gray-400 border border-gray-500/30">
Default (diff)
</span>
</td>
<td class="p-4">
<div class="font-mono text-xs text-slate-500 bg-black/30 px-2 py-1 rounded w-fit">{{ problem.checksum ? problem.checksum.substring(0, 12) + '...' : 'N/A' }}</div>
</td>
<td class="p-4 flex gap-2">
<button @click="viewProblem(problem.problem_id)" class="text-xs bg-gray-700 hover:bg-gray-600 text-white px-3 py-1.5 rounded transition-colors border border-gray-600">
👁 View
</button>
<button @click="downloadProblem(problem.problem_id)" class="text-xs bg-green-600/20 hover:bg-green-600 text-green-300 hover:text-white px-3 py-1.5 rounded transition-colors border border-green-600/30">
⬇ Download
</button>
<button @click="deleteProblem(problem.problem_id)" class="text-xs bg-red-600/20 hover:bg-red-600 text-red-300 hover:text-white px-3 py-1.5 rounded transition-colors border border-red-600/30">
🗑 Delete
</button>
</td>
</tr>
<tr v-if="!problems.length">
<td colspan="5" class="p-8 text-center text-slate-500 italic">
No problem packages cached
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Problem Detail Modal -->
<div v-if="selectedProblem" class="fixed inset-0 bg-black/80 backdrop-blur-sm flex items-center justify-center z-50 p-4" @click.self="selectedProblem = null">
<div class="bg-gray-900 rounded-2xl border border-gray-700 shadow-2xl w-full max-w-3xl max-h-[90vh] flex flex-col">
<div class="p-6 border-b border-gray-800 flex justify-between items-center bg-gray-800/50 rounded-t-2xl">
<div>
<h3 class="text-xl font-bold text-white flex items-center gap-3">
Problem Details
<span class="font-mono text-sm text-green-400 bg-green-400/10 px-2 py-1 rounded">{{ selectedProblem.problem_id }}</span>
</h3>
</div>
<button @click="selectedProblem = null" class="text-slate-400 hover:text-white bg-gray-800 hover:bg-gray-700 w-8 h-8 rounded-full flex items-center justify-center transition-colors">✕</button>
</div>
<div class="p-6 overflow-y-auto flex-1 space-y-6">
<!-- Meta Info -->
<div class="grid grid-cols-2 gap-4">
<div class="bg-gray-800 rounded-xl p-4 border border-gray-700">
<div class="text-xs text-slate-500 uppercase tracking-wider mb-1">Testcase Count</div>
<div class="text-2xl font-bold text-white">{{ selectedProblem.testcase_count }}</div>
</div>
<div class="bg-gray-800 rounded-xl p-4 border border-gray-700">
<div class="text-xs text-slate-500 uppercase tracking-wider mb-1">Checker</div>
<div class="text-lg font-bold" :class="selectedProblem.checker ? 'text-green-400' : 'text-slate-400'">
{{ selectedProblem.checker ? selectedProblem.checker.type : 'Default (diff)' }}
</div>
</div>
</div>
<!-- Checksum -->
<div class="bg-gray-800 rounded-xl p-4 border border-gray-700">
<div class="text-xs text-slate-500 uppercase tracking-wider mb-2">SHA256 Checksum</div>
<div class="font-mono text-sm text-slate-300 bg-black/30 p-2 rounded">{{ selectedProblem.checksum || 'N/A' }}</div>
</div>
<!-- Testcases List -->
<div class="bg-gray-800 rounded-xl p-4 border border-gray-700">
<div class="text-xs text-slate-500 uppercase tracking-wider mb-3">Testcases</div>
<div class="grid grid-cols-2 md:grid-cols-3 gap-2 max-h-60 overflow-y-auto">
<div v-for="tc in selectedProblem.testcases" :key="tc.input" class="flex items-center gap-2 text-xs font-mono bg-black/20 p-2 rounded">
<span class="text-green-400">{{ tc.input }}</span>
<span class="text-slate-500">→</span>
<span :class="tc.output_exists ? 'text-blue-400' : 'text-red-400'">{{ tc.output }}</span>
<span v-if="!tc.output_exists" class="text-red-400" title="Output file missing">⚠️</span>
</div>
</div>
</div>
<!-- Meta JSON -->
<div class="bg-gray-800 rounded-xl p-4 border border-gray-700">
<div class="text-xs text-slate-500 uppercase tracking-wider mb-2">meta.json</div>
<pre class="text-xs text-slate-400 bg-black/30 p-3 rounded max-h-40 overflow-y-auto font-mono">{{ JSON.stringify(selectedProblem.meta, null, 2) }}</pre>
</div>
</div>
</div>
</div>
<!-- Details Modal -->
<div v-if="selectedJob" class="fixed inset-0 bg-black/80 backdrop-blur-sm flex items-center justify-center z-50 p-4" @click.self="selectedJob = null">
<div class="bg-gray-900 rounded-2xl border border-gray-700 shadow-2xl w-full max-w-5xl max-h-[90vh] flex flex-col animate-scale-in">
<!-- Modal Header -->
<div class="p-6 border-b border-gray-800 flex justify-between items-center bg-gray-800/50 rounded-t-2xl">
<div>
<h3 class="text-xl font-bold text-white flex items-center gap-3">
Submission Details
<span class="font-mono text-sm text-blue-400 bg-blue-400/10 px-2 py-1 rounded">{{ selectedJob.submission_id }}</span>
</h3>
<p class="text-slate-400 text-sm mt-1">{{ selectedJob.problem_id }} • {{ selectedJob.language }}</p>
</div>
<button @click="selectedJob = null" class="text-slate-400 hover:text-white bg-gray-800 hover:bg-gray-700 w-8 h-8 rounded-full flex items-center justify-center transition-colors">✕</button>
</div>
<!-- Modal Body -->
<div class="p-6 overflow-y-auto flex-1 space-y-8 custom-scrollbar">
<!-- Status Banner -->
<div class="flex gap-4">
<div class="flex-1 bg-gray-800 rounded-xl p-4 border border-gray-700">
<div class="text-xs text-slate-500 uppercase tracking-wider mb-1">Verdict</div>
<div class="text-2xl font-bold" :class="{
'text-green-400': selectedJob.status === 'AC' || selectedJob.status === 'OK',
'text-red-400': ['WA', 'RE', 'TLE', 'XX', 'CE'].includes(selectedJob.status)
}">{{ selectedJob.status }}</div>
</div>
<div class="flex-1 bg-gray-800 rounded-xl p-4 border border-gray-700">
<div class="text-xs text-slate-500 uppercase tracking-wider mb-1">Time</div>
<div class="text-2xl font-mono text-white">{{ selectedJob.time }}s</div>
</div>
<div class="flex-1 bg-gray-800 rounded-xl p-4 border border-gray-700">
<div class="text-xs text-slate-500 uppercase tracking-wider mb-1">Memory</div>
<div class="text-2xl font-mono text-white">{{ selectedJob.memory }}KB</div>
</div>
</div>
<!-- Message -->
<div v-if="selectedJob.message" class="bg-gray-800/50 rounded-xl p-4 border border-gray-700">
<h4 class="text-sm font-bold text-slate-300 mb-2 uppercase tracking-wider">System Message</h4>
<pre class="text-sm text-slate-300 whitespace-pre-wrap font-mono">{{ selectedJob.message }}</pre>
</div>
<!-- Compile Info -->
<div v-if="selectedJob.compile_info && (selectedJob.compile_info.status !== 'OK' || selectedJob.compile_info.stderr)" class="rounded-xl p-4 border" :class="selectedJob.compile_info.status === 'OK' ? 'bg-yellow-900/10 border-yellow-900/30' : 'bg-red-900/20 border-red-900/50'">
<h4 class="text-sm font-bold mb-2 uppercase tracking-wider" :class="selectedJob.compile_info.status === 'OK' ? 'text-yellow-400' : 'text-red-400'">
{{ selectedJob.compile_info.status === 'OK' ? 'Compilation Warnings' : 'Compilation Error' }}
</h4>
<pre class="text-xs whitespace-pre-wrap font-mono bg-black/30 p-3 rounded" :class="selectedJob.compile_info.status === 'OK' ? 'text-yellow-200' : 'text-red-200'">{{ selectedJob.compile_info.stderr }}</pre>
</div>
<!-- Test Case Details -->
<div v-if="selectedJob.tasks && selectedJob.tasks.length > 0" class="bg-gray-800 rounded-xl p-4 border border-gray-700">
<h4 class="text-sm font-bold text-slate-300 mb-4 uppercase tracking-wider">Test Case Details</h4>
<div class="space-y-4">
<div v-for="task in selectedJob.tasks" :key="task.task_id" class="border border-gray-700 rounded-lg overflow-hidden">
<div class="bg-gray-700/50 px-4 py-2 flex justify-between items-center">
<div class="flex items-center gap-3">
<span class="font-bold text-slate-300">Subtask {{ task.task_id }}</span>
<span class="px-2 py-0.5 rounded text-xs font-bold border" :class="{
'bg-green-500/10 text-green-400 border-green-500/30': task.status === 'AC',
'bg-red-500/10 text-red-400 border-red-500/30': task.status !== 'AC'
}">{{ task.status }}</span>
</div>
<span class="text-sm text-slate-400 font-mono">Score: {{ task.score }}</span>
</div>
<div class="divide-y divide-gray-700">
<div v-for="case_item in task.cases" :key="case_item.case_name" class="p-3 bg-gray-800/50 hover:bg-gray-700/30 transition-colors">
<div class="flex justify-between items-start mb-2">
<div class="flex items-center gap-3">
<span class="font-mono text-xs text-slate-500 w-24 truncate" :title="case_item.case_name">{{ case_item.case_name }}</span>
<span class="font-bold text-sm w-8" :class="{
'text-green-400': case_item.status === 'AC',
'text-red-400': case_item.status !== 'AC'
}">{{ case_item.status }}</span>
</div>
<div class="flex gap-4 text-xs text-slate-400 font-mono">
<span title="Time Usage">⏱ {{ case_item.time }}s</span>
<span title="Memory Usage">💾 {{ case_item.memory }}KB</span>
</div>
</div>
<div v-if="case_item.message" class="text-xs text-slate-300 font-mono bg-black/20 p-2 rounded whitespace-pre-wrap mt-2">{{ case_item.message }}</div>
</div>
</div>
</div>
</div>
</div>
<div v-if="selectedJob.network_log" class="bg-blue-900/10 rounded-xl p-4 border border-blue-900/30">
<h4 class="text-sm font-bold text-blue-400 mb-2 uppercase tracking-wider flex items-center gap-2">
<span>🌐</span> Network Access Logs
</h4>
<div class="bg-black/30 rounded-lg p-3 max-h-60 overflow-y-auto custom-scrollbar">
<pre class="text-xs text-blue-200 whitespace-pre-wrap font-mono">{{ selectedJob.network_log }}</pre>
</div>
</div>
<!-- Static Analysis -->
<div v-if="selectedJob.static_analysis" class="bg-yellow-900/10 rounded-xl p-4 border border-yellow-900/30">
<h4 class="text-sm font-bold text-yellow-400 mb-2 uppercase tracking-wider flex items-center gap-2">
<span>🔍</span> Static Analysis Report
</h4>
<div class="bg-black/30 rounded-lg p-3 max-h-60 overflow-y-auto custom-scrollbar">
<pre class="text-xs text-yellow-200 whitespace-pre-wrap font-mono">{{ JSON.stringify(selectedJob.static_analysis, null, 2) }}</pre>
</div>
</div>
<!-- Standard Output/Error -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-gray-800 rounded-xl p-4 border border-gray-700">
<h4 class="text-sm font-bold text-slate-300 mb-2 uppercase tracking-wider">Standard Output (Truncated)</h4>
<pre class="text-xs text-slate-400 whitespace-pre-wrap font-mono bg-black/30 p-3 rounded h-40 overflow-y-auto custom-scrollbar">{{ selectedJob.stdout || '(Empty)' }}</pre>
</div>
<div class="bg-gray-800 rounded-xl p-4 border border-gray-700">
<h4 class="text-sm font-bold text-slate-300 mb-2 uppercase tracking-wider">Standard Error (Truncated)</h4>
<pre class="text-xs text-red-400/70 whitespace-pre-wrap font-mono bg-black/30 p-3 rounded h-40 overflow-y-auto custom-scrollbar">{{ selectedJob.stderr || '(Empty)' }}</pre>
</div>
</div>
<!-- Source Code -->
<div v-if="selectedJob.source_code" class="bg-green-900/10 rounded-xl p-4 border border-green-900/30">
<div class="flex justify-between items-center mb-2">
<h4 class="text-sm font-bold text-green-400 uppercase tracking-wider flex items-center gap-2">
<span>📄</span> Source Code
<span class="text-xs text-green-300/60 font-normal normal-case">({{ selectedJob.language }})</span>
</h4>
<button @click="downloadSourceCode(selectedJob)"
class="text-xs bg-green-600/20 hover:bg-green-600 text-green-300 hover:text-white px-3 py-1.5 rounded transition-colors border border-green-600/30">
⬇ Download
</button>
</div>
<div class="bg-black/30 rounded-lg p-3 max-h-80 overflow-y-auto custom-scrollbar">
<pre class="text-xs text-green-200 whitespace-pre-wrap font-mono">{{ selectedJob.source_code }}</pre>
</div>
</div>
<div v-else class="bg-gray-800/50 rounded-xl p-4 border border-gray-700">
<h4 class="text-sm font-bold text-slate-500 uppercase tracking-wider flex items-center gap-2">
<span>📄</span> Source Code
<span class="text-xs text-slate-600 font-normal normal-case">(Not available - older submissions may not have source code stored)</span>
</h4>
</div>
</div>
</div>
</div>
<!-- API Key Modal -->
<div v-if="showApiKeyModal" class="fixed inset-0 bg-black/80 backdrop-blur-sm flex items-center justify-center z-50 p-4" @click.self="showApiKeyModal = false">
<div class="bg-gray-900 rounded-2xl border border-gray-700 shadow-2xl w-full max-w-md">
<div class="p-6 border-b border-gray-800 flex justify-between items-center bg-gray-800/50 rounded-t-2xl">
<h3 class="text-xl font-bold text-white flex items-center gap-2">
🔑 API Key Configuration
</h3>
<button @click="showApiKeyModal = false" class="text-slate-400 hover:text-white bg-gray-800 hover:bg-gray-700 w-8 h-8 rounded-full flex items-center justify-center transition-colors">✕</button>
</div>
<div class="p-6 space-y-4">
<div>
<label class="text-sm text-slate-400 block mb-2">Enter your Sandbox API Key:</label>
<input v-model="apiKeyInput" type="password"
class="w-full bg-gray-800 border border-gray-600 rounded-lg px-4 py-3 text-white font-mono focus:outline-none focus:border-blue-500"
placeholder="your-api-key-here"
@keyup.enter="saveApiKey">
</div>
<p class="text-xs text-slate-500">
The API key is stored in your browser's localStorage and will persist across sessions.
</p>
<div class="flex gap-3">
<button @click="saveApiKey"
class="flex-1 bg-blue-600 hover:bg-blue-500 text-white px-4 py-2 rounded-lg font-bold transition-colors">
Save
</button>
<button @click="showApiKeyModal = false"
class="flex-1 bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-lg font-bold transition-colors">
Cancel
</button>
</div>
</div>
</div>
</div>
<!-- Batch Test Config Modal -->
<div v-if="showBatchConfigModal" class="fixed inset-0 bg-black/80 backdrop-blur-sm flex items-center justify-center z-50 p-4" @click.self="showBatchConfigModal = false">
<div class="bg-gray-900 rounded-2xl border border-gray-700 shadow-2xl w-full max-w-lg">
<div class="p-6 border-b border-gray-800 flex justify-between items-center bg-gray-800/50 rounded-t-2xl">
<h3 class="text-xl font-bold text-white flex items-center gap-2">
🚀 Batch Test Configuration
</h3>
<button @click="showBatchConfigModal = false" class="text-slate-400 hover:text-white bg-gray-800 hover:bg-gray-700 w-8 h-8 rounded-full flex items-center justify-center transition-colors">✕</button>
</div>
<div class="p-6 space-y-4">
<div class="grid grid-cols-2 gap-4">
<div>
<label class="text-sm text-slate-400 block mb-2">Total Tests:</label>
<input v-model.number="batchTestConfig.totalTests" type="number" min="1" max="10000"
class="w-full bg-gray-800 border border-gray-600 rounded-lg px-4 py-2 text-white font-mono focus:outline-none focus:border-blue-500">
</div>
<div>
<label class="text-sm text-slate-400 block mb-2">Batch Size (Concurrency):</label>
<input v-model.number="batchTestConfig.batchSize" type="number" min="1" max="100"
class="w-full bg-gray-800 border border-gray-600 rounded-lg px-4 py-2 text-white font-mono focus:outline-none focus:border-blue-500">
</div>
</div>
<div>
<label class="text-sm text-slate-400 block mb-2">Error Threshold (stop after N consecutive errors):</label>
<input v-model.number="batchTestConfig.errorThreshold" type="number" min="1" max="100"
class="w-full bg-gray-800 border border-gray-600 rounded-lg px-4 py-2 text-white font-mono focus:outline-none focus:border-blue-500">
</div>
<div>
<label class="text-sm text-slate-400 block mb-2">Problem IDs (one per line):</label>
<textarea v-model="batchTestConfig.problemsText"
class="w-full bg-gray-800 border border-gray-600 rounded-lg px-4 py-3 text-white font-mono focus:outline-none focus:border-blue-500 h-32"
placeholder="hello_world add_two_numbers ..."></textarea>
<p class="text-xs text-slate-500 mt-1">Tests will cycle through these problems. Make sure they exist in /api/v1/test_local/</p>
</div>
<div class="flex gap-3 pt-2">
<button @click="startBatchTest"
class="flex-1 bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-500 hover:to-blue-500 text-white px-4 py-3 rounded-lg font-bold transition-colors">
🚀 Start Test
</button>
<button @click="showBatchConfigModal = false"
class="flex-1 bg-gray-700 hover:bg-gray-600 text-white px-4 py-3 rounded-lg font-bold transition-colors">
Cancel
</button>
</div>
</div>
</div>
</div>
</div>
<script>
const { createApp, ref, onMounted, computed, reactive } = Vue
createApp({
setup() {
const stats = ref({})
const historyList = ref([])
const authHistory = ref([])
const checkers = ref([])
const problems = ref([])
const selectedProblem = ref(null)
const isPaused = ref(false)
const currentTab = ref('monitor')
const selectedJob = ref(null)
// API Key 管理
const apiKey = ref(localStorage.getItem('sandbox_api_key') || '')
const showApiKeyModal = ref(false)
const apiKeyInput = ref('')
// 批量測試設定
const batchTestConfig = reactive({
totalTests: 100,
batchSize: 10,
problemsText: 'hello_world\nadd_two_numbers', // 用於 textarea 綁定
errorThreshold: 5 // 連續錯誤達此數則停止
})
// 計算屬性:將文字轉為陣列
const batchTestProblems = computed(() => {
return batchTestConfig.problemsText.split('\n').map(p => p.trim()).filter(p => p)
})
const showBatchConfigModal = ref(false)
const batchTestProgress = reactive({
running: false,
current: 0,