@syncular/server-hono 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-page.d.ts +15 -16
- package/dist/admin-page.js +1626 -493
- package/dist/admin.d.ts +39 -12
- package/dist/admin.js +268 -203
- package/dist/index.d.ts +15 -0
- package/dist/index.js +31 -8
- package/package.json +4 -3
- package/src/admin-page.ts +1626 -493
- package/src/admin.ts +403 -218
- package/src/index.ts +56 -8
package/dist/admin-page.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The single static console page
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* The single static console page: no framework, no build step, one file.
|
|
3
|
+
* It fetches the sibling JSON endpoints (relative to its own mount path)
|
|
4
|
+
* and renders them in eight views: Overview, Clients, Commits, Rows,
|
|
5
|
+
* Scopes, Events, Reactions, and Storage. Each view loads only the
|
|
6
|
+
* endpoints it shows, so a refresh on one view costs one to five reads.
|
|
6
7
|
*
|
|
7
|
-
* Styling follows docs/STYLE.md:
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Styling follows docs/STYLE.md and the docs shell: pure black, one amber
|
|
9
|
+
* accent with phosphor/red status colors, hairline borders, square corners.
|
|
10
|
+
* The page ships as one self-contained string with no network fetches, so
|
|
11
|
+
* it uses the system font stacks (monospace for data, sans for prose); a
|
|
12
|
+
* host with IBM Plex installed renders in Plex.
|
|
11
13
|
*
|
|
12
14
|
* The HTML is a single exported string so the routes module can serve it
|
|
13
15
|
* with no filesystem read (works identically on Bun, Node, and Workers).
|
|
@@ -18,202 +20,477 @@
|
|
|
18
20
|
* frame. Static demos can reuse this page while their admin routes run in a
|
|
19
21
|
* Web Worker.
|
|
20
22
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* a table filter), the row inspector, scope activity, and the event tail —
|
|
26
|
-
* live over SSE (`/events/stream`) when the ring is wired, falling back to
|
|
27
|
-
* the 2-second poll otherwise.
|
|
23
|
+
* The event tail is live over SSE (`/events/stream`) when the ring is wired.
|
|
24
|
+
* The parent transport carries no stream, and an SSE failure closes the
|
|
25
|
+
* stream for good; both states poll `/events` on every refresh and say so
|
|
26
|
+
* in the header and the Events view.
|
|
28
27
|
*/
|
|
29
28
|
export const ADMIN_CONSOLE_HTML = `<!doctype html>
|
|
30
29
|
<html lang="en">
|
|
31
30
|
<head>
|
|
32
31
|
<meta charset="utf-8" />
|
|
33
32
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
33
|
+
<meta name="color-scheme" content="dark" />
|
|
34
34
|
<title>Syncular console</title>
|
|
35
|
+
<link rel="icon" href="data:," />
|
|
35
36
|
<style>
|
|
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
|
-
|
|
37
|
+
:root{--void:#000;--panel:#0a0908;--raised:#12110f;--ink:#f4efe4;--dim:#9a948a;--faint:#756f64;--line:rgba(154,148,138,.22);--line-strong:rgba(154,148,138,.45);--amber:#ffb000;--phos:#a9bf6e;--cyan:#6fb3c0;--sand:#e3d3a2;--red:#ff7a59;
|
|
38
|
+
--mono:'IBM Plex Mono',ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--sans:'IBM Plex Sans',ui-sans-serif,system-ui,-apple-system,'Segoe UI',sans-serif;color-scheme:dark}
|
|
39
|
+
*{box-sizing:border-box}
|
|
40
|
+
body{margin:0;height:100vh;display:flex;flex-direction:column;background:var(--void);color:var(--ink);font:13px/1.5 var(--mono);-webkit-font-smoothing:antialiased}
|
|
41
|
+
::selection{background:var(--amber);color:#000}
|
|
42
|
+
:focus-visible{outline:2px solid var(--amber);outline-offset:2px}
|
|
43
|
+
button,input,select{font:inherit;color:inherit}
|
|
44
|
+
button{cursor:pointer}
|
|
45
|
+
[hidden]{display:none!important}
|
|
46
|
+
.field label,.btn,.pill,.side a,.kicker,.ph h2,.kpi .l,.verdict b,.kv dt,h3,.dt th,.st,.empty b,.banner b,.sugg,.seg button,.dt td::before{text-transform:uppercase}
|
|
47
|
+
code{font-family:var(--mono);font-size:.92em;color:var(--sand)}
|
|
48
|
+
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
|
|
49
|
+
.skip{position:absolute;left:8px;top:-40px;z-index:50;background:var(--amber);color:#000;padding:6px 10px}
|
|
50
|
+
.skip:focus{top:8px}
|
|
51
|
+
.dim{color:var(--dim)}
|
|
52
|
+
|
|
53
|
+
.top{flex:none;display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;min-height:56px;padding:8px 20px;border-bottom:1px solid var(--line);background:var(--void)}
|
|
54
|
+
.brand{display:flex;align-items:center;gap:10px;font-weight:600;font-size:13px;letter-spacing:.22em;white-space:nowrap;margin-right:6px}
|
|
55
|
+
.brand svg{width:20px;height:20px;flex:none}
|
|
56
|
+
.brand .sl{color:var(--faint);font-weight:400;letter-spacing:0}
|
|
57
|
+
.brand .sub{color:var(--amber);font-weight:500;letter-spacing:.14em}
|
|
58
|
+
.field{display:flex;align-items:stretch;height:32px;border:1px solid var(--line-strong);background:var(--void)}
|
|
59
|
+
.field:focus-within{border-color:var(--amber)}
|
|
60
|
+
.field label{display:flex;align-items:center;padding:0 9px;border-right:1px solid var(--line);font-size:10.5px;letter-spacing:.16em;color:var(--dim)}
|
|
61
|
+
.field input{width:13rem;min-width:0;border:0;outline:0;background:none;padding:0 10px;font-size:12px}
|
|
62
|
+
input::placeholder{color:var(--faint)}
|
|
63
|
+
.grow{flex:1}
|
|
64
|
+
.btn{height:32px;padding:0 12px;border:1px solid var(--line-strong);background:var(--void);font-size:11px;letter-spacing:.12em;white-space:nowrap;transition:border-color .15s,background .15s,color .15s}
|
|
65
|
+
.btn:hover{border-color:var(--ink)}
|
|
66
|
+
.btn.amber{background:var(--amber);border-color:var(--amber);color:#000;font-weight:600}
|
|
67
|
+
.btn.amber:hover{background:#ffc233;border-color:#ffc233}
|
|
68
|
+
.btn.on{border-color:var(--amber);color:var(--amber)}
|
|
69
|
+
.btn.sm{height:26px;padding:0 9px;font-size:10.5px}
|
|
70
|
+
.btn.sq{width:32px;padding:0}
|
|
71
|
+
.pill{display:inline-flex;align-items:center;gap:7px;height:26px;padding:0 9px;border:1px solid var(--line);font-size:10.5px;letter-spacing:.14em;color:var(--dim);white-space:nowrap}
|
|
72
|
+
.pill i{width:7px;height:7px;background:currentColor}
|
|
73
|
+
.pill.ok{color:var(--phos);border-color:rgba(169,191,110,.45)}
|
|
74
|
+
.pill.ok i{animation:pulse 1.6s ease-in-out infinite}
|
|
75
|
+
.pill.warn{color:var(--amber);border-color:rgba(255,176,0,.6)}
|
|
76
|
+
.pill.err{color:var(--red);border-color:var(--red)}
|
|
77
|
+
@keyframes pulse{50%{opacity:.25}}
|
|
78
|
+
#updated{font-size:11px;color:var(--dim);white-space:nowrap}
|
|
79
|
+
#updated.err{color:var(--red)}
|
|
80
|
+
|
|
81
|
+
.shell{flex:1;min-height:0;display:grid;grid-template-columns:208px minmax(0,1fr)}
|
|
82
|
+
.side{overflow:auto;border-right:1px solid var(--line);padding:12px 0}
|
|
83
|
+
.side a{display:flex;align-items:center;gap:10px;padding:9px 16px;border-left:2px solid transparent;color:var(--dim);text-decoration:none;font-size:11.5px;letter-spacing:.14em;white-space:nowrap}
|
|
84
|
+
.side a b{font-weight:400;font-size:10.5px;color:var(--faint)}
|
|
85
|
+
.side a .n{margin-left:auto;font-size:10.5px;letter-spacing:0;color:var(--faint)}
|
|
86
|
+
.side a:hover{color:var(--ink)}
|
|
87
|
+
.side a[aria-current=page]{color:var(--ink);border-left-color:var(--amber);background:linear-gradient(90deg,rgba(255,176,0,.09),transparent)}
|
|
88
|
+
.side a[aria-current=page] b{color:var(--amber)}
|
|
89
|
+
.side .foot{margin-top:12px;padding:12px 16px;border-top:1px solid var(--line);font-size:10.5px;letter-spacing:.06em;color:var(--faint);line-height:1.8}
|
|
90
|
+
kbd{display:inline-block;min-width:18px;padding:0 4px;border:1px solid var(--line-strong);font:10.5px/16px var(--mono);text-align:center;color:var(--ink)}
|
|
91
|
+
main{min-width:0;overflow:auto;padding:20px 24px 40px}
|
|
92
|
+
main:focus{outline:0}
|
|
93
|
+
|
|
94
|
+
.vh{margin-bottom:16px}
|
|
95
|
+
.kicker{margin:0;font-size:10.5px;letter-spacing:.18em;color:var(--amber)}
|
|
96
|
+
h1{margin:4px 0 0;font-size:20px;line-height:1.25;font-weight:600;letter-spacing:-.01em;overflow-wrap:anywhere}
|
|
97
|
+
h1 .dot{color:var(--amber)}
|
|
98
|
+
.lede{margin:6px 0 0;max-width:46rem;font:13.5px/1.6 var(--sans);color:var(--dim)}
|
|
99
|
+
.panel{position:relative;min-width:0;border:1px solid var(--line);background:var(--panel)}
|
|
100
|
+
.panel+.panel{margin-top:14px}
|
|
101
|
+
.ph{display:flex;align-items:center;gap:10px;min-height:38px;padding:0 14px;border-bottom:1px solid var(--line)}
|
|
102
|
+
.ph h2{margin:0;font-size:10.5px;font-weight:500;letter-spacing:.18em;color:var(--dim);white-space:nowrap}
|
|
103
|
+
.ph .meta{margin-left:auto;font-size:10.5px;color:var(--faint);text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
104
|
+
.pb{padding:14px}
|
|
105
|
+
.fig::before,.fig::after{content:'';position:absolute;width:9px;height:9px;border:0 solid var(--amber);pointer-events:none}
|
|
106
|
+
.fig::before{top:-1px;left:-1px;border-top-width:1px;border-left-width:1px}
|
|
107
|
+
.fig::after{bottom:-1px;right:-1px;border-bottom-width:1px;border-right-width:1px}
|
|
108
|
+
.ov{display:grid;gap:14px;grid-template-columns:repeat(3,minmax(0,1fr))}
|
|
109
|
+
.ov .panel+.panel{margin-top:0}
|
|
110
|
+
.span2{grid-column:span 2}
|
|
111
|
+
.span3{grid-column:1/-1}
|
|
112
|
+
.cols{display:grid;gap:14px;grid-template-columns:repeat(auto-fit,minmax(300px,1fr))}
|
|
113
|
+
.cols .panel+.panel{margin-top:0}
|
|
114
|
+
|
|
115
|
+
.kpis{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));border-top:1px solid var(--line);border-left:1px solid var(--line);margin-bottom:14px}
|
|
116
|
+
.kpi{min-width:0;padding:12px 14px 12px;border-right:1px solid var(--line);border-bottom:1px solid var(--line);background:var(--panel)}
|
|
117
|
+
.kpi .l{font-size:10px;letter-spacing:.16em;color:var(--dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
118
|
+
.kpi .v{margin-top:6px;font-size:24px;line-height:1.15;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
119
|
+
.big{font-size:24px;line-height:1.15;font-weight:500;font-variant-numeric:tabular-nums}
|
|
120
|
+
.kpi .v small,.big small{margin-left:4px;font-size:11.5px;font-weight:400;color:var(--dim)}
|
|
121
|
+
.kpi .s{margin-top:3px;font-size:11px;color:var(--dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
122
|
+
.kpi .viz{height:26px;margin-top:10px;display:flex;align-items:flex-end}
|
|
123
|
+
.kpi .viz svg{display:block;width:100%;height:26px}
|
|
124
|
+
.kpi.warn .v{color:var(--amber)}
|
|
125
|
+
.kpi.bad .v{color:var(--red)}
|
|
126
|
+
.stack{display:flex;width:100%;height:6px;background:var(--line)}
|
|
127
|
+
.stack b{display:block;height:100%}
|
|
128
|
+
.c-ok{background:var(--phos)}.c-am{background:var(--amber)}.c-err{background:var(--red)}.c-dim{background:rgba(154,148,138,.45)}.c-cy{background:var(--cyan)}
|
|
129
|
+
.bar{fill:var(--amber)}.bar.r{fill:var(--red)}.bar.z{fill:var(--line-strong)}
|
|
130
|
+
|
|
131
|
+
.chart{position:relative}
|
|
132
|
+
.chart svg{display:block;width:100%;height:190px}
|
|
133
|
+
.chart .grid{stroke:var(--line);stroke-width:1}
|
|
134
|
+
.chart g:hover .hit{fill:rgba(255,176,0,.1)}
|
|
135
|
+
.axis{display:flex;justify-content:space-between;margin-top:6px;font-size:10px;color:var(--faint)}
|
|
136
|
+
.ymax{position:absolute;top:-2px;left:0;font-size:10px;color:var(--faint);background:var(--panel);padding-right:6px}
|
|
137
|
+
.legend{display:flex;flex-wrap:wrap;gap:6px 16px;margin-top:12px;font-size:10.5px;letter-spacing:.06em;color:var(--dim)}
|
|
138
|
+
.legend i{display:inline-block;width:8px;height:8px;margin-right:6px;vertical-align:-1px}
|
|
139
|
+
.legend .r{margin-left:auto}
|
|
140
|
+
|
|
141
|
+
.gauge{position:relative;display:flex;height:28px;margin:24px 0 8px;border:1px solid var(--line-strong);background:var(--void)}
|
|
142
|
+
.gauge i{display:block;height:100%}
|
|
143
|
+
.g-pruned{background:repeating-linear-gradient(135deg,rgba(154,148,138,.22) 0 3px,transparent 3px 7px)}
|
|
144
|
+
.g-prunable{background:repeating-linear-gradient(135deg,rgba(255,176,0,.55) 0 3px,rgba(255,176,0,.12) 3px 7px)}
|
|
145
|
+
.g-retained{background:rgba(255,176,0,.2);box-shadow:inset 0 0 0 1px rgba(255,176,0,.45)}
|
|
146
|
+
.mark{position:absolute;top:-7px;bottom:-7px;width:0;border-left:1px dashed var(--cyan)}
|
|
147
|
+
.mark span{position:absolute;bottom:100%;margin-bottom:2px;font-size:10px;color:var(--cyan);white-space:nowrap;transform:translateX(-50%)}
|
|
148
|
+
.mark.l span{transform:none}.mark.e span{transform:translateX(-100%)}
|
|
149
|
+
.gscale{display:flex;justify-content:space-between;font-size:10.5px;color:var(--dim)}
|
|
150
|
+
.verdict{margin:14px 0 0;font:13px/1.55 var(--sans);color:var(--dim)}
|
|
151
|
+
.verdict b{font:600 10.5px var(--mono);letter-spacing:.14em;margin-right:8px}
|
|
152
|
+
|
|
153
|
+
.kv{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:7px 18px;margin:0;font-size:12px}
|
|
154
|
+
.kv dt{padding-top:1px;font-size:10.5px;letter-spacing:.12em;color:var(--dim);white-space:nowrap}
|
|
155
|
+
.kv dd{margin:0;min-width:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}
|
|
156
|
+
.kv+.kv,.kv+h3,.tw+h3,.empty+h3,pre+h3{margin-top:18px}
|
|
157
|
+
.mb h3:not(:first-child),.verdict+.kv{margin-top:20px}
|
|
158
|
+
h3{margin:0 0 8px;font-size:10.5px;font-weight:500;letter-spacing:.18em;color:var(--dim)}
|
|
159
|
+
.hist{display:grid;grid-template-columns:max-content minmax(0,1fr) max-content;gap:9px 12px;align-items:center;font-size:11.5px}
|
|
160
|
+
.hist .lb{color:var(--dim)}
|
|
161
|
+
.hist .tr{display:flex;height:12px;background:var(--void);border:1px solid var(--line)}
|
|
162
|
+
.hist .tr b{display:block;height:100%}
|
|
163
|
+
.hist .ct{text-align:right;font-variant-numeric:tabular-nums}
|
|
164
|
+
|
|
165
|
+
.tb{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:10px 14px;border-bottom:1px solid var(--line)}
|
|
166
|
+
.inp{height:30px;min-width:0;padding:0 10px;border:1px solid var(--line-strong);border-radius:0;background:var(--void);font-size:12px}
|
|
167
|
+
.inp:focus{outline:0;border-color:var(--amber)}
|
|
168
|
+
select.inp{padding-right:4px}
|
|
169
|
+
.tb .grow{flex:1 1 12rem}
|
|
170
|
+
.chk{display:inline-flex;align-items:center;gap:6px;font-size:11px;letter-spacing:.06em;color:var(--dim);white-space:nowrap}
|
|
171
|
+
.chk input{accent-color:var(--amber)}
|
|
172
|
+
.count{margin-left:auto;font-size:11px;color:var(--faint);white-space:nowrap}
|
|
173
|
+
|
|
174
|
+
.tw{overflow:auto;max-height:calc(100vh - 250px)}
|
|
175
|
+
.tw.short{max-height:none}
|
|
176
|
+
.dt{width:100%;border-collapse:separate;border-spacing:0;font-size:12px;font-variant-numeric:tabular-nums}
|
|
177
|
+
.dt th{position:sticky;top:0;z-index:1;padding:0;background:var(--raised);border-bottom:1px solid var(--line-strong);text-align:left;font-weight:500;font-size:10.5px;letter-spacing:.12em;color:var(--dim);white-space:nowrap}
|
|
178
|
+
.dt th>span,.dt th>button{display:flex;align-items:center;gap:6px;width:100%;padding:8px 12px;border:0;background:none;color:inherit;font:inherit;letter-spacing:inherit;text-transform:inherit;text-align:inherit}
|
|
179
|
+
.dt th.num>button,.dt th.num>span{justify-content:flex-end}
|
|
180
|
+
.dt th>button:hover{color:var(--ink)}
|
|
181
|
+
.dt th>button::after{content:'↕';color:var(--faint);font-size:10px}
|
|
182
|
+
.dt th[aria-sort=ascending]>button::after{content:'↑';color:var(--amber)}
|
|
183
|
+
.dt th[aria-sort=descending]>button::after{content:'↓';color:var(--amber)}
|
|
184
|
+
.dt td{padding:7px 12px;border-bottom:1px solid var(--line);white-space:nowrap;vertical-align:middle}
|
|
185
|
+
.dt tbody tr:last-child td{border-bottom:0}
|
|
186
|
+
.dt tr[data-i]{cursor:pointer}
|
|
187
|
+
.dt tbody tr:hover td{background:rgba(255,176,0,.045)}
|
|
188
|
+
.dt tr[data-i]:focus-visible{outline:2px solid var(--amber);outline-offset:-2px}
|
|
189
|
+
.dt tr.cur td{background:rgba(255,176,0,.07)}
|
|
190
|
+
.dt .num{text-align:right}
|
|
191
|
+
.dt td.fill{width:100%;max-width:0}
|
|
192
|
+
.trunc{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
193
|
+
.id{text-transform:none;display:inline-flex;align-items:center;gap:4px;max-width:100%;min-width:0;vertical-align:middle}
|
|
194
|
+
.id>span,.id>a{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
195
|
+
.w-id .id>span{max-width:38ch}
|
|
196
|
+
.w-sm .id>span,.w-sm .id>a{max-width:20ch}
|
|
197
|
+
.cp{flex:none;display:inline-grid;place-items:center;width:20px;height:20px;padding:0;border:1px solid transparent;background:none;color:var(--faint);opacity:0}
|
|
198
|
+
.cp svg{width:12px;height:12px}
|
|
199
|
+
tr:hover .cp,.cp:focus-visible,.kv .cp,.mh .cp{opacity:1}
|
|
200
|
+
.cp:hover{color:var(--amber);border-color:var(--line-strong)}
|
|
201
|
+
@media (hover:none){.cp{opacity:1}}
|
|
202
|
+
.tags{display:flex;flex-wrap:wrap;gap:4px;white-space:normal}
|
|
203
|
+
.tag{padding:0 6px;border:1px solid var(--line-strong);font-size:10.5px;line-height:18px;white-space:nowrap}
|
|
204
|
+
button.tag{background:none;cursor:pointer}
|
|
205
|
+
button.tag:hover{border-color:var(--amber);color:var(--amber)}
|
|
206
|
+
.st{display:inline-flex;align-items:center;gap:6px;font-size:10.5px;letter-spacing:.12em;white-space:nowrap;color:var(--dim)}
|
|
207
|
+
.st::before{content:'';width:6px;height:6px;background:currentColor}
|
|
208
|
+
.st.ok{color:var(--phos)}.st.warn{color:var(--amber)}.st.err{color:var(--red)}.st.idle{color:var(--faint)}
|
|
209
|
+
.lag{display:inline-flex;align-items:center;gap:8px}
|
|
210
|
+
.lag i{display:block;width:44px;height:4px;background:var(--line)}
|
|
211
|
+
.lag i b{display:block;height:100%;background:var(--amber)}
|
|
212
|
+
.lag.z{color:var(--dim)}
|
|
213
|
+
.ty{color:var(--amber)}
|
|
214
|
+
.ty.err{color:var(--red)}
|
|
215
|
+
.ty.info{color:var(--ink)}
|
|
216
|
+
|
|
217
|
+
.empty{padding:28px 18px;text-align:center;font:13px/1.6 var(--sans);color:var(--dim)}
|
|
218
|
+
.empty b{display:block;margin-bottom:6px;font:500 11px var(--mono);letter-spacing:.16em;color:var(--ink)}
|
|
219
|
+
.empty.sm{padding:16px 14px}
|
|
220
|
+
.errbox{margin:14px;padding:10px 12px;border:1px solid var(--red);border-left-width:3px;background:rgba(255,122,89,.06);font-size:12px}
|
|
221
|
+
.errbox code{color:var(--red);font-weight:600;font-size:12px}
|
|
222
|
+
.errbox .hs{margin-left:8px;font-size:10.5px;color:var(--dim)}
|
|
223
|
+
.errbox p{margin:5px 0 0;font:12.5px/1.55 var(--sans);color:var(--dim)}
|
|
224
|
+
.skel{padding:14px}
|
|
225
|
+
.skel i{display:block;height:11px;margin:9px 0;background:linear-gradient(90deg,var(--raised),#201d18,var(--raised));background-size:200% 100%;animation:shimmer 1.4s linear infinite}
|
|
226
|
+
.skel i:nth-child(2){width:82%}.skel i:nth-child(3){width:64%}
|
|
227
|
+
@keyframes shimmer{to{background-position:-200% 0}}
|
|
228
|
+
.banner{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin-bottom:14px;padding:10px 14px;border:1px solid rgba(255,176,0,.6);border-left-width:3px;background:rgba(255,176,0,.05);font:12.5px/1.55 var(--sans);color:var(--dim)}
|
|
229
|
+
.banner b{font:600 10.5px var(--mono);letter-spacing:.14em;color:var(--amber)}
|
|
230
|
+
.banner.err{border-color:var(--red);background:rgba(255,122,89,.06)}
|
|
231
|
+
.banner.err b{color:var(--red)}
|
|
232
|
+
.banner span{flex:1 1 20rem}
|
|
233
|
+
.sugg{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:10px 14px;border-bottom:1px solid var(--line);font-size:10.5px;letter-spacing:.12em;color:var(--dim)}
|
|
234
|
+
.sugg:empty{display:none}
|
|
235
|
+
.acts{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px;margin-top:16px}
|
|
236
|
+
.ph .seg{margin-left:6px}
|
|
237
|
+
.nocov{fill:rgba(154,148,138,.1)}
|
|
238
|
+
.vbox{display:flex;flex-wrap:wrap;align-items:baseline;gap:6px 14px;margin:14px;padding:14px 16px;border:1px solid var(--line-strong);border-left:3px solid currentColor}
|
|
239
|
+
.vbox b{font:600 15px var(--mono);letter-spacing:.06em}
|
|
240
|
+
.vbox span{flex:1 1 22rem;font:13px/1.55 var(--sans);color:var(--dim)}
|
|
241
|
+
.vbox.ok{color:var(--phos)}.vbox.warn{color:var(--amber)}.vbox.err{color:var(--red)}.vbox.idle{color:var(--dim)}
|
|
242
|
+
.lnk{color:var(--ink);text-decoration:underline;text-decoration-color:rgba(255,176,0,.5);text-underline-offset:3px}
|
|
243
|
+
.lnk:hover{color:var(--amber)}
|
|
244
|
+
.kicker .lnk{color:var(--amber)}
|
|
245
|
+
a.tag{color:var(--ink);text-decoration:none}
|
|
246
|
+
a.tag:hover{border-color:var(--amber);color:var(--amber)}
|
|
247
|
+
.tag.on,.tag.on:hover{background:var(--amber);border-color:var(--amber);color:#000}
|
|
248
|
+
.dev::before{content:'';display:inline-block;width:6px;height:6px;margin-right:6px;background:var(--faint)}
|
|
249
|
+
.dev.on::before{background:var(--phos)}
|
|
250
|
+
.pager{margin:0;padding:10px 14px;border-top:1px solid var(--line)}
|
|
251
|
+
.search input{width:16rem}
|
|
252
|
+
h1 .cp{opacity:1;vertical-align:middle;margin-left:6px}
|
|
253
|
+
.view>.panel,.view>.cols{margin-top:14px}
|
|
254
|
+
.row-card .ph h2{text-transform:none;letter-spacing:.02em;color:var(--ink);font-size:12px;overflow:hidden;text-overflow:ellipsis}
|
|
255
|
+
|
|
256
|
+
pre.json{margin:0;padding:12px 14px;border:1px solid var(--line);background:var(--void);font:12px/1.6 var(--mono);overflow:auto;white-space:pre;max-height:60vh}
|
|
257
|
+
.jk{color:var(--sand)}.js{color:var(--phos)}.jn{color:var(--cyan)}.jb{color:var(--amber)}.jz{color:var(--faint)}
|
|
258
|
+
|
|
259
|
+
dialog{width:min(880px,calc(100vw - 24px));max-width:none;max-height:calc(100vh - 48px);padding:0;border:1px solid var(--line-strong);background:var(--panel);color:var(--ink);overflow:visible}
|
|
260
|
+
dialog[open]{display:flex;flex-direction:column}
|
|
261
|
+
dialog::backdrop{background:rgba(0,0,0,.82)}
|
|
262
|
+
.mh{flex:none;display:flex;align-items:center;gap:10px;padding:12px 14px;border-bottom:1px solid var(--line)}
|
|
263
|
+
.mh .tt{min-width:0;flex:1}
|
|
264
|
+
.mh h2{display:flex;align-items:center;gap:6px;margin:3px 0 0;font-size:14px;font-weight:600;min-width:0}
|
|
265
|
+
.mh h2 span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
266
|
+
.seg{display:inline-flex;flex:none}
|
|
267
|
+
.seg button{height:26px;padding:0 10px;border:1px solid var(--line-strong);background:none;color:var(--dim);font-size:10.5px;letter-spacing:.12em}
|
|
268
|
+
.seg button+button{border-left:0}
|
|
269
|
+
.seg button[aria-pressed=true]{background:var(--amber);border-color:var(--amber);color:#000}
|
|
270
|
+
.mb{flex:1;min-height:0;overflow:auto;padding:16px}
|
|
271
|
+
.keys{display:grid;grid-template-columns:max-content 1fr;gap:9px 16px;margin:0;font:13px/1.5 var(--sans);color:var(--dim)}
|
|
272
|
+
.keys dt{white-space:nowrap}
|
|
273
|
+
#toast{position:fixed;left:50%;bottom:18px;z-index:60;transform:translateX(-50%);max-width:calc(100vw - 32px);padding:8px 14px;border:1px solid var(--amber);background:var(--panel);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
274
|
+
|
|
275
|
+
@media (max-width:1400px){.top{gap:8px 10px;padding:8px 16px}.field{flex:1 1 0;min-width:9rem}.field input{flex:1;width:auto}#updated{display:none}}
|
|
276
|
+
@media (max-width:1300px){.kpis{grid-template-columns:repeat(3,minmax(0,1fr))}.ov{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
|
277
|
+
@media (max-width:900px){
|
|
278
|
+
.field{order:9;flex:1 1 40%}
|
|
279
|
+
body{display:block;height:auto}
|
|
280
|
+
.shell{display:block}
|
|
281
|
+
.side{position:sticky;top:0;z-index:15;display:flex;overflow-x:auto;padding:0;border-right:0;border-bottom:1px solid var(--line);background:var(--void);scrollbar-width:none}
|
|
282
|
+
.side::-webkit-scrollbar{display:none}
|
|
283
|
+
.side a{flex:none;padding:11px 12px;border-left:0;border-bottom:2px solid transparent}
|
|
284
|
+
.side a[aria-current=page]{border-bottom-color:var(--amber);background:none}
|
|
285
|
+
.side a .n,.side .foot{display:none}
|
|
286
|
+
main{overflow:visible;padding:16px}
|
|
287
|
+
.tw{max-height:70vh}
|
|
288
|
+
}
|
|
289
|
+
@media (max-width:760px){.ov{grid-template-columns:minmax(0,1fr)}.span2{grid-column:auto}}
|
|
290
|
+
@media (max-width:640px){
|
|
291
|
+
.top{padding:8px 12px}
|
|
292
|
+
.field{order:9;flex:1 1 100%}
|
|
293
|
+
.field input{flex:1;width:auto}
|
|
294
|
+
#updated{display:none}
|
|
295
|
+
.kpis{grid-template-columns:repeat(2,minmax(0,1fr))}
|
|
296
|
+
.kpi .v{font-size:20px}
|
|
297
|
+
.tw{max-height:none;overflow:visible}
|
|
298
|
+
.dt,.dt tbody,.dt thead{display:block}
|
|
299
|
+
.dt thead tr{display:flex;flex-wrap:wrap;gap:4px;padding:8px 10px;border-bottom:1px solid var(--line)}
|
|
300
|
+
.dt th{position:static;border:1px solid var(--line);background:none}
|
|
301
|
+
.dt th>button,.dt th>span{padding:3px 8px}
|
|
302
|
+
.dt th.ns,.dt th:has(>span){display:none}
|
|
303
|
+
.dt thead:not(:has(button)){display:none}
|
|
304
|
+
.dt tbody tr{display:block;padding:6px 0;border-bottom:1px solid var(--line)}
|
|
305
|
+
.dt tbody tr:last-child{border-bottom:0}
|
|
306
|
+
.dt td{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:3px 12px;border:0;white-space:normal;text-align:right}
|
|
307
|
+
.dt td::before{content:attr(data-l);flex:none;font-size:10px;letter-spacing:.12em;color:var(--dim)}
|
|
308
|
+
.dt td.fill{width:auto;max-width:none}
|
|
309
|
+
.dt td .trunc{min-width:0}
|
|
310
|
+
.dt .tags{justify-content:flex-end}
|
|
311
|
+
.w-id .id>span,.w-id .id>a,.w-sm .id>span,.w-sm .id>a{max-width:58vw}
|
|
312
|
+
.mb{padding:12px}
|
|
313
|
+
}
|
|
314
|
+
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
|
|
140
315
|
</style>
|
|
141
316
|
</head>
|
|
142
317
|
<body>
|
|
143
|
-
<
|
|
144
|
-
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
</label>
|
|
318
|
+
<a class="skip" href="#main">Skip to content</a>
|
|
319
|
+
<header class="top">
|
|
320
|
+
<div class="brand"><svg viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="2.6" fill="#ffb000"/><circle cx="10" cy="10" r="5.6" fill="none" stroke="#ffb000" stroke-width="1.2"/><circle cx="10" cy="10" r="8.6" fill="none" stroke="#9a948a" stroke-width="1" stroke-dasharray="2 2"/></svg>SYNCULAR <span class="sl">/</span> <span class="sub">CONSOLE</span></div>
|
|
321
|
+
<div class="field"><label for="partition">Partition</label><input id="partition" type="text" list="partitions-list" placeholder="only partition" autocomplete="off" spellcheck="false" /></div>
|
|
322
|
+
<form id="search-form" class="field search" role="search"><label for="q">Find</label><input id="q" type="search" placeholder="Client, actor, row, commit or write id" autocomplete="off" spellcheck="false" /></form>
|
|
148
323
|
<datalist id="partitions-list"></datalist>
|
|
149
|
-
<
|
|
150
|
-
<
|
|
151
|
-
<span
|
|
152
|
-
<
|
|
324
|
+
<span class="grow"></span>
|
|
325
|
+
<span id="live" class="pill" title="Event stream state"><i></i><span>Connecting</span></span>
|
|
326
|
+
<span id="updated"></span>
|
|
327
|
+
<select id="auto" class="btn" aria-label="Auto refresh" title="Auto refresh (a)">
|
|
328
|
+
<option value="0">Auto off</option><option value="2000">Every 2 s</option><option value="5000">Every 5 s</option><option value="15000">Every 15 s</option>
|
|
329
|
+
</select>
|
|
330
|
+
<button id="refresh" class="btn amber" type="button" title="Refresh (r)">Refresh</button>
|
|
331
|
+
<button id="help-btn" class="btn sq" type="button" aria-label="Keyboard shortcuts" title="Keyboard shortcuts (?)">?</button>
|
|
153
332
|
</header>
|
|
154
|
-
<div
|
|
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
|
-
<div id="
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
333
|
+
<div class="shell">
|
|
334
|
+
<nav class="side" aria-label="Console views">
|
|
335
|
+
<a id="nav-overview" href="#/overview"><b>01</b>Overview</a>
|
|
336
|
+
<a id="nav-people" href="#/people"><b>02</b>People<span class="n" id="n-people"></span></a>
|
|
337
|
+
<a id="nav-data" href="#/data"><b>03</b>Data<span class="n" id="n-data"></span></a>
|
|
338
|
+
<a id="nav-commits" href="#/commits"><b>04</b>Commits<span class="n" id="n-commits"></span></a>
|
|
339
|
+
<a id="nav-events" href="#/events"><b>05</b>Events<span class="n" id="n-events"></span></a>
|
|
340
|
+
<a id="nav-reactions" href="#/reactions"><b>06</b>Reactions<span class="n" id="n-reactions"></span></a>
|
|
341
|
+
<a id="nav-storage" href="#/storage"><b>07</b>Storage</a>
|
|
342
|
+
<div class="foot"><span id="side-mode">Loading the admin capabilities.</span><br/><kbd>?</kbd> shortcuts</div>
|
|
343
|
+
</nav>
|
|
344
|
+
<main id="main" tabindex="-1">
|
|
345
|
+
<div id="alert" class="banner err" role="alert" hidden></div>
|
|
346
|
+
|
|
347
|
+
<section id="view-overview" class="view" aria-labelledby="h-overview">
|
|
348
|
+
<div class="vh"><p class="kicker">01 · Overview</p><h1 id="h-overview">Partition <span id="ov-part">…</span><span class="dot">.</span></h1></div>
|
|
349
|
+
<div class="kpis" id="kpis" aria-label="Key figures"></div>
|
|
350
|
+
<div class="ov">
|
|
351
|
+
<div class="panel span2"><div class="ph"><h2>Request volume</h2><span class="meta" id="vol-meta"></span></div><div class="pb" id="ov-volume" data-skel></div></div>
|
|
352
|
+
<div class="panel fig"><div class="ph"><h2>Horizon and retention</h2></div><div class="pb" id="ov-horizon" data-skel></div></div>
|
|
353
|
+
<div class="panel"><div class="ph"><h2>Cursor lag</h2><span class="meta" id="lag-meta"></span></div><div id="ov-lag" data-skel></div></div>
|
|
354
|
+
<div class="panel span2"><div class="ph"><h2>Failing</h2><div class="seg" role="group" aria-label="Group failures"><button type="button" data-act="err-tab" data-tab="code" aria-pressed="true">By code</button><button type="button" data-act="err-tab" data-tab="client" aria-pressed="false">By client</button></div><span class="meta" id="err-meta"></span></div><div id="ov-errors" data-skel></div></div>
|
|
355
|
+
<div class="panel span3"><div class="ph"><h2>Fleet</h2><span class="meta" id="fleet-meta"></span></div><div id="ov-fleet" data-skel></div></div>
|
|
356
|
+
</div>
|
|
357
|
+
</section>
|
|
358
|
+
|
|
359
|
+
<section id="view-people" class="view" aria-labelledby="h-people" hidden>
|
|
360
|
+
<div class="vh"><p class="kicker">02 · People</p><h1 id="h-people">People and devices<span class="dot">.</span></h1><p class="lede">Every actor in this partition with the devices it syncs from. An actor opens its failed and warned requests; a device opens its client page: subscriptions, lease, failures, recent events, and a delivery trace.</p></div>
|
|
361
|
+
<div id="people-rt"></div>
|
|
362
|
+
<div class="cols"><div class="panel"><div class="ph"><h2>Schema rollout</h2><span class="meta" id="rollout-meta"></span></div><div class="pb" id="people-rollout" data-skel></div></div></div>
|
|
363
|
+
<div class="panel">
|
|
364
|
+
<div class="tb"><input id="people-q" data-focus class="inp grow" type="search" placeholder="Filter by actor or client id" aria-label="Filter actors by actor or client id" /><span class="count" id="people-count"></span></div>
|
|
365
|
+
<div id="people-table" data-skel></div>
|
|
366
|
+
</div>
|
|
367
|
+
<div class="panel" id="people-fail-panel" hidden><div class="ph"><h2 id="people-fail-h">Failures and warnings</h2><span class="meta" id="people-fail-meta"></span></div><div id="people-fail"></div></div>
|
|
368
|
+
</section>
|
|
369
|
+
|
|
370
|
+
<section id="view-client" class="view" aria-labelledby="h-client" hidden>
|
|
371
|
+
<div class="vh"><p class="kicker"><a class="lnk" href="#/people">People</a> · Client</p><h1 id="h-client"></h1><p class="lede" id="client-line"></p></div>
|
|
372
|
+
<div id="client-body" data-skel></div>
|
|
373
|
+
</section>
|
|
374
|
+
|
|
375
|
+
<section id="view-data" class="view" aria-labelledby="h-data" hidden>
|
|
376
|
+
<div class="vh"><p class="kicker">03 · Data</p><h1 id="h-data">Tables<span class="dot">.</span></h1><p class="lede">The server's authoritative rows, table by table. A table opens a row browser filtered by scope; a row shows its values, its history, and which clients hold it.</p></div>
|
|
377
|
+
<div class="panel"><div id="data-tables" data-skel></div></div>
|
|
378
|
+
</section>
|
|
379
|
+
|
|
380
|
+
<section id="view-table" class="view" aria-labelledby="h-table" hidden>
|
|
381
|
+
<div class="vh"><p class="kicker"><a class="lnk" href="#/data">Data</a> · Table</p><h1 id="h-table"></h1><p class="lede" id="table-line"></p></div>
|
|
382
|
+
<div class="panel">
|
|
383
|
+
<div id="table-scopes" class="sugg"></div>
|
|
384
|
+
<div id="table-rows" data-skel></div>
|
|
385
|
+
</div>
|
|
386
|
+
<div class="panel" id="table-activity-panel" hidden><div class="ph"><h2>Recent commits in this scope</h2><span class="meta" id="table-activity-meta"></span></div><div id="table-activity"></div></div>
|
|
387
|
+
</section>
|
|
388
|
+
|
|
389
|
+
<section id="view-row" class="view" aria-labelledby="h-row" hidden>
|
|
390
|
+
<div class="vh"><p class="kicker"><a class="lnk" href="#/data">Data</a> · <a class="lnk" id="row-table-link" href="#/data">table</a> · Row</p><h1 id="h-row"></h1><p class="lede" id="row-line"></p></div>
|
|
391
|
+
<div class="cols">
|
|
392
|
+
<div class="panel"><div class="ph"><h2>Values</h2><span class="meta" id="row-meta"></span></div><div id="row-values" data-skel></div></div>
|
|
393
|
+
<div class="panel"><div class="ph"><h2>History</h2><span class="meta" id="row-history-meta"></span></div><div id="row-history" data-skel></div></div>
|
|
394
|
+
</div>
|
|
395
|
+
<div class="panel"><div class="ph"><h2>Who has this row</h2><span class="meta" id="delivery-meta"></span></div><div id="row-delivery" data-skel></div></div>
|
|
396
|
+
</section>
|
|
397
|
+
|
|
398
|
+
<section id="view-commits" class="view" aria-labelledby="h-commits" hidden>
|
|
399
|
+
<div class="vh"><p class="kicker">04 · Commits</p><h1 id="h-commits">Commits<span class="dot">.</span></h1><p class="lede">The commit log, newest first, with the first changes of each commit. A commit opens every row change with its values. A client commit id from a bug report opens what happened to that write.</p></div>
|
|
400
|
+
<div class="panel">
|
|
401
|
+
<div class="tb"><input id="commits-table" data-focus class="inp grow" type="search" list="tables-list" placeholder="Filter by table" aria-label="Filter commits by table" /><select id="commits-limit" class="inp" aria-label="Commits per page"><option value="50">50 per page</option><option value="200">200 per page</option><option value="500">500 per page</option></select>
|
|
402
|
+
<form id="write-form" class="field"><label for="write-id">Write</label><input id="write-id" placeholder="Client commit id" spellcheck="false" /></form><span class="count" id="commits-count"></span></div>
|
|
403
|
+
<div id="commits-list" data-skel></div>
|
|
404
|
+
</div>
|
|
405
|
+
<datalist id="tables-list"></datalist>
|
|
406
|
+
</section>
|
|
407
|
+
|
|
408
|
+
<section id="view-events" class="view" aria-labelledby="h-events" hidden>
|
|
409
|
+
<div class="vh"><p class="kicker">05 · Events</p><h1 id="h-events">Event stream<span class="dot">.</span></h1><p class="lede">Server events from the in-memory ring, newest first, one row per sync request. A request opens all of its events. Kind and client filter on the server; family, level, and text filter the buffered tail.</p></div>
|
|
410
|
+
<div id="ev-banner"></div>
|
|
411
|
+
<div class="panel">
|
|
412
|
+
<div class="tb">
|
|
413
|
+
<select id="ev-kind" class="inp" aria-label="Event kind"></select>
|
|
414
|
+
<input id="ev-client" class="inp" type="search" placeholder="Client id" aria-label="Filter events by client id" spellcheck="false" />
|
|
415
|
+
<select id="ev-level" class="inp" aria-label="Level"><option value="">All levels</option><option value="warn">Warnings and errors</option><option value="err">Errors only</option></select>
|
|
416
|
+
<input id="ev-q" data-focus class="inp grow" type="search" placeholder="Search event fields" aria-label="Search event fields" />
|
|
417
|
+
<label class="chk"><input id="ev-idle" type="checkbox" /> <span id="ev-idle-label">Show idle rounds</span></label>
|
|
418
|
+
<button id="ev-pause" class="btn sm" type="button" title="Pause (space)">Pause</button>
|
|
419
|
+
<button id="ev-clear" class="btn sm" type="button">Clear</button>
|
|
420
|
+
<span class="count" id="ev-count"></span>
|
|
421
|
+
</div>
|
|
422
|
+
<div id="ev-table" data-skel></div>
|
|
423
|
+
</div>
|
|
424
|
+
</section>
|
|
425
|
+
|
|
426
|
+
<section id="view-reactions" class="view" aria-labelledby="h-reactions" hidden>
|
|
427
|
+
<div class="vh"><p class="kicker">06 · Reactions</p><h1 id="h-reactions">Durable reactions<span class="dot">.</span></h1><p class="lede">The reaction queue of this partition, dead letters first, with attempts and the last failure code. Reaction rows carry application payloads.</p></div>
|
|
428
|
+
<div class="panel">
|
|
429
|
+
<div class="tb"><select id="rx-status" class="inp" aria-label="Reaction status"><option value="">All statuses</option><option value="pending">Pending</option><option value="leased">Leased</option><option value="completed">Completed</option><option value="dead-letter">Dead letter</option></select><input id="rx-type" data-focus class="inp grow" type="search" placeholder="Reaction type" aria-label="Filter by reaction type" spellcheck="false" /><span class="count" id="rx-count"></span></div>
|
|
430
|
+
<div id="rx-table" data-skel></div>
|
|
431
|
+
</div>
|
|
432
|
+
</section>
|
|
433
|
+
|
|
434
|
+
<section id="view-storage" class="view" aria-labelledby="h-storage" hidden>
|
|
435
|
+
<div class="vh"><p class="kicker">07 · Storage</p><h1 id="h-storage">Storage<span class="dot">.</span></h1><p class="lede">Segment and blob store counters, and the commit log's retention state.</p></div>
|
|
436
|
+
<div class="cols">
|
|
437
|
+
<div class="panel"><div class="ph"><h2>Segments</h2><span class="meta" id="seg-meta"></span></div><div class="pb" id="st-seg" data-skel></div></div>
|
|
438
|
+
<div class="panel"><div class="ph"><h2>Blobs</h2><span class="meta" id="blob-meta"></span></div><div class="pb" id="st-blob" data-skel></div></div>
|
|
439
|
+
<div class="panel fig"><div class="ph"><h2>Commit log</h2></div><div class="pb" id="st-horizon" data-skel></div></div>
|
|
440
|
+
</div>
|
|
441
|
+
</section>
|
|
442
|
+
|
|
443
|
+
<section id="view-search" class="view" aria-labelledby="h-search" hidden>
|
|
444
|
+
<div class="vh"><p class="kicker">Find</p><h1 id="h-search"></h1><p class="lede">Clients and actors whose id contains the text, rows whose id equals it in any table, the commit with that sequence number, and the writes logged under that client commit id.</p></div>
|
|
445
|
+
<div id="search-body" data-skel></div>
|
|
446
|
+
</section>
|
|
447
|
+
</main>
|
|
207
448
|
</div>
|
|
208
|
-
|
|
209
|
-
<
|
|
210
|
-
<span
|
|
211
|
-
|
|
212
|
-
</
|
|
449
|
+
|
|
450
|
+
<dialog id="modal" aria-labelledby="m-title">
|
|
451
|
+
<div class="mh"><div class="tt"><p class="kicker" id="m-kicker"></p><h2><span id="m-title"></span><button id="m-copy" class="cp" type="button" aria-label="Copy id" title="Copy"></button></h2></div>
|
|
452
|
+
<div class="seg" role="group" aria-label="Detail format"><button type="button" id="m-tab-sum" aria-pressed="true">Summary</button><button type="button" id="m-tab-json" aria-pressed="false">JSON</button></div>
|
|
453
|
+
<button id="m-close" class="btn sm" type="button">Close</button></div>
|
|
454
|
+
<div class="mb"><div id="m-sum"></div><div id="m-json" hidden></div></div>
|
|
455
|
+
</dialog>
|
|
456
|
+
<dialog id="help" aria-labelledby="help-title">
|
|
457
|
+
<div class="mh"><div class="tt"><p class="kicker">Console</p><h2 id="help-title"><span>Keyboard shortcuts</span></h2></div><button id="help-close" class="btn sm" type="button">Close</button></div>
|
|
458
|
+
<div class="mb"><dl class="keys">
|
|
459
|
+
<dt><kbd>1</kbd> to <kbd>7</kbd></dt><dd>Open Overview, People, Data, Commits, Events, Reactions, Storage</dd>
|
|
460
|
+
<dt><kbd>/</kbd></dt><dd>Find a client, actor, row, commit, or write by id</dd>
|
|
461
|
+
<dt><kbd>f</kbd></dt><dd>Focus the filter of the current view</dd>
|
|
462
|
+
<dt><kbd>r</kbd></dt><dd>Refresh the current view</dd>
|
|
463
|
+
<dt><kbd>a</kbd></dt><dd>Cycle auto refresh: off, 2 s, 5 s, 15 s</dd>
|
|
464
|
+
<dt><kbd>p</kbd></dt><dd>Focus the partition picker</dd>
|
|
465
|
+
<dt><kbd>space</kbd></dt><dd>Pause or resume the event stream (Events view)</dd>
|
|
466
|
+
<dt><kbd>Enter</kbd></dt><dd>Open the focused table row</dd>
|
|
467
|
+
<dt><kbd>Esc</kbd></dt><dd>Close a dialog or leave a field</dd>
|
|
468
|
+
<dt><kbd>?</kbd></dt><dd>Show this list</dd>
|
|
469
|
+
</dl></div>
|
|
470
|
+
</dialog>
|
|
471
|
+
<dialog id="confirm" aria-labelledby="c-title">
|
|
472
|
+
<div class="mh"><div class="tt"><p class="kicker">Action</p><h2 id="c-title"><span id="c-text"></span></h2></div></div>
|
|
473
|
+
<div class="mb"><div id="c-body"></div><div class="acts"><button id="c-cancel" class="btn sm" type="button">Cancel</button><button id="c-ok" class="btn sm amber" type="button">Confirm</button></div></div>
|
|
474
|
+
</dialog>
|
|
475
|
+
<div id="toast" role="status" hidden></div>
|
|
213
476
|
<script>
|
|
214
|
-
(
|
|
215
|
-
|
|
216
|
-
var
|
|
477
|
+
(() => {
|
|
478
|
+
'use strict';
|
|
479
|
+
var $ = id => document.getElementById(id);
|
|
480
|
+
var html = (id, v) => { $(id).innerHTML = v; };
|
|
481
|
+
var txt = (id, v) => { $(id).textContent = v; };
|
|
482
|
+
var NL = String.fromCharCode(10);
|
|
483
|
+
var NAV = ['overview', 'people', 'data', 'commits', 'events', 'reactions', 'storage'];
|
|
484
|
+
// Pages without a sidebar entry highlight the section they belong to.
|
|
485
|
+
var SECTION = { client: 'people', table: 'data', row: 'data' };
|
|
486
|
+
var EVENT_TYPES = ['request.handled', 'push.applied', 'push.rejected', 'push.conflicted', 'pull.served',
|
|
487
|
+
'realtime.opened', 'realtime.closed', 'realtime.delta', 'realtime.wake', 'reaction.queued', 'reaction.started',
|
|
488
|
+
'reaction.retried', 'reaction.completed', 'reaction.dead_lettered', 'reaction.prune_completed',
|
|
489
|
+
'segment.downloaded', 'blob.uploaded', 'blob.downloaded', 'blob.swept', 'prune.completed',
|
|
490
|
+
'scopes.resolve_failed', 'lease.issued', 'lease.revoked'];
|
|
491
|
+
var MAX_TAIL = 200, PAGE_ROWS = 50, FLEET_PAGE = 25;
|
|
492
|
+
var SKEL = '<div class="skel" aria-label="Loading"><i></i><i></i><i></i></div>';
|
|
493
|
+
var COPY_SVG = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M5.5 5.5h8v8h-8zM2.5 10.5v-8h8" fill="none" stroke="currentColor"/></svg>';
|
|
217
494
|
|
|
218
495
|
// The endpoints are siblings of the page under the SAME mount prefix. The
|
|
219
496
|
// page is served at the mount root (…/admin or …/admin/); strip any
|
|
@@ -224,7 +501,7 @@ export const ADMIN_CONSOLE_HTML = `<!doctype html>
|
|
|
224
501
|
var nextRequestId = 1;
|
|
225
502
|
var parentRequests = {};
|
|
226
503
|
if (parentTransport) {
|
|
227
|
-
window.addEventListener('message',
|
|
504
|
+
window.addEventListener('message', event => {
|
|
228
505
|
if (event.source !== window.parent || event.origin !== location.origin) return;
|
|
229
506
|
var message = event.data;
|
|
230
507
|
if (!message || message.kind !== 'syncular-admin-response' || typeof message.id !== 'number') return;
|
|
@@ -232,353 +509,1209 @@ export const ADMIN_CONSOLE_HTML = `<!doctype html>
|
|
|
232
509
|
if (!request) return;
|
|
233
510
|
delete parentRequests[message.id];
|
|
234
511
|
if (message.ok) request.resolve(message.body);
|
|
235
|
-
else request.reject(
|
|
512
|
+
else request.reject(apiError(message.body, message.status));
|
|
236
513
|
});
|
|
237
514
|
}
|
|
515
|
+
function apiError(body, status) {
|
|
516
|
+
var b = body && typeof body === 'object' ? body : {};
|
|
517
|
+
var err = new Error(typeof b.message === 'string' ? b.message : 'The endpoint answered HTTP ' + status + '.');
|
|
518
|
+
err.code = typeof b.code === 'string' ? b.code : 'console.unexpected_response';
|
|
519
|
+
err.status = status;
|
|
520
|
+
err.action = typeof b.recommendedAction === 'string' ? b.recommendedAction : '';
|
|
521
|
+
err.details = b.details && typeof b.details === 'object' ? b.details : {};
|
|
522
|
+
return err;
|
|
523
|
+
}
|
|
238
524
|
function qs(params) {
|
|
239
525
|
var parts = [];
|
|
240
|
-
var p =
|
|
526
|
+
var p = $('partition').value.trim();
|
|
241
527
|
if (p) parts.push('partition=' + encodeURIComponent(p));
|
|
242
|
-
if (params) Object.keys(params).forEach(
|
|
528
|
+
if (params) Object.keys(params).forEach(k => {
|
|
243
529
|
var v = params[k];
|
|
244
|
-
if (v !== undefined && v !== null && v !== '')
|
|
245
|
-
parts.push(k + '=' + encodeURIComponent(v));
|
|
246
|
-
}
|
|
530
|
+
if (v !== undefined && v !== null && v !== '') parts.push(k + '=' + encodeURIComponent(v));
|
|
247
531
|
});
|
|
248
532
|
return parts.length ? '?' + parts.join('&') : '';
|
|
249
533
|
}
|
|
250
|
-
|
|
251
|
-
|
|
534
|
+
// A partition switch bumps the epoch; answers to older requests reject
|
|
535
|
+
// with STALE so they never render into the new partition's panels.
|
|
536
|
+
var epoch = 0, STALE = new Error('stale');
|
|
537
|
+
function get(path, params) { return call(path, qs(params), 'GET'); }
|
|
538
|
+
function post(path) { return call(path, qs(), 'POST'); }
|
|
539
|
+
function call(path, query, method) {
|
|
540
|
+
var ep = epoch;
|
|
541
|
+
return send(path, query, method).then(b => {
|
|
542
|
+
if (ep !== epoch) throw STALE;
|
|
543
|
+
return b;
|
|
544
|
+
}, err => {
|
|
545
|
+
throw ep !== epoch ? STALE : err;
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
function send(path, query, method) {
|
|
252
549
|
if (parentTransport) {
|
|
253
|
-
return new Promise(
|
|
550
|
+
return new Promise((resolve, reject) => {
|
|
254
551
|
var id = nextRequestId++;
|
|
255
552
|
parentRequests[id] = { resolve: resolve, reject: reject };
|
|
256
|
-
window.parent.postMessage({
|
|
257
|
-
kind: 'syncular-admin-request', id: id, path: path + query
|
|
258
|
-
}, location.origin);
|
|
553
|
+
window.parent.postMessage({ kind: 'syncular-admin-request', id: id, path: path + query, method: method }, location.origin);
|
|
259
554
|
});
|
|
260
555
|
}
|
|
261
|
-
return fetch(base + path + query, { headers: { accept: 'application/json' } })
|
|
262
|
-
.then(
|
|
263
|
-
if (!r.ok)
|
|
264
|
-
return
|
|
556
|
+
return fetch(base + path + query, { method: method, headers: { accept: 'application/json' } }).then(r => {
|
|
557
|
+
return r.json().then(b => {
|
|
558
|
+
if (!r.ok) throw apiError(b, r.status);
|
|
559
|
+
return b;
|
|
560
|
+
}, () => {
|
|
561
|
+
throw apiError({ code: 'console.unexpected_response', message: 'The endpoint answered HTTP ' + r.status + ' with a body that is not JSON.' }, r.status);
|
|
265
562
|
});
|
|
563
|
+
}, () => {
|
|
564
|
+
throw apiError({ code: 'console.network_error', message: 'The request did not reach the admin routes.' }, 0);
|
|
565
|
+
});
|
|
266
566
|
}
|
|
567
|
+
var enc = encodeURIComponent;
|
|
568
|
+
function route(view, args) { return '#/' + [view].concat(args || []).map(enc).join('/'); }
|
|
569
|
+
|
|
570
|
+
// -- formatting ----------------------------------------------------------
|
|
267
571
|
function esc(v) {
|
|
268
|
-
return String(v == null ? '' : v)
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
function
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if (d < 60000) return Math.round(d / 1000) + 's';
|
|
276
|
-
if (d < 3600000) return Math.round(d / 60000) + 'm';
|
|
277
|
-
return Math.round(d / 3600000) + 'h';
|
|
278
|
-
}
|
|
279
|
-
function until(ms) {
|
|
280
|
-
var d = ms - Date.now();
|
|
281
|
-
if (d <= 0) return 'expired';
|
|
282
|
-
if (d < 60000) return 'in ' + Math.round(d / 1000) + 's';
|
|
283
|
-
if (d < 3600000) return 'in ' + Math.round(d / 60000) + 'm';
|
|
284
|
-
return 'in ' + Math.round(d / 3600000) + 'h';
|
|
572
|
+
return String(v == null ? '' : v).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
573
|
+
}
|
|
574
|
+
function fmt(n) { return n == null ? '–' : Number(n).toLocaleString('en-US'); }
|
|
575
|
+
function pad(n, w) { return String(n).padStart(w || 2, '0'); }
|
|
576
|
+
function clock(ms, withMs) {
|
|
577
|
+
var d = new Date(ms);
|
|
578
|
+
return pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds()) + (withMs ? '.' + pad(d.getMilliseconds(), 3) : '');
|
|
285
579
|
}
|
|
580
|
+
function stamp(ms) { return new Date(ms).toISOString(); }
|
|
581
|
+
function span(d) {
|
|
582
|
+
d = Math.abs(d);
|
|
583
|
+
if (d < 1000) return Math.round(d) + ' ms';
|
|
584
|
+
if (d < 60000) return Math.round(d / 1000) + ' s';
|
|
585
|
+
if (d < 3600000) return Math.round(d / 60000) + ' min';
|
|
586
|
+
if (d < 86400000) return Math.round(d / 3600000) + ' h';
|
|
587
|
+
return Math.round(d / 86400000) + ' d';
|
|
588
|
+
}
|
|
589
|
+
function ago(ms) { return Date.now() - ms < 0 ? 'now' : span(Date.now() - ms) + ' ago'; }
|
|
590
|
+
function rel(ms) { return ms > Date.now() ? 'in ' + span(ms - Date.now()) : span(Date.now() - ms) + ' ago'; }
|
|
591
|
+
function when(ms) { return '<span title="' + esc(stamp(ms)) + '">' + ago(ms) + '</span>'; }
|
|
592
|
+
function dur(n) { return n == null ? '–' : (n < 10 ? n.toFixed(1) : String(Math.round(n))); }
|
|
286
593
|
function bytes(n) {
|
|
287
|
-
if (n == null) return '
|
|
594
|
+
if (n == null) return '–';
|
|
288
595
|
if (n < 1024) return n + ' B';
|
|
289
596
|
if (n < 1048576) return (n / 1024).toFixed(1) + ' KiB';
|
|
290
|
-
return (n / 1048576).toFixed(1) + ' MiB';
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
function
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
function
|
|
303
|
-
|
|
304
|
-
function
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
return
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
var
|
|
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
|
-
|
|
597
|
+
if (n < 1073741824) return (n / 1048576).toFixed(1) + ' MiB';
|
|
598
|
+
return (n / 1073741824).toFixed(2) + ' GiB';
|
|
599
|
+
}
|
|
600
|
+
function pct(n) { return (n * 100).toFixed(n > 0 && n < 0.1 ? 1 : 0) + '%'; }
|
|
601
|
+
function st(cls, text) { return '<span class="st ' + cls + '">' + esc(text) + '</span>'; }
|
|
602
|
+
function copyBtn(v) { return '<button type="button" class="cp" data-copy="' + esc(v) + '" aria-label="Copy ' + esc(v) + '" title="Copy">' + COPY_SVG + '</button>'; }
|
|
603
|
+
function idCell(v) { return '<span class="id"><span title="' + esc(v) + '">' + esc(v) + '</span>' + copyBtn(v) + '</span>'; }
|
|
604
|
+
function idText(v) { return '<span class="id"><span title="' + esc(v) + '">' + esc(v) + '</span></span>'; }
|
|
605
|
+
function link(href, text, cls) { return '<a class="lnk ' + (cls || '') + '" href="' + esc(href) + '" title="' + esc(text) + '">' + esc(text) + '</a>'; }
|
|
606
|
+
function clientLink(id) { return '<span class="id">' + link(route('client', [id]), id) + copyBtn(id) + '</span>'; }
|
|
607
|
+
function rowLink(t, id, text) { return link(route('row', [t, id]), text || t + ' / ' + id); }
|
|
608
|
+
function seqBtn(seq) { return '<button type="button" class="tag" data-seq="' + seq + '">' + fmt(seq) + '</button>'; }
|
|
609
|
+
function trunc(text) { return '<span class="trunc" title="' + esc(text) + '">' + esc(text) + '</span>'; }
|
|
610
|
+
function tags(list) { return '<span class="tags">' + list.map(t => '<span class="tag">' + esc(t) + '</span>').join('') + '</span>'; }
|
|
611
|
+
function scopeTags(scopes) { return tags(Object.keys(scopes || {}).map(k => k + ': ' + [].concat(scopes[k]).join(', '))); }
|
|
612
|
+
function empty(title, text, small) { return '<div class="empty' + (small ? ' sm' : '') + '"><b>' + esc(title) + '</b>' + text + '</div>'; }
|
|
613
|
+
function errBox(err) {
|
|
614
|
+
return '<div class="errbox" role="alert"><code>' + esc(err.code || 'console.render_failed') + '</code>' +
|
|
615
|
+
(err.status ? '<span class="hs">HTTP ' + esc(err.status) + '</span>' : '') +
|
|
616
|
+
'<p>' + esc(err.message) + (err.action ? ' Recommended action: ' + esc(err.action) + '.' : '') + '</p></div>';
|
|
617
|
+
}
|
|
618
|
+
function kv(pairs) { return '<dl class="kv">' + pairs.map(p => '<dt>' + esc(p[0]) + '</dt><dd>' + p[1] + '</dd>').join('') + '</dl>'; }
|
|
619
|
+
function jhtml(v, ind) {
|
|
620
|
+
ind = ind || '';
|
|
621
|
+
if (v === null || v === undefined) return '<span class="jz">null</span>';
|
|
622
|
+
if (typeof v === 'string') return '<span class="js">' + esc(JSON.stringify(v)) + '</span>';
|
|
623
|
+
if (typeof v === 'number') return '<span class="jn">' + v + '</span>';
|
|
624
|
+
if (typeof v === 'boolean') return '<span class="jb">' + v + '</span>';
|
|
625
|
+
var arr = Array.isArray(v);
|
|
626
|
+
var keys = arr ? v.map((_, i) => i) : Object.keys(v);
|
|
627
|
+
if (!keys.length) return arr ? '[]' : '{}';
|
|
628
|
+
var inner = ind + ' ';
|
|
629
|
+
return (arr ? '[' : '{') + NL + keys.map(k => {
|
|
630
|
+
return inner + (arr ? '' : '<span class="jk">' + esc(JSON.stringify(k)) + '</span>: ') + jhtml(v[k], inner);
|
|
631
|
+
}).join(',' + NL) + NL + ind + (arr ? ']' : '}');
|
|
632
|
+
}
|
|
633
|
+
function json(v) { return '<pre class="json">' + jhtml(v) + '</pre>'; }
|
|
634
|
+
// Values follow SPEC §11 rendering: bytes and crdt columns arrive as
|
|
635
|
+
// base64 strings, json and blob_ref columns as parsed JSON.
|
|
636
|
+
function cell(v, type) {
|
|
637
|
+
if (v === null || v === undefined) return '<span class="dim">null</span>';
|
|
638
|
+
if ((type === 'bytes' || type === 'crdt') && typeof v === 'string') {
|
|
639
|
+
var n = Math.floor(v.length * 3 / 4) - (v.slice(-2) === '==' ? 2 : v.slice(-1) === '=' ? 1 : 0);
|
|
640
|
+
return '<span class="trunc" title="' + esc(v) + '">' + type + ' · ' + bytes(n) + ' <span class="dim">base64 ' + esc(v.slice(0, 24)) + (v.length > 24 ? '…' : '') + '</span></span>';
|
|
641
|
+
}
|
|
642
|
+
return trunc(typeof v === 'string' ? v : JSON.stringify(v));
|
|
643
|
+
}
|
|
644
|
+
function schemaOf(t) { return INFO.tables.filter(x => x.name === t)[0]; }
|
|
645
|
+
// Connection state comes from the realtime hub; without one the console
|
|
646
|
+
// shows when a client last synced and never guesses a connection.
|
|
647
|
+
function presence(c) {
|
|
648
|
+
if (INFO.realtime && c.connected) return st('ok', 'connected') + (c.connectedSinceMs ? ' <span class="dim">' + span(Date.now() - c.connectedSinceMs) + '</span>' : '');
|
|
649
|
+
return '<span class="dim" title="' + esc(stamp(c.updatedAtMs)) + '">seen ' + ago(c.updatedAtMs) + '</span>';
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// -- events: level, summary ----------------------------------------------
|
|
653
|
+
function level(e) {
|
|
654
|
+
var t = e.type;
|
|
655
|
+
if (t === 'push.rejected' || t === 'reaction.dead_lettered' || t === 'scopes.resolve_failed' ||
|
|
656
|
+
(t === 'request.handled' && (e.outcome === 'error' || e.outcome === 'rejected')) ||
|
|
657
|
+
((t === 'segment.downloaded' || t === 'blob.downloaded') && e.outcome === 'error')) return 'err';
|
|
658
|
+
if (t === 'push.conflicted' || t === 'reaction.retried' || t === 'lease.revoked' ||
|
|
659
|
+
(t === 'request.handled' && (e.outcome === 'reset' || e.outcome === 'schema_floor')) ||
|
|
660
|
+
(t === 'realtime.wake' && e.reason === 'delta-too-large') ||
|
|
661
|
+
(t === 'pull.served' && e.subscriptions.some(s => s.status !== 'active'))) return 'warn';
|
|
662
|
+
return 'info';
|
|
663
|
+
}
|
|
664
|
+
var RANK = { err: 0, warn: 1, info: 2 }, LEVEL_LABEL = { err: 'error', warn: 'warn', info: 'info' };
|
|
665
|
+
var SUMMARY_KEYS = ['outcome', 'errorCode', 'code', 'commitSeq', 'operations', 'opIndex', 'reason', 'reactionType',
|
|
666
|
+
'attempt', 'phase', 'message', 'previousHorizonSeq', 'horizonSeq', 'removedCommits', 'swept', 'changes', 'bytes',
|
|
667
|
+
'durationMs', 'segmentId', 'blobId', 'leaseId', 'registrations'];
|
|
668
|
+
function summary(e) {
|
|
669
|
+
if (e.type === 'request.handled') {
|
|
670
|
+
return e.outcome + (e.errorCode ? ' ' + e.errorCode : '') + ' · ' + dur(e.durationMs) + ' ms · ' + e.pushCommits +
|
|
671
|
+
' pushed · ' + (e.pulled ? 'pulled ' + e.subscriptions + ' subs' : 'no pull') + ' · ' + bytes(e.bytesIn) + ' in, ' + bytes(e.bytesOut) + ' out';
|
|
672
|
+
}
|
|
673
|
+
if (e.type === 'pull.served') {
|
|
674
|
+
var modes = {}, commits = 0;
|
|
675
|
+
e.subscriptions.forEach(s => { var k = s.status === 'active' ? s.mode : s.status; modes[k] = (modes[k] || 0) + 1; commits += s.commits; });
|
|
676
|
+
return Object.keys(modes).map(k => modes[k] + ' ' + k).join(', ') + ' · ' + commits + ' commits · through ' + e.acceptedThrough;
|
|
677
|
+
}
|
|
678
|
+
return (e.table && e.rowId ? e.table + ' / ' + e.rowId + ' · ' : '') + SUMMARY_KEYS.filter(k => e[k] !== undefined).map(k => {
|
|
679
|
+
return k + ' ' + (typeof e[k] === 'string' ? e[k] : JSON.stringify(e[k]));
|
|
680
|
+
}).join(' · ') + (e.replay ? ' · replay' : '');
|
|
681
|
+
}
|
|
682
|
+
function detailCell(e) {
|
|
683
|
+
return e.table && e.rowId ? '<span class="tags">' + rowLink(e.table, e.rowId) + '</span>' + trunc(summary(e).slice(e.table.length + e.rowId.length + 6)) : trunc(summary(e));
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
// -- tables: sortable, pickable ------------------------------------------
|
|
687
|
+
var T = {};
|
|
688
|
+
function table(id, cols, rows, emptyHtml, pick, current) {
|
|
689
|
+
var t = T[id] || (T[id] = { k: -1, d: 1 });
|
|
690
|
+
t.cols = cols; t.rows = rows; t.empty = emptyHtml; t.pick = pick; t.current = current;
|
|
691
|
+
drawTable(id);
|
|
692
|
+
}
|
|
693
|
+
function drawTable(id) {
|
|
694
|
+
var t = T[id], host = $(id);
|
|
695
|
+
host.setAttribute('data-tbl', id);
|
|
696
|
+
if (!t.rows.length) { host.innerHTML = t.empty; return; }
|
|
697
|
+
var order = t.rows.map((r, i) => i);
|
|
698
|
+
if (t.k >= 0) {
|
|
699
|
+
var col = t.cols[t.k];
|
|
700
|
+
order.sort((a, b) => {
|
|
701
|
+
var x = col.v(t.rows[a]), y = col.v(t.rows[b]);
|
|
702
|
+
return (x < y ? -1 : x > y ? 1 : a - b) * (x === y ? 1 : t.d);
|
|
703
|
+
});
|
|
380
704
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
'<
|
|
384
|
-
'<
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
705
|
+
host.innerHTML = '<div class="tw' + (t.rows.length < 8 ? ' short' : '') + '"><table class="dt"><thead><tr>' + t.cols.map((c, ci) => {
|
|
706
|
+
var cls = (c.ns ? 'ns ' : '') + (c.c || '');
|
|
707
|
+
if (c.ns || !c.v) return '<th scope="col" class="' + cls + '"><span>' + c.l + '</span></th>';
|
|
708
|
+
return '<th scope="col" class="' + cls + '"' + (t.k === ci ? ' aria-sort="' + (t.d > 0 ? 'ascending' : 'descending') + '"' : '') +
|
|
709
|
+
'><button type="button" data-sort="' + ci + '">' + c.l + '</button></th>';
|
|
710
|
+
}).join('') + '</tr></thead><tbody>' + order.map(i => {
|
|
711
|
+
var r = t.rows[i];
|
|
712
|
+
return '<tr' + (t.pick ? ' tabindex="0" data-i="' + i + '"' : '') + (t.current && t.current(r) ? ' class="cur"' : '') + '>' +
|
|
713
|
+
t.cols.map(c => '<td class="' + (c.c || '') + '" data-l="' + c.l + '">' + c.h(r) + '</td>').join('') + '</tr>';
|
|
714
|
+
}).join('') + '</tbody></table></div>';
|
|
715
|
+
}
|
|
716
|
+
function numCol(label, key) { return { l: label, c: 'num', d: -1, v: r => r[key], h: r => fmt(r[key]) }; }
|
|
717
|
+
function sortBy(id, ci) {
|
|
718
|
+
var t = T[id];
|
|
719
|
+
if (t.k === ci) t.d = -t.d; else { t.k = ci; t.d = t.cols[ci].d || 1; }
|
|
720
|
+
drawTable(id);
|
|
721
|
+
var b = $(id).querySelector('[data-sort="' + ci + '"]');
|
|
722
|
+
if (b) b.focus();
|
|
723
|
+
}
|
|
724
|
+
function pager(host, acts) {
|
|
725
|
+
$(host).insertAdjacentHTML('beforeend', '<div class="acts pager">' + acts.map(a => '<button type="button" class="btn sm" data-act="' + a[0] + '"' + (a[2] ? '' : ' disabled') + '>' + a[1] + '</button>').join('') + '</div>');
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// -- state ---------------------------------------------------------------
|
|
729
|
+
// INFO is the admin's capability record from GET /info; it outlives
|
|
730
|
+
// partition switches. S holds the current partition's reads.
|
|
731
|
+
var INFO = null, S = {}, ERR_TAB = 'code', at = { view: 'overview', args: [] };
|
|
732
|
+
var tail = { mode: 'idle', src: null, list: [], held: [], paused: false };
|
|
733
|
+
function reset() {
|
|
734
|
+
S = { errs: {}, fleetOffset: 0 };
|
|
735
|
+
document.querySelectorAll('[data-skel]').forEach(h => { h.innerHTML = SKEL; });
|
|
736
|
+
['n-people', 'n-data', 'n-commits', 'n-events', 'n-reactions'].forEach(id => { $(id).textContent = ''; });
|
|
737
|
+
renderKpis();
|
|
738
|
+
}
|
|
739
|
+
function ringOff(text) {
|
|
740
|
+
return empty('No event ring', text + ' A Workers deployment without a Durable Object namespace serves the console from the Worker, which keeps no events. Add a <code>coordinator</code> to record them.', true);
|
|
741
|
+
}
|
|
742
|
+
function partial(m) { return m.coverage && !m.coverage.complete; }
|
|
743
|
+
// Clients a person would call "online": an open socket with a realtime
|
|
744
|
+
// hub, else a sync round within the last hour.
|
|
745
|
+
function online(c) { return INFO.realtime ? !!c.connected : Date.now() - c.updatedAtMs < 3600000; }
|
|
746
|
+
function onlineWord() { return INFO.realtime ? 'connected' : 'seen in the last hour'; }
|
|
747
|
+
function behindSchema(list) { return INFO.schemaVersion == null ? [] : list.filter(c => c.schemaVersion != null && c.schemaVersion < INFO.schemaVersion); }
|
|
748
|
+
|
|
749
|
+
// -- overview ------------------------------------------------------------
|
|
750
|
+
function sparkBars(vals, errs, red) {
|
|
751
|
+
var max = Math.max.apply(null, vals.concat([1])), H = 26;
|
|
752
|
+
return '<svg viewBox="0 0 ' + vals.length * 4 + ' ' + H + '" preserveAspectRatio="none" aria-hidden="true">' + vals.map((v, i) => {
|
|
753
|
+
var h = v ? Math.max(1.5, v / max * H) : 1, e = errs && errs[i] ? Math.max(1.5, errs[i] / max * H) : 0;
|
|
754
|
+
return '<rect class="bar' + (v ? (red ? ' r' : '') : ' z') + '" x="' + (i * 4) + '" y="' + (H - h) + '" width="3" height="' + h + '"/>' +
|
|
755
|
+
(e ? '<rect class="bar r" x="' + (i * 4) + '" y="' + (H - e) + '" width="3" height="' + e + '"/>' : '');
|
|
756
|
+
}).join('') + '</svg>';
|
|
757
|
+
}
|
|
758
|
+
function stack(parts) {
|
|
759
|
+
var total = parts.reduce((s, p) => s + p[0], 0);
|
|
760
|
+
return '<div class="stack">' + (total ? parts.map(p => p[0] ? '<b class="' + p[1] + '" style="width:' + (p[0] / total * 100) + '%"></b>' : '').join('') : '') + '</div>';
|
|
761
|
+
}
|
|
762
|
+
function kpi(label, value, unit, sub, viz, cls) {
|
|
763
|
+
return '<div class="kpi ' + (cls || '') + '"><div class="l">' + label + '</div><div class="v">' + value +
|
|
764
|
+
(unit ? '<small>' + unit + '</small>' : '') + '</div><div class="s" title="' + esc(sub) + '">' + esc(sub) + '</div><div class="viz">' + (viz || '') + '</div></div>';
|
|
765
|
+
}
|
|
766
|
+
function renderKpis() {
|
|
767
|
+
var m = S.metrics, h = S.horizon, c = S.clients, e = S.errs, out = '';
|
|
768
|
+
if (m && INFO && INFO.hasEventStream) {
|
|
769
|
+
var b = m.buckets, p = m.pushes, cut = partial(m);
|
|
770
|
+
var scope = cut ? 'since ' + clock(m.coverage.fromMs) + ' (partial window)' : 'in the last ' + span(m.windowMs);
|
|
771
|
+
out += kpi('Requests', m.requests.perMinute >= 10 ? fmt(Math.round(m.requests.perMinute)) : m.requests.perMinute.toFixed(1), '/min',
|
|
772
|
+
fmt(m.requests.count) + ' ' + scope, sparkBars(b.counts, b.errors), cut ? 'warn' : '');
|
|
773
|
+
out += kpi('Error rate', pct(m.requests.errorRate), '', fmt(m.requests.errorCount) + ' rejected or failed ' + scope,
|
|
774
|
+
sparkBars(b.counts.map((n, i) => n ? b.errors[i] / n : 0), null, true), m.requests.errorRate > 0 ? 'bad' : cut ? 'warn' : '');
|
|
775
|
+
out += kpi('Latency p95', dur(m.requests.p95Ms), 'ms', 'p50 ' + dur(m.requests.p50Ms) + ' ms ' + scope, sparkBars(b.p95Ms.map(v => v || 0)), cut ? 'warn' : '');
|
|
776
|
+
out += kpi('Pushes', fmt(p.applied), 'applied', fmt(p.conflicted) + ' conflicted · ' + fmt(p.rejected) + ' rejected',
|
|
777
|
+
sparkBars(b.pushes.map(x => x.applied + x.conflicted + x.rejected), b.pushes.map(x => x.conflicted + x.rejected)),
|
|
778
|
+
p.conflicted + p.rejected > 0 || cut ? 'warn' : '');
|
|
390
779
|
} else {
|
|
391
|
-
|
|
780
|
+
var why = e.metrics ? e.metrics.code : INFO && !INFO.hasEventStream ? 'no event ring wired' : 'loading';
|
|
781
|
+
['Requests', 'Error rate', 'Latency p95', 'Pushes'].forEach(l => { out += kpi(l, '–', '', why, '', ''); });
|
|
392
782
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
el('commits').innerHTML = table(['seq', 'actor', 'client', 'changes', 'tables', 'when'],
|
|
406
|
-
list.map(function (c) {
|
|
407
|
-
return [esc(c.commitSeq), esc(c.actorId), esc(c.clientId), esc(c.changeCount),
|
|
408
|
-
'<span class="wrap">' + esc(c.tables.join(', ')) + '</span>', ago(c.createdAtMs)];
|
|
409
|
-
}));
|
|
783
|
+
if (c) {
|
|
784
|
+
var on = c.filter(online).length, old = behindSchema(c).length;
|
|
785
|
+
out += kpi('Clients', fmt(on), '/ ' + fmt(S.clientTotal) + ' ' + onlineWord(),
|
|
786
|
+
old ? fmt(old) + ' below server schema v' + INFO.schemaVersion : fmt(c.filter(x => x.lag > 0).length) + ' behind the head',
|
|
787
|
+
stack([[on, 'c-ok'], [c.length - on, 'c-dim']]), old ? 'warn' : '');
|
|
788
|
+
} else out += kpi('Clients', '–', '', e.clients ? e.clients.code : 'loading', '', '');
|
|
789
|
+
if (h) {
|
|
790
|
+
out += kpi('Commit log', fmt(h.maxCommitSeq), 'head', fmt(h.retainedCommits) + ' retained · horizon ' + fmt(h.horizonSeq),
|
|
791
|
+
stack([[h.horizonSeq, 'c-dim'], [h.recommendedHorizonSeq - h.horizonSeq, 'c-am'], [h.maxCommitSeq - h.recommendedHorizonSeq, 'c-cy']]),
|
|
792
|
+
h.recommendation === 'prune-recommended' ? 'warn' : '');
|
|
793
|
+
} else out += kpi('Commit log', '–', '', e.horizon ? e.horizon.code : 'loading', '', '');
|
|
794
|
+
html('kpis', out);
|
|
410
795
|
}
|
|
411
|
-
function
|
|
412
|
-
var
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
796
|
+
function renderVolume() {
|
|
797
|
+
var m = S.metrics, host = $('ov-volume');
|
|
798
|
+
if (!INFO.hasEventStream) { txt('vol-meta', ''); host.innerHTML = ringOff('Request metrics come from the event ring.'); return; }
|
|
799
|
+
var b = m.buckets, c = b.counts, er = b.errors, n = c.length, max = Math.max.apply(null, c.concat([1])), W = n * 10, H = 100;
|
|
800
|
+
var from = m.atMs - m.windowMs, cut = partial(m);
|
|
801
|
+
var svg = '<svg viewBox="0 0 ' + W + ' ' + H + '" preserveAspectRatio="none" role="img" aria-label="Requests per ' + span(b.widthMs) + ' bucket over the last ' + span(m.windowMs) + ', peak ' + max + '">' +
|
|
802
|
+
(cut ? '<rect class="nocov" x="0" y="0" height="' + H + '" width="' + Math.max(0, Math.min(W, (m.coverage.fromMs - from) / m.windowMs * W)) + '"/>' : '') +
|
|
803
|
+
'<line class="grid" x1="0" x2="' + W + '" y1="0.5" y2="0.5" vector-effect="non-scaling-stroke"/><line class="grid" x1="0" x2="' + W + '" y1="50" y2="50" vector-effect="non-scaling-stroke"/><line class="grid" x1="0" x2="' + W + '" y1="99.5" y2="99.5" vector-effect="non-scaling-stroke"/>';
|
|
804
|
+
for (var i = 0; i < n; i++) {
|
|
805
|
+
var hOk = (c[i] - er[i]) / max * H, hErr = er[i] / max * H, x = i * 10 + 1.5, pu = b.pushes[i];
|
|
806
|
+
svg += '<g><title>' + clock(from + i * b.widthMs) + ' to ' + clock(from + (i + 1) * b.widthMs) + ': ' + c[i] + ' requests, ' + er[i] + ' failed' +
|
|
807
|
+
(b.p95Ms[i] != null ? ', p95 ' + dur(b.p95Ms[i]) + ' ms' : '') + ', ' + pu.applied + ' pushes applied, ' + pu.conflicted + ' conflicted, ' + pu.rejected + ' rejected</title>' +
|
|
808
|
+
'<rect class="hit" x="' + (i * 10) + '" y="0" width="10" height="' + H + '" fill="transparent"/>' +
|
|
809
|
+
(hOk ? '<rect class="bar" x="' + x + '" y="' + (H - hOk - hErr) + '" width="7" height="' + hOk + '"/>' : '') +
|
|
810
|
+
(hErr ? '<rect class="bar r" x="' + x + '" y="' + (H - hErr) + '" width="7" height="' + hErr + '"/>' : '') + '</g>';
|
|
422
811
|
}
|
|
423
|
-
|
|
812
|
+
txt('vol-meta', span(b.widthMs) + ' buckets');
|
|
813
|
+
host.innerHTML = (cut ? '<div class="banner"><b>Partial window</b><span>The event ring evicted events inside the ' + span(m.windowMs) + ' window. Every figure here covers only the last ' +
|
|
814
|
+
span(m.atMs - m.coverage.fromMs) + ', since ' + clock(m.coverage.fromMs) + ' (shaded range has no data). Raise the ring capacity for a full window.</span></div>' : '') +
|
|
815
|
+
'<div class="chart"><span class="ymax">' + fmt(max) + '</span>' + svg + '</svg><div class="axis"><span>' + span(m.windowMs) + ' ago</span><span>' + span(m.windowMs / 2) + ' ago</span><span>now</span></div></div>' +
|
|
816
|
+
'<div class="legend"><span><i class="c-am"></i>requests</span><span><i class="c-err"></i>rejected or failed</span><span class="r">' + fmt(m.requests.count) + ' requests · p50 ' + dur(m.requests.p50Ms) + ' ms · p95 ' + dur(m.requests.p95Ms) + ' ms</span></div>';
|
|
424
817
|
}
|
|
425
|
-
function
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
818
|
+
function renderHorizon(id, h) {
|
|
819
|
+
var host = $(id);
|
|
820
|
+
if (h.maxCommitSeq === 0) { host.innerHTML = empty('Empty commit log', 'The partition has no commits yet, so there is nothing to retain or prune.', true); return; }
|
|
821
|
+
var max = h.maxCommitSeq, pos = n => Math.max(0, Math.min(100, n / max * 100));
|
|
822
|
+
var hz = pos(h.horizonSeq), rec = pos(h.recommendedHorizonSeq), floor = h.activeCursorFloor, marker = '';
|
|
823
|
+
if (floor !== null) {
|
|
824
|
+
var fp = pos(Math.max(floor, 0));
|
|
825
|
+
marker = '<span class="mark' + (fp < 15 ? ' l' : fp > 85 ? ' e' : '') + '" style="left:' + fp + '%"><span>cursor floor ' + fmt(floor) + '</span></span>';
|
|
826
|
+
}
|
|
827
|
+
var prune = h.recommendation === 'prune-recommended';
|
|
828
|
+
host.innerHTML = '<div class="gauge" role="img" aria-label="Commit log from 0 to head ' + max + ': horizon ' + h.horizonSeq + ', a prune pass would reach ' + h.recommendedHorizonSeq + '">' +
|
|
829
|
+
'<i class="g-pruned" style="width:' + hz + '%"></i><i class="g-prunable" style="width:' + (rec - hz) + '%"></i><i class="g-retained" style="width:' + (100 - rec) + '%"></i>' + marker + '</div>' +
|
|
830
|
+
'<div class="gscale"><span>0</span><span>head ' + fmt(max) + '</span></div>' +
|
|
831
|
+
'<div class="legend"><span><i class="g-pruned" style="border:1px solid var(--line-strong)"></i>pruned</span><span><i class="g-prunable"></i>prunable now</span><span><i class="g-retained"></i>retained</span></div>' +
|
|
832
|
+
(INFO.actions ? '<div class="acts" style="margin:0 0 -6px"><button type="button" class="btn sm' + (prune ? ' amber' : '') + '" data-act="prune">Prune now</button></div>' : '') +
|
|
833
|
+
'<p class="verdict"><b class="' + (prune ? 'ty' : 'dim') + '">' + (prune ? 'Prune recommended' : 'Up to date') + '</b>' +
|
|
834
|
+
(prune ? 'A prune pass would advance the horizon from ' + fmt(h.horizonSeq) + ' to ' + fmt(h.recommendedHorizonSeq) + ' and drop ' + fmt(h.recommendedHorizonSeq - h.horizonSeq) + ' commits.'
|
|
835
|
+
: 'A prune pass now would leave the horizon at ' + fmt(h.horizonSeq) + '.') + '</p>' +
|
|
836
|
+
kv([['Head', fmt(h.maxCommitSeq)], ['Horizon', fmt(h.horizonSeq)], ['Prune target', fmt(h.recommendedHorizonSeq)],
|
|
837
|
+
['Retained', fmt(h.retainedCommits) + ' commits'],
|
|
838
|
+
['Cursor floor', floor === null ? '<span class="dim">no active clients</span>' : fmt(floor) + (floor < 0 ? ' <span class="dim">(a client has not pulled yet)</span>' : '')]]);
|
|
839
|
+
}
|
|
840
|
+
var LAG_BUCKETS = [[0, 0, 'in sync'], [1, 9, '1 to 9'], [10, 99, '10 to 99'], [100, 999, '100 to 999'], [1000, Infinity, '1000 +']];
|
|
841
|
+
function renderLag() {
|
|
842
|
+
var c = S.clients;
|
|
843
|
+
txt('lag-meta', c.length ? 'commits behind head' : '');
|
|
844
|
+
if (!c.length) { html('ov-lag', empty('No clients', 'No client has synced this partition. Clients appear after their first request.', true)); return; }
|
|
845
|
+
var rows = LAG_BUCKETS.map(b => {
|
|
846
|
+
var inB = c.filter(x => x.lag >= b[0] && x.lag <= b[1]), a = inB.filter(online).length;
|
|
847
|
+
return [b[2], a, inB.length - a];
|
|
848
|
+
});
|
|
849
|
+
var max = Math.max.apply(null, rows.map(r => r[1] + r[2]).concat([1]));
|
|
850
|
+
html('ov-lag', '<div class="pb"><div class="hist">' + rows.map(r => {
|
|
851
|
+
return '<span class="lb">' + r[0] + '</span><span class="tr" title="' + r[1] + ' ' + onlineWord() + ', ' + r[2] + ' other" aria-hidden="true"><b class="c-am" style="width:' + (r[1] / max * 100) + '%"></b><b class="c-dim" style="width:' + (r[2] / max * 100) + '%"></b></span><span class="ct">' + (r[1] + r[2]) + '<span class="sr"> clients, ' + r[1] + ' ' + onlineWord() + '</span></span>';
|
|
852
|
+
}).join('') + '</div><div class="legend"><span><i class="c-am"></i>' + onlineWord() + '</span><span><i class="c-dim"></i>other</span></div></div><div id="ov-lagtop"></div>');
|
|
853
|
+
var top = c.filter(x => x.lag > 0).sort((a, b) => b.lag - a.lag).slice(0, 5);
|
|
854
|
+
if (top.length) {
|
|
855
|
+
table('ov-lagtop', [
|
|
856
|
+
{ l: 'Most behind', c: 'w-sm fill', h: x => clientLink(x.clientId) },
|
|
857
|
+
{ l: 'Lag', c: 'num', h: x => fmt(x.lag) },
|
|
858
|
+
{ l: 'Seen', c: 'num', h: x => when(x.updatedAtMs) }
|
|
859
|
+
], top, '', x => { nav('client', [x.clientId]); });
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
function renderErrors() {
|
|
863
|
+
var r = S.errors;
|
|
864
|
+
document.querySelectorAll('[data-act="err-tab"]').forEach(b => { b.setAttribute('aria-pressed', String(b.getAttribute('data-tab') === ERR_TAB)); });
|
|
865
|
+
if (!INFO.hasEventStream) { txt('err-meta', ''); html('ov-errors', ringOff('Failures come from the event ring.')); return; }
|
|
866
|
+
var cut = r.coverage && !r.coverage.complete;
|
|
867
|
+
txt('err-meta', cut ? 'since ' + clock(r.coverage.fromMs) + ' (partial)' : 'last ' + span(r.windowMs));
|
|
868
|
+
var none = empty('Nothing failing', 'No rejected request, push, or failed delivery in the ' + (cut ? 'covered part of the window' : 'last ' + span(r.windowMs)) + '.', true);
|
|
869
|
+
if (ERR_TAB === 'code') {
|
|
870
|
+
table('ov-errors', [
|
|
871
|
+
{ l: 'Code', v: x => x.code, h: x => '<span class="ty err">' + esc(x.code) + '</span>' },
|
|
872
|
+
{ l: 'Source', v: x => x.source, h: x => esc(x.source) },
|
|
873
|
+
numCol('Count', 'count'), numCol('Clients', 'clients'),
|
|
874
|
+
{ l: 'Last', c: 'num', d: -1, v: x => x.lastAtMs, h: x => when(x.lastAtMs) },
|
|
875
|
+
{ l: 'Rows and clients', c: 'fill', ns: true, h: x => '<span class="tags">' + x.sampleRows.map(w => rowLink(w.table, w.rowId)).concat(x.sampleClientIds.map(id => link(route('client', [id]), id, 'tag'))).join('') + '</span>' }
|
|
876
|
+
], r.byCode, none, x => { $('ev-q').value = x.code; nav('events'); renderTail(); });
|
|
877
|
+
} else {
|
|
878
|
+
table('ov-errors', [
|
|
879
|
+
{ l: 'Client', c: 'w-sm', v: x => x.clientId, h: x => clientLink(x.clientId) },
|
|
880
|
+
{ l: 'Actor', c: 'w-sm', v: x => x.actorId, h: x => idText(x.actorId) },
|
|
881
|
+
numCol('Count', 'count'),
|
|
882
|
+
{ l: 'Last code', v: x => x.lastCode, h: x => '<span class="ty err">' + esc(x.lastCode) + '</span>' },
|
|
883
|
+
{ l: 'Last', c: 'num fill', d: -1, v: x => x.lastAtMs, h: x => when(x.lastAtMs) }
|
|
884
|
+
], r.byClient.slice(0, 10), none, x => { nav('client', [x.clientId]); });
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// -- loaders -------------------------------------------------------------
|
|
889
|
+
function fail(hosts, key) {
|
|
890
|
+
return err => {
|
|
891
|
+
if (err === STALE) return null;
|
|
892
|
+
if (key) { S.errs[key] = err; renderKpis(); }
|
|
893
|
+
hosts.forEach(id => { $(id).innerHTML = errBox(err); });
|
|
894
|
+
return err;
|
|
895
|
+
};
|
|
431
896
|
}
|
|
432
|
-
function
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
897
|
+
function loadMetrics() {
|
|
898
|
+
if (!INFO.hasEventStream) { renderKpis(); renderVolume(); return null; }
|
|
899
|
+
return get('/metrics').then(r => { S.metrics = r.metrics; renderKpis(); renderVolume(); return null; }).catch(fail(['ov-volume'], 'metrics'));
|
|
900
|
+
}
|
|
901
|
+
function loadErrors() {
|
|
902
|
+
if (!INFO.hasEventStream) { renderErrors(); return null; }
|
|
903
|
+
return get('/errors', { windowMs: 300000 }).then(r => { S.errors = r.errors; renderErrors(); return null; }).catch(err => { txt('err-meta', ''); return fail(['ov-errors'])(err); });
|
|
904
|
+
}
|
|
905
|
+
function loadHorizon(hosts) {
|
|
906
|
+
return get('/horizon').then(r => {
|
|
907
|
+
var h = r.horizon;
|
|
908
|
+
S.horizon = h;
|
|
909
|
+
txt('ov-part', h.partition);
|
|
910
|
+
$('partition').placeholder = h.partition;
|
|
911
|
+
hosts.forEach(id => { renderHorizon(id, h); });
|
|
912
|
+
renderKpis();
|
|
913
|
+
return null;
|
|
914
|
+
}).catch(fail(hosts, 'horizon'));
|
|
915
|
+
}
|
|
916
|
+
function loadClients() {
|
|
917
|
+
return get('/clients', { sort: 'lag', limit: 500 }).then(r => {
|
|
918
|
+
S.clients = r.clients;
|
|
919
|
+
S.clientTotal = r.total;
|
|
920
|
+
renderLag(); renderKpis();
|
|
921
|
+
return null;
|
|
922
|
+
}).catch(fail(['ov-lag'], 'clients'));
|
|
923
|
+
}
|
|
924
|
+
function loadFleet() {
|
|
925
|
+
return get('/partitions', { limit: FLEET_PAGE, offset: S.fleetOffset }).then(r => {
|
|
926
|
+
var list = r.partitions, cur = S.horizon ? S.horizon.partition : $('partition').value.trim(), off = S.fleetOffset;
|
|
927
|
+
html('partitions-list', list.map(p => '<option value="' + esc(p.partition) + '"></option>').join(''));
|
|
928
|
+
var prune = list.filter(p => p.recommendation === 'prune-recommended').length;
|
|
929
|
+
txt('fleet-meta', fmt(r.total) + ' partitions' + (r.total > list.length ? ' · ' + fmt(off + 1) + ' to ' + fmt(off + list.length) + ' shown' : '') + (prune ? ' · ' + prune + ' to prune' : ''));
|
|
930
|
+
table('ov-fleet', [
|
|
931
|
+
{ l: 'Partition', c: 'w-sm', v: p => p.partition, h: p => idCell(p.partition) },
|
|
932
|
+
numCol('Head', 'maxCommitSeq'), numCol('Horizon', 'horizonSeq'), numCol('Retained', 'retainedCommits'),
|
|
933
|
+
{ l: 'Clients', c: 'num', d: -1, v: p => p.knownClients, h: p => fmt(p.knownClients) },
|
|
934
|
+
{ l: 'State', c: 'fill', v: p => p.recommendation, h: p => p.recommendation === 'prune-recommended' ? st('warn', 'prune recommended') : st('ok', 'up to date') }
|
|
935
|
+
], list, empty('No partitions', 'The partition registry is empty.', true), p => { setPartition(p.partition); }, p => p.partition === cur);
|
|
936
|
+
if (r.total > FLEET_PAGE) pager('ov-fleet', [['fleet-prev', 'Previous', off > 0], ['fleet-next', 'Next', off + list.length < r.total]]);
|
|
937
|
+
return null;
|
|
938
|
+
}).catch(err => { txt('fleet-meta', ''); return fail(['ov-fleet'])(err); });
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
// -- people --------------------------------------------------------------
|
|
942
|
+
function loadPeople(args) {
|
|
943
|
+
if (args[0] !== undefined) $('people-q').value = args[0];
|
|
944
|
+
$('people-fail-panel').hidden = args[0] === undefined;
|
|
945
|
+
if (args[0] !== undefined) txt('people-fail-h', 'Failures and warnings · ' + args[0]);
|
|
946
|
+
html('people-rt', INFO.realtime ? '' : '<div class="banner"><b>No realtime hub</b><span>This admin has no realtime hub wired, so it cannot see open sockets. Each device shows when it last synced instead.</span></div>');
|
|
947
|
+
return get('/actors').then(r => {
|
|
948
|
+
S.actors = r.actors;
|
|
949
|
+
var all = [];
|
|
950
|
+
r.actors.forEach(a => { all = all.concat(a.clients); });
|
|
951
|
+
S.devices = all;
|
|
952
|
+
txt('n-people', fmt(r.actors.length));
|
|
953
|
+
renderRollout(); renderPeople();
|
|
954
|
+
return null;
|
|
955
|
+
}).catch(fail(['people-table', 'people-rollout']));
|
|
956
|
+
}
|
|
957
|
+
function renderRollout() {
|
|
958
|
+
var by = {}, c = S.devices, server = INFO.schemaVersion;
|
|
959
|
+
c.forEach(x => { var k = x.schemaVersion == null ? 'unknown' : x.schemaVersion; by[k] = (by[k] || 0) + 1; });
|
|
960
|
+
var keys = Object.keys(by).sort((a, b) => (a === 'unknown' ? -1 : Number(a)) - (b === 'unknown' ? -1 : Number(b)));
|
|
961
|
+
var max = Math.max.apply(null, keys.map(k => by[k]).concat([1])), old = behindSchema(c);
|
|
962
|
+
txt('rollout-meta', server == null ? 'server schema unknown' : 'server schema v' + server);
|
|
963
|
+
if (!c.length) { html('people-rollout', empty('No devices', 'No client has synced this partition yet.', true)); return; }
|
|
964
|
+
html('people-rollout', '<div class="hist">' + keys.map(k => {
|
|
965
|
+
var below = server != null && k !== 'unknown' && Number(k) < server;
|
|
966
|
+
return '<span class="lb">' + (k === 'unknown' ? 'unknown' : 'schema v' + k) + '</span><span class="tr" aria-hidden="true"><b class="' + (below ? 'c-err' : k === 'unknown' ? 'c-dim' : 'c-ok') + '" style="width:' + (by[k] / max * 100) + '%"></b></span><span class="ct">' + by[k] + '</span>';
|
|
967
|
+
}).join('') + '</div><p class="verdict">' + (old.length
|
|
968
|
+
? '<b class="ty err">' + old.length + ' behind</b>' + old.length + ' devices run a schema below the server\\'s v' + server + ': ' + old.slice(0, 6).map(x => link(route('client', [x.clientId]), x.clientId)).join(', ') + (old.length > 6 ? ' and ' + (old.length - 6) + ' more' : '') + '.'
|
|
969
|
+
: server == null ? 'The server reports no schema version.' : '<b class="dim">Rolled out</b>Every device that reports a schema runs v' + server + ' or newer.') + '</p>');
|
|
970
|
+
}
|
|
971
|
+
function renderPeople() {
|
|
972
|
+
var q = $('people-q').value.trim().toLowerCase(), list = S.actors.filter(a => !q || a.actorId.toLowerCase().indexOf(q) >= 0 || a.clients.some(c => c.clientId.toLowerCase().indexOf(q) >= 0));
|
|
973
|
+
txt('people-count', fmt(list.length) + ' of ' + fmt(S.actors.length) + ' actors · ' + fmt(S.devices.length) + ' devices');
|
|
974
|
+
table('people-table', [
|
|
975
|
+
{ l: 'Actor', c: 'w-sm', v: a => a.actorId, h: a => idCell(a.actorId) },
|
|
976
|
+
{ l: INFO.realtime ? 'Connected' : 'Last seen', c: 'num', d: -1, v: a => INFO.realtime ? a.connected : a.lastSeenMs, h: a => INFO.realtime ? (a.connected ? st('ok', a.connected + ' of ' + a.clients.length) : '<span class="dim">none</span>') : when(a.lastSeenMs) },
|
|
977
|
+
{ l: 'Max lag', c: 'num', d: -1, v: a => a.maxLag, h: a => fmt(a.maxLag) },
|
|
978
|
+
{ l: 'Failures', c: 'num', d: -1, v: a => a.recentFailures, h: a => a.recentFailures ? link(route('people', [a.actorId]), fmt(a.recentFailures), 'ty err') : '<span class="dim">0</span>' },
|
|
979
|
+
{ l: 'Devices', c: 'fill', ns: true, h: a => '<span class="tags">' + a.clients.map(c => '<a class="tag dev' + (online(c) ? ' on' : '') + '" href="' + esc(route('client', [c.clientId])) + '" title="' + esc(c.clientId + ' · ' + (INFO.realtime && c.connected ? 'connected' : 'seen ' + ago(c.updatedAtMs)) + ' · lag ' + c.lag) + '">' + esc(c.clientId.length > 14 ? c.clientId.slice(0, 13) + '…' : c.clientId) + (c.schemaVersion != null && INFO.schemaVersion != null && c.schemaVersion < INFO.schemaVersion ? ' · v' + c.schemaVersion : '') + '</a>').join('') + '</span>' }
|
|
980
|
+
], list, S.actors.length ? empty('No match', 'No actor or device matches the filter.') : empty('No actors', 'No client has synced this partition yet.'), a => { nav('people', [a.actorId]); });
|
|
981
|
+
}
|
|
982
|
+
function loadClientPage(args) {
|
|
983
|
+
var id = args[0];
|
|
984
|
+
html('h-client', esc(id) + copyBtn(id));
|
|
985
|
+
return get('/clients/' + enc(id), { eventLimit: 50 }).then(r => {
|
|
986
|
+
var d = r.detail, c = d.client;
|
|
987
|
+
if (!d.exists) { txt('client-line', ''); html('client-body', empty('No record', 'This partition has no cursor record for client ' + esc(id) + '.')); return null; }
|
|
988
|
+
$('client-line').innerHTML = presence(c) + ' · actor ' + link(route('people', [c.actorId]), c.actorId) + ' · ' + fmt(c.lag) + ' commits behind';
|
|
989
|
+
var lease = d.lease
|
|
990
|
+
? esc(d.lease.leaseId) + ' · ' + (d.lease.revoked ? st('err', 'revoked') : d.lease.expiresAtMs > Date.now() ? st('ok', 'expires ' + rel(d.lease.expiresAtMs)) : st('warn', 'expired')) +
|
|
991
|
+
(INFO.actions && !d.lease.revoked ? ' <button type="button" class="btn sm amber" data-act="revoke" data-cid="' + esc(id) + '">Revoke lease</button>' : '')
|
|
992
|
+
: '<span class="dim">none</span>';
|
|
993
|
+
var head = S.horizon ? ' <span class="dim">head ' + fmt(S.horizon.maxCommitSeq) + '</span>' : '';
|
|
994
|
+
html('client-body', '<div class="cols"><div class="panel"><div class="ph"><h2>Client</h2></div><div class="pb">' +
|
|
995
|
+
kv([['Connection', INFO.realtime ? (c.connected ? st('ok', 'connected') + (c.connectedSinceMs ? ' since ' + clock(c.connectedSinceMs) : '') : st('idle', 'no open socket')) : '<span class="dim">no realtime hub</span>'],
|
|
996
|
+
['Last sync', esc(ago(c.updatedAtMs)) + ' <span class="dim">' + esc(stamp(c.updatedAtMs)) + '</span>'],
|
|
997
|
+
['Cursor', fmt(c.cursor) + head], ['Lag', fmt(c.lag) + ' commits'],
|
|
998
|
+
['Schema', c.schemaVersion == null ? '–' : 'v' + c.schemaVersion + (INFO.schemaVersion != null && c.schemaVersion < INFO.schemaVersion ? ' ' + st('err', 'below server v' + INFO.schemaVersion) : '')],
|
|
999
|
+
['Wire', c.wireVersion == null ? '–' : 'v' + c.wireVersion], ['Lease', lease]]) + '</div></div>' +
|
|
1000
|
+
'<div class="panel"><div class="ph"><h2>Trace a row for this client</h2></div><form class="pb" id="client-trace" data-cid="' + esc(id) + '">' +
|
|
1001
|
+
'<p class="verdict" style="margin:0 0 12px">Shows whether this client receives a row, and why not.</p><div class="tb" style="padding:0;border:0">' +
|
|
1002
|
+
'<select class="inp" name="t" aria-label="Table">' + INFO.tables.map(t => '<option>' + esc(t.name) + '</option>').join('') + '</select>' +
|
|
1003
|
+
'<input class="inp grow" name="r" placeholder="Row id" aria-label="Row id" spellcheck="false" /><button class="btn amber" type="submit">Trace</button></div></form></div></div>' +
|
|
1004
|
+
'<div class="panel"><div class="ph"><h2>Failures and warnings</h2><span class="meta" id="client-fail-meta"></span></div><div id="client-fail"></div></div>' +
|
|
1005
|
+
'<div class="panel"><div class="ph"><h2>Subscriptions</h2><span class="meta">' + c.subscriptions.length + '</span></div><div id="client-subs"></div></div>' +
|
|
1006
|
+
'<div class="panel"><div class="ph"><h2>Recent events</h2><span class="meta">' + d.events.length + '</span></div><div id="client-events"></div></div>');
|
|
1007
|
+
table('client-subs', [
|
|
1008
|
+
{ l: 'Id', c: 'w-sm', h: s => idCell(s.id) },
|
|
1009
|
+
{ l: 'Table', h: s => link(route('table', [s.table]), s.table) },
|
|
1010
|
+
{ l: 'Scopes', c: 'fill', h: s => '<span class="tags">' + Object.keys(s.scopes).map(k => s.scopes[k].map(v => link(route('table', [s.table, k + ':' + v]), k + ': ' + v, 'tag')).join('')).join('') + '</span>' }
|
|
1011
|
+
], c.subscriptions, empty('No subscriptions', 'The client has no active subscriptions.', true));
|
|
1012
|
+
table('client-events', EV_COLS, d.events, empty('No events', 'The ring holds no events for this client.', true), openEvent);
|
|
1013
|
+
return loadFailures('client-fail', { clientId: id });
|
|
1014
|
+
}, fail(['client-body']));
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
// -- data browser --------------------------------------------------------
|
|
1018
|
+
function loadTables() {
|
|
1019
|
+
return get('/tables').then(r => {
|
|
1020
|
+
txt('n-data', fmt(r.tables.length));
|
|
1021
|
+
table('data-tables', [
|
|
1022
|
+
{ l: 'Table', v: t => t.name, h: t => link(route('table', [t.name]), t.name) },
|
|
1023
|
+
numCol('Rows', 'rowCount'),
|
|
1024
|
+
{ l: 'Columns', c: 'fill', ns: true, h: t => '<span class="dim">' + esc(t.columns.map(c => c.name + (c.primaryKey ? ' (key)' : '')).join(', ')) + '</span>' }
|
|
1025
|
+
], r.tables, empty('No tables', 'The server schema declares no tables.'), t => { nav('table', [t.name]); });
|
|
1026
|
+
return null;
|
|
1027
|
+
}, fail(['data-tables']));
|
|
1028
|
+
}
|
|
1029
|
+
function loadTablePage(args) {
|
|
1030
|
+
var t = args[0], scope = args[1], key = t + '|' + (scope || '');
|
|
1031
|
+
if (S.pageKey !== key) { S.pageKey = key; S.pageStack = []; }
|
|
1032
|
+
var after = S.pageStack[S.pageStack.length - 1], schema = schemaOf(t);
|
|
1033
|
+
html('h-table', esc(t) + '<span class="dot">.</span>');
|
|
1034
|
+
txt('table-line', scope ? 'Rows whose scope ' + scope.replace(':', ' is ') + '.' : 'All rows, ordered by row id.');
|
|
1035
|
+
var sv = scope ? scope.split(':') : null;
|
|
1036
|
+
$('table-activity-panel').hidden = !sv;
|
|
1037
|
+
var jobs = [(S.clients ? Promise.resolve() : loadClients()).then(() => get('/rows/' + enc(t), { limit: PAGE_ROWS, afterRowId: after, scope: scope })).then(r => {
|
|
1038
|
+
var p = r.page, cols = schema ? schema.columns.filter(c => !c.primaryKey).slice(0, 4) : [];
|
|
1039
|
+
var seen = {}, chips = [];
|
|
1040
|
+
(S.clients || []).forEach(c => c.subscriptions.forEach(s => {
|
|
1041
|
+
if (s.table === t) Object.keys(s.scopes).forEach(k => s.scopes[k].forEach(v => { seen[k + ':' + v] = 1; }));
|
|
445
1042
|
}));
|
|
1043
|
+
p.rows.forEach(row => Object.keys(row.scopes || {}).forEach(k => { seen[k + ':' + row.scopes[k]] = 1; }));
|
|
1044
|
+
chips = Object.keys(seen).sort().slice(0, 30);
|
|
1045
|
+
html('table-scopes', 'Scope ' + link(route('table', [t]), 'all rows', 'tag' + (scope ? '' : ' on')) +
|
|
1046
|
+
chips.map(k => link(route('table', [t, k]), k.replace(':', ': '), 'tag' + (k === scope ? ' on' : ''))).join(''));
|
|
1047
|
+
table('table-rows', [
|
|
1048
|
+
{ l: 'Row id', c: 'w-sm', v: x => x.rowId, h: x => rowLink(t, x.rowId, x.rowId) },
|
|
1049
|
+
numCol('Version', 'serverVersion'),
|
|
1050
|
+
{ l: 'Scopes', ns: true, h: x => scopeTags(x.scopes) }
|
|
1051
|
+
].concat(cols.map((c, i) => ({ l: c.name, ns: true, c: i === cols.length - 1 ? 'fill' : '', h: x => cell(x.values[c.name], c.type) }))),
|
|
1052
|
+
p.rows, empty('No rows', scope ? 'No row in ' + esc(t) + ' carries scope ' + esc(scope) + '.' : 'The table holds no rows in this partition.'), x => { nav('row', [t, x.rowId]); });
|
|
1053
|
+
if (after !== undefined || p.nextAfterRowId) {
|
|
1054
|
+
S.pageNext = p.nextAfterRowId;
|
|
1055
|
+
pager('table-rows', [['rows-first', 'First', after !== undefined], ['rows-prev', 'Previous', after !== undefined], ['rows-next', 'Next', !!p.nextAfterRowId]]);
|
|
1056
|
+
}
|
|
1057
|
+
return null;
|
|
1058
|
+
}, fail(['table-rows']))];
|
|
1059
|
+
if (sv) {
|
|
1060
|
+
jobs.push(get('/scope-activity', { variable: sv[0], value: sv.slice(1).join(':') }).then(r => {
|
|
1061
|
+
txt('table-activity-meta', fmt(r.activity.length) + ' commits');
|
|
1062
|
+
table('table-activity', [
|
|
1063
|
+
{ l: 'Seq', c: 'num', d: -1, v: a => a.commitSeq, h: a => '<span class="ty">' + fmt(a.commitSeq) + '</span>' },
|
|
1064
|
+
{ l: 'Table', v: a => a.table, h: a => esc(a.table) },
|
|
1065
|
+
{ l: 'Actor', c: 'w-sm', v: a => a.actorId, h: a => idText(a.actorId) },
|
|
1066
|
+
numCol('Changes', 'changeCount'),
|
|
1067
|
+
{ l: 'When', c: 'num fill', d: -1, v: a => a.createdAtMs, h: a => when(a.createdAtMs) }
|
|
1068
|
+
], r.activity, empty('No activity', 'No recent commit touched ' + esc(scope) + '.', true), a => { openCommit(a.commitSeq); });
|
|
1069
|
+
return null;
|
|
1070
|
+
}, fail(['table-activity'])));
|
|
1071
|
+
}
|
|
1072
|
+
return Promise.all(jobs).then(list => list.filter(Boolean)[0] || null);
|
|
1073
|
+
}
|
|
1074
|
+
var VERDICT = {
|
|
1075
|
+
delivered: ['ok', 'Delivered', 'The client has pulled the row\\'s last change.'],
|
|
1076
|
+
'pending-pull': ['warn', 'Pending pull', 'A subscription covers the row, and the client\\'s cursor is behind the row\\'s last change. The next pull delivers it.'],
|
|
1077
|
+
'row-deleted': ['warn', 'Row deleted', 'The row\\'s last change is a delete. A client that held the row drops it on its next pull.'],
|
|
1078
|
+
'scope-mismatch': ['err', 'Scope mismatch', 'The client subscribes to the table, but no subscription requests the row\\'s scope values.'],
|
|
1079
|
+
'scope-denied': ['err', 'Scope denied', 'A subscription requests the row\\'s scopes, but the actor\\'s allowed scopes from resolveScopes exclude them, so the server never delivers the row.'],
|
|
1080
|
+
'no-subscription': ['idle', 'No subscription', 'The client has no subscription on this table.'],
|
|
1081
|
+
'client-unknown': ['err', 'Client unknown', 'This partition has no cursor record for the client.'],
|
|
1082
|
+
'row-missing': ['err', 'Row missing', 'The partition holds no row with this id in this table.']
|
|
1083
|
+
};
|
|
1084
|
+
var VORDER = ['row-missing', 'client-unknown', 'no-subscription', 'scope-denied', 'scope-mismatch', 'row-deleted', 'pending-pull', 'delivered'];
|
|
1085
|
+
function verdictOf(v) { return VERDICT[v] || ['err', v, 'The console does not know this verdict.']; }
|
|
1086
|
+
var HISTORY_COLS = [
|
|
1087
|
+
{ l: 'Seq', c: 'num', d: -1, v: x => x.commitSeq, h: x => '<span class="ty">' + fmt(x.commitSeq) + '</span>' },
|
|
1088
|
+
{ l: 'Op', v: x => x.op, h: x => esc(x.op) },
|
|
1089
|
+
numCol('Version', 'rowVersion'),
|
|
1090
|
+
{ l: 'Client', c: 'w-sm', v: x => x.clientId, h: x => clientLink(x.clientId) },
|
|
1091
|
+
{ l: 'When', c: 'num fill', d: -1, v: x => x.createdAtMs, h: x => when(x.createdAtMs) }
|
|
1092
|
+
];
|
|
1093
|
+
function loadRowPage(args) {
|
|
1094
|
+
var t = args[0], id = args[1], schema = schemaOf(t);
|
|
1095
|
+
html('h-row', esc(id) + copyBtn(id));
|
|
1096
|
+
$('row-table-link').href = route('table', [t]);
|
|
1097
|
+
txt('row-table-link', t);
|
|
1098
|
+
return Promise.all([get('/rows/' + enc(t) + '/' + enc(id)).then(r => {
|
|
1099
|
+
var row = r.row;
|
|
1100
|
+
$('row-line').innerHTML = row.exists ? 'Version ' + fmt(row.serverVersion) + scopeTags(row.scopes) : st('idle', 'not in the table') + ' The partition holds no live row with this id.';
|
|
1101
|
+
txt('row-meta', row.exists ? 'version ' + fmt(row.serverVersion) : '');
|
|
1102
|
+
if (!row.exists) html('row-values', empty('No row', 'There are no current values to show.', true));
|
|
1103
|
+
else if (!row.values) html('row-values', empty('No decoded values', 'The server returned no column values for this row.', true));
|
|
1104
|
+
else {
|
|
1105
|
+
var cols = schema ? schema.columns : Object.keys(row.values).map(k => ({ name: k, type: '' }));
|
|
1106
|
+
table('row-values', [
|
|
1107
|
+
{ l: 'Column', v: x => x.name, h: x => esc(x.name) + (x.primaryKey ? ' <span class="st warn">key</span>' : '') },
|
|
1108
|
+
{ l: 'Type', v: x => x.type, h: x => '<span class="dim">' + esc(x.type) + (x.nullable ? '?' : '') + '</span>' },
|
|
1109
|
+
{ l: 'Value', c: 'fill', ns: true, h: x => cell(row.values[x.name], x.type) }
|
|
1110
|
+
], cols, empty('No columns', 'The schema declares no columns.', true));
|
|
1111
|
+
}
|
|
1112
|
+
txt('row-history-meta', row.history.length + ' changes');
|
|
1113
|
+
table('row-history', HISTORY_COLS, row.history, empty('No history', 'The retained commit log holds no change to this row.', true), x => { openCommit(x.commitSeq); });
|
|
1114
|
+
return null;
|
|
1115
|
+
}, fail(['row-values', 'row-history'])), get('/rows/' + enc(t) + '/' + enc(id) + '/delivery').then(r => {
|
|
1116
|
+
var d = r.delivery, counts = {};
|
|
1117
|
+
d.clients.forEach(x => { counts[x.verdict] = (counts[x.verdict] || 0) + 1; });
|
|
1118
|
+
txt('delivery-meta', VORDER.filter(v => counts[v]).map(v => counts[v] + ' ' + v).join(' · ') + (d.lastChange ? ' · last change at ' + fmt(d.lastChange.commitSeq) : ''));
|
|
1119
|
+
table('row-delivery', [
|
|
1120
|
+
{ l: 'Client', c: 'w-sm', v: x => x.client.clientId, h: x => clientLink(x.client.clientId) },
|
|
1121
|
+
{ l: 'Actor', c: 'w-sm', v: x => x.client.actorId, h: x => idText(x.client.actorId) },
|
|
1122
|
+
{ l: INFO.realtime ? 'Connection' : 'Last sync', v: x => x.client.updatedAtMs, h: x => presence(x.client) },
|
|
1123
|
+
{ l: 'Cursor', c: 'num', d: -1, v: x => x.client.cursor, h: x => fmt(x.client.cursor) },
|
|
1124
|
+
{ l: 'Verdict', c: 'fill', v: x => VORDER.indexOf(x.verdict), h: x => { var v = verdictOf(x.verdict); return st(v[0], v[1]); } }
|
|
1125
|
+
], d.clients, empty('No clients', 'No client has a cursor record in this partition.', true), x => { openTrace(t, id, x.client.clientId); });
|
|
1126
|
+
return null;
|
|
1127
|
+
}, fail(['row-delivery']))]).then(list => list.filter(Boolean)[0] || null);
|
|
1128
|
+
}
|
|
1129
|
+
function openTrace(t, id, client) {
|
|
1130
|
+
var token = openModal('Delivery trace', client, true, SKEL);
|
|
1131
|
+
get('/trace', { table: t, rowId: id, clientId: client }).then(r => {
|
|
1132
|
+
if (token !== modalToken) return;
|
|
1133
|
+
var x = r.trace, v = verdictOf(x.verdict), lc = x.lastChange, c = x.client;
|
|
1134
|
+
var detail = x.verdict === 'pending-pull' && c && lc ? ' Cursor ' + fmt(c.cursor) + ', last change at ' + fmt(lc.commitSeq) + '.' : '';
|
|
1135
|
+
fillModal('<div class="vbox ' + v[0] + '" style="margin:0 0 16px"><b>' + esc(v[1]) + '</b><span>' + esc(v[2] + detail) + '</span></div>' +
|
|
1136
|
+
kv([['Row', rowLink(t, id) + (x.row.exists ? ' · version ' + fmt(x.row.serverVersion) + ' ' + scopeTags(x.row.scopes) : ' ' + st('idle', 'missing'))],
|
|
1137
|
+
['Last change', lc ? seqBtn(lc.commitSeq) + ' ' + esc(lc.op) + ' by ' + esc(lc.actorId) + ' ' + ago(lc.createdAtMs) : '<span class="dim">none retained; horizon ' + fmt(x.horizonSeq) + '</span>'],
|
|
1138
|
+
['Client', c ? clientLink(client) + ' · cursor ' + fmt(c.cursor) + ' · ' + presence(c) : st('err', 'unknown')],
|
|
1139
|
+
['Allowed', x.allowed === undefined ? '<span class="dim">no resolver</span>' : x.allowed === 'outage' ? st('err', 'resolveScopes outage') : scopeTags(x.allowed)]]) +
|
|
1140
|
+
'<h3>Subscriptions on ' + esc(t) + ' · ' + x.subscriptions.length + '</h3><div id="m-subs"></div><h3>Rejected pushes · ' + x.rejections.length + '</h3><div id="m-events"></div>', x);
|
|
1141
|
+
table('m-subs', [
|
|
1142
|
+
{ l: 'Id', c: 'w-sm', h: s => idCell(s.id) },
|
|
1143
|
+
{ l: 'Requested scopes', h: s => scopeTags(s.scopes) },
|
|
1144
|
+
{ l: 'Requested', h: s => s.requestedMatch ? st('ok', 'covers row') : st('err', 'mismatch') },
|
|
1145
|
+
{ l: 'Allowed', h: s => s.effectiveMatch === undefined ? '<span class="dim">not checked</span>' : s.effectiveMatch ? st('ok', 'covers row') : st('err', 'denied') },
|
|
1146
|
+
{ l: 'Mismatches', c: 'fill', h: s => s.mismatches.length ? tags(s.mismatches.map(m => m.variable + ': row ' + m.rowValue + ', requested ' + (m.requested.join(', ') || 'none'))) : '<span class="dim">none</span>' }
|
|
1147
|
+
], x.subscriptions, empty('No subscriptions', 'The client has no subscription on ' + esc(t) + '.', true));
|
|
1148
|
+
table('m-events', EV_COLS, x.rejections, empty('No rejections', 'The ring holds no rejected or conflicted push for this row.', true), openEvent);
|
|
1149
|
+
}, err => { if (token === modalToken && err !== STALE) fillModal(errBox(err), { code: err.code, message: err.message }); });
|
|
446
1150
|
}
|
|
447
1151
|
|
|
448
|
-
// --
|
|
449
|
-
|
|
1152
|
+
// -- commits, writes, search ---------------------------------------------
|
|
1153
|
+
function loadCommits() {
|
|
1154
|
+
var before = S.commitPages ? S.commitPages[S.commitPages.length - 1] : undefined, limit = Number($('commits-limit').value);
|
|
1155
|
+
return get('/commits', { table: $('commits-table').value.trim(), limit: limit, beforeSeq: before, sample: 5 }).then(r => {
|
|
1156
|
+
var list = r.commits, f = $('commits-table').value.trim();
|
|
1157
|
+
S.commitOldest = list.length ? list[list.length - 1].commitSeq : null;
|
|
1158
|
+
if (before === undefined) txt('n-commits', list.length ? fmt(list[0].commitSeq) : '0');
|
|
1159
|
+
txt('commits-count', fmt(list.length) + ' commits' + (f ? ' touching ' + f : '') + (before === undefined ? '' : ' before seq ' + fmt(before)));
|
|
1160
|
+
table('commits-list', [
|
|
1161
|
+
{ l: 'Seq', c: 'num', d: -1, v: c => c.commitSeq, h: c => '<span class="ty">' + fmt(c.commitSeq) + '</span>' },
|
|
1162
|
+
{ l: 'Client', c: 'w-sm', v: c => c.clientId, h: c => clientLink(c.clientId) },
|
|
1163
|
+
{ l: 'Actor', c: 'w-sm', v: c => c.actorId, h: c => idText(c.actorId) },
|
|
1164
|
+
{ l: 'Changes', c: 'fill', ns: true, h: c => '<span class="tags">' + c.sample.map(s => link(route('row', [s.table, s.rowId]), s.op + ' ' + s.table + ' / ' + s.rowId, 'tag')).join('') +
|
|
1165
|
+
(c.changeCount > c.sample.length ? '<span class="dim">+' + fmt(c.changeCount - c.sample.length) + ' more</span>' : '') + '</span>' },
|
|
1166
|
+
{ l: 'When', c: 'num', d: -1, v: c => c.createdAtMs, h: c => when(c.createdAtMs) }
|
|
1167
|
+
], list, f ? empty('No commits', 'No commit on this page touched table ' + esc(f) + '.')
|
|
1168
|
+
: empty('No commits', before === undefined ? 'The commit log of this partition is empty.' : 'No retained commit is older than seq ' + fmt(before) + '.'), c => { openCommit(c.commitSeq); });
|
|
1169
|
+
if (before !== undefined || list.length >= limit) pager('commits-list', [['commits-newest', 'Newest', before !== undefined], ['commits-newer', 'Newer', before !== undefined], ['commits-older', 'Older', list.length >= limit]]);
|
|
1170
|
+
return null;
|
|
1171
|
+
}).catch(fail(['commits-list']));
|
|
1172
|
+
}
|
|
1173
|
+
var RESULT_COLS = [
|
|
1174
|
+
{ l: 'Op', c: 'num', h: x => fmt(x.opIndex) },
|
|
1175
|
+
{ l: 'Status', h: x => st(x.status === 'applied' ? 'ok' : x.status === 'conflict' ? 'warn' : 'err', x.status) },
|
|
1176
|
+
{ l: 'Code', h: x => x.code ? '<span class="ty err">' + esc(x.code) + '</span>' : '<span class="dim">–</span>' },
|
|
1177
|
+
{ l: 'Server version', c: 'num', h: x => fmt(x.serverVersion) },
|
|
1178
|
+
{ l: 'Message', c: 'fill', h: x => x.message ? trunc(x.message) : '' }
|
|
1179
|
+
];
|
|
1180
|
+
function openWrite(id) {
|
|
1181
|
+
var token = openModal('Write', id, true, SKEL);
|
|
1182
|
+
get('/writes/' + enc(id)).then(r => {
|
|
1183
|
+
if (token !== modalToken) return;
|
|
1184
|
+
var w = r.write;
|
|
1185
|
+
fillModal((w.outcomes.length ? '' : empty('No recorded outcome', 'No client has a stored outcome for this client commit id. The server never received it, or its idempotency record expired.', true)) +
|
|
1186
|
+
w.outcomes.map((o, i) => '<h3>' + (o.status === 'applied' ? st('ok', 'applied') : st('err', 'rejected')) + ' · client ' + clientLink(o.clientId) +
|
|
1187
|
+
(o.commitSeq !== undefined ? ' · commit ' + seqBtn(o.commitSeq) : '') + (o.recordedAtMs ? ' · ' + ago(o.recordedAtMs) : '') + '</h3><div id="m-res-' + i + '"></div>').join('') +
|
|
1188
|
+
'<h3>Ring events · ' + w.events.length + '</h3><div id="m-events"></div>', w);
|
|
1189
|
+
w.outcomes.forEach((o, i) => { table('m-res-' + i, RESULT_COLS, o.results, empty('No results', 'The outcome carries no per-operation results.', true)); });
|
|
1190
|
+
table('m-events', EV_COLS, w.events, empty('No events', 'The ring holds no events for this write.', true), openEvent);
|
|
1191
|
+
}, err => { if (token === modalToken && err !== STALE) fillModal(errBox(err), { code: err.code, message: err.message }); });
|
|
1192
|
+
}
|
|
1193
|
+
function loadSearch(args) {
|
|
1194
|
+
var q = args[0] || '';
|
|
1195
|
+
$('q').value = q;
|
|
1196
|
+
html('h-search', 'Results for <span class="ty">' + esc(q) + '</span>');
|
|
1197
|
+
return get('/search', { q: q }).then(r => {
|
|
1198
|
+
var x = r.search, hits = [];
|
|
1199
|
+
x.clients.forEach(c => hits.push(['client', [c.clientId]]));
|
|
1200
|
+
x.actors.forEach(a => hits.push(['people', [a]]));
|
|
1201
|
+
x.rows.forEach(w => hits.push(['row', [w.table, w.rowId]]));
|
|
1202
|
+
if (hits.length === 1 && !x.commit && !x.writes.length) { history.replaceState(null, '', route(hits[0][0], hits[0][1])); show(); return null; }
|
|
1203
|
+
html('search-body', (hits.length || x.commit || x.writes.length ? '' : empty('Nothing found', 'No client, actor, row, commit, or write in this partition matches ' + esc(q) + '.')) +
|
|
1204
|
+
(x.clients.length ? '<div class="panel"><div class="ph"><h2>Clients</h2><span class="meta">' + x.clients.length + '</span></div><div id="s-clients"></div></div>' : '') +
|
|
1205
|
+
(x.actors.length ? '<div class="panel"><div class="ph"><h2>Actors</h2></div><div class="sugg">' + x.actors.map(a => link(route('people', [a]), a, 'tag')).join('') + '</div></div>' : '') +
|
|
1206
|
+
(x.rows.length ? '<div class="panel"><div class="ph"><h2>Rows</h2></div><div class="sugg">' + x.rows.map(w => link(route('row', [w.table, w.rowId]), w.table + ' / ' + w.rowId, 'tag')).join('') + '</div></div>' : '') +
|
|
1207
|
+
(x.commit ? '<div class="panel"><div class="ph"><h2>Commit</h2></div><div class="sugg">' + seqBtn(x.commit.commitSeq) + ' by ' + esc(x.commit.actorId) + ' · ' + fmt(x.commit.changeCount) + ' changes · ' + ago(x.commit.createdAtMs) + '</div></div>' : '') +
|
|
1208
|
+
(x.writes.length ? '<div class="panel"><div class="ph"><h2>Writes</h2></div><div class="sugg"><button type="button" class="tag" data-write="' + esc(q) + '">' + esc(q) + '</button> ' + x.writes.map(o => o.status + ' from ' + esc(o.clientId)).join(', ') + '</div></div>' : ''));
|
|
1209
|
+
if (x.clients.length) {
|
|
1210
|
+
table('s-clients', [
|
|
1211
|
+
{ l: 'Client', c: 'w-id', h: c => clientLink(c.clientId) },
|
|
1212
|
+
{ l: 'Actor', h: c => idText(c.actorId) },
|
|
1213
|
+
{ l: 'Connection', h: c => presence(c) },
|
|
1214
|
+
{ l: 'Lag', c: 'num fill', h: c => fmt(c.lag) }
|
|
1215
|
+
], x.clients, '', c => { nav('client', [c.clientId]); });
|
|
1216
|
+
}
|
|
1217
|
+
return null;
|
|
1218
|
+
}, fail(['search-body']));
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
var RX_STATE = { pending: 'warn', leased: 'ok', completed: 'idle', 'dead-letter': 'err' }, RX_ORDER = { 'dead-letter': 0, leased: 1, pending: 2, completed: 3 };
|
|
1222
|
+
function loadReactions() {
|
|
1223
|
+
return get('/reactions', { status: $('rx-status').value, type: $('rx-type').value.trim(), limit: 100 }).then(r => {
|
|
1224
|
+
var list = r.reactions, counts = {};
|
|
1225
|
+
list.forEach(x => { counts[x.status] = (counts[x.status] || 0) + 1; });
|
|
1226
|
+
txt('n-reactions', counts['dead-letter'] ? counts['dead-letter'] + ' dead' : fmt(list.length));
|
|
1227
|
+
txt('rx-count', Object.keys(counts).map(k => fmt(counts[k]) + ' ' + k).join(' · ') || '0 reactions');
|
|
1228
|
+
table('rx-table', [
|
|
1229
|
+
{ l: 'Key', c: 'w-id', v: x => x.idempotencyKey, h: x => idCell(x.idempotencyKey) },
|
|
1230
|
+
{ l: 'Type', v: x => x.type, h: x => esc(x.type) + ' <span class="dim">v' + x.version + '</span>' },
|
|
1231
|
+
{ l: 'Status', v: x => RX_ORDER[x.status], h: x => st(RX_STATE[x.status], x.status) },
|
|
1232
|
+
{ l: 'Attempts', c: 'num', d: -1, v: x => x.attempts, h: x => x.attempts + ' / ' + x.maxAttempts },
|
|
1233
|
+
{ l: 'Available', c: 'num', v: x => x.availableAtMs, h: x => '<span title="' + esc(stamp(x.availableAtMs)) + '">' + rel(x.availableAtMs) + '</span>' },
|
|
1234
|
+
{ l: 'Source', c: 'num', d: -1, v: x => x.sourceCommitSeq, h: x => 'seq ' + fmt(x.sourceCommitSeq) },
|
|
1235
|
+
{ l: 'Last failure', c: 'fill', v: x => x.lastFailure ? x.lastFailure.code : '', h: x => x.lastFailure ? '<span class="ty err">' + esc(x.lastFailure.code) + '</span>' : '<span class="dim">none</span>' }
|
|
1236
|
+
], list.slice().sort((a, b) => RX_ORDER[a.status] - RX_ORDER[b.status]), empty('No reactions', 'No durable reaction matches. A reaction planner queues reactions atomically with accepted commits.'), x => {
|
|
1237
|
+
openModal('Reaction', x.idempotencyKey, true, kv([['Type', esc(x.type) + ' v' + x.version], ['Status', st(RX_STATE[x.status], x.status)],
|
|
1238
|
+
['Attempts', x.attempts + ' of ' + x.maxAttempts], ['Available', esc(stamp(x.availableAtMs))],
|
|
1239
|
+
['Source', 'commit ' + seqBtn(x.sourceCommitSeq) + ' · client ' + clientLink(x.sourceClientId)],
|
|
1240
|
+
['Lease', x.leaseOwner ? esc(x.leaseOwner) + ' until ' + esc(stamp(x.leaseExpiresAtMs)) : 'none'],
|
|
1241
|
+
['Last failure', x.lastFailure ? '<code>' + esc(x.lastFailure.code) + '</code> ' + ago(x.lastFailure.atMs) : 'none']]) +
|
|
1242
|
+
(INFO.actions && x.status === 'dead-letter' ? '<div class="acts"><button type="button" class="btn sm amber" data-act="retry" data-key="' + esc(x.idempotencyKey) + '">Retry reaction</button></div>' : '') +
|
|
1243
|
+
'<h3>Payload</h3>' + json(x.payload), x);
|
|
1244
|
+
});
|
|
1245
|
+
return null;
|
|
1246
|
+
}).catch(err => { txt('rx-count', ''); return fail(['rx-table'])(err); });
|
|
1247
|
+
}
|
|
1248
|
+
function loadStats() {
|
|
1249
|
+
return get('/stats').then(r => {
|
|
1250
|
+
var s = r.stats.segments, b = r.stats.blobs;
|
|
1251
|
+
html('seg-meta', s && s.approximate ? st('warn', 'approximate') : '');
|
|
1252
|
+
html('blob-meta', b && b.approximate ? st('warn', 'approximate') : '');
|
|
1253
|
+
var approx = '<p class="verdict">The S3 store counts through a pointer accumulator; the numbers drift under concurrent writers and after lifecycle GC.</p>';
|
|
1254
|
+
html('st-seg', s
|
|
1255
|
+
? '<div class="big">' + fmt(s.count) + '<small>segments · ' + bytes(s.bytes) + '</small></div><div style="margin:14px 0 12px">' + stack([[s.rowsSegments, 'c-am'], [s.sqliteSegments, 'c-cy']]) + '</div>' +
|
|
1256
|
+
kv([['Rows segments', fmt(s.rowsSegments)], ['SQLite images', fmt(s.sqliteSegments)], ['Bytes', bytes(s.bytes)]]) + (s.approximate ? approx : '')
|
|
1257
|
+
: empty('No segment stats', 'No segment store is wired on this admin, or the store does not report stats.', true));
|
|
1258
|
+
html('st-blob', b
|
|
1259
|
+
? '<div class="big">' + fmt(b.count) + '<small>blobs · ' + bytes(b.bytes) + '</small></div><div style="margin-top:14px">' + kv([['Blobs', fmt(b.count)], ['Bytes', bytes(b.bytes)], ['Average', b.count ? bytes(Math.round(b.bytes / b.count)) : '–']]) + '</div>' + (b.approximate ? approx : '')
|
|
1260
|
+
: empty('No blob stats', 'No blob store is wired on this admin, or the store does not report stats.', true));
|
|
1261
|
+
return null;
|
|
1262
|
+
}).catch(fail(['st-seg', 'st-blob']));
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
// -- event tail: SSE when the ring is wired, polled otherwise -------------
|
|
1266
|
+
var MODE = {
|
|
1267
|
+
idle: ['', 'Connecting'], connecting: ['', 'Connecting'], live: ['ok', 'Live'], poll: ['warn', 'Polling'],
|
|
1268
|
+
closed: ['err', 'Stream closed'], off: ['warn', 'No event ring'], error: ['err', 'Events failed']
|
|
1269
|
+
};
|
|
1270
|
+
function setMode(mode) {
|
|
1271
|
+
tail.mode = mode;
|
|
1272
|
+
var m = tail.paused ? ['warn', 'Paused'] : MODE[mode];
|
|
1273
|
+
$('live').className = 'pill ' + m[0];
|
|
1274
|
+
$('live').lastChild.textContent = m[1];
|
|
1275
|
+
var b = '';
|
|
1276
|
+
if (tail.paused) b = '<div class="banner"><b>Paused</b><span>' + fmt(tail.held.length) + ' new events held. The list stays still until you resume.</span><button class="btn sm" type="button" data-act="pause">Resume</button></div>';
|
|
1277
|
+
else if (mode === 'poll') b = '<div class="banner"><b>Polling</b><span>The parent-frame transport carries no event stream. Events reload with every refresh (<kbd>r</kbd>) and with auto refresh.</span></div>';
|
|
1278
|
+
else if (mode === 'closed') b = '<div class="banner err"><b>Stream closed</b><span>The live event stream failed (authorization, network, or the server closed it). Events now reload with every refresh.</span><button class="btn sm" type="button" data-act="reconnect">Reconnect</button></div>';
|
|
1279
|
+
else if (mode === 'off') b = '<div class="banner"><b>No event ring</b><span>This deployment keeps no events, so there is no event tail and no metrics. A Workers deployment without a Durable Object namespace serves the console from the Worker; add a <code>coordinator</code> to record events.</span></div>';
|
|
1280
|
+
html('ev-banner', b);
|
|
1281
|
+
txt('ev-pause', tail.paused ? 'Resume' + (tail.held.length ? ' (' + tail.held.length + ')' : '') : 'Pause');
|
|
1282
|
+
$('ev-pause').className = 'btn sm' + (tail.paused ? ' on' : '');
|
|
1283
|
+
}
|
|
1284
|
+
function tailFilters() {
|
|
1285
|
+
var kind = $('ev-kind').value, p = { limit: MAX_TAIL };
|
|
1286
|
+
if (kind && kind.indexOf('.') > 0) p.type = kind;
|
|
1287
|
+
var c = $('ev-client').value.trim();
|
|
1288
|
+
if (c) p.clientId = c;
|
|
1289
|
+
return p;
|
|
1290
|
+
}
|
|
1291
|
+
var EV_COLS = [
|
|
1292
|
+
{ l: 'Time', d: -1, v: e => e.atMs, h: e => '<span title="' + esc(stamp(e.atMs)) + '">' + clock(e.atMs, true) + '</span>' },
|
|
1293
|
+
{ l: 'Level', v: e => RANK[level(e)], h: e => { var l = level(e); return st(l === 'info' ? 'idle' : l, LEVEL_LABEL[l]); } },
|
|
1294
|
+
{ l: 'Type', v: e => e.type, h: e => '<span class="ty ' + level(e) + '">' + esc(e.type) + '</span>' },
|
|
1295
|
+
{ l: 'Detail', c: 'fill', ns: true, h: detailCell }
|
|
1296
|
+
];
|
|
1297
|
+
// One row per sync request: every event of a request shares requestId.
|
|
1298
|
+
// An idle round pushed nothing and pulled no commit on any subscription.
|
|
1299
|
+
function groups(list) {
|
|
1300
|
+
var by = {}, out = [];
|
|
1301
|
+
list.forEach(e => {
|
|
1302
|
+
if (!e.requestId) { out.push({ events: [e], atMs: e.atMs }); return; }
|
|
1303
|
+
var g = by[e.requestId];
|
|
1304
|
+
if (!g) { g = by[e.requestId] = { id: e.requestId, events: [], atMs: e.atMs }; out.push(g); }
|
|
1305
|
+
g.events.push(e);
|
|
1306
|
+
if (e.type === 'request.handled') g.rh = e;
|
|
1307
|
+
});
|
|
1308
|
+
out.forEach(g => {
|
|
1309
|
+
g.level = g.events.reduce((l, e) => RANK[level(e)] < RANK[l] ? level(e) : l, 'info');
|
|
1310
|
+
g.clientId = g.events.map(e => e.clientId).filter(Boolean)[0];
|
|
1311
|
+
g.actorId = g.events.map(e => e.actorId).filter(Boolean)[0];
|
|
1312
|
+
g.idle = !!g.rh && g.level === 'info' && g.rh.pushCommits === 0 && g.events.every(e => e.type !== 'pull.served' || e.subscriptions.every(s => !s.commits));
|
|
1313
|
+
});
|
|
1314
|
+
return out;
|
|
1315
|
+
}
|
|
1316
|
+
function groupSummary(g) {
|
|
1317
|
+
if (!g.id) return summary(g.events[0]);
|
|
1318
|
+
var pulled = 0, rh = g.rh;
|
|
1319
|
+
g.events.forEach(e => { if (e.type === 'pull.served') e.subscriptions.forEach(s => { pulled += s.commits; }); });
|
|
1320
|
+
var bad = g.events.filter(e => e.type === 'push.rejected' || e.type === 'push.conflicted');
|
|
1321
|
+
return (rh ? rh.outcome + (rh.errorCode ? ' ' + rh.errorCode : '') + ' · ' + dur(rh.durationMs) + ' ms · ' + rh.pushCommits + ' pushed · ' : 'in flight · ') +
|
|
1322
|
+
pulled + ' commits pulled' + (bad.length ? ' · ' + bad.map(e => e.type.slice(5) + (e.table ? ' ' + e.table + ' / ' + e.rowId : '')).join(', ') : '') + ' · ' + g.events.length + ' events';
|
|
1323
|
+
}
|
|
1324
|
+
var GROUP_COLS = [
|
|
1325
|
+
{ l: 'Time', d: -1, v: g => g.atMs, h: g => '<span title="' + esc(stamp(g.atMs)) + '">' + clock(g.atMs, true) + '</span>' },
|
|
1326
|
+
{ l: 'Level', v: g => RANK[g.level], h: g => st(g.level === 'info' ? 'idle' : g.level, LEVEL_LABEL[g.level]) },
|
|
1327
|
+
{ l: 'Kind', v: g => g.id ? 'request' : g.events[0].type, h: g => '<span class="ty ' + g.level + '">' + (g.id ? 'sync request' : esc(g.events[0].type)) + '</span>' },
|
|
1328
|
+
{ l: 'Client', c: 'w-sm', v: g => g.clientId || g.actorId || '', h: g => g.clientId ? clientLink(g.clientId) : '<span class="dim">' + esc(g.actorId || g.events[0].workerId || '') + '</span>' },
|
|
1329
|
+
{ l: 'Detail', c: 'fill', ns: true, h: g => {
|
|
1330
|
+
if (!g.id) return detailCell(g.events[0]);
|
|
1331
|
+
var hit = g.events.filter(e => e.table && e.rowId);
|
|
1332
|
+
return (hit.length ? '<span class="tags">' + hit.map(e => rowLink(e.table, e.rowId)).join('') + '</span>' : '') + trunc(groupSummary(g));
|
|
1333
|
+
} }
|
|
1334
|
+
];
|
|
1335
|
+
function renderTail() {
|
|
1336
|
+
var kind = $('ev-kind').value, lv = $('ev-level').value, q = $('ev-q').value.trim().toLowerCase(), showIdle = $('ev-idle').checked;
|
|
1337
|
+
var all = groups(tail.list.filter(e => !kind || kind.indexOf('.') > 0 || e.type.indexOf(kind + '.') === 0));
|
|
1338
|
+
var idle = all.filter(g => g.idle).length;
|
|
1339
|
+
var rows = all.filter(g => (showIdle || !g.idle) && (lv !== 'err' || g.level === 'err') && (lv !== 'warn' || g.level !== 'info') && (!q || JSON.stringify(g.events).toLowerCase().indexOf(q) >= 0));
|
|
1340
|
+
txt('ev-idle-label', showIdle ? 'Show idle rounds' : 'Show idle rounds (' + idle + ' hidden)');
|
|
1341
|
+
txt('n-events', tail.mode === 'off' ? '' : fmt(tail.list.length));
|
|
1342
|
+
txt('ev-count', fmt(rows.length) + ' of ' + fmt(all.length) + ' rows · ' + fmt(tail.list.length) + ' events');
|
|
1343
|
+
table('ev-table', GROUP_COLS, rows, tail.mode === 'off'
|
|
1344
|
+
? empty('No event ring', 'The event tail needs a <code>RingBufferEvents</code> passed to the admin.')
|
|
1345
|
+
: tail.list.length ? empty('No match', fmt(all.length) + ' buffered rows, none match the filters' + (idle && !showIdle ? ' or they are idle rounds' : '') + '.')
|
|
1346
|
+
: empty('No events yet', 'The tail fills as clients push, pull, and connect.'), g => { if (g.id) openRequest(g); else openEvent(g.events[0]); });
|
|
1347
|
+
}
|
|
1348
|
+
function stopStream() { if (tail.src) { tail.src.close(); tail.src = null; } }
|
|
450
1349
|
function connectStream() {
|
|
451
|
-
|
|
452
|
-
tail.list = [];
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
1350
|
+
stopStream();
|
|
1351
|
+
tail.list = []; tail.held = [];
|
|
1352
|
+
setMode('connecting');
|
|
1353
|
+
renderTail();
|
|
1354
|
+
var src = new EventSource(base + '/events/stream' + qs(tailFilters()));
|
|
1355
|
+
tail.src = src;
|
|
1356
|
+
src.onopen = () => { setMode('live'); };
|
|
1357
|
+
src.onmessage = msg => {
|
|
1358
|
+
var e = JSON.parse(msg.data);
|
|
1359
|
+
if (tail.paused) {
|
|
1360
|
+
tail.held.unshift(e);
|
|
1361
|
+
if (tail.held.length > MAX_TAIL) tail.held.length = MAX_TAIL;
|
|
1362
|
+
setMode(tail.mode);
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
if (tail.mode !== 'live') setMode('live');
|
|
1366
|
+
tail.list.unshift(e);
|
|
458
1367
|
if (tail.list.length > MAX_TAIL) tail.list.length = MAX_TAIL;
|
|
459
|
-
|
|
1368
|
+
renderTail();
|
|
460
1369
|
};
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
tail.source = null;
|
|
465
|
-
el('events-live').innerHTML = chip('poll', '');
|
|
1370
|
+
src.onerror = () => {
|
|
1371
|
+
src.close();
|
|
1372
|
+
if (tail.src === src) { tail.src = null; setMode('closed'); }
|
|
466
1373
|
};
|
|
467
1374
|
}
|
|
468
|
-
function
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
1375
|
+
function startTail() {
|
|
1376
|
+
stopStream();
|
|
1377
|
+
tail.list = []; tail.held = [];
|
|
1378
|
+
setMode('connecting');
|
|
1379
|
+
if (!INFO.hasEventStream) { setMode('off'); renderTail(); return Promise.resolve(null); }
|
|
1380
|
+
if (!parentTransport && typeof EventSource === 'function') { connectStream(); return Promise.resolve(null); }
|
|
1381
|
+
return get('/events', tailFilters()).then(res => {
|
|
1382
|
+
tail.list = res.events;
|
|
1383
|
+
setMode('poll');
|
|
1384
|
+
renderTail();
|
|
1385
|
+
return null;
|
|
1386
|
+
}, err => { if (err !== STALE) setMode('error'); return fail(['ev-table'])(err); });
|
|
1387
|
+
}
|
|
1388
|
+
function loadTail() {
|
|
1389
|
+
if (tail.mode === 'live' || tail.mode === 'connecting') return Promise.resolve(null);
|
|
1390
|
+
if (tail.mode !== 'poll' && tail.mode !== 'closed') return startTail();
|
|
1391
|
+
if (tail.paused) return Promise.resolve(null);
|
|
1392
|
+
return get('/events', tailFilters()).then(res => { tail.list = res.events; renderTail(); return null; }, fail(['ev-table']));
|
|
1393
|
+
}
|
|
1394
|
+
function togglePause() {
|
|
1395
|
+
tail.paused = !tail.paused;
|
|
1396
|
+
if (!tail.paused && tail.held.length) {
|
|
1397
|
+
tail.list = tail.held.concat(tail.list).slice(0, MAX_TAIL);
|
|
1398
|
+
tail.held = [];
|
|
1399
|
+
}
|
|
1400
|
+
setMode(tail.mode);
|
|
1401
|
+
renderTail();
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
// -- dialogs -------------------------------------------------------------
|
|
1405
|
+
var modal = $('modal'), help = $('help'), modalToken = 0;
|
|
1406
|
+
function modalTab(which) {
|
|
1407
|
+
$('m-sum').hidden = which !== 'sum';
|
|
1408
|
+
$('m-json').hidden = which === 'sum';
|
|
1409
|
+
$('m-tab-sum').setAttribute('aria-pressed', String(which === 'sum'));
|
|
1410
|
+
$('m-tab-json').setAttribute('aria-pressed', String(which !== 'sum'));
|
|
1411
|
+
}
|
|
1412
|
+
function openModal(kicker, title, copyable, sumHtml, data) {
|
|
1413
|
+
modalToken++;
|
|
1414
|
+
txt('m-kicker', kicker);
|
|
1415
|
+
txt('m-title', title);
|
|
1416
|
+
$('m-title').title = title;
|
|
1417
|
+
$('m-copy').hidden = !copyable;
|
|
1418
|
+
$('m-copy').setAttribute('data-copy', title);
|
|
1419
|
+
html('m-copy', COPY_SVG);
|
|
1420
|
+
fillModal(sumHtml, data);
|
|
1421
|
+
modalTab('sum');
|
|
1422
|
+
if (!modal.open) modal.showModal();
|
|
1423
|
+
return modalToken;
|
|
1424
|
+
}
|
|
1425
|
+
function fillModal(sumHtml, data) {
|
|
1426
|
+
html('m-sum', sumHtml);
|
|
1427
|
+
html('m-json', data === undefined ? SKEL : json(data));
|
|
1428
|
+
}
|
|
1429
|
+
function openCommit(seq) {
|
|
1430
|
+
var token = openModal('Commit ' + fmt(seq), '…', false, SKEL);
|
|
1431
|
+
get('/commits/' + seq).then(r => {
|
|
1432
|
+
if (token !== modalToken) return null;
|
|
1433
|
+
var c = r.commit;
|
|
1434
|
+
txt('m-title', c.clientCommitId);
|
|
1435
|
+
$('m-copy').hidden = false;
|
|
1436
|
+
$('m-copy').setAttribute('data-copy', c.clientCommitId);
|
|
1437
|
+
fillModal(kv([['Seq', '<span class="ty">' + fmt(c.commitSeq) + '</span>'], ['Client', clientLink(c.clientId)],
|
|
1438
|
+
['Actor', esc(c.actorId)], ['Created', esc(stamp(c.createdAtMs)) + ' <span class="dim">' + ago(c.createdAtMs) + '</span>'],
|
|
1439
|
+
['Write', '<button type="button" class="tag" data-write="' + esc(c.clientCommitId) + '">look up ' + esc(c.clientCommitId) + '</button>']]) +
|
|
1440
|
+
'<h3>Changes · ' + c.changes.length + '</h3><div id="m-changes"></div>', r);
|
|
1441
|
+
table('m-changes', [
|
|
1442
|
+
{ l: 'Row', c: 'w-sm', v: x => x.table + x.rowId, h: x => rowLink(x.table, x.rowId) },
|
|
1443
|
+
{ l: 'Op', v: x => x.op, h: x => esc(x.op) + (x.undecodable ? ' ' + st('err', 'undecodable') : '') },
|
|
1444
|
+
numCol('Version', 'rowVersion'),
|
|
1445
|
+
{ l: 'Scopes', ns: true, h: x => scopeTags(x.scopes) },
|
|
1446
|
+
{ l: 'Values', c: 'fill', ns: true, h: x => x.values ? trunc(JSON.stringify(x.values)) : '<span class="dim">–</span>' }
|
|
1447
|
+
], c.changes, empty('No changes', 'The commit carries no row changes.', true), x => { nav('row', [x.table, x.rowId]); });
|
|
1448
|
+
return null;
|
|
1449
|
+
}, err => { if (token === modalToken && err !== STALE) fillModal(errBox(err), { code: err.code, message: err.message }); });
|
|
1450
|
+
}
|
|
1451
|
+
// Requests with an error or warning in the ring for one client or actor,
|
|
1452
|
+
// one row per request; a row opens the request with all its events.
|
|
1453
|
+
function loadFailures(id, params) {
|
|
1454
|
+
if (!INFO.hasEventStream) { html(id, ringOff('Failures come from the event ring.')); return null; }
|
|
1455
|
+
return get('/events', Object.assign({ limit: 1000 }, params)).then(r => {
|
|
1456
|
+
var rows = groups(r.events).filter(g => g.level !== 'info');
|
|
1457
|
+
txt(id + '-meta', fmt(rows.length) + ' in the ring');
|
|
1458
|
+
table(id, GROUP_COLS, rows, empty('No failures', 'The event ring holds no failed, rejected, or conflicted request for this ' + (params.clientId ? 'client' : 'actor') + '.', true), g => { if (g.id) openRequest(g); else openEvent(g.events[0]); });
|
|
1459
|
+
return null;
|
|
1460
|
+
}, fail([id]));
|
|
1461
|
+
}
|
|
1462
|
+
function openRequest(g) {
|
|
1463
|
+
var token = openModal('Sync request', g.id, true, SKEL);
|
|
1464
|
+
get('/events', { requestId: g.id, limit: MAX_TAIL }).then(r => {
|
|
1465
|
+
if (token !== modalToken) return;
|
|
1466
|
+
fillModal('<p class="verdict" style="margin:0 0 14px">' + esc(groupSummary(groups(r.events)[0] || g)) + '</p>' + (g.clientId ? kv([['Client', clientLink(g.clientId)]]) : '') + '<h3>Events · ' + r.events.length + '</h3><div id="m-events"></div>', r.events);
|
|
1467
|
+
table('m-events', EV_COLS, r.events, empty('No events', 'The ring no longer holds events for this request.', true), openEvent);
|
|
1468
|
+
}, err => { if (token === modalToken && err !== STALE) fillModal(errBox(err), g.events); });
|
|
1469
|
+
}
|
|
1470
|
+
function openEvent(e) {
|
|
1471
|
+
var keys = Object.keys(e).filter(k => k !== 'type' && k !== 'atMs');
|
|
1472
|
+
openModal(LEVEL_LABEL[level(e)] + ' event', e.type, false, kv([['Time', esc(stamp(e.atMs))], ['Summary', esc(summary(e))]]
|
|
1473
|
+
.concat(e.table && e.rowId ? [['Row', rowLink(e.table, e.rowId)]] : [])
|
|
1474
|
+
.concat(e.clientCommitId ? [['Write', '<button type="button" class="tag" data-write="' + esc(e.clientCommitId) + '">look up ' + esc(e.clientCommitId) + '</button>']] : [])
|
|
1475
|
+
.concat(keys.map(k => {
|
|
1476
|
+
var v = e[k];
|
|
1477
|
+
return [k, k === 'clientId' ? clientLink(v) : typeof v === 'string' ? (k.slice(-2) === 'Id' ? idCell(v) : esc(v)) : typeof v === 'object' ? '<code>' + esc(JSON.stringify(v)) + '</code>' : esc(String(v))];
|
|
1478
|
+
}))), e);
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
// -- routing and refresh -------------------------------------------------
|
|
1482
|
+
var LOADERS = {
|
|
1483
|
+
overview: () => [loadMetrics(), loadErrors(), loadHorizon(['ov-horizon']), loadClients(), loadFleet()],
|
|
1484
|
+
people: args => [loadPeople(args), args[0] === undefined ? null : loadFailures('people-fail', { actorId: args[0] })],
|
|
1485
|
+
client: args => [loadClientPage(args), S.horizon ? null : loadHorizon([])],
|
|
1486
|
+
data: () => [loadTables()],
|
|
1487
|
+
table: args => [loadTablePage(args)],
|
|
1488
|
+
row: args => [loadRowPage(args)],
|
|
1489
|
+
commits: () => [loadCommits()],
|
|
1490
|
+
events: () => [loadTail()],
|
|
1491
|
+
reactions: () => [loadReactions()],
|
|
1492
|
+
storage: () => [loadStats(), loadHorizon(['st-horizon'])],
|
|
1493
|
+
search: args => [loadSearch(args)]
|
|
1494
|
+
};
|
|
1495
|
+
function report(errs) {
|
|
1496
|
+
var auth = errs.filter(e => e.code === 'sync.auth_required')[0];
|
|
1497
|
+
$('alert').hidden = !auth;
|
|
1498
|
+
if (auth) html('alert', '<b>sync.auth_required</b><span>The host\\'s authorize guard rejected the console\\'s requests. Sign in to the host, or open the console with the credentials its guard expects, then refresh.</span>');
|
|
1499
|
+
$('updated').className = errs.length ? 'err' : '';
|
|
1500
|
+
txt('updated', errs.length ? errs.length + ' failed · ' + (errs[0].code || 'console.render_failed') : 'Updated ' + clock(Date.now()));
|
|
1501
|
+
}
|
|
1502
|
+
// Every view needs the capability record first; a failed /info renders
|
|
1503
|
+
// its error into every panel, and refresh retries it.
|
|
1504
|
+
function boot() {
|
|
1505
|
+
txt('updated', 'Loading…');
|
|
1506
|
+
return get('/info').then(r => {
|
|
1507
|
+
INFO = r;
|
|
1508
|
+
html('tables-list', r.tables.map(t => '<option value="' + esc(t.name) + '"></option>').join(''));
|
|
1509
|
+
txt('side-mode', r.actions ? 'Operator actions enabled: retry, prune, revoke.' : 'Read-only: the host passed no authorizeActions.');
|
|
1510
|
+
startTail();
|
|
1511
|
+
return show();
|
|
1512
|
+
}, err => {
|
|
1513
|
+
if (err === STALE) return;
|
|
1514
|
+
if (err.details.parameter === 'partition') {
|
|
1515
|
+
// Several partitions and none picked: offer the picker.
|
|
1516
|
+
document.querySelectorAll('[data-skel]').forEach(h => { h.innerHTML = empty('Pick a partition', 'This deployment has several partitions. Choose one in the partition picker (<kbd>p</kbd>).'); });
|
|
1517
|
+
// A partition-scoped guard denies the fleet list; the picker still
|
|
1518
|
+
// takes a typed partition then.
|
|
1519
|
+
get('/partitions').then(r => { html('partitions-list', r.partitions.map(p => '<option value="' + esc(p.partition) + '"></option>').join('')); }, () => {});
|
|
1520
|
+
$('partition').focus();
|
|
474
1521
|
return;
|
|
475
1522
|
}
|
|
476
|
-
|
|
477
|
-
|
|
1523
|
+
document.querySelectorAll('[data-skel]').forEach(h => { h.innerHTML = errBox(err); });
|
|
1524
|
+
setMode('error');
|
|
1525
|
+
report([err]);
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
var busy = {};
|
|
1529
|
+
function load() {
|
|
1530
|
+
if (!INFO) return boot();
|
|
1531
|
+
var key = location.hash;
|
|
1532
|
+
if (busy[key]) return busy[key];
|
|
1533
|
+
$('updated').className = '';
|
|
1534
|
+
txt('updated', 'Loading…');
|
|
1535
|
+
busy[key] = Promise.all(LOADERS[at.view](at.args)).then(results => {
|
|
1536
|
+
busy[key] = null;
|
|
1537
|
+
report(results.filter(Boolean));
|
|
478
1538
|
});
|
|
1539
|
+
return busy[key];
|
|
1540
|
+
}
|
|
1541
|
+
function show() {
|
|
1542
|
+
var parts = location.hash.replace(/^#\\/?/, '').split('/').filter(Boolean).map(decodeURIComponent);
|
|
1543
|
+
var view = LOADERS[parts[0]] ? parts[0] : 'overview';
|
|
1544
|
+
at = { view: view, args: parts.slice(1) };
|
|
1545
|
+
if (!parts.length || !LOADERS[parts[0]]) history.replaceState(null, '', route(view));
|
|
1546
|
+
document.querySelectorAll('section.view').forEach(s => { s.hidden = s.id !== 'view-' + view; });
|
|
1547
|
+
var section = SECTION[view] || view;
|
|
1548
|
+
NAV.forEach(v => { if (v === section) $('nav-' + v).setAttribute('aria-current', 'page'); else $('nav-' + v).removeAttribute('aria-current'); });
|
|
1549
|
+
if (modal.open) modal.close();
|
|
1550
|
+
$('main').scrollTop = 0;
|
|
1551
|
+
return load();
|
|
1552
|
+
}
|
|
1553
|
+
function nav(view, args) {
|
|
1554
|
+
var h = route(view, args);
|
|
1555
|
+
if (location.hash !== h) history.pushState(null, '', h);
|
|
1556
|
+
return show();
|
|
1557
|
+
}
|
|
1558
|
+
function setPartition(p) {
|
|
1559
|
+
$('partition').value = p;
|
|
1560
|
+
partitionChanged();
|
|
1561
|
+
}
|
|
1562
|
+
function partitionChanged() {
|
|
1563
|
+
if (modal.open) modal.close();
|
|
1564
|
+
epoch++;
|
|
1565
|
+
busy = {};
|
|
1566
|
+
reset();
|
|
1567
|
+
if (!INFO) { boot(); return; }
|
|
1568
|
+
startTail();
|
|
1569
|
+
show();
|
|
1570
|
+
}
|
|
1571
|
+
var timer = null;
|
|
1572
|
+
function setAuto(ms) {
|
|
1573
|
+
$('auto').value = String(ms);
|
|
1574
|
+
if (timer) clearInterval(timer);
|
|
1575
|
+
timer = ms > 0 ? setInterval(load, ms) : null;
|
|
1576
|
+
$('auto').className = 'btn' + (ms > 0 ? ' on' : '');
|
|
1577
|
+
}
|
|
1578
|
+
var toastTimer = null;
|
|
1579
|
+
function toast(text) {
|
|
1580
|
+
txt('toast', text);
|
|
1581
|
+
$('toast').hidden = false;
|
|
1582
|
+
if (toastTimer) clearTimeout(toastTimer);
|
|
1583
|
+
toastTimer = setTimeout(() => { $('toast').hidden = true; }, 2200);
|
|
1584
|
+
}
|
|
1585
|
+
function copy(text) {
|
|
1586
|
+
if (!navigator.clipboard) { toast('Clipboard unavailable: the page is not a secure context'); return; }
|
|
1587
|
+
navigator.clipboard.writeText(text).then(() => { toast('Copied ' + text); }, () => { toast('Copy failed: the browser denied clipboard access'); });
|
|
1588
|
+
}
|
|
1589
|
+
var confirmBox = $('confirm'), pending = null;
|
|
1590
|
+
function confirmWrite(title, body, path, after) {
|
|
1591
|
+
pending = { path: path, after: after };
|
|
1592
|
+
txt('c-text', title);
|
|
1593
|
+
html('c-body', '<p class="verdict" style="margin:0">' + body + '</p><p class="verdict">The console sends <code>POST ' + esc(path) + '</code>.</p>');
|
|
1594
|
+
$('c-ok').hidden = false;
|
|
1595
|
+
txt('c-cancel', 'Cancel');
|
|
1596
|
+
confirmBox.showModal();
|
|
1597
|
+
}
|
|
1598
|
+
function runWrite() {
|
|
1599
|
+
var w = pending;
|
|
1600
|
+
$('c-ok').hidden = true;
|
|
1601
|
+
html('c-body', SKEL);
|
|
1602
|
+
post(w.path).then(r => {
|
|
1603
|
+
html('c-body', '<p class="verdict" style="margin:0 0 12px"><b class="ty">Done</b>The server answered:</p>' + json(r));
|
|
1604
|
+
toast('Write applied: POST ' + w.path);
|
|
1605
|
+
w.after();
|
|
1606
|
+
}, err => { html('c-body', err === STALE ? '' : errBox(err)); }).then(() => { txt('c-cancel', 'Close'); });
|
|
1607
|
+
}
|
|
1608
|
+
var ACTS = {
|
|
1609
|
+
pause: () => togglePause(),
|
|
1610
|
+
reconnect: () => connectStream(),
|
|
1611
|
+
'err-tab': el => { ERR_TAB = el.getAttribute('data-tab'); if (S.errors) renderErrors(); },
|
|
1612
|
+
'fleet-prev': () => { S.fleetOffset = Math.max(0, S.fleetOffset - FLEET_PAGE); loadFleet(); },
|
|
1613
|
+
'fleet-next': () => { S.fleetOffset += FLEET_PAGE; loadFleet(); },
|
|
1614
|
+
'commits-older': () => { S.commitPages = (S.commitPages || []).concat([S.commitOldest]); loadCommits(); },
|
|
1615
|
+
'commits-newer': () => { S.commitPages = S.commitPages.slice(0, -1); if (!S.commitPages.length) S.commitPages = null; loadCommits(); },
|
|
1616
|
+
'commits-newest': () => { S.commitPages = null; loadCommits(); },
|
|
1617
|
+
'rows-next': () => { S.pageStack.push(S.pageNext); load(); },
|
|
1618
|
+
'rows-prev': () => { S.pageStack.pop(); load(); },
|
|
1619
|
+
'rows-first': () => { S.pageStack = []; load(); },
|
|
1620
|
+
retry: el => {
|
|
1621
|
+
var k = el.getAttribute('data-key');
|
|
1622
|
+
confirmWrite('Retry reaction ' + k, 'The reaction returns to pending with its attempts reset, and a worker claims it again.', '/reactions/' + enc(k) + '/retry', () => { modal.close(); loadReactions(); });
|
|
1623
|
+
},
|
|
1624
|
+
prune: () => {
|
|
1625
|
+
var h = S.horizon;
|
|
1626
|
+
confirmWrite('Prune the commit log', 'A prune pass advances the horizon of partition ' + esc(h.partition) + ' from ' + fmt(h.horizonSeq) + ' toward ' + fmt(h.recommendedHorizonSeq) +
|
|
1627
|
+
' and deletes the commits below it. A client whose cursor falls under the new horizon re-bootstraps.', '/prune', load);
|
|
1628
|
+
},
|
|
1629
|
+
revoke: el => {
|
|
1630
|
+
var id = el.getAttribute('data-cid');
|
|
1631
|
+
confirmWrite('Revoke the lease of ' + id, 'The client loses its lease at once; its next request needs a fresh authorized round.', '/clients/' + enc(id) + '/revoke-lease', load);
|
|
1632
|
+
}
|
|
1633
|
+
};
|
|
1634
|
+
function pickRow(tr) {
|
|
1635
|
+
var id = tr.closest('[data-tbl]').getAttribute('data-tbl'), t = T[id];
|
|
1636
|
+
if (t && t.pick) t.pick(t.rows[Number(tr.getAttribute('data-i'))]);
|
|
479
1637
|
}
|
|
480
1638
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
status.textContent = 'error: ' + err.message;
|
|
502
|
-
}).finally(function () { loading = false; });
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
function inspect() {
|
|
506
|
-
var t = el('inspect-table').value.trim();
|
|
507
|
-
var id = el('inspect-row').value.trim();
|
|
508
|
-
if (!t || !id) { el('inspect').innerHTML = empty('table and rowId required'); return; }
|
|
509
|
-
get('/rows/' + encodeURIComponent(t) + '/' + encodeURIComponent(id))
|
|
510
|
-
.then(function (r) { renderInspection(r.row); })
|
|
511
|
-
.catch(function (err) { el('inspect').innerHTML = empty('error: ' + err.message); });
|
|
512
|
-
}
|
|
513
|
-
function scopeQuery() {
|
|
514
|
-
var variable = el('scope-variable').value.trim();
|
|
515
|
-
var value = el('scope-value').value.trim();
|
|
516
|
-
if (!variable || !value) { el('scope').innerHTML = empty('variable and value required'); return; }
|
|
517
|
-
get('/scope-activity', { variable: variable, value: value })
|
|
518
|
-
.then(function (r) { renderScope(r.activity); })
|
|
519
|
-
.catch(function (err) { el('scope').innerHTML = empty('error: ' + err.message); });
|
|
520
|
-
}
|
|
521
|
-
function openDetail(clientId) {
|
|
522
|
-
el('modal').hidden = false;
|
|
523
|
-
el('modal-title').textContent = clientId;
|
|
524
|
-
el('detail-body').innerHTML = empty('loading ' + clientId + '…');
|
|
525
|
-
get('/clients/' + encodeURIComponent(clientId))
|
|
526
|
-
.then(function (r) { renderDetail(r.detail); })
|
|
527
|
-
.catch(function (err) { el('detail-body').innerHTML = empty('error: ' + err.message); });
|
|
528
|
-
}
|
|
529
|
-
function closeDetail() { el('modal').hidden = true; }
|
|
530
|
-
function onEnter(id, fn) {
|
|
531
|
-
el(id).addEventListener('keydown', function (e) { if (e.key === 'Enter') fn(); });
|
|
532
|
-
}
|
|
533
|
-
function pickedRow(target, attr) {
|
|
534
|
-
var row = target.closest ? target.closest('tr[data-' + attr + ']') : null;
|
|
535
|
-
return row ? row.getAttribute('data-' + attr) : null;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
el('refresh').addEventListener('click', loadAll);
|
|
539
|
-
el('partition').addEventListener('change', function () {
|
|
540
|
-
if (tail.source) { tail.source.close(); tail.source = null; }
|
|
541
|
-
closeDetail();
|
|
542
|
-
loadAll();
|
|
543
|
-
});
|
|
544
|
-
el('commits-filter').addEventListener('change', loadAll);
|
|
545
|
-
el('events-filter').addEventListener('change', function () {
|
|
546
|
-
if (tail.source) connectStream(); else loadAll();
|
|
547
|
-
});
|
|
548
|
-
el('clients').addEventListener('click', function (e) {
|
|
549
|
-
var id = pickedRow(e.target, 'client');
|
|
550
|
-
if (id !== null) openDetail(id);
|
|
551
|
-
});
|
|
552
|
-
el('detail-close').addEventListener('click', closeDetail);
|
|
553
|
-
el('modal').addEventListener('click', function (e) {
|
|
554
|
-
if (e.target === el('modal')) closeDetail();
|
|
1639
|
+
// -- wiring --------------------------------------------------------------
|
|
1640
|
+
html('ev-kind', '<option value="">All kinds</option><optgroup label="Families">' +
|
|
1641
|
+
['request', 'push', 'pull', 'realtime', 'reaction', 'segment', 'blob', 'prune', 'scopes', 'lease'].map(f => '<option value="' + f + '">' + f + '.*</option>').join('') +
|
|
1642
|
+
'</optgroup><optgroup label="Types">' + EVENT_TYPES.map(t => '<option value="' + t + '">' + t + '</option>').join('') + '</optgroup>');
|
|
1643
|
+
document.addEventListener('click', e => {
|
|
1644
|
+
var t = e.target, el;
|
|
1645
|
+
if (!t || !t.closest) return;
|
|
1646
|
+
if ((el = t.closest('[data-copy]'))) { e.preventDefault(); e.stopPropagation(); copy(el.getAttribute('data-copy')); return; }
|
|
1647
|
+
if ((el = t.closest('[data-sort]'))) { sortBy(el.closest('[data-tbl]').getAttribute('data-tbl'), Number(el.getAttribute('data-sort'))); return; }
|
|
1648
|
+
if ((el = t.closest('[data-act]'))) { ACTS[el.getAttribute('data-act')](el); return; }
|
|
1649
|
+
if ((el = t.closest('[data-seq]'))) { openCommit(Number(el.getAttribute('data-seq'))); return; }
|
|
1650
|
+
if ((el = t.closest('[data-write]'))) { openWrite(el.getAttribute('data-write')); return; }
|
|
1651
|
+
if ((el = t.closest('a[href^="#/"]'))) {
|
|
1652
|
+
if (e.metaKey || e.ctrlKey || e.shiftKey || e.button) return;
|
|
1653
|
+
e.preventDefault();
|
|
1654
|
+
if (location.hash !== el.getAttribute('href')) history.pushState(null, '', el.getAttribute('href'));
|
|
1655
|
+
show();
|
|
1656
|
+
return;
|
|
1657
|
+
}
|
|
1658
|
+
if ((el = t.closest('tr[data-i]'))) pickRow(el);
|
|
555
1659
|
});
|
|
556
|
-
document.addEventListener('keydown',
|
|
557
|
-
if (e.
|
|
1660
|
+
document.addEventListener('keydown', e => {
|
|
1661
|
+
if (e.metaKey || e.ctrlKey || e.altKey) return;
|
|
1662
|
+
var t = e.target, tag = t && t.tagName;
|
|
1663
|
+
if (e.key === 'Enter' && tag === 'TR' && t.hasAttribute('data-i')) { e.preventDefault(); pickRow(t); return; }
|
|
1664
|
+
if (tag === 'INPUT' || tag === 'SELECT' || tag === 'TEXTAREA') { if (e.key === 'Escape') t.blur(); return; }
|
|
1665
|
+
if (modal.open || help.open || confirmBox.open) return;
|
|
1666
|
+
var n = Number(e.key);
|
|
1667
|
+
if (n >= 1 && n <= NAV.length) nav(NAV[n - 1]);
|
|
1668
|
+
else if (e.key === '/') $('q').focus();
|
|
1669
|
+
else if (e.key === 'f') { var f = document.querySelector('#view-' + at.view + ' [data-focus]'); if (f) f.focus(); }
|
|
1670
|
+
else if (e.key === 'r') load();
|
|
1671
|
+
else if (e.key === 'a') { var o = [0, 2000, 5000, 15000]; setAuto(o[(o.indexOf(Number($('auto').value)) + 1) % o.length]); }
|
|
1672
|
+
else if (e.key === 'p') $('partition').focus();
|
|
1673
|
+
else if (e.key === ' ' && at.view === 'events' && tag !== 'BUTTON') togglePause();
|
|
1674
|
+
else if (e.key === '?') help.showModal();
|
|
1675
|
+
else return;
|
|
1676
|
+
e.preventDefault();
|
|
558
1677
|
});
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
1678
|
+
window.addEventListener('hashchange', () => { show(); });
|
|
1679
|
+
window.addEventListener('popstate', () => { show(); });
|
|
1680
|
+
document.addEventListener('submit', e => {
|
|
1681
|
+
var f = e.target;
|
|
1682
|
+
e.preventDefault();
|
|
1683
|
+
if (f.id === 'search-form') { var q = $('q').value.trim(); if (q) nav('search', [q]); }
|
|
1684
|
+
else if (f.id === 'write-form') { var w = $('write-id').value.trim(); if (w) openWrite(w); }
|
|
1685
|
+
else if (f.id === 'client-trace') { var r = f.querySelector('[name=r]').value.trim(); if (r) openTrace(f.querySelector('[name=t]').value, r, f.getAttribute('data-cid')); }
|
|
562
1686
|
});
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
1687
|
+
$('refresh').addEventListener('click', () => { load(); });
|
|
1688
|
+
$('auto').addEventListener('change', () => setAuto(Number($('auto').value)));
|
|
1689
|
+
$('help-btn').addEventListener('click', () => { help.showModal(); });
|
|
1690
|
+
$('help-close').addEventListener('click', () => { help.close(); });
|
|
1691
|
+
$('m-close').addEventListener('click', () => { modal.close(); });
|
|
1692
|
+
$('m-tab-sum').addEventListener('click', () => { modalTab('sum'); });
|
|
1693
|
+
$('m-tab-json').addEventListener('click', () => { modalTab('json'); });
|
|
1694
|
+
$('c-ok').addEventListener('click', runWrite);
|
|
1695
|
+
$('c-cancel').addEventListener('click', () => { confirmBox.close(); });
|
|
1696
|
+
[modal, help, confirmBox].forEach(d => { d.addEventListener('click', e => { if (e.target === d) d.close(); }); });
|
|
1697
|
+
$('partition').addEventListener('change', partitionChanged);
|
|
1698
|
+
$('people-q').addEventListener('input', () => { if (S.actors) renderPeople(); });
|
|
1699
|
+
$('commits-table').addEventListener('change', () => { S.commitPages = null; loadCommits(); });
|
|
1700
|
+
$('commits-limit').addEventListener('change', () => { S.commitPages = null; loadCommits(); });
|
|
1701
|
+
function refilter() { if (tail.mode === 'live' || tail.mode === 'connecting') connectStream(); else loadTail(); }
|
|
1702
|
+
$('ev-kind').addEventListener('change', refilter);
|
|
1703
|
+
$('ev-client').addEventListener('change', refilter);
|
|
1704
|
+
$('ev-level').addEventListener('change', renderTail);
|
|
1705
|
+
$('ev-idle').addEventListener('change', renderTail);
|
|
1706
|
+
$('ev-q').addEventListener('input', renderTail);
|
|
1707
|
+
$('ev-pause').addEventListener('click', togglePause);
|
|
1708
|
+
$('ev-clear').addEventListener('click', () => { tail.list = []; tail.held = []; setMode(tail.mode); renderTail(); });
|
|
1709
|
+
$('rx-status').addEventListener('change', loadReactions);
|
|
1710
|
+
$('rx-type').addEventListener('change', loadReactions);
|
|
1711
|
+
|
|
1712
|
+
reset();
|
|
1713
|
+
boot();
|
|
581
1714
|
})();
|
|
582
1715
|
</script>
|
|
583
1716
|
</body>
|
|
584
|
-
</html
|
|
1717
|
+
</html>`.replace(/^ +(?:\/\/.*\n)?/gm, '');
|