show server diagnostics in client
This commit is contained in:
+16
-1
@@ -2,6 +2,7 @@
|
||||
let serverAddress = 'http://127.0.0.1:8787';
|
||||
let connectionState = 'OFFLINE';
|
||||
let serverVersion = '—';
|
||||
let diagnostics: { status: string; database: string; twitch_identity_count: number; unseen_notification_count: number; realtime: string } | undefined;
|
||||
let activeView = 'Live dashboard';
|
||||
let sessionToken = '';
|
||||
let authenticated = false;
|
||||
@@ -92,6 +93,7 @@
|
||||
connectionState = 'CONNECTED';
|
||||
await loadActivity();
|
||||
await loadNotifications();
|
||||
await loadDiagnostics();
|
||||
await loadStreamInfo();
|
||||
connectRealtime();
|
||||
if (!mustReplaceCredentials) password = '';
|
||||
@@ -141,6 +143,7 @@
|
||||
oauthLink = '';
|
||||
notifications = [];
|
||||
showNotifications = false;
|
||||
diagnostics = undefined;
|
||||
}
|
||||
|
||||
function connectRealtime() {
|
||||
@@ -199,6 +202,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDiagnostics() {
|
||||
try {
|
||||
const response = await fetch(`${serverAddress}/api/v1/server/diagnostics`, {
|
||||
headers: { authorization: `Bearer ${sessionToken}` },
|
||||
});
|
||||
if (!response.ok) return;
|
||||
diagnostics = await response.json();
|
||||
} catch {
|
||||
diagnostics = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async function markNotificationSeen(notificationId: string) {
|
||||
const response = await fetch(`${serverAddress}/api/v1/admin/notifications/${notificationId}/seen`, {
|
||||
method: 'POST',
|
||||
@@ -412,7 +427,7 @@
|
||||
<div class="empty-row">Sign in as administrator to connect accounts.</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="side-section side-footer"><div class="micro">REALTIME</div><div class="mono">{realtimeState}</div><div class="micro version-label">SERVER VERSION</div><div class="mono">{serverVersion}</div></div>
|
||||
<div class="side-section side-footer"><div class="micro">REALTIME</div><div class="mono">{realtimeState}</div>{#if diagnostics}<div class="micro version-label">DATABASE</div><div class="mono">{diagnostics.database.toUpperCase()}</div><div class="micro version-label">TWITCH IDENTITIES</div><div class="mono">{diagnostics.twitch_identity_count}</div>{/if}<div class="micro version-label">SERVER VERSION</div><div class="mono">{serverVersion}</div></div>
|
||||
</aside>
|
||||
|
||||
<section class="content-area">
|
||||
|
||||
Reference in New Issue
Block a user