-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstartup.html
More file actions
855 lines (793 loc) · 33.6 KB
/
Copy pathstartup.html
File metadata and controls
855 lines (793 loc) · 33.6 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>sirosid-dev</title>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Helvetica Neue', Arial, system-ui, sans-serif;
min-height: 100vh;
color: #1a1a1a;
background: #fff;
font-size: 14px;
line-height: 1.5;
}
.navbar {
background: #fff;
border-bottom: 1px solid #e0e0e0;
position: sticky; top: 0; z-index: 100;
}
.navbar-inner {
max-width: 1200px;
margin: 0 auto;
padding: 0.6rem 2rem;
display: flex;
align-items: center;
}
.navbar-brand {
display: flex; align-items: center; gap: 0.6rem;
text-decoration: none; color: #1C4587;
font-weight: 600; font-size: 1.1rem;
}
.navbar-brand svg { height: 32px; width: auto; }
.navbar-links {
margin-left: auto;
display: flex; gap: 1.25rem; align-items: center;
}
.navbar-links a {
color: #555; text-decoration: none;
font-size: 0.875rem; font-weight: 500;
transition: color 0.2s;
}
.navbar-links a:hover { color: #1C4587; }
.content { max-width: 1200px; margin: 2rem auto; padding: 0 2rem; }
h1 { color: #1C4587; font-size: 1.6rem; margin-bottom: 0.5rem; font-weight: 700; }
.subtitle { color: #555; margin-bottom: 1.5rem; font-size: 0.95rem; }
a { color: #1C4587; text-decoration: none; }
a:hover { text-decoration: underline; }
.card {
background: #fff;
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 1.25rem;
margin-bottom: 1.25rem;
}
.card h2 {
font-size: 0.85rem;
text-transform: uppercase;
letter-spacing: 0.03em;
color: #555;
font-weight: 600;
margin-bottom: 0.75rem;
}
.links { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.links a {
display: inline-block;
padding: 0.5rem 1.25rem;
background: #1C4587;
border: none;
border-radius: 6px;
color: #fff;
font-weight: 500;
font-size: 0.9rem;
transition: background 0.15s;
}
.links a:hover { background: #163a70; text-decoration: none; }
table { width: 100%; border-collapse: collapse; }
th {
text-align: left; color: #555; font-weight: 600; font-size: 0.8rem;
text-transform: uppercase; letter-spacing: 0.03em;
padding: 0.5rem 0.75rem; border-bottom: 1px solid #e0e0e0;
background: #f8f9fa;
}
td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #e0e0e0; vertical-align: top; }
.svc-name { font-weight: 500; color: #1a1a1a; white-space: nowrap; }
.status-dot {
display: inline-block; width: 8px; height: 8px;
border-radius: 50%; margin-right: 6px; vertical-align: middle;
}
.dot-up { background: #22c55e; }
.dot-down { background: #ccc; }
.dot-checking { background: #f59e0b; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }
.meta { color: #555; font-size: 0.8rem; }
code {
background: #f0f0f0;
padding: 0.15rem 0.4rem;
border-radius: 3px;
font-size: 0.85em;
color: #333;
}
.footer {
border-top: 1px solid #e0e0e0;
margin-top: 2rem;
padding: 1.5rem 0;
font-size: 0.8rem;
color: #555;
}
.footer-inner {
max-width: 1200px;
margin: 0 auto;
padding: 0 2rem;
display: flex;
align-items: center;
justify-content: space-between;
}
.footer a { color: #555; transition: color 0.2s; }
.footer a:hover { color: #1C4587; text-decoration: none; }
.port { color: #888; font-size: 0.75rem; font-weight: normal; }
/* Conformance card styles */
.conf-btn {
display: inline-block;
padding: 0.4rem 1rem;
border: none;
border-radius: 6px;
color: #fff;
font-weight: 500;
font-size: 0.85rem;
cursor: pointer;
transition: background 0.15s, opacity 0.15s;
}
.conf-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.conf-btn-primary { background: #1C4587; }
.conf-btn-primary:hover:not(:disabled) { background: #163a70; }
.conf-btn-secondary { background: #555; }
.conf-btn-secondary:hover:not(:disabled) { background: #444; }
.conf-run-grid { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.conf-status { margin-bottom: 0.75rem; font-size: 0.9rem; }
.conf-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.conf-results { margin-top: 0.75rem; }
.conf-results table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.conf-results th { text-align: left; color: #555; font-weight: 600; font-size: 0.75rem; text-transform: uppercase; padding: 0.35rem 0.5rem; border-bottom: 1px solid #e0e0e0; background: #f8f9fa; }
.conf-results td { padding: 0.35rem 0.5rem; border-bottom: 1px solid #e0e0e0; }
.conf-results td a { color: #1C4587; text-decoration: none; font-size: 0.75rem; }
.conf-results td a:hover { text-decoration: underline; }
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.badge-pass { background: #dcfce7; color: #166534; }
.badge-fail { background: #fee2e2; color: #991b1b; }
.badge-warn { background: #fef9c3; color: #854d0e; }
.badge-run { background: #dbeafe; color: #1e40af; }
.badge-skip { background: #f0f0f0; color: #555; }
.run-header { cursor: pointer; padding: 0.6rem 0; border-bottom: 1px solid #e0e0e0; user-select: none; }
.run-header:hover { background: #f8f9fa; }
.run-toggle { display: inline-block; width: 1em; font-size: 0.8rem; color: #888; margin-right: 0.3rem; }
.run-time { font-size: 0.75rem; color: #888; margin-left: 0.5rem; }
.run-body { padding: 0.5rem 0; }
.run-body.collapsed { display: none; }
.run-summary { display: inline-flex; gap: 0.5rem; align-items: center; }
/* Log viewer panel */
.log-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 200; }
.log-overlay.active { display: block; }
.log-panel {
position: fixed; top: 0; right: 0; bottom: 0; width: min(75vw, 900px);
background: #fff; box-shadow: -4px 0 20px rgba(0,0,0,0.15); z-index: 201;
display: flex; flex-direction: column; transform: translateX(100%);
transition: transform 0.2s ease;
}
.log-panel.active { transform: translateX(0); }
.log-panel-header {
display: flex; align-items: center; gap: 0.75rem; padding: 1rem 1.25rem;
border-bottom: 1px solid #e0e0e0; background: #f8f9fa; flex-shrink: 0;
}
.log-panel-header h3 { font-size: 0.95rem; font-weight: 600; color: #1a1a1a; flex: 1; margin: 0; }
.log-panel-close {
background: none; border: none; font-size: 1.4rem; cursor: pointer;
color: #888; padding: 0 0.3rem; line-height: 1;
}
.log-panel-close:hover { color: #333; }
.log-panel-body { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; }
.log-entry { margin-bottom: 0.75rem; border: 1px solid #e8e8e8; border-radius: 6px; overflow: hidden; }
.log-entry-header {
display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.75rem;
background: #f8f9fa; cursor: pointer; font-size: 0.82rem; user-select: none;
}
.log-entry-header:hover { background: #f0f0f0; }
.log-src { font-weight: 600; color: #555; min-width: 5em; }
.log-msg { flex: 1; color: #1a1a1a; word-break: break-word; }
.log-entry-body { display: none; padding: 0.5rem 0.75rem; font-size: 0.78rem; background: #fafafa; border-top: 1px solid #e8e8e8; }
.log-entry-body.open { display: block; }
.log-entry-body pre {
white-space: pre-wrap; word-break: break-all; margin: 0;
font-family: 'SF Mono', 'Consolas', 'Monaco', monospace; font-size: 0.78rem;
color: #333; max-height: 400px; overflow-y: auto;
}
.log-entry.log-fail { border-left: 3px solid #ef4444; }
.log-entry.log-pass { border-left: 3px solid #22c55e; }
.log-entry.log-warn { border-left: 3px solid #f59e0b; }
.log-entry.log-info { border-left: 3px solid #3b82f6; }
.log-module-info { margin-bottom: 1rem; padding: 0.75rem; background: #f8f9fa; border-radius: 6px; font-size: 0.85rem; }
.log-module-info dt { font-weight: 600; color: #555; display: inline; }
.log-module-info dd { display: inline; margin: 0 1rem 0 0.3rem; }
/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid #e0e0e0; margin-bottom: 1.25rem; }
.tab {
padding: 0.6rem 1.5rem;
font-size: 0.9rem;
font-weight: 600;
color: #555;
cursor: pointer;
border: none;
background: none;
border-bottom: 2px solid transparent;
margin-bottom: -2px;
transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: #1C4587; }
.tab.active { color: #1C4587; border-bottom-color: #1C4587; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
</style>
</head>
<body>
<nav class="navbar">
<div class="navbar-inner">
<a class="navbar-brand" href="/">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 239 234" width="32" height="32">
<path fill="#1C4587" d="M 51.746094 89.585938 C 85.816406 84.324219 85.816406 84.324219 91.074219 50.246094 C 96.335938 84.324219 96.335938 84.324219 130.40625 89.585938 C 96.328125 94.84375 96.335938 94.910156 91.074219 128.929688 C 85.816406 94.847656 85.816406 94.847656 51.746094 89.585938 M 162.640625 217.410156 C 153.421875 157.6875 153.421875 157.6875 93.714844 148.46875 C 153.421875 139.246094 153.421875 139.246094 162.640625 79.523438 C 171.621094 137.710938 171.863281 139.207031 227.089844 147.773438 C 229.964844 137.921875 231.511719 127.503906 231.511719 116.71875 C 231.511719 55.589844 181.964844 6.03125 120.847656 6.03125 C 59.734375 6.03125 10.1875 55.589844 10.1875 116.71875 C 10.1875 177.851562 59.734375 227.410156 120.847656 227.410156 C 170.65625 227.410156 212.777344 194.496094 226.660156 149.226562 C 171.84375 157.730469 171.597656 159.472656 162.640625 217.410156"/>
</svg>
sirosid-dev
</a>
<div class="navbar-links">
<a href="/id/default/login">Login</a>
<a href="/id/default/">Dashboard</a>
</div>
</div>
</nav>
<div class="content">
<h1>Development Environment</h1>
<div class="subtitle">Local service dashboard</div>
<div class="card">
<h2>Quick Links</h2>
<div class="links">
<a href="/id/default/login">Wallet Login</a>
<a href="/id/default/">Wallet Dashboard</a>
</div>
</div>
<div class="tabs">
<button class="tab active" onclick="switchTab('status')">Status</button>
<button class="tab" onclick="switchTab('conformance')">Conformance</button>
</div>
<div id="tab-status" class="tab-panel active">
<div class="card">
<h2>Services</h2>
<table>
<thead><tr><th>Service</th><th>Status</th><th>Details</th></tr></thead>
<tbody id="svc-table"></tbody>
</table>
</div>
<div class="card" id="storage-card">
<h2>Storage</h2>
<div id="storage-body"><span class="meta">Checking env-admin…</span></div>
</div>
<div class="card">
<h2>Build Info</h2>
<div id="build-info"><span class="meta">Loading…</span></div>
</div>
</div>
<div id="tab-conformance" class="tab-panel">
<div class="card" id="conformance-card">
<h2>Conformance Suite</h2>
<div class="conf-status" id="conf-status">
<span class="conf-status-dot dot-checking"></span>Checking conformance suite…
</div>
<div class="conf-run-grid" id="conf-buttons"></div>
<div class="conf-results" id="conf-results"></div>
</div>
</div>
</div>
<div class="footer">
<div class="footer-inner">
<span>© SIROS Foundation · Auto-refreshes every 10s</span>
<a href="#" onclick="checkAll();return false;">Refresh now</a>
</div>
</div>
<script>
function switchTab(name) {
document.querySelectorAll('.tab-panel').forEach(function(p) { p.classList.remove('active'); });
document.querySelectorAll('.tab').forEach(function(t) { t.classList.remove('active'); });
document.getElementById('tab-' + name).classList.add('active');
document.querySelector('.tab[onclick*="' + name + '"]').classList.add('active');
}
var SERVICES = [
{ name: "wallet-frontend", check: "/id/default/login", port: 3000 },
{ name: "wallet-backend", check: "/_health/backend", port: 8080 },
{ name: "wallet-admin", check: "/_health/admin", port: 8081 },
{ name: "wallet-engine", check: "/_health/engine", port: 8082 },
{ name: "mock-trust-pdp", check: "/_health/mock-pdp", port: 9081 },
{ name: "mock-verifier", check: "/_health/mock-verifier", port: 9011 },
{ name: "vctm-registry", check: "/_health/registry", port: 8080 },
{ name: "go-trust", check: "/_health/go-trust", port: 9095 },
{ name: "vc-issuer", check: "/_health/vc-issuer", port: 9000 },
{ name: "vc-verifier", check: "/_health/vc-verifier", port: 9001 },
{ name: "vc-apigw", check: "/_health/vc-apigw", port: 9003 },
{ name: "vc-registry", check: "/_health/vc-registry", port: 9004 },
{ name: "mini-oidc", check: "/_health/mini-oidc", port: 9005 }
];
var svcStatus = {};
function renderTable() {
var tbody = document.getElementById("svc-table");
tbody.innerHTML = "";
SERVICES.forEach(function(svc) {
var s = svcStatus[svc.name] || { state: "checking", detail: null };
var dotClass = s.state === "up" ? "dot-up" : s.state === "down" ? "dot-down" : "dot-checking";
var label = s.state === "up" ? "running" : s.state === "down" ? "not reachable" : "checking\u2026";
var detail = "";
if (s.detail) {
var parts = [];
if (s.detail.service) parts.push(s.detail.service);
if (s.detail.roles) parts.push("roles: " + s.detail.roles.join(", "));
if (s.detail.capabilities) parts.push(s.detail.capabilities.length + " capabilities");
if (s.detail.mode) parts.push("mode: " + s.detail.mode);
if (s.detail.pdp) parts.push(s.detail.pdp);
if (s.detail.verifier) parts.push(s.detail.verifier);
if (s.detail.trusted_issuers) parts.push(s.detail.trusted_issuers + " issuers");
if (s.detail.trusted_verifiers) parts.push(s.detail.trusted_verifiers + " verifiers");
detail = parts.join(" · ");
}
var tr = document.createElement("tr");
tr.innerHTML =
'<td class="svc-name">' + svc.name + ' <span class="port">:' + svc.port + '</span></td>' +
'<td><span class="status-dot ' + dotClass + '"></span>' + label + '</td>' +
'<td class="meta">' + detail + '</td>';
tbody.appendChild(tr);
});
}
function checkService(svc) {
svcStatus[svc.name] = { state: "checking", detail: null };
fetch(svc.check, { mode: "cors" })
.then(function(r) {
if (!r.ok) throw new Error(r.status);
return r.text().then(function(text) {
try { return JSON.parse(text); } catch(e) { return null; }
});
})
.then(function(data) {
svcStatus[svc.name] = { state: "up", detail: data };
renderTable();
})
.catch(function() {
svcStatus[svc.name] = { state: "down", detail: null };
renderTable();
});
}
function checkAll() {
SERVICES.forEach(checkService);
}
function loadBuildInfo() {
fetch("/build-info.json")
.then(function(r) { if (!r.ok) throw new Error(r.status); return r.json(); })
.then(function(info) {
var el = document.getElementById("build-info");
// Source repos: what's checked out on disk right now.
var html = '<div class="meta" style="margin-bottom:0.35rem">Source repositories — git state on disk</div>';
html += '<table style="width:100%">';
html += '<thead><tr><th>Component</th><th>Branch</th><th>Commit</th><th>Last commit</th></tr></thead><tbody>';
(info.components || []).forEach(function(c) {
// A dirty tree means the running image may not match this commit.
var dirty = c.dirty
? ' <span title="uncommitted changes - a built image may not match this commit"'
+ ' style="color:#B45309;font-weight:600">dirty</span>'
: '';
html += '<tr>' +
'<td class="svc-name">' + esc(c.name) + dirty + '</td>' +
'<td class="meta"><code>' + esc(c.branch || "?") + '</code></td>' +
'<td class="meta"><code>' + esc((c.commit || "?").substring(0, 10)) + '</code></td>' +
'<td class="meta">' + esc(c.built || "?") + '</td></tr>';
});
html += '</tbody></table>';
// Running images: what each container is ACTUALLY running, which the
// git table above can't tell you - a local image can lag its repo, and
// several components are pulled rather than built at all.
var services = info.services || [];
if (services.length) {
html += '<div class="meta" style="margin:0.9rem 0 0.35rem">Running images — what each container came from</div>';
html += '<table style="width:100%">';
html += '<thead><tr><th>Service</th><th>Origin</th><th>Image</th><th>Image ID</th><th>Started</th></tr></thead><tbody>';
services.forEach(function(s) {
var col = s.origin === "registry" ? "#1C4587"
: s.origin === "local build" ? "#166534" : "#888";
html += '<tr>' +
'<td class="svc-name">' + esc(s.service) + '</td>' +
'<td class="meta" style="color:' + col + ';font-weight:600">' + esc(s.origin || "?") + '</td>' +
'<td class="meta"><code>' + esc(s.image || "?") + '</code></td>' +
'<td class="meta"><code>' + esc(s.image_id || "?") + '</code></td>' +
'<td class="meta">' + esc(s.created || "?") + '</td></tr>';
});
html += '</tbody></table>';
}
if (info.generated) {
html += '<div class="meta" style="margin-top:0.5rem">Generated: ' + esc(info.generated) +
' — refresh with <code>make build-info</code></div>';
}
el.innerHTML = html;
})
.catch(function() {
document.getElementById("build-info").innerHTML =
'<span class="meta">Not available — run <code>make build-info</code> to generate</span>';
});
}
function esc(s) {
var d = document.createElement("div");
d.appendChild(document.createTextNode(s));
return d.innerHTML;
}
// Unregister any service workers that might intercept navigation to /
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then(function(regs) {
regs.forEach(function(r) { r.unregister(); });
});
}
checkAll();
loadBuildInfo();
setInterval(checkAll, 10000);
// =========================================================================
// Conformance Dashboard
// =========================================================================
var confBase = "/_conformance";
var confAvailable = false;
var confRuns = {}; // runId -> run state
var confEventSource = null;
function confStatusEl() { return document.getElementById("conf-status"); }
function checkConformance() {
fetch(confBase + "/api/status")
.then(function(r) { return r.json(); })
.then(function(data) {
confAvailable = data.conformance_suite === "connected";
var dot = confAvailable ? "dot-up" : "dot-down";
var label = confAvailable ? "Connected" : "Not available";
confStatusEl().innerHTML =
'<span class="conf-status-dot ' + dot + '"></span>' + label +
' <span class="meta">(' + esc(data.url || "") + ')</span>';
if (confAvailable) {
loadConfPlans();
if (!confEventSource) connectSSE();
}
})
.catch(function() {
confAvailable = false;
confStatusEl().innerHTML =
'<span class="conf-status-dot dot-down"></span>Runner not available ' +
'<span class="meta">(start with <code>make up CONFORMANCE=yes</code>)</span>';
});
}
function loadConfPlans() {
fetch(confBase + "/api/plans")
.then(function(r) { return r.json(); })
.then(function(plans) {
var el = document.getElementById("conf-buttons");
el.innerHTML = "";
plans.forEach(function(p) {
var btn = document.createElement("button");
btn.className = "conf-btn " + (p.phase === 1 ? "conf-btn-primary" : "conf-btn-secondary");
btn.textContent = p.label;
btn.title = p.planName + " (Phase " + p.phase + ")";
btn.onclick = function() { startConfRun(p.id, btn); };
el.appendChild(btn);
});
})
.catch(function() {});
}
function startConfRun(planType, btn) {
if (btn) btn.disabled = true;
fetch(confBase + "/api/runs", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ planType: planType })
})
.then(function(r) { return r.json(); })
.then(function(data) {
if (data.error) {
alert("Error: " + data.error);
if (btn) btn.disabled = false;
return;
}
confRuns[data.id] = {
id: data.id,
planType: data.planType,
status: "creating",
startedAt: Date.now(),
modules: [],
results: []
};
renderConfResults();
setTimeout(function() { if (btn) btn.disabled = false; }, 5000);
})
.catch(function(err) {
alert("Failed to start run: " + err);
if (btn) btn.disabled = false;
});
}
function connectSSE() {
if (confEventSource) confEventSource.close();
confEventSource = new EventSource(confBase + "/api/events");
confEventSource.addEventListener("run_start", function(e) {
var d = JSON.parse(e.data);
confRuns[d.id] = confRuns[d.id] || { id: d.id, planType: d.planType, status: "creating", startedAt: Date.now(), modules: [], results: [] };
confRuns[d.id].label = d.label;
collapsedRuns[d.id] = false; // new runs start expanded
renderConfResults();
});
confEventSource.addEventListener("run_update", function(e) {
var d = JSON.parse(e.data);
if (confRuns[d.id]) {
confRuns[d.id].status = d.status;
if (d.modules) confRuns[d.id].modules = d.modules;
if (d.planId) confRuns[d.id].planId = d.planId;
if (d.planDetailUrl) confRuns[d.id].planDetailUrl = d.planDetailUrl;
}
renderConfResults();
});
confEventSource.addEventListener("run_state", function(e) {
var d = JSON.parse(e.data);
confRuns[d.id] = d;
renderConfResults();
});
confEventSource.addEventListener("module_event", function(e) {
var d = JSON.parse(e.data);
var run = confRuns[d.runId];
if (!run) return;
if (d.type === "module_start") {
run.currentModule = d.module;
} else if (d.type === "module_result") {
run.results = run.results || [];
var idx = run.results.findIndex(function(r) { return r.module === d.module; });
var entry = { module: d.module, status: d.status, result: d.result, moduleId: d.moduleId, logUrl: d.logUrl };
if (idx >= 0) run.results[idx] = entry;
else run.results.push(entry);
run.currentModule = null;
}
renderConfResults();
});
confEventSource.addEventListener("run_finished", function(e) {
var d = JSON.parse(e.data);
if (confRuns[d.id]) {
confRuns[d.id].status = "finished";
confRuns[d.id].passed = d.passed;
confRuns[d.id].failed = d.failed;
confRuns[d.id].total = d.total;
confRuns[d.id].finishedAt = Date.now();
confRuns[d.id].planDetailUrl = d.planDetailUrl;
// Auto-expand finished runs
collapsedRuns[d.id] = false;
}
renderConfResults();
});
confEventSource.addEventListener("run_error", function(e) {
var d = JSON.parse(e.data);
if (confRuns[d.id]) {
confRuns[d.id].status = "error";
confRuns[d.id].error = d.error;
}
renderConfResults();
});
confEventSource.onerror = function() {
setTimeout(function() { if (confAvailable) connectSSE(); }, 5000);
};
}
function resultBadge(result) {
if (!result) return '<span class="badge badge-run">running</span>';
var cls = result === "PASSED" ? "badge-pass"
: result === "WARNING" ? "badge-warn"
: result === "SKIPPED" || result === "REVIEW" ? "badge-skip"
: "badge-fail";
return '<span class="badge ' + cls + '">' + esc(result) + '</span>';
}
function formatTime(ts) {
if (!ts) return "";
var d = new Date(ts);
return d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" });
}
function formatDuration(start, end) {
if (!start || !end) return "";
var secs = Math.round((end - start) / 1000);
if (secs < 60) return secs + "s";
return Math.floor(secs / 60) + "m " + (secs % 60) + "s";
}
var collapsedRuns = {};
function toggleRunCollapse(id) {
collapsedRuns[id] = !collapsedRuns[id];
var body = document.getElementById("run-body-" + id);
if (body) body.classList.toggle("collapsed", !!collapsedRuns[id]);
var toggle = document.getElementById("run-toggle-" + id);
if (toggle) toggle.textContent = collapsedRuns[id] ? "▶" : "▼";
}
function renderConfResults() {
var el = document.getElementById("conf-results");
var ids = Object.keys(confRuns).sort(function(a, b) {
return (confRuns[b].startedAt || 0) - (confRuns[a].startedAt || 0);
});
if (ids.length === 0) {
el.innerHTML = '<span class="meta">No runs yet. Click a button above to start a conformance test plan.</span>';
return;
}
var html = "";
ids.forEach(function(id) {
var run = confRuns[id];
var isActive = run.status === "running" || run.status === "creating";
// Auto-collapse finished/error runs (but not if user toggled)
if (!(id in collapsedRuns)) collapsedRuns[id] = !isActive && run.status !== "finished";
var collapsed = collapsedRuns[id];
// Status badge for the run header
var statusBadge = "";
if (run.status === "finished") {
var passCount = (run.results || []).filter(function(r) { return r.result === "PASSED"; }).length;
var failCount = (run.results || []).filter(function(r) { return r.result !== "PASSED" && r.result !== "SKIPPED"; }).length;
var total = (run.results || []).length;
if (failCount === 0) {
statusBadge = '<span class="badge badge-pass">' + passCount + '/' + total + ' passed</span>';
} else {
statusBadge = '<span class="badge badge-fail">' + failCount + ' failed</span> <span class="badge badge-pass">' + passCount + ' passed</span>';
}
} else if (run.status === "error") {
statusBadge = '<span class="badge badge-fail">error</span>';
} else if (run.status === "running") {
statusBadge = '<span class="badge badge-run">running</span>';
} else {
statusBadge = '<span class="badge badge-run">' + esc(run.status) + '</span>';
}
// Time info
var timeInfo = formatTime(run.startedAt);
if (run.finishedAt) timeInfo += " (" + formatDuration(run.startedAt, run.finishedAt) + ")";
html += '<div style="margin-bottom:0.5rem">';
// Collapsible header
html += '<div class="run-header" onclick="toggleRunCollapse(\'' + esc(id) + '\')">';
html += '<span class="run-toggle" id="run-toggle-' + esc(id) + '">' + (collapsed ? '▶' : '▼') + '</span>';
html += '<strong>' + esc(run.label || run.planType) + '</strong> ';
html += '<span class="run-summary">' + statusBadge + '</span>';
if (timeInfo) html += '<span class="run-time">' + esc(timeInfo) + '</span>';
if (run.planDetailUrl) {
html += ' <a href="' + esc(run.planDetailUrl) + '" target="_blank" style="font-size:0.75rem;color:#1C4587" onclick="event.stopPropagation()">↗ suite</a>';
}
html += '</div>';
// Collapsible body
html += '<div class="run-body' + (collapsed ? ' collapsed' : '') + '" id="run-body-' + esc(id) + '">';
if (run.status === "error") {
html += '<div style="color:#991b1b;font-size:0.85rem;padding:0.4rem 0">Error: ' + esc(run.error || "unknown") + '</div>';
}
// Module table
var modules = run.modules || [];
var results = run.results || [];
if (modules.length > 0 || results.length > 0) {
html += '<table><thead><tr><th>Module</th><th>Result</th><th></th></tr></thead><tbody>';
// Show completed results first
results.forEach(function(r) {
html += '<tr><td class="svc-name">' + esc(r.module) + '</td><td>' + resultBadge(r.result) + '</td>';
html += '<td>';
if (r.moduleId) {
html += '<a href="#" onclick="event.preventDefault();showLog(\'' + esc(r.moduleId) + '\',\'' + esc(r.module) + '\')">view log</a>';
}
html += '</td></tr>';
});
// Show pending modules
var completedModules = results.map(function(r) { return r.module; });
modules.forEach(function(m) {
if (completedModules.indexOf(m) >= 0) return;
var badge = m === run.currentModule
? '<span class="badge badge-run">running</span>'
: '<span class="meta">pending</span>';
html += '<tr><td class="svc-name">' + esc(m) + '</td><td>' + badge + '</td><td></td></tr>';
});
html += '</tbody></table>';
}
html += '</div>'; // close run-body
html += '</div>'; // close outer
});
el.innerHTML = html;
}
// Load previous runs
function loadConfRuns() {
fetch(confBase + "/api/runs")
.then(function(r) { return r.json(); })
.then(function(list) {
list.forEach(function(run) { confRuns[run.id] = run; });
renderConfResults();
})
.catch(function() {});
}
checkConformance();
loadConfRuns();
setInterval(checkConformance, 30000);
// =========================================================================
// Log Viewer
// =========================================================================
function showLog(moduleId, moduleName) {
var overlay = document.getElementById("log-overlay");
var panel = document.getElementById("log-panel");
var body = document.getElementById("log-panel-body");
var title = document.getElementById("log-panel-title");
title.textContent = moduleName || moduleId;
body.innerHTML = '<span class="meta">Loading log…</span>';
overlay.classList.add("active");
// Trigger panel slide after overlay is visible
requestAnimationFrame(function() { panel.classList.add("active"); });
// Fetch module info and log in parallel
Promise.all([
fetch(confBase + "/api/info/" + encodeURIComponent(moduleId)).then(function(r) { return r.json(); }),
fetch(confBase + "/api/log/" + encodeURIComponent(moduleId)).then(function(r) { return r.json(); })
]).then(function(results) {
var info = results[0];
var log = results[1];
renderLogPanel(info, log);
}).catch(function(err) {
body.innerHTML = '<div style="color:#991b1b">Failed to load log: ' + esc(String(err)) + '</div>';
});
}
function closeLogPanel() {
var panel = document.getElementById("log-panel");
var overlay = document.getElementById("log-overlay");
panel.classList.remove("active");
setTimeout(function() { overlay.classList.remove("active"); }, 200);
}
function renderLogPanel(info, log) {
var body = document.getElementById("log-panel-body");
var html = "";
// Module summary
html += '<div class="log-module-info"><dl style="margin:0">';
html += '<dt>Status:</dt><dd>' + resultBadge(info.result || info.status) + '</dd>';
if (info.testModule) { html += '<dt>Module:</dt><dd>' + esc(info.testModule) + '</dd>'; }
if (info.testName) { html += '<dt>Test:</dt><dd>' + esc(info.testName) + '</dd>'; }
if (info.description) { html += '<dt>Description:</dt><dd>' + esc(info.description) + '</dd>'; }
html += '</dl></div>';
// Log entries
if (!Array.isArray(log) || log.length === 0) {
html += '<span class="meta">No log entries.</span>';
} else {
log.forEach(function(entry, idx) {
var src = entry.src || "";
var msg = entry.msg || "";
var result = entry.result || "";
var entryClass = "log-info";
if (result === "FAILURE") entryClass = "log-fail";
else if (result === "WARNING") entryClass = "log-warn";
else if (result === "SUCCESS") entryClass = "log-pass";
else if (msg.toLowerCase().indexOf("error") >= 0 || msg.toLowerCase().indexOf("fail") >= 0) entryClass = "log-fail";
html += '<div class="log-entry ' + entryClass + '">';
html += '<div class="log-entry-header" onclick="toggleLogEntry(' + idx + ')">';
if (result) html += resultBadge(result === "FAILURE" ? "FAILED" : result) + ' ';
html += '<span class="log-src">' + esc(src) + '</span>';
html += '<span class="log-msg">' + esc(msg.substring(0, 200)) + (msg.length > 200 ? "..." : "") + '</span>';
html += '</div>';
// Detail body — show all fields
html += '<div class="log-entry-body" id="log-entry-' + idx + '">';
if (msg.length > 200) {
html += '<p><strong>Message:</strong></p><pre>' + esc(msg) + '</pre>';
}
// Show other relevant fields
var skipKeys = {"src":1, "msg":1, "result":1, "_type":1};
var details = Object.keys(entry).filter(function(k) { return !skipKeys[k] && entry[k]; });
if (details.length > 0) {
details.forEach(function(k) {
var val = entry[k];
if (typeof val === "object") val = JSON.stringify(val, null, 2);
else val = String(val);
html += '<p style="margin:0.3rem 0"><strong>' + esc(k) + ':</strong></p>';
html += '<pre>' + esc(val) + '</pre>';
});
}
html += '</div>';
html += '</div>';
});
}
body.innerHTML = html;
}
function toggleLogEntry(idx) {
var el = document.getElementById("log-entry-" + idx);
if (el) el.classList.toggle("open");
}
</script>
<!-- Log viewer panel -->
<div id="log-overlay" class="log-overlay" onclick="closeLogPanel()"></div>
<div id="log-panel" class="log-panel" onclick="event.stopPropagation()">
<div class="log-panel-header">
<h3 id="log-panel-title">Log</h3>
<button class="log-panel-close" onclick="closeLogPanel()" title="Close">×</button>
</div>
<div class="log-panel-body" id="log-panel-body"></div>
</div>
<!-- Storage card: status of every store + "Clear all data" via env-admin.
One file shared with the Fly dashboard (dashboard/storage-card.js). -->
<script src="/storage-card.js"></script>
</body>
</html>