Auto-refresh Watchtower status
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 12s
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 12s
This commit is contained in:
31
admin.js
31
admin.js
@@ -35,6 +35,7 @@ let latestContainers = [];
|
||||
let dangerToken = null;
|
||||
let dangerExpiresAt = 0;
|
||||
let dangerTimer = null;
|
||||
let opsAutoRefreshTimer = null;
|
||||
|
||||
function base64UrlEncode(buffer) {
|
||||
return btoa(String.fromCharCode(...new Uint8Array(buffer)))
|
||||
@@ -322,14 +323,21 @@ function renderDisks(disks = []) {
|
||||
function renderWatchtower(watchtower) {
|
||||
latestWatchtower = watchtower;
|
||||
const officialSession = watchtower?.lastSession;
|
||||
const statusGenerated = watchtower?.generatedAt
|
||||
? new Date(watchtower.generatedAt).toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit', second: '2-digit' })
|
||||
: '--';
|
||||
const officialHtml = officialSession
|
||||
? `
|
||||
<div class="ops-line"><strong>Offizieller Lauf</strong><span>${officialSession.finishedAt ? new Date(officialSession.finishedAt).toLocaleString('de-DE') : '--'}</span></div>
|
||||
<div class="ops-line"><strong>Geprueft</strong><span>${officialSession.scanned ?? '--'}</span></div>
|
||||
<div class="ops-line"><strong>Aktualisiert</strong><span>${officialSession.updated ?? '--'}</span></div>
|
||||
<div class="ops-line"><strong>Fehler</strong><span>${officialSession.failed ?? '--'}</span></div>
|
||||
<div class="ops-line"><strong>Status aktualisiert</strong><span>${statusGenerated}</span></div>
|
||||
`
|
||||
: `<div class="ops-line"><strong>Offizieller Lauf</strong><span>${watchtower?.tail?.slice(-2)?.join(' | ') || 'Noch nicht gefunden'}</span></div>`;
|
||||
: `
|
||||
<div class="ops-line"><strong>Offizieller Lauf</strong><span>${watchtower?.tail?.slice(-2)?.join(' | ') || 'Noch nicht gefunden'}</span></div>
|
||||
<div class="ops-line"><strong>Status aktualisiert</strong><span>${statusGenerated}</span></div>
|
||||
`;
|
||||
|
||||
if (lastManualWatchtowerRun) {
|
||||
const run = lastManualWatchtowerRun;
|
||||
@@ -551,10 +559,13 @@ async function pollWatchtowerRun(runId, attempt = 0) {
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshOps() {
|
||||
diskStatus.textContent = 'Lade...';
|
||||
watchtowerStatus.textContent = 'Lade...';
|
||||
containerStatus.textContent = 'Lade...';
|
||||
async function refreshOps(options = {}) {
|
||||
const silent = Boolean(options.silent);
|
||||
if (!silent) {
|
||||
diskStatus.textContent = 'Lade...';
|
||||
watchtowerStatus.textContent = 'Lade...';
|
||||
containerStatus.textContent = 'Lade...';
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/status', { cache: 'no-store' });
|
||||
@@ -570,6 +581,15 @@ async function refreshOps() {
|
||||
}
|
||||
}
|
||||
|
||||
function startOpsAutoRefresh() {
|
||||
window.clearInterval(opsAutoRefreshTimer);
|
||||
opsAutoRefreshTimer = window.setInterval(() => {
|
||||
if (document.visibilityState === 'visible') {
|
||||
refreshOps({ silent: true });
|
||||
}
|
||||
}, 60000);
|
||||
}
|
||||
|
||||
async function boot() {
|
||||
await handleCallback();
|
||||
tokenSet = getStoredTokens();
|
||||
@@ -593,6 +613,7 @@ async function boot() {
|
||||
adminUser.textContent = `Angemeldet als ${claims.preferred_username || claims.email}`;
|
||||
renderEditor();
|
||||
refreshOps();
|
||||
startOpsAutoRefresh();
|
||||
}
|
||||
|
||||
loginButton.addEventListener('click', login);
|
||||
|
||||
Reference in New Issue
Block a user