@bsv/overlay-express 2.0.2 → 2.1.1
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/cjs/mod.js +7 -1
- package/dist/cjs/mod.js.map +1 -1
- package/dist/cjs/package.json +3 -1
- package/dist/cjs/src/BanAwareLookupWrapper.js +76 -0
- package/dist/cjs/src/BanAwareLookupWrapper.js.map +1 -0
- package/dist/cjs/src/BanService.js +118 -0
- package/dist/cjs/src/BanService.js.map +1 -0
- package/dist/cjs/src/JanitorService.js +206 -93
- package/dist/cjs/src/JanitorService.js.map +1 -1
- package/dist/cjs/src/OverlayExpress.js +522 -71
- package/dist/cjs/src/OverlayExpress.js.map +1 -1
- package/dist/cjs/src/makeUserInterface.js +889 -217
- package/dist/cjs/src/makeUserInterface.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/mod.js +4 -1
- package/dist/esm/mod.js.map +1 -1
- package/dist/esm/src/BanAwareLookupWrapper.js +78 -0
- package/dist/esm/src/BanAwareLookupWrapper.js.map +1 -0
- package/dist/esm/src/BanService.js +115 -0
- package/dist/esm/src/BanService.js.map +1 -0
- package/dist/esm/src/JanitorService.js +199 -92
- package/dist/esm/src/JanitorService.js.map +1 -1
- package/dist/esm/src/OverlayExpress.js +528 -72
- package/dist/esm/src/OverlayExpress.js.map +1 -1
- package/dist/esm/src/makeUserInterface.js +889 -217
- package/dist/esm/src/makeUserInterface.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/mod.d.ts +4 -1
- package/dist/types/mod.d.ts.map +1 -1
- package/dist/types/src/BanAwareLookupWrapper.d.ts +31 -0
- package/dist/types/src/BanAwareLookupWrapper.d.ts.map +1 -0
- package/dist/types/src/BanService.d.ts +81 -0
- package/dist/types/src/BanService.d.ts.map +1 -0
- package/dist/types/src/JanitorService.d.ts +69 -13
- package/dist/types/src/JanitorService.d.ts.map +1 -1
- package/dist/types/src/OverlayExpress.d.ts +28 -4
- package/dist/types/src/OverlayExpress.d.ts.map +1 -1
- package/dist/types/src/makeUserInterface.d.ts +2 -0
- package/dist/types/src/makeUserInterface.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/mod.ts +4 -1
- package/package.json +3 -1
- package/src/BanAwareLookupWrapper.ts +95 -0
- package/src/BanService.ts +154 -0
- package/src/JanitorService.ts +277 -101
- package/src/OverlayExpress.ts +575 -76
- package/src/__tests__/BanAwareLookupWrapper.test.ts +255 -0
- package/src/__tests__/BanService.test.ts +310 -0
- package/src/__tests__/JanitorService.test.ts +342 -5
- package/src/__tests__/OverlayExpress.test.ts +19 -6
- package/src/__tests__/makeUserInterface.test.ts +4 -3
- package/src/makeUserInterface.ts +892 -217
package/src/makeUserInterface.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface UIConfig {
|
|
|
18
18
|
secondaryBackgroundColor?: string
|
|
19
19
|
secondaryTextColor?: string
|
|
20
20
|
defaultContent?: string
|
|
21
|
+
/** Admin identity key for wallet-based admin detection */
|
|
22
|
+
adminIdentityKey?: string
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export default (config: UIConfig = {}): string => {
|
|
@@ -37,7 +39,8 @@ export default (config: UIConfig = {}): string => {
|
|
|
37
39
|
borderColor = '#B6C2CF',
|
|
38
40
|
secondaryBackgroundColor = '#f8f8f8',
|
|
39
41
|
secondaryTextColor = '#0e0e0e',
|
|
40
|
-
defaultContent = generalGuide
|
|
42
|
+
defaultContent = generalGuide,
|
|
43
|
+
adminIdentityKey = ''
|
|
41
44
|
} = config
|
|
42
45
|
|
|
43
46
|
return `<!DOCTYPE html>
|
|
@@ -61,8 +64,14 @@ export default (config: UIConfig = {}): string => {
|
|
|
61
64
|
--secondary-background-color: ${secondaryBackgroundColor};
|
|
62
65
|
--secondary-text-color: ${secondaryTextColor};
|
|
63
66
|
--primary-text-color: ${primaryTextColor};
|
|
67
|
+
--success-color: #22c55e;
|
|
68
|
+
--warning-color: #f59e0b;
|
|
69
|
+
--danger-color: #ef4444;
|
|
70
|
+
--info-color: #3b82f6;
|
|
64
71
|
}
|
|
65
72
|
|
|
73
|
+
* { box-sizing: border-box; }
|
|
74
|
+
|
|
66
75
|
body {
|
|
67
76
|
font-family: var(--font-family);
|
|
68
77
|
background-color: var(--background-color);
|
|
@@ -71,13 +80,8 @@ export default (config: UIConfig = {}): string => {
|
|
|
71
80
|
color: var(--primary-text-color);
|
|
72
81
|
}
|
|
73
82
|
|
|
74
|
-
h1, h2, h3 {
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
p {
|
|
79
|
-
line-height: 1.5;
|
|
80
|
-
}
|
|
83
|
+
h1, h2, h3 { font-family: var(--heading-font-family); }
|
|
84
|
+
p { line-height: 1.5; }
|
|
81
85
|
|
|
82
86
|
.welcome {
|
|
83
87
|
background-clip: text;
|
|
@@ -86,14 +90,8 @@ export default (config: UIConfig = {}): string => {
|
|
|
86
90
|
cursor: pointer;
|
|
87
91
|
}
|
|
88
92
|
|
|
89
|
-
a {
|
|
90
|
-
|
|
91
|
-
text-decoration: none;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
a:hover {
|
|
95
|
-
color: var(--secondary-color);
|
|
96
|
-
}
|
|
93
|
+
a { color: var(--link-color); text-decoration: none; }
|
|
94
|
+
a:hover { color: var(--secondary-color); }
|
|
97
95
|
|
|
98
96
|
.main {
|
|
99
97
|
display: flex;
|
|
@@ -111,24 +109,16 @@ export default (config: UIConfig = {}): string => {
|
|
|
111
109
|
padding: 15px 15px 15px 35px;
|
|
112
110
|
overflow-y: auto;
|
|
113
111
|
width: 360px;
|
|
112
|
+
min-width: 360px;
|
|
114
113
|
background-color: var(--secondary-background-color);
|
|
115
114
|
color: var(--secondary-text-color);
|
|
116
115
|
}
|
|
117
116
|
|
|
118
|
-
.column_right {
|
|
119
|
-
width: calc(100% - 360px);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
#documentation_container {
|
|
123
|
-
padding: 0 8em;
|
|
124
|
-
margin: 0;
|
|
125
|
-
}
|
|
117
|
+
.column_right { width: calc(100% - 360px); }
|
|
126
118
|
|
|
127
|
-
|
|
128
|
-
.list-item {
|
|
129
|
-
margin: 0;
|
|
130
|
-
}
|
|
119
|
+
#documentation_container { padding: 0 8em; margin: 0; }
|
|
131
120
|
|
|
121
|
+
.list-item { margin: 0; }
|
|
132
122
|
.list-item a {
|
|
133
123
|
display: block;
|
|
134
124
|
width: 100%;
|
|
@@ -141,51 +131,25 @@ export default (config: UIConfig = {}): string => {
|
|
|
141
131
|
font-weight: 500;
|
|
142
132
|
cursor: pointer;
|
|
143
133
|
}
|
|
144
|
-
|
|
145
134
|
.list-item a:hover, .list-item a.active {
|
|
146
135
|
background: var(--primary-color) linear-gradient(90deg, var(--primary-color), var(--secondary-color));
|
|
147
136
|
color: white;
|
|
148
137
|
cursor: pointer;
|
|
149
138
|
border-radius: 8px 0 0 8px;
|
|
150
139
|
}
|
|
151
|
-
|
|
152
|
-
ul#manager_list, ul#provider_list, ul#external_list {
|
|
140
|
+
ul#manager_list, ul#provider_list, ul#external_list, ul#admin_list {
|
|
153
141
|
list-style-type: none;
|
|
154
142
|
padding-left: 0;
|
|
155
143
|
margin-top: 0.5em;
|
|
156
144
|
}
|
|
157
145
|
|
|
158
|
-
|
|
159
|
-
.detail-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.detail-icon {
|
|
166
|
-
width: 60px;
|
|
167
|
-
height: 60px;
|
|
168
|
-
margin-right: 1em;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
.detail-text {
|
|
172
|
-
display: flex;
|
|
173
|
-
flex-direction: column;
|
|
174
|
-
}
|
|
146
|
+
.detail-header { display: flex; align-items: center; margin-bottom: 1em; }
|
|
147
|
+
.detail-icon { width: 60px; height: 60px; margin-right: 1em; }
|
|
148
|
+
.detail-text { display: flex; flex-direction: column; }
|
|
149
|
+
.detail-title { margin: 0; }
|
|
150
|
+
.detail-description, .detail-version, .detail-info { margin: 0.2em 0; }
|
|
151
|
+
.detail-info a { color: var(--link-color); }
|
|
175
152
|
|
|
176
|
-
.detail-title {
|
|
177
|
-
margin: 0;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.detail-description, .detail-version, .detail-info {
|
|
181
|
-
margin: 0.2em 0;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.detail-info a {
|
|
185
|
-
color: var(--link-color);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/* Code highlighting styles */
|
|
189
153
|
pre {
|
|
190
154
|
position: relative;
|
|
191
155
|
padding: 1em;
|
|
@@ -194,7 +158,6 @@ export default (config: UIConfig = {}): string => {
|
|
|
194
158
|
background-color: #282c34;
|
|
195
159
|
margin: 1em 0;
|
|
196
160
|
}
|
|
197
|
-
|
|
198
161
|
pre[data-language]:before {
|
|
199
162
|
content: attr(data-language);
|
|
200
163
|
position: absolute;
|
|
@@ -207,13 +170,10 @@ export default (config: UIConfig = {}): string => {
|
|
|
207
170
|
border-radius: 0 0 0 4px;
|
|
208
171
|
text-transform: uppercase;
|
|
209
172
|
}
|
|
210
|
-
|
|
211
173
|
code {
|
|
212
174
|
font-family: Menlo, Monaco, 'Courier New', monospace;
|
|
213
175
|
font-size: 0.9em;
|
|
214
176
|
}
|
|
215
|
-
|
|
216
|
-
/* Inline code */
|
|
217
177
|
p code, li code {
|
|
218
178
|
background-color: #3e4451;
|
|
219
179
|
padding: 0.2em 0.4em;
|
|
@@ -221,26 +181,227 @@ export default (config: UIConfig = {}): string => {
|
|
|
221
181
|
white-space: nowrap;
|
|
222
182
|
}
|
|
223
183
|
|
|
224
|
-
/*
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
184
|
+
/* ============ ADMIN DASHBOARD STYLES ============ */
|
|
185
|
+
#admin_section { display: none; }
|
|
186
|
+
#admin_section.visible { display: block; }
|
|
187
|
+
.admin-divider { border-top: 1px solid #ccc; margin-top: 1em; padding-top: 0.5em; }
|
|
229
188
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
189
|
+
.admin-login {
|
|
190
|
+
padding: 2em 8em;
|
|
191
|
+
}
|
|
192
|
+
.admin-login h2 { margin-bottom: 0.5em; }
|
|
193
|
+
.admin-login p { color: #999; margin-bottom: 1.5em; }
|
|
194
|
+
.admin-login-form { display: flex; gap: 0.5em; align-items: center; flex-wrap: wrap; }
|
|
195
|
+
.admin-login-form input {
|
|
196
|
+
padding: 0.6em 1em;
|
|
197
|
+
border: 1px solid #555;
|
|
198
|
+
border-radius: 6px;
|
|
199
|
+
background: #2a2a2a;
|
|
200
|
+
color: var(--primary-text-color);
|
|
201
|
+
font-size: 0.9em;
|
|
202
|
+
width: 350px;
|
|
203
|
+
}
|
|
204
|
+
.admin-login-form input::placeholder { color: #777; }
|
|
233
205
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
206
|
+
.btn {
|
|
207
|
+
padding: 0.6em 1.2em;
|
|
208
|
+
border: none;
|
|
209
|
+
border-radius: 6px;
|
|
210
|
+
cursor: pointer;
|
|
211
|
+
font-size: 0.85em;
|
|
212
|
+
font-weight: 600;
|
|
213
|
+
transition: all 0.2s;
|
|
214
|
+
display: inline-flex;
|
|
215
|
+
align-items: center;
|
|
216
|
+
gap: 0.4em;
|
|
217
|
+
}
|
|
218
|
+
.btn:hover { filter: brightness(1.1); }
|
|
219
|
+
.btn-primary { background: var(--primary-color); color: white; }
|
|
220
|
+
.btn-danger { background: var(--danger-color); color: white; }
|
|
221
|
+
.btn-warning { background: var(--warning-color); color: #111; }
|
|
222
|
+
.btn-success { background: var(--success-color); color: white; }
|
|
223
|
+
.btn-sm { padding: 0.3em 0.7em; font-size: 0.8em; }
|
|
224
|
+
.btn-outline {
|
|
225
|
+
background: transparent;
|
|
226
|
+
border: 1px solid var(--primary-color);
|
|
227
|
+
color: var(--primary-color);
|
|
228
|
+
}
|
|
239
229
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
230
|
+
.admin-panel { padding: 0 8em 2em; }
|
|
231
|
+
.admin-panel h2 { margin-bottom: 0.3em; }
|
|
232
|
+
.admin-panel .subtitle { color: #999; margin-top: 0; margin-bottom: 1.5em; }
|
|
233
|
+
|
|
234
|
+
.stats-grid {
|
|
235
|
+
display: grid;
|
|
236
|
+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
237
|
+
gap: 1em;
|
|
238
|
+
margin-bottom: 2em;
|
|
239
|
+
}
|
|
240
|
+
.stat-card {
|
|
241
|
+
background: var(--section-background-color);
|
|
242
|
+
border-radius: 10px;
|
|
243
|
+
padding: 1.2em;
|
|
244
|
+
}
|
|
245
|
+
.stat-card .stat-label { font-size: 0.8em; color: #999; text-transform: uppercase; letter-spacing: 0.05em; }
|
|
246
|
+
.stat-card .stat-value { font-size: 1.8em; font-weight: 700; margin: 0.1em 0; }
|
|
247
|
+
.stat-card .stat-value.success { color: var(--success-color); }
|
|
248
|
+
.stat-card .stat-value.warning { color: var(--warning-color); }
|
|
249
|
+
.stat-card .stat-value.danger { color: var(--danger-color); }
|
|
250
|
+
.stat-card .stat-value.info { color: var(--info-color); }
|
|
251
|
+
|
|
252
|
+
.action-bar {
|
|
253
|
+
display: flex;
|
|
254
|
+
gap: 0.5em;
|
|
255
|
+
flex-wrap: wrap;
|
|
256
|
+
margin-bottom: 1.5em;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.search-bar {
|
|
260
|
+
display: flex;
|
|
261
|
+
gap: 0.5em;
|
|
262
|
+
margin-bottom: 1em;
|
|
263
|
+
}
|
|
264
|
+
.search-bar input {
|
|
265
|
+
flex: 1;
|
|
266
|
+
padding: 0.6em 1em;
|
|
267
|
+
border: 1px solid #555;
|
|
268
|
+
border-radius: 6px;
|
|
269
|
+
background: #2a2a2a;
|
|
270
|
+
color: var(--primary-text-color);
|
|
271
|
+
font-size: 0.9em;
|
|
272
|
+
}
|
|
273
|
+
.search-bar input::placeholder { color: #777; }
|
|
274
|
+
|
|
275
|
+
.data-table {
|
|
276
|
+
width: 100%;
|
|
277
|
+
border-collapse: collapse;
|
|
278
|
+
font-size: 0.85em;
|
|
279
|
+
}
|
|
280
|
+
.data-table th {
|
|
281
|
+
text-align: left;
|
|
282
|
+
padding: 0.7em 0.8em;
|
|
283
|
+
background: var(--section-background-color);
|
|
284
|
+
border-bottom: 2px solid #555;
|
|
285
|
+
font-weight: 600;
|
|
286
|
+
white-space: nowrap;
|
|
287
|
+
}
|
|
288
|
+
.data-table td {
|
|
289
|
+
padding: 0.6em 0.8em;
|
|
290
|
+
border-bottom: 1px solid #333;
|
|
291
|
+
vertical-align: middle;
|
|
292
|
+
}
|
|
293
|
+
.data-table tr:hover td { background: rgba(255,255,255,0.03); }
|
|
294
|
+
.data-table .mono {
|
|
295
|
+
font-family: Menlo, Monaco, 'Courier New', monospace;
|
|
296
|
+
font-size: 0.85em;
|
|
297
|
+
}
|
|
298
|
+
.data-table .truncate {
|
|
299
|
+
max-width: 200px;
|
|
300
|
+
overflow: hidden;
|
|
301
|
+
text-overflow: ellipsis;
|
|
302
|
+
white-space: nowrap;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.health-dot {
|
|
306
|
+
width: 10px;
|
|
307
|
+
height: 10px;
|
|
308
|
+
border-radius: 50%;
|
|
309
|
+
display: inline-block;
|
|
310
|
+
margin-right: 0.4em;
|
|
311
|
+
}
|
|
312
|
+
.health-dot.green { background: var(--success-color); }
|
|
313
|
+
.health-dot.yellow { background: var(--warning-color); }
|
|
314
|
+
.health-dot.red { background: var(--danger-color); }
|
|
315
|
+
.health-dot.gray { background: #666; }
|
|
316
|
+
|
|
317
|
+
.pagination {
|
|
318
|
+
display: flex;
|
|
319
|
+
align-items: center;
|
|
320
|
+
gap: 0.5em;
|
|
321
|
+
margin-top: 1em;
|
|
322
|
+
justify-content: center;
|
|
323
|
+
}
|
|
324
|
+
.pagination .page-info { color: #999; font-size: 0.85em; }
|
|
325
|
+
|
|
326
|
+
.toast-container {
|
|
327
|
+
position: fixed;
|
|
328
|
+
top: 1em;
|
|
329
|
+
right: 1em;
|
|
330
|
+
z-index: 9999;
|
|
331
|
+
display: flex;
|
|
332
|
+
flex-direction: column;
|
|
333
|
+
gap: 0.5em;
|
|
334
|
+
}
|
|
335
|
+
.toast {
|
|
336
|
+
padding: 0.8em 1.2em;
|
|
337
|
+
border-radius: 8px;
|
|
338
|
+
font-size: 0.85em;
|
|
339
|
+
font-weight: 500;
|
|
340
|
+
animation: slideIn 0.3s ease;
|
|
341
|
+
max-width: 400px;
|
|
342
|
+
}
|
|
343
|
+
.toast.success { background: var(--success-color); color: white; }
|
|
344
|
+
.toast.error { background: var(--danger-color); color: white; }
|
|
345
|
+
.toast.info { background: var(--info-color); color: white; }
|
|
346
|
+
@keyframes slideIn { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0); } }
|
|
347
|
+
|
|
348
|
+
.loading { color: #999; font-style: italic; padding: 2em; text-align: center; }
|
|
349
|
+
.empty-state { color: #777; text-align: center; padding: 3em 1em; }
|
|
350
|
+
.empty-state p { font-size: 1.1em; }
|
|
351
|
+
|
|
352
|
+
.admin-form-row {
|
|
353
|
+
display: flex; gap: 0.5em; align-items: center; margin-bottom: 1em; flex-wrap: wrap;
|
|
354
|
+
}
|
|
355
|
+
.admin-form-row select, .admin-form-row input {
|
|
356
|
+
padding: 0.6em 1em;
|
|
357
|
+
border: 1px solid #555;
|
|
358
|
+
border-radius: 6px;
|
|
359
|
+
background: #2a2a2a;
|
|
360
|
+
color: var(--primary-text-color);
|
|
361
|
+
font-size: 0.9em;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.health-result-card {
|
|
365
|
+
background: var(--section-background-color);
|
|
366
|
+
border-radius: 10px;
|
|
367
|
+
padding: 1.5em;
|
|
368
|
+
margin-top: 1em;
|
|
369
|
+
}
|
|
370
|
+
.health-result-card h3 { margin-top: 0; }
|
|
371
|
+
.health-result-row {
|
|
372
|
+
display: flex; justify-content: space-between; padding: 0.4em 0;
|
|
373
|
+
border-bottom: 1px solid #444;
|
|
374
|
+
}
|
|
375
|
+
.health-result-row:last-child { border-bottom: none; }
|
|
376
|
+
|
|
377
|
+
.confirm-overlay {
|
|
378
|
+
position: fixed; top: 0; left: 0; right: 0; bottom: 0;
|
|
379
|
+
background: rgba(0,0,0,0.6); z-index: 9998;
|
|
380
|
+
display: flex; align-items: center; justify-content: center;
|
|
381
|
+
}
|
|
382
|
+
.confirm-dialog {
|
|
383
|
+
background: #2a2a2a; border-radius: 12px; padding: 2em;
|
|
384
|
+
max-width: 420px; width: 90%;
|
|
385
|
+
}
|
|
386
|
+
.confirm-dialog h3 { margin-top: 0; }
|
|
387
|
+
.confirm-dialog .actions { display: flex; gap: 0.5em; justify-content: flex-end; margin-top: 1.5em; }
|
|
388
|
+
|
|
389
|
+
.badge {
|
|
390
|
+
display: inline-block;
|
|
391
|
+
padding: 0.15em 0.5em;
|
|
392
|
+
border-radius: 4px;
|
|
393
|
+
font-size: 0.75em;
|
|
394
|
+
font-weight: 600;
|
|
395
|
+
}
|
|
396
|
+
.badge-domain { background: #1e40af; color: white; }
|
|
397
|
+
.badge-outpoint { background: #7c3aed; color: white; }
|
|
398
|
+
|
|
399
|
+
@media screen and (max-width: 850px) {
|
|
400
|
+
.main { flex-direction: column; }
|
|
401
|
+
.column_left { max-height: 30vh; min-width: unset; }
|
|
402
|
+
.column_left, .column_right { width: 90%; margin: 0; padding: 0 5%; }
|
|
403
|
+
#documentation_container, .admin-panel, .admin-login { margin: 0; padding: 0; }
|
|
404
|
+
.stats-grid { grid-template-columns: repeat(2, 1fr); }
|
|
244
405
|
}
|
|
245
406
|
|
|
246
407
|
${additionalStyles}
|
|
@@ -250,11 +411,15 @@ export default (config: UIConfig = {}): string => {
|
|
|
250
411
|
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.7.0/build/highlight.min.js"></script>
|
|
251
412
|
<script>
|
|
252
413
|
const faviconUrl = '${faviconUrl}';
|
|
414
|
+
const HOST = '${host}';
|
|
415
|
+
const CONFIGURED_ADMIN_IDENTITY_KEY = '${adminIdentityKey}';
|
|
253
416
|
|
|
417
|
+
/* ==========================================
|
|
418
|
+
MARKDOWN CONVERTER
|
|
419
|
+
========================================== */
|
|
254
420
|
const showdown = window.showdown;
|
|
255
421
|
window.hljs.configure({ languages: ['typescript', 'javascript', 'json', 'html', 'css', 'bash', 'markdown'] });
|
|
256
422
|
|
|
257
|
-
|
|
258
423
|
const Convert = (md) => {
|
|
259
424
|
let converter = new showdown.Converter({
|
|
260
425
|
ghCompatibleHeaderId: true,
|
|
@@ -266,23 +431,17 @@ export default (config: UIConfig = {}): string => {
|
|
|
266
431
|
parseImgDimensions: true,
|
|
267
432
|
simplifiedAutoLink: true
|
|
268
433
|
});
|
|
269
|
-
// Set to use GitHub flavor markdown
|
|
270
434
|
converter.setFlavor('github');
|
|
271
|
-
|
|
272
|
-
// Set language detection for code blocks
|
|
273
435
|
converter.setOption('ghCodeBlocks', true);
|
|
274
436
|
converter.setOption('omitExtraWLInCodeBlocks', true);
|
|
275
437
|
converter.setOption('literalMidWordUnderscores', true);
|
|
276
438
|
converter.setOption('parseImgDimensions', true);
|
|
277
|
-
|
|
278
|
-
// Add custom extension for adding language-specific class to code blocks
|
|
279
439
|
const codeExtension = () => [
|
|
280
440
|
{
|
|
281
441
|
type: 'output',
|
|
282
442
|
filter: function(text) {
|
|
283
|
-
return text.replace(/<pre><code
|
|
443
|
+
return text.replace(/<pre><code\\s*class="([^"]*)">(.*?)<\\/code><\\/pre>/gs, function(match, language, content) {
|
|
284
444
|
if (language) {
|
|
285
|
-
// Clean up the language identifier
|
|
286
445
|
const lang = language.replace('language-', '').trim();
|
|
287
446
|
return \`<pre data-language="\${lang}"><code class="language-\${lang} hljs">\${content}</code></pre>\`;
|
|
288
447
|
} else {
|
|
@@ -292,148 +451,666 @@ export default (config: UIConfig = {}): string => {
|
|
|
292
451
|
}
|
|
293
452
|
}
|
|
294
453
|
];
|
|
295
|
-
|
|
296
|
-
// Add the extension
|
|
297
454
|
converter.addExtension(codeExtension());
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return html;
|
|
455
|
+
return converter.makeHtml(md);
|
|
301
456
|
};
|
|
302
457
|
|
|
303
|
-
window.returnHome = () => {
|
|
304
|
-
if (!window.defaultHtml) {
|
|
305
|
-
let newStuff = Convert(${defaultContent});
|
|
306
|
-
window.defaultHtml = newStuff;
|
|
307
|
-
}
|
|
308
|
-
document.getElementById('documentation_container').innerHTML = window.defaultHtml;
|
|
309
|
-
window.location.hash = '';
|
|
310
|
-
document.querySelectorAll('.list-item a').forEach(item => {
|
|
311
|
-
item.classList.remove('active');
|
|
312
|
-
});
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
// Function to apply syntax highlighting after content is inserted
|
|
316
458
|
const applyHighlighting = () => {
|
|
317
459
|
document.querySelectorAll('pre code').forEach(block => {
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
// Check for language class
|
|
321
|
-
const classList = Array.from(blockElement.classList);
|
|
460
|
+
const classList = Array.from(block.classList);
|
|
322
461
|
const langClass = classList.find(cls => cls.startsWith('language-'));
|
|
323
|
-
|
|
324
462
|
if (langClass) {
|
|
325
463
|
const language = langClass.replace('language-', '');
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if (preElement) {
|
|
329
|
-
preElement.setAttribute('data-language', language);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// Apply highlighting to all code blocks
|
|
334
|
-
try {
|
|
335
|
-
// @ts-ignore - hljs is loaded from CDN
|
|
336
|
-
window.hljs.highlightElement(blockElement);
|
|
337
|
-
} catch (e) {
|
|
338
|
-
console.error('Error highlighting code:', e);
|
|
464
|
+
const preElement = block.parentElement;
|
|
465
|
+
if (preElement) { preElement.setAttribute('data-language', language); }
|
|
339
466
|
}
|
|
467
|
+
try { window.hljs.highlightElement(block); } catch (e) {}
|
|
340
468
|
});
|
|
341
469
|
};
|
|
342
470
|
|
|
471
|
+
/* ==========================================
|
|
472
|
+
DOCUMENTATION NAVIGATION
|
|
473
|
+
========================================== */
|
|
343
474
|
let managersData = {};
|
|
344
475
|
let providersData = {};
|
|
345
476
|
|
|
346
|
-
|
|
477
|
+
window.returnHome = () => {
|
|
478
|
+
if (!window.defaultHtml) {
|
|
479
|
+
window.defaultHtml = Convert(${defaultContent});
|
|
480
|
+
}
|
|
481
|
+
document.getElementById('documentation_container').innerHTML = window.defaultHtml;
|
|
482
|
+
document.getElementById('documentation_container').style.display = '';
|
|
483
|
+
document.getElementById('admin_content').style.display = 'none';
|
|
484
|
+
window.location.hash = '';
|
|
485
|
+
document.querySelectorAll('.list-item a').forEach(item => item.classList.remove('active'));
|
|
486
|
+
};
|
|
487
|
+
|
|
347
488
|
const updateSelectedItem = (type, id) => {
|
|
348
|
-
// Update URL hash
|
|
349
489
|
window.location.hash = \`\${type}/\${id}\`;
|
|
350
|
-
|
|
351
|
-
// Remove active class from all list items
|
|
352
|
-
document.querySelectorAll('.list-item a').forEach(item => {
|
|
353
|
-
item.classList.remove('active');
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
// Add active class to selected item
|
|
490
|
+
document.querySelectorAll('.list-item a').forEach(item => item.classList.remove('active'));
|
|
357
491
|
const selector = \`[data-\${type}="\${id}"]\`;
|
|
358
492
|
const selectedItem = document.querySelector(selector);
|
|
359
|
-
if (selectedItem)
|
|
360
|
-
selectedItem.classList.add('active');
|
|
361
|
-
}
|
|
493
|
+
if (selectedItem) selectedItem.classList.add('active');
|
|
362
494
|
};
|
|
363
495
|
|
|
364
|
-
// @ts-ignore - Adding custom property to window
|
|
365
496
|
window.managerDocumentation = async (manager) => {
|
|
366
497
|
try {
|
|
367
|
-
|
|
498
|
+
document.getElementById('documentation_container').style.display = '';
|
|
499
|
+
document.getElementById('admin_content').style.display = 'none';
|
|
500
|
+
let res = await fetch(\`\${HOST}/getDocumentationForTopicManager?manager=\${manager}\`);
|
|
368
501
|
let docs = await res.text();
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
let managerData = managersData[manager];
|
|
372
|
-
let iconURL = managerData.iconURL || faviconUrl;
|
|
373
|
-
|
|
374
|
-
document.getElementById('documentation_container').innerHTML = managerReadme;
|
|
502
|
+
document.getElementById('documentation_container').innerHTML = Convert(docs);
|
|
375
503
|
applyHighlighting();
|
|
376
|
-
|
|
377
|
-
// Update active item and URL
|
|
378
504
|
updateSelectedItem('manager', manager);
|
|
379
|
-
} catch (error) {
|
|
380
|
-
console.error('Error fetching manager documentation:', error);
|
|
381
|
-
}
|
|
505
|
+
} catch (error) { console.error('Error fetching manager documentation:', error); }
|
|
382
506
|
};
|
|
383
507
|
|
|
384
|
-
// @ts-ignore - Adding custom property to window
|
|
385
508
|
window.topicDocumentation = async (provider) => {
|
|
386
509
|
try {
|
|
387
|
-
|
|
510
|
+
document.getElementById('documentation_container').style.display = '';
|
|
511
|
+
document.getElementById('admin_content').style.display = 'none';
|
|
512
|
+
let res = await fetch(\`\${HOST}/getDocumentationForLookupServiceProvider?lookupService=\${provider}\`);
|
|
388
513
|
let docs = await res.text();
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
let providerData = providersData[provider];
|
|
392
|
-
let iconURL = providerData.iconURL || faviconUrl;
|
|
393
|
-
|
|
394
|
-
document.getElementById('documentation_container').innerHTML = providerReadme;
|
|
514
|
+
document.getElementById('documentation_container').innerHTML = Convert(docs);
|
|
395
515
|
applyHighlighting();
|
|
396
|
-
|
|
397
|
-
// Update active item and URL
|
|
398
516
|
updateSelectedItem('provider', provider);
|
|
399
|
-
} catch (error) {
|
|
400
|
-
|
|
517
|
+
} catch (error) { console.error('Error fetching provider documentation:', error); }
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
/* ==========================================
|
|
521
|
+
TOAST NOTIFICATIONS
|
|
522
|
+
========================================== */
|
|
523
|
+
function showToast(message, type = 'info') {
|
|
524
|
+
const container = document.getElementById('toast_container');
|
|
525
|
+
const toast = document.createElement('div');
|
|
526
|
+
toast.className = \`toast \${type}\`;
|
|
527
|
+
toast.textContent = message;
|
|
528
|
+
container.appendChild(toast);
|
|
529
|
+
setTimeout(() => { toast.style.opacity = '0'; setTimeout(() => toast.remove(), 300); }, 4000);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/* ==========================================
|
|
533
|
+
ADMIN DASHBOARD
|
|
534
|
+
========================================== */
|
|
535
|
+
const Admin = {
|
|
536
|
+
token: null,
|
|
537
|
+
isAdmin: false,
|
|
538
|
+
|
|
539
|
+
walletAuthMode: false,
|
|
540
|
+
authFetch: null,
|
|
541
|
+
|
|
542
|
+
init() {
|
|
543
|
+
this.token = sessionStorage.getItem('adminToken');
|
|
544
|
+
if (this.token) {
|
|
545
|
+
this.isAdmin = true;
|
|
546
|
+
this.showAdminSection();
|
|
547
|
+
}
|
|
548
|
+
this.tryWalletDetection();
|
|
549
|
+
},
|
|
550
|
+
|
|
551
|
+
async tryWalletDetection() {
|
|
552
|
+
try {
|
|
553
|
+
// Dynamically import WalletClient from the BSV SDK
|
|
554
|
+
// This works when the user has a wallet extension installed
|
|
555
|
+
const { WalletClient } = await import('https://cdn.jsdelivr.net/npm/@bsv/sdk@2/+esm');
|
|
556
|
+
const wallet = new WalletClient('auto', window.location.origin);
|
|
557
|
+
const { publicKey } = await wallet.getPublicKey({ identityKey: true });
|
|
558
|
+
|
|
559
|
+
// Fetch the server's admin config to compare identity keys
|
|
560
|
+
const configRes = await fetch(HOST + '/admin/config');
|
|
561
|
+
const config = await configRes.json();
|
|
562
|
+
|
|
563
|
+
if (config.adminIdentityKey && publicKey === config.adminIdentityKey) {
|
|
564
|
+
// Identity matches the admin key - create AuthFetch for authenticated requests
|
|
565
|
+
const { AuthFetch } = await import('https://cdn.jsdelivr.net/npm/@bsv/sdk@2/+esm');
|
|
566
|
+
this.authFetch = new AuthFetch(wallet);
|
|
567
|
+
this.walletAuthMode = true;
|
|
568
|
+
this.isAdmin = true;
|
|
569
|
+
this.showAdminSection();
|
|
570
|
+
showToast('Wallet detected - admin access granted', 'success');
|
|
571
|
+
}
|
|
572
|
+
} catch (e) {
|
|
573
|
+
// Wallet not available or identity doesn't match - fall back to token auth
|
|
574
|
+
}
|
|
575
|
+
},
|
|
576
|
+
|
|
577
|
+
showAdminSection() {
|
|
578
|
+
document.getElementById('admin_section').classList.add('visible');
|
|
579
|
+
},
|
|
580
|
+
|
|
581
|
+
async login(token) {
|
|
582
|
+
// Verify token by making a test request
|
|
583
|
+
try {
|
|
584
|
+
const res = await fetch(\`\${HOST}/admin/stats\`, {
|
|
585
|
+
headers: { 'Authorization': \`Bearer \${token}\` }
|
|
586
|
+
});
|
|
587
|
+
if (res.ok) {
|
|
588
|
+
this.token = token;
|
|
589
|
+
this.isAdmin = true;
|
|
590
|
+
sessionStorage.setItem('adminToken', token);
|
|
591
|
+
this.showAdminSection();
|
|
592
|
+
showToast('Admin login successful', 'success');
|
|
593
|
+
return true;
|
|
594
|
+
} else {
|
|
595
|
+
showToast('Invalid admin token', 'error');
|
|
596
|
+
return false;
|
|
597
|
+
}
|
|
598
|
+
} catch (e) {
|
|
599
|
+
showToast('Connection error', 'error');
|
|
600
|
+
return false;
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
|
|
604
|
+
logout() {
|
|
605
|
+
this.token = null;
|
|
606
|
+
this.isAdmin = false;
|
|
607
|
+
this.walletAuthMode = false;
|
|
608
|
+
this.authFetch = null;
|
|
609
|
+
sessionStorage.removeItem('adminToken');
|
|
610
|
+
document.getElementById('admin_section').classList.remove('visible');
|
|
611
|
+
window.returnHome();
|
|
612
|
+
showToast('Logged out', 'info');
|
|
613
|
+
},
|
|
614
|
+
|
|
615
|
+
async api(method, path, body) {
|
|
616
|
+
if (!this.token && !this.walletAuthMode) { showToast('Not authenticated', 'error'); return null; }
|
|
617
|
+
try {
|
|
618
|
+
const url = \`\${HOST || window.location.origin}\${path}\`;
|
|
619
|
+
|
|
620
|
+
// Use AuthFetch (BSV mutual auth) when wallet auth is active
|
|
621
|
+
if (this.walletAuthMode && this.authFetch) {
|
|
622
|
+
const opts = { method, headers: { 'Content-Type': 'application/json' } };
|
|
623
|
+
if (body) opts.body = JSON.stringify(body);
|
|
624
|
+
const res = await this.authFetch.fetch(url, opts);
|
|
625
|
+
const data = await res.json();
|
|
626
|
+
if (data.status === 'error') { showToast(data.message, 'error'); }
|
|
627
|
+
return data;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// Fall back to Bearer token auth
|
|
631
|
+
const opts = {
|
|
632
|
+
method,
|
|
633
|
+
headers: {
|
|
634
|
+
'Authorization': \`Bearer \${this.token}\`,
|
|
635
|
+
'Content-Type': 'application/json'
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
if (body) opts.body = JSON.stringify(body);
|
|
639
|
+
const res = await fetch(url, opts);
|
|
640
|
+
const data = await res.json();
|
|
641
|
+
if (data.status === 'error') { showToast(data.message, 'error'); }
|
|
642
|
+
return data;
|
|
643
|
+
} catch (e) { showToast('Request failed: ' + e.message, 'error'); return null; }
|
|
644
|
+
},
|
|
645
|
+
|
|
646
|
+
/* ---------- Dashboard Overview ---------- */
|
|
647
|
+
async showOverview() {
|
|
648
|
+
switchToAdmin('admin-overview');
|
|
649
|
+
const container = document.getElementById('admin_content');
|
|
650
|
+
container.innerHTML = '<div class="loading">Loading dashboard...</div>';
|
|
651
|
+
const result = await this.api('GET', '/admin/stats');
|
|
652
|
+
if (!result || result.status !== 'success') return;
|
|
653
|
+
const d = result.data;
|
|
654
|
+
const uptime = d.uptime ? formatDuration(d.uptime) : 'N/A';
|
|
655
|
+
container.innerHTML = \`
|
|
656
|
+
<div class="admin-panel">
|
|
657
|
+
<h2>Dashboard Overview</h2>
|
|
658
|
+
<p class="subtitle">\${d.nodeName} on \${d.network}net — uptime: \${uptime}</p>
|
|
659
|
+
<div class="stats-grid">
|
|
660
|
+
<div class="stat-card"><div class="stat-label">SHIP Records</div><div class="stat-value info">\${d.shipRecordCount}</div></div>
|
|
661
|
+
<div class="stat-card"><div class="stat-label">SLAP Records</div><div class="stat-value info">\${d.slapRecordCount}</div></div>
|
|
662
|
+
<div class="stat-card"><div class="stat-label">Banned Domains</div><div class="stat-value \${d.bannedDomains > 0 ? 'warning' : 'success'}">\${d.bannedDomains}</div></div>
|
|
663
|
+
<div class="stat-card"><div class="stat-label">Banned Outpoints</div><div class="stat-value \${d.bannedOutpoints > 0 ? 'warning' : 'success'}">\${d.bannedOutpoints}</div></div>
|
|
664
|
+
<div class="stat-card"><div class="stat-label">Topic Managers</div><div class="stat-value">\${d.topicManagers.length}</div></div>
|
|
665
|
+
<div class="stat-card"><div class="stat-label">Lookup Services</div><div class="stat-value">\${d.lookupServices.length}</div></div>
|
|
666
|
+
</div>
|
|
667
|
+
<h3>Quick Actions</h3>
|
|
668
|
+
<div class="action-bar">
|
|
669
|
+
<button class="btn btn-primary" onclick="Admin.runJanitor()">Run Janitor</button>
|
|
670
|
+
<button class="btn btn-primary" onclick="Admin.syncAds()">Sync Advertisements</button>
|
|
671
|
+
\${d.gaspSyncEnabled ? '<button class="btn btn-primary" onclick="Admin.gaspSync()">GASP Sync</button>' : ''}
|
|
672
|
+
</div>
|
|
673
|
+
<h3>Hosted Topics</h3>
|
|
674
|
+
<p style="color:#999">\${d.topicManagers.join(', ')}</p>
|
|
675
|
+
<h3>Hosted Lookup Services</h3>
|
|
676
|
+
<p style="color:#999">\${d.lookupServices.join(', ')}</p>
|
|
677
|
+
</div>
|
|
678
|
+
\`;
|
|
679
|
+
},
|
|
680
|
+
|
|
681
|
+
/* ---------- SHIP Records ---------- */
|
|
682
|
+
shipPage: 1,
|
|
683
|
+
shipSearch: '',
|
|
684
|
+
async showShipRecords(page, search) {
|
|
685
|
+
switchToAdmin('admin-ship');
|
|
686
|
+
this.shipPage = page || 1;
|
|
687
|
+
this.shipSearch = typeof search === 'string' ? search : this.shipSearch;
|
|
688
|
+
const container = document.getElementById('admin_content');
|
|
689
|
+
container.innerHTML = '<div class="loading">Loading SHIP records...</div>';
|
|
690
|
+
const qs = \`?page=\${this.shipPage}&limit=30\${this.shipSearch ? '&search=' + encodeURIComponent(this.shipSearch) : ''}\`;
|
|
691
|
+
const result = await this.api('GET', '/admin/ship-records' + qs);
|
|
692
|
+
if (!result || result.status !== 'success') return;
|
|
693
|
+
const { records, total, page: pg, pages } = result.data;
|
|
694
|
+
container.innerHTML = \`
|
|
695
|
+
<div class="admin-panel">
|
|
696
|
+
<h2>SHIP Records</h2>
|
|
697
|
+
<p class="subtitle">Hosts advertising topic managers (\${total} total)</p>
|
|
698
|
+
<div class="search-bar">
|
|
699
|
+
<input type="text" id="ship_search" placeholder="Search by domain, topic, txid, or identity key..." value="\${escHtml(this.shipSearch)}" onkeydown="if(event.key==='Enter')Admin.showShipRecords(1,this.value)" />
|
|
700
|
+
<button class="btn btn-primary" onclick="Admin.showShipRecords(1,document.getElementById('ship_search').value)">Search</button>
|
|
701
|
+
</div>
|
|
702
|
+
\${records.length === 0 ? '<div class="empty-state"><p>No SHIP records found.</p></div>' : \`
|
|
703
|
+
<div style="overflow-x:auto">
|
|
704
|
+
<table class="data-table">
|
|
705
|
+
<thead>
|
|
706
|
+
<tr>
|
|
707
|
+
<th>Health</th>
|
|
708
|
+
<th>Domain</th>
|
|
709
|
+
<th>Topic</th>
|
|
710
|
+
<th>Identity Key</th>
|
|
711
|
+
<th>Outpoint</th>
|
|
712
|
+
<th>Created</th>
|
|
713
|
+
<th>Actions</th>
|
|
714
|
+
</tr>
|
|
715
|
+
</thead>
|
|
716
|
+
<tbody>
|
|
717
|
+
\${records.map(r => \`
|
|
718
|
+
<tr>
|
|
719
|
+
<td><span class="health-dot \${healthDotClass(r.down)}"></span>\${r.down ? 'Down: '+r.down : 'OK'}</td>
|
|
720
|
+
<td class="mono truncate" title="\${escHtml(r.domain)}">\${escHtml(r.domain)}</td>
|
|
721
|
+
<td>\${escHtml(r.topic)}</td>
|
|
722
|
+
<td class="mono truncate" title="\${escHtml(r.identityKey)}">\${escHtml((r.identityKey||'').substring(0,12))}...</td>
|
|
723
|
+
<td class="mono truncate" title="\${r.txid}.\${r.outputIndex}">\${r.txid.substring(0,8)}...\${r.outputIndex}</td>
|
|
724
|
+
<td>\${r.createdAt ? new Date(r.createdAt).toLocaleDateString() : 'N/A'}</td>
|
|
725
|
+
<td>
|
|
726
|
+
<button class="btn btn-sm btn-primary" onclick="Admin.healthCheck('\${escHtml(r.domain)}')">Ping</button>
|
|
727
|
+
<button class="btn btn-sm btn-danger" onclick="Admin.confirmRemoveToken('\${r.txid}', \${r.outputIndex}, '\${escHtml(r.domain)}')">Remove</button>
|
|
728
|
+
<button class="btn btn-sm btn-warning" onclick="Admin.confirmBanDomain('\${escHtml(r.domain)}')">Ban Host</button>
|
|
729
|
+
</td>
|
|
730
|
+
</tr>
|
|
731
|
+
\`).join('')}
|
|
732
|
+
</tbody>
|
|
733
|
+
</table>
|
|
734
|
+
</div>
|
|
735
|
+
<div class="pagination">
|
|
736
|
+
<button class="btn btn-sm btn-outline" \${pg <= 1 ? 'disabled' : ''} onclick="Admin.showShipRecords(\${pg - 1})">Prev</button>
|
|
737
|
+
<span class="page-info">Page \${pg} of \${pages}</span>
|
|
738
|
+
<button class="btn btn-sm btn-outline" \${pg >= pages ? 'disabled' : ''} onclick="Admin.showShipRecords(\${pg + 1})">Next</button>
|
|
739
|
+
</div>
|
|
740
|
+
\`}
|
|
741
|
+
</div>
|
|
742
|
+
\`;
|
|
743
|
+
},
|
|
744
|
+
|
|
745
|
+
/* ---------- SLAP Records ---------- */
|
|
746
|
+
slapPage: 1,
|
|
747
|
+
slapSearch: '',
|
|
748
|
+
async showSlapRecords(page, search) {
|
|
749
|
+
switchToAdmin('admin-slap');
|
|
750
|
+
this.slapPage = page || 1;
|
|
751
|
+
this.slapSearch = typeof search === 'string' ? search : this.slapSearch;
|
|
752
|
+
const container = document.getElementById('admin_content');
|
|
753
|
+
container.innerHTML = '<div class="loading">Loading SLAP records...</div>';
|
|
754
|
+
const qs = \`?page=\${this.slapPage}&limit=30\${this.slapSearch ? '&search=' + encodeURIComponent(this.slapSearch) : ''}\`;
|
|
755
|
+
const result = await this.api('GET', '/admin/slap-records' + qs);
|
|
756
|
+
if (!result || result.status !== 'success') return;
|
|
757
|
+
const { records, total, page: pg, pages } = result.data;
|
|
758
|
+
container.innerHTML = \`
|
|
759
|
+
<div class="admin-panel">
|
|
760
|
+
<h2>SLAP Records</h2>
|
|
761
|
+
<p class="subtitle">Hosts advertising lookup services (\${total} total)</p>
|
|
762
|
+
<div class="search-bar">
|
|
763
|
+
<input type="text" id="slap_search" placeholder="Search by domain, service, txid, or identity key..." value="\${escHtml(this.slapSearch)}" onkeydown="if(event.key==='Enter')Admin.showSlapRecords(1,this.value)" />
|
|
764
|
+
<button class="btn btn-primary" onclick="Admin.showSlapRecords(1,document.getElementById('slap_search').value)">Search</button>
|
|
765
|
+
</div>
|
|
766
|
+
\${records.length === 0 ? '<div class="empty-state"><p>No SLAP records found.</p></div>' : \`
|
|
767
|
+
<div style="overflow-x:auto">
|
|
768
|
+
<table class="data-table">
|
|
769
|
+
<thead>
|
|
770
|
+
<tr>
|
|
771
|
+
<th>Health</th>
|
|
772
|
+
<th>Domain</th>
|
|
773
|
+
<th>Service</th>
|
|
774
|
+
<th>Identity Key</th>
|
|
775
|
+
<th>Outpoint</th>
|
|
776
|
+
<th>Created</th>
|
|
777
|
+
<th>Actions</th>
|
|
778
|
+
</tr>
|
|
779
|
+
</thead>
|
|
780
|
+
<tbody>
|
|
781
|
+
\${records.map(r => \`
|
|
782
|
+
<tr>
|
|
783
|
+
<td><span class="health-dot \${healthDotClass(r.down)}"></span>\${r.down ? 'Down: '+r.down : 'OK'}</td>
|
|
784
|
+
<td class="mono truncate" title="\${escHtml(r.domain)}">\${escHtml(r.domain)}</td>
|
|
785
|
+
<td>\${escHtml(r.service)}</td>
|
|
786
|
+
<td class="mono truncate" title="\${escHtml(r.identityKey)}">\${escHtml((r.identityKey||'').substring(0,12))}...</td>
|
|
787
|
+
<td class="mono truncate" title="\${r.txid}.\${r.outputIndex}">\${r.txid.substring(0,8)}...\${r.outputIndex}</td>
|
|
788
|
+
<td>\${r.createdAt ? new Date(r.createdAt).toLocaleDateString() : 'N/A'}</td>
|
|
789
|
+
<td>
|
|
790
|
+
<button class="btn btn-sm btn-primary" onclick="Admin.healthCheck('\${escHtml(r.domain)}')">Ping</button>
|
|
791
|
+
<button class="btn btn-sm btn-danger" onclick="Admin.confirmRemoveToken('\${r.txid}', \${r.outputIndex}, '\${escHtml(r.domain)}')">Remove</button>
|
|
792
|
+
<button class="btn btn-sm btn-warning" onclick="Admin.confirmBanDomain('\${escHtml(r.domain)}')">Ban Host</button>
|
|
793
|
+
</td>
|
|
794
|
+
</tr>
|
|
795
|
+
\`).join('')}
|
|
796
|
+
</tbody>
|
|
797
|
+
</table>
|
|
798
|
+
</div>
|
|
799
|
+
<div class="pagination">
|
|
800
|
+
<button class="btn btn-sm btn-outline" \${pg <= 1 ? 'disabled' : ''} onclick="Admin.showSlapRecords(\${pg - 1})">Prev</button>
|
|
801
|
+
<span class="page-info">Page \${pg} of \${pages}</span>
|
|
802
|
+
<button class="btn btn-sm btn-outline" \${pg >= pages ? 'disabled' : ''} onclick="Admin.showSlapRecords(\${pg + 1})">Next</button>
|
|
803
|
+
</div>
|
|
804
|
+
\`}
|
|
805
|
+
</div>
|
|
806
|
+
\`;
|
|
807
|
+
},
|
|
808
|
+
|
|
809
|
+
/* ---------- Ban List ---------- */
|
|
810
|
+
async showBanList() {
|
|
811
|
+
switchToAdmin('admin-bans');
|
|
812
|
+
const container = document.getElementById('admin_content');
|
|
813
|
+
container.innerHTML = '<div class="loading">Loading ban list...</div>';
|
|
814
|
+
const result = await this.api('GET', '/admin/bans');
|
|
815
|
+
if (!result || result.status !== 'success') return;
|
|
816
|
+
const bans = result.data.bans || [];
|
|
817
|
+
const domainBans = bans.filter(b => b.type === 'domain');
|
|
818
|
+
const outpointBans = bans.filter(b => b.type === 'outpoint');
|
|
819
|
+
container.innerHTML = \`
|
|
820
|
+
<div class="admin-panel">
|
|
821
|
+
<h2>Ban List</h2>
|
|
822
|
+
<p class="subtitle">Banned domains and outpoints are blocked from being re-synced via GASP (\${bans.length} total)</p>
|
|
823
|
+
<h3>Add Ban</h3>
|
|
824
|
+
<div class="admin-form-row">
|
|
825
|
+
<select id="ban_type"><option value="domain">Domain</option><option value="outpoint">Outpoint</option></select>
|
|
826
|
+
<input type="text" id="ban_value" placeholder="e.g. https://dead-host.example.com or txid.outputIndex" style="flex:1" />
|
|
827
|
+
<input type="text" id="ban_reason" placeholder="Reason (optional)" style="width:200px" />
|
|
828
|
+
<button class="btn btn-danger" onclick="Admin.addBan()">Ban</button>
|
|
829
|
+
</div>
|
|
830
|
+
<h3>Banned Domains (\${domainBans.length})</h3>
|
|
831
|
+
\${domainBans.length === 0 ? '<p style="color:#777">No banned domains.</p>' : \`
|
|
832
|
+
<table class="data-table">
|
|
833
|
+
<thead><tr><th>Domain</th><th>Reason</th><th>Banned At</th><th>Actions</th></tr></thead>
|
|
834
|
+
<tbody>
|
|
835
|
+
\${domainBans.map(b => \`
|
|
836
|
+
<tr>
|
|
837
|
+
<td class="mono">\${escHtml(b.value)}</td>
|
|
838
|
+
<td>\${escHtml(b.reason || 'N/A')}</td>
|
|
839
|
+
<td>\${new Date(b.bannedAt).toLocaleString()}</td>
|
|
840
|
+
<td><button class="btn btn-sm btn-success" onclick="Admin.unban('domain','\${escHtml(b.value)}')">Unban</button></td>
|
|
841
|
+
</tr>
|
|
842
|
+
\`).join('')}
|
|
843
|
+
</tbody>
|
|
844
|
+
</table>\`}
|
|
845
|
+
<h3 style="margin-top:2em">Banned Outpoints (\${outpointBans.length})</h3>
|
|
846
|
+
\${outpointBans.length === 0 ? '<p style="color:#777">No banned outpoints.</p>' : \`
|
|
847
|
+
<table class="data-table">
|
|
848
|
+
<thead><tr><th>Outpoint</th><th>Domain</th><th>Reason</th><th>Banned At</th><th>Actions</th></tr></thead>
|
|
849
|
+
<tbody>
|
|
850
|
+
\${outpointBans.map(b => \`
|
|
851
|
+
<tr>
|
|
852
|
+
<td class="mono truncate" title="\${escHtml(b.value)}">\${escHtml(b.value.substring(0,20))}...</td>
|
|
853
|
+
<td class="mono">\${escHtml(b.domain || 'N/A')}</td>
|
|
854
|
+
<td>\${escHtml(b.reason || 'N/A')}</td>
|
|
855
|
+
<td>\${new Date(b.bannedAt).toLocaleString()}</td>
|
|
856
|
+
<td><button class="btn btn-sm btn-success" onclick="Admin.unban('outpoint','\${escHtml(b.value)}')">Unban</button></td>
|
|
857
|
+
</tr>
|
|
858
|
+
\`).join('')}
|
|
859
|
+
</tbody>
|
|
860
|
+
</table>\`}
|
|
861
|
+
</div>
|
|
862
|
+
\`;
|
|
863
|
+
},
|
|
864
|
+
|
|
865
|
+
/* ---------- Health Checker ---------- */
|
|
866
|
+
async showHealthChecker() {
|
|
867
|
+
switchToAdmin('admin-health');
|
|
868
|
+
const container = document.getElementById('admin_content');
|
|
869
|
+
container.innerHTML = \`
|
|
870
|
+
<div class="admin-panel">
|
|
871
|
+
<h2>Health Checker</h2>
|
|
872
|
+
<p class="subtitle">Ping a host's /health endpoint to verify it is online</p>
|
|
873
|
+
<div class="admin-form-row">
|
|
874
|
+
<input type="text" id="health_url" placeholder="https://overlay-host.example.com" style="flex:1" onkeydown="if(event.key==='Enter')Admin.healthCheck(this.value)" />
|
|
875
|
+
<button class="btn btn-primary" onclick="Admin.healthCheck(document.getElementById('health_url').value)">Check Health</button>
|
|
876
|
+
</div>
|
|
877
|
+
<div id="health_results"></div>
|
|
878
|
+
</div>
|
|
879
|
+
\`;
|
|
880
|
+
},
|
|
881
|
+
|
|
882
|
+
async healthCheck(url) {
|
|
883
|
+
if (!url) return;
|
|
884
|
+
showToast('Checking health of ' + url + '...', 'info');
|
|
885
|
+
const result = await this.api('POST', '/admin/health-check', { url });
|
|
886
|
+
if (!result || result.status !== 'success') return;
|
|
887
|
+
const d = result.data;
|
|
888
|
+
const resultsEl = document.getElementById('health_results');
|
|
889
|
+
if (resultsEl) {
|
|
890
|
+
resultsEl.innerHTML = \`
|
|
891
|
+
<div class="health-result-card">
|
|
892
|
+
<h3><span class="health-dot \${d.healthy ? 'green' : 'red'}"></span>\${d.healthy ? 'Healthy' : 'Unhealthy'}</h3>
|
|
893
|
+
<div class="health-result-row"><span>URL</span><span class="mono">\${escHtml(d.url)}</span></div>
|
|
894
|
+
<div class="health-result-row"><span>Response Time</span><span>\${d.responseTimeMs}ms</span></div>
|
|
895
|
+
\${d.statusCode ? \`<div class="health-result-row"><span>Status Code</span><span>\${d.statusCode}</span></div>\` : ''}
|
|
896
|
+
\${d.error ? \`<div class="health-result-row"><span>Error</span><span style="color:var(--danger-color)">\${escHtml(d.error)}</span></div>\` : ''}
|
|
897
|
+
</div>
|
|
898
|
+
\`;
|
|
899
|
+
} else {
|
|
900
|
+
showToast(url + ' is ' + (d.healthy ? 'HEALTHY' : 'UNHEALTHY') + ' (' + d.responseTimeMs + 'ms)', d.healthy ? 'success' : 'error');
|
|
901
|
+
}
|
|
902
|
+
},
|
|
903
|
+
|
|
904
|
+
/* ---------- Actions ---------- */
|
|
905
|
+
async runJanitor() {
|
|
906
|
+
showToast('Running janitor...', 'info');
|
|
907
|
+
const result = await this.api('POST', '/admin/janitor');
|
|
908
|
+
if (!result || result.status !== 'success') return;
|
|
909
|
+
const s = result.data?.summary;
|
|
910
|
+
if (s) {
|
|
911
|
+
showToast(\`Janitor complete: \${s.totalChecked} checked, \${s.healthy} healthy, \${s.unhealthy} unhealthy, \${s.removed} removed, \${s.banned} banned\`, 'success');
|
|
912
|
+
} else {
|
|
913
|
+
showToast('Janitor run completed', 'success');
|
|
914
|
+
}
|
|
915
|
+
},
|
|
916
|
+
|
|
917
|
+
async syncAds() {
|
|
918
|
+
showToast('Syncing advertisements...', 'info');
|
|
919
|
+
const result = await this.api('POST', '/admin/syncAdvertisements');
|
|
920
|
+
if (result && result.status === 'success') showToast('Advertisements synced', 'success');
|
|
921
|
+
},
|
|
922
|
+
|
|
923
|
+
async gaspSync() {
|
|
924
|
+
showToast('Starting GASP sync (this may take a while)...', 'info');
|
|
925
|
+
const result = await this.api('POST', '/admin/startGASPSync');
|
|
926
|
+
if (result && result.status === 'success') showToast('GASP sync completed', 'success');
|
|
927
|
+
},
|
|
928
|
+
|
|
929
|
+
async addBan() {
|
|
930
|
+
const type = document.getElementById('ban_type').value;
|
|
931
|
+
const value = document.getElementById('ban_value').value.trim();
|
|
932
|
+
const reason = document.getElementById('ban_reason').value.trim();
|
|
933
|
+
if (!value) { showToast('Value is required', 'error'); return; }
|
|
934
|
+
const result = await this.api('POST', '/admin/ban', { type, value, reason: reason || undefined });
|
|
935
|
+
if (result && result.status === 'success') {
|
|
936
|
+
showToast(result.message, 'success');
|
|
937
|
+
this.showBanList();
|
|
938
|
+
}
|
|
939
|
+
},
|
|
940
|
+
|
|
941
|
+
async unban(type, value) {
|
|
942
|
+
const result = await this.api('POST', '/admin/unban', { type, value });
|
|
943
|
+
if (result && result.status === 'success') {
|
|
944
|
+
showToast(result.message, 'success');
|
|
945
|
+
this.showBanList();
|
|
946
|
+
}
|
|
947
|
+
},
|
|
948
|
+
|
|
949
|
+
confirmRemoveToken(txid, outputIndex, domain) {
|
|
950
|
+
showConfirm(
|
|
951
|
+
'Remove Token',
|
|
952
|
+
\`Remove token <code>\${txid.substring(0,12)}...\${outputIndex}</code> from \${escHtml(domain)}?\`,
|
|
953
|
+
[
|
|
954
|
+
{ label: 'Remove Only', class: 'btn-danger', action: () => this.removeToken(txid, outputIndex, false, false) },
|
|
955
|
+
{ label: 'Remove & Ban Outpoint', class: 'btn-warning', action: () => this.removeToken(txid, outputIndex, true, false) },
|
|
956
|
+
{ label: 'Remove & Ban Domain', class: 'btn-warning', action: () => this.removeToken(txid, outputIndex, true, true) },
|
|
957
|
+
]
|
|
958
|
+
);
|
|
959
|
+
},
|
|
960
|
+
|
|
961
|
+
confirmBanDomain(domain) {
|
|
962
|
+
showConfirm(
|
|
963
|
+
'Ban Domain',
|
|
964
|
+
\`Ban <strong>\${escHtml(domain)}</strong>?<br><br>This will remove ALL SHIP and SLAP records for this domain and prevent GASP from re-syncing them.\`,
|
|
965
|
+
[
|
|
966
|
+
{ label: 'Ban Domain', class: 'btn-danger', action: () => this.banDomain(domain) },
|
|
967
|
+
]
|
|
968
|
+
);
|
|
969
|
+
},
|
|
970
|
+
|
|
971
|
+
async removeToken(txid, outputIndex, ban, banDomain) {
|
|
972
|
+
const result = await this.api('POST', '/admin/remove-token', { txid, outputIndex, ban, banDomain });
|
|
973
|
+
if (result && result.status === 'success') {
|
|
974
|
+
showToast(result.message, 'success');
|
|
975
|
+
// Refresh current view
|
|
976
|
+
const hash = window.location.hash.substring(1);
|
|
977
|
+
if (hash.startsWith('admin/ship')) this.showShipRecords(this.shipPage);
|
|
978
|
+
else if (hash.startsWith('admin/slap')) this.showSlapRecords(this.slapPage);
|
|
979
|
+
}
|
|
980
|
+
},
|
|
981
|
+
|
|
982
|
+
async banDomain(domain) {
|
|
983
|
+
const result = await this.api('POST', '/admin/ban', { type: 'domain', value: domain, reason: 'Manually banned by admin' });
|
|
984
|
+
if (result && result.status === 'success') {
|
|
985
|
+
showToast(result.message, 'success');
|
|
986
|
+
const hash = window.location.hash.substring(1);
|
|
987
|
+
if (hash.startsWith('admin/ship')) this.showShipRecords(this.shipPage);
|
|
988
|
+
else if (hash.startsWith('admin/slap')) this.showSlapRecords(this.slapPage);
|
|
989
|
+
else if (hash.startsWith('admin/ban')) this.showBanList();
|
|
990
|
+
}
|
|
401
991
|
}
|
|
402
992
|
};
|
|
403
993
|
|
|
404
|
-
|
|
994
|
+
/* ==========================================
|
|
995
|
+
HELPERS
|
|
996
|
+
========================================== */
|
|
997
|
+
function escHtml(str) {
|
|
998
|
+
if (!str) return '';
|
|
999
|
+
const div = document.createElement('div');
|
|
1000
|
+
div.textContent = str;
|
|
1001
|
+
return div.innerHTML;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
function healthDotClass(downCount) {
|
|
1005
|
+
if (!downCount || downCount === 0) return 'green';
|
|
1006
|
+
if (downCount === 1) return 'yellow';
|
|
1007
|
+
return 'red';
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
function formatDuration(ms) {
|
|
1011
|
+
const s = Math.floor(ms / 1000);
|
|
1012
|
+
const d = Math.floor(s / 86400);
|
|
1013
|
+
const h = Math.floor((s % 86400) / 3600);
|
|
1014
|
+
const m = Math.floor((s % 3600) / 60);
|
|
1015
|
+
const parts = [];
|
|
1016
|
+
if (d > 0) parts.push(d + 'd');
|
|
1017
|
+
if (h > 0) parts.push(h + 'h');
|
|
1018
|
+
parts.push(m + 'm');
|
|
1019
|
+
return parts.join(' ');
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
function switchToAdmin(activeId) {
|
|
1023
|
+
document.getElementById('documentation_container').style.display = 'none';
|
|
1024
|
+
document.getElementById('admin_content').style.display = '';
|
|
1025
|
+
document.querySelectorAll('.list-item a').forEach(item => item.classList.remove('active'));
|
|
1026
|
+
const el = document.querySelector('[data-admin="' + activeId + '"]');
|
|
1027
|
+
if (el) el.classList.add('active');
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
function showConfirm(title, message, buttons) {
|
|
1031
|
+
const overlay = document.createElement('div');
|
|
1032
|
+
overlay.className = 'confirm-overlay';
|
|
1033
|
+
overlay.innerHTML = \`
|
|
1034
|
+
<div class="confirm-dialog">
|
|
1035
|
+
<h3>\${title}</h3>
|
|
1036
|
+
<p>\${message}</p>
|
|
1037
|
+
<div class="actions">
|
|
1038
|
+
<button class="btn btn-outline" id="confirm_cancel">Cancel</button>
|
|
1039
|
+
\${buttons.map((b, i) => \`<button class="btn \${b.class}" id="confirm_btn_\${i}">\${b.label}</button>\`).join('')}
|
|
1040
|
+
</div>
|
|
1041
|
+
</div>
|
|
1042
|
+
\`;
|
|
1043
|
+
document.body.appendChild(overlay);
|
|
1044
|
+
document.getElementById('confirm_cancel').onclick = () => overlay.remove();
|
|
1045
|
+
buttons.forEach((b, i) => {
|
|
1046
|
+
document.getElementById('confirm_btn_' + i).onclick = () => { overlay.remove(); b.action(); };
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
/* ==========================================
|
|
1051
|
+
ADMIN LOGIN FROM DOCS VIEW
|
|
1052
|
+
========================================== */
|
|
1053
|
+
window.showAdminLogin = () => {
|
|
1054
|
+
document.getElementById('documentation_container').style.display = 'none';
|
|
1055
|
+
document.getElementById('admin_content').style.display = '';
|
|
1056
|
+
document.querySelectorAll('.list-item a').forEach(item => item.classList.remove('active'));
|
|
1057
|
+
const loginEl = document.querySelector('[data-admin="admin-login"]');
|
|
1058
|
+
if (loginEl) loginEl.classList.add('active');
|
|
1059
|
+
document.getElementById('admin_content').innerHTML = \`
|
|
1060
|
+
<div class="admin-login">
|
|
1061
|
+
<h2>Admin Login</h2>
|
|
1062
|
+
<p>Authenticate with your BSV wallet (automatic if wallet extension is present and identity key matches), or enter the admin bearer token.</p>
|
|
1063
|
+
<div class="admin-login-form">
|
|
1064
|
+
<input type="password" id="admin_token_input" placeholder="Admin Bearer Token" onkeydown="if(event.key==='Enter')handleAdminLogin()" />
|
|
1065
|
+
<button class="btn btn-primary" onclick="handleAdminLogin()">Login with Token</button>
|
|
1066
|
+
</div>
|
|
1067
|
+
<p style="margin-top:1em;color:#777;font-size:0.85em">If you have a BSV wallet extension installed and your identity key matches the server admin key, you will be authenticated automatically via BSV mutual authentication.</p>
|
|
1068
|
+
</div>
|
|
1069
|
+
\`;
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1072
|
+
async function handleAdminLogin() {
|
|
1073
|
+
const token = document.getElementById('admin_token_input').value.trim();
|
|
1074
|
+
if (!token) return;
|
|
1075
|
+
const success = await Admin.login(token);
|
|
1076
|
+
if (success) Admin.showOverview();
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/* ==========================================
|
|
1080
|
+
PAGE INITIALIZATION
|
|
1081
|
+
========================================== */
|
|
405
1082
|
const handleUrlHash = () => {
|
|
406
|
-
const hash = window.location.hash.substring(1);
|
|
407
|
-
if (hash)
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
1083
|
+
const hash = window.location.hash.substring(1);
|
|
1084
|
+
if (!hash) return;
|
|
1085
|
+
const [type, id] = hash.split('/');
|
|
1086
|
+
if (type === 'manager' && id && managersData[id]) {
|
|
1087
|
+
window.managerDocumentation(id);
|
|
1088
|
+
} else if (type === 'provider' && id && providersData[id]) {
|
|
1089
|
+
window.topicDocumentation(id);
|
|
1090
|
+
} else if (type === 'admin') {
|
|
1091
|
+
if (!Admin.isAdmin) { window.showAdminLogin(); return; }
|
|
1092
|
+
switch (id) {
|
|
1093
|
+
case 'overview': Admin.showOverview(); break;
|
|
1094
|
+
case 'ship': Admin.showShipRecords(1); break;
|
|
1095
|
+
case 'slap': Admin.showSlapRecords(1); break;
|
|
1096
|
+
case 'bans': Admin.showBanList(); break;
|
|
1097
|
+
case 'health': Admin.showHealthChecker(); break;
|
|
1098
|
+
default: Admin.showOverview(); break;
|
|
421
1099
|
}
|
|
422
1100
|
}
|
|
423
1101
|
};
|
|
424
1102
|
|
|
425
1103
|
document.addEventListener('DOMContentLoaded', () => {
|
|
1104
|
+
Admin.init();
|
|
1105
|
+
|
|
426
1106
|
let managersLoaded = false;
|
|
427
1107
|
let providersLoaded = false;
|
|
428
1108
|
|
|
429
|
-
// Check if both managers and providers are loaded before handling hash
|
|
430
1109
|
const checkAllLoaded = () => {
|
|
431
|
-
if (managersLoaded && providersLoaded) {
|
|
432
|
-
handleUrlHash();
|
|
433
|
-
}
|
|
1110
|
+
if (managersLoaded && providersLoaded) { handleUrlHash(); }
|
|
434
1111
|
};
|
|
435
1112
|
|
|
436
|
-
fetch('
|
|
1113
|
+
fetch(HOST + '/listTopicManagers')
|
|
437
1114
|
.then(res => res.json())
|
|
438
1115
|
.then(managers => {
|
|
439
1116
|
managersData = managers;
|
|
@@ -442,25 +1119,19 @@ export default (config: UIConfig = {}): string => {
|
|
|
442
1119
|
let managerData = managers[manager];
|
|
443
1120
|
let li = document.createElement('li');
|
|
444
1121
|
li.className = 'list-item';
|
|
445
|
-
li.innerHTML =
|
|
446
|
-
<a data-manager="\${manager}" onclick="window.managerDocumentation('\${manager}')">
|
|
447
|
-
\${managerData.name}
|
|
448
|
-
</a>
|
|
449
|
-
\`;
|
|
1122
|
+
li.innerHTML = \`<a data-manager="\${manager}" onclick="window.managerDocumentation('\${manager}')">\${managerData.name}</a>\`;
|
|
450
1123
|
managerList.appendChild(li);
|
|
451
1124
|
});
|
|
452
1125
|
managersLoaded = true;
|
|
453
1126
|
checkAllLoaded();
|
|
454
1127
|
})
|
|
455
1128
|
.catch(() => {
|
|
456
|
-
|
|
457
|
-
message.innerText = 'Something went wrong!';
|
|
458
|
-
manager_list.insertBefore(message, manager_list.children[0]);
|
|
1129
|
+
document.getElementById('manager_list').innerHTML = '<li style="color:#999">Failed to load</li>';
|
|
459
1130
|
managersLoaded = true;
|
|
460
1131
|
checkAllLoaded();
|
|
461
1132
|
});
|
|
462
1133
|
|
|
463
|
-
fetch('
|
|
1134
|
+
fetch(HOST + '/listLookupServiceProviders')
|
|
464
1135
|
.then(res => res.json())
|
|
465
1136
|
.then(providers => {
|
|
466
1137
|
providersData = providers;
|
|
@@ -469,55 +1140,41 @@ export default (config: UIConfig = {}): string => {
|
|
|
469
1140
|
let providerData = providers[provider];
|
|
470
1141
|
let li = document.createElement('li');
|
|
471
1142
|
li.className = 'list-item';
|
|
472
|
-
li.innerHTML =
|
|
473
|
-
<a data-provider="\${provider}" onclick="window.topicDocumentation('\${provider}')">
|
|
474
|
-
\${providerData.name}
|
|
475
|
-
</a>
|
|
476
|
-
\`;
|
|
1143
|
+
li.innerHTML = \`<a data-provider="\${provider}" onclick="window.topicDocumentation('\${provider}')">\${providerData.name}</a>\`;
|
|
477
1144
|
providerList.appendChild(li);
|
|
478
1145
|
});
|
|
479
1146
|
providersLoaded = true;
|
|
480
1147
|
checkAllLoaded();
|
|
481
1148
|
})
|
|
482
1149
|
.catch(() => {
|
|
483
|
-
|
|
484
|
-
message.innerText = 'Something went wrong!';
|
|
485
|
-
provider_list.insertBefore(message, provider_list.children[0]);
|
|
1150
|
+
document.getElementById('provider_list').innerHTML = '<li style="color:#999">Failed to load</li>';
|
|
486
1151
|
providersLoaded = true;
|
|
487
1152
|
checkAllLoaded();
|
|
488
1153
|
});
|
|
489
1154
|
|
|
490
|
-
// Check
|
|
1155
|
+
// Check hash on initial load and listen for changes
|
|
491
1156
|
const checkUrlHash = () => {
|
|
492
|
-
const hash = window.location.hash.substring(1);
|
|
1157
|
+
const hash = window.location.hash.substring(1);
|
|
493
1158
|
if (hash) {
|
|
494
1159
|
const parts = hash.split('/');
|
|
495
1160
|
if (parts.length === 2) {
|
|
496
|
-
const type = parts
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
if (type === '
|
|
500
|
-
window.managerDocumentation(id);
|
|
501
|
-
} else if (type === 'provider' && id && providersData[id]) {
|
|
502
|
-
window.topicDocumentation(id);
|
|
503
|
-
}
|
|
1161
|
+
const [type, id] = parts;
|
|
1162
|
+
if (type === 'manager' && id && managersData[id]) { window.managerDocumentation(id); }
|
|
1163
|
+
else if (type === 'provider' && id && providersData[id]) { window.topicDocumentation(id); }
|
|
1164
|
+
else if (type === 'admin') { handleUrlHash(); }
|
|
504
1165
|
}
|
|
505
1166
|
} else {
|
|
506
|
-
// Display default message when no manager or provider is selected
|
|
507
1167
|
returnHome();
|
|
508
1168
|
}
|
|
509
1169
|
};
|
|
510
|
-
|
|
511
|
-
// Listen for hash changes
|
|
512
1170
|
window.addEventListener('hashchange', checkUrlHash);
|
|
513
|
-
|
|
514
|
-
// Check hash on initial page load
|
|
515
1171
|
checkUrlHash();
|
|
516
1172
|
});
|
|
517
1173
|
</script>
|
|
518
1174
|
</head>
|
|
519
1175
|
|
|
520
1176
|
<body>
|
|
1177
|
+
<div id="toast_container" class="toast-container"></div>
|
|
521
1178
|
<div class="main">
|
|
522
1179
|
<div class="column_left">
|
|
523
1180
|
<div class="page_head">
|
|
@@ -532,16 +1189,34 @@ export default (config: UIConfig = {}): string => {
|
|
|
532
1189
|
<ul id="provider_list"></ul>
|
|
533
1190
|
</div>
|
|
534
1191
|
<div>
|
|
535
|
-
|
|
1192
|
+
<h3>External Links</h3>
|
|
536
1193
|
<ul id="external_list">
|
|
537
1194
|
<li class="list-item"><a href="https://github.com/bsv-blockchain/overlay-services" target="_blank">Overlay Services GitHub</a></li>
|
|
538
1195
|
<li class="list-item"><a href="https://bsv.brc.dev/transactions/0076" target="_blank">BRC-76 GASP</a></li>
|
|
539
1196
|
<li class="list-item"><a href="https://fast.brc.dev" target="_blank">Quick Start for App Developers</a></li>
|
|
540
1197
|
</ul>
|
|
541
1198
|
</div>
|
|
1199
|
+
<div id="admin_section">
|
|
1200
|
+
<div class="admin-divider"></div>
|
|
1201
|
+
<h3>Admin Dashboard</h3>
|
|
1202
|
+
<ul id="admin_list">
|
|
1203
|
+
<li class="list-item"><a data-admin="admin-overview" onclick="Admin.showOverview()">Overview</a></li>
|
|
1204
|
+
<li class="list-item"><a data-admin="admin-ship" onclick="Admin.showShipRecords(1)">SHIP Records</a></li>
|
|
1205
|
+
<li class="list-item"><a data-admin="admin-slap" onclick="Admin.showSlapRecords(1)">SLAP Records</a></li>
|
|
1206
|
+
<li class="list-item"><a data-admin="admin-bans" onclick="Admin.showBanList()">Ban List</a></li>
|
|
1207
|
+
<li class="list-item"><a data-admin="admin-health" onclick="Admin.showHealthChecker()">Health Checker</a></li>
|
|
1208
|
+
<li class="list-item"><a onclick="Admin.logout()" style="color:var(--danger-color)">Logout</a></li>
|
|
1209
|
+
</ul>
|
|
1210
|
+
</div>
|
|
1211
|
+
<div id="admin_login_link" style="margin-top:1em">
|
|
1212
|
+
<ul style="list-style:none;padding:0">
|
|
1213
|
+
<li class="list-item"><a data-admin="admin-login" onclick="window.showAdminLogin()">Admin Login</a></li>
|
|
1214
|
+
</ul>
|
|
1215
|
+
</div>
|
|
542
1216
|
</div>
|
|
543
1217
|
<div class="column_right">
|
|
544
1218
|
<div id="documentation_container"></div>
|
|
1219
|
+
<div id="admin_content" style="display:none"></div>
|
|
545
1220
|
</div>
|
|
546
1221
|
</div>
|
|
547
1222
|
</body>
|