Tighten control plane flow and status presentation

This commit is contained in:
Keith Casko
2026-10-02 11:20:13 -04:00
parent be741fbc1b
commit bcf115a83b
4 changed files with 88 additions and 54 deletions
+12 -19
View File
@@ -19,9 +19,7 @@ const fields = {
healthWoodpecker: document.querySelector("#health-woodpecker"),
healthKuma: document.querySelector("#health-kuma"),
healthPrometheus: document.querySelector("#health-prometheus"),
giteaVersion: document.querySelector("#gitea-version"),
pipelineGiteaState: document.querySelector("#pipeline-gitea-state"),
pipelineGiteaVersion: document.querySelector("#pipeline-gitea-version"),
pipelineWoodpeckerState: document.querySelector("#pipeline-woodpecker-state"),
deployedCommit: document.querySelector("#deployed-commit"),
};
@@ -31,7 +29,7 @@ const telemetryHistory = {
memory: [],
};
let lastSuccessfulUpdate = null;
let lastSampledAt = null;
let requestInFlight = false;
function updateClock() {
@@ -80,8 +78,6 @@ function setUnavailable() {
element.classList.add("status-down");
}
}
fields.giteaVersion.textContent = "VERSION --";
fields.pipelineGiteaVersion.textContent = "VERSION --";
fields.deployedCommit.textContent = "-------";
refreshElement.textContent = "TELEMETRY UNAVAILABLE";
refreshElement.classList.add("telemetry-error");
@@ -104,10 +100,6 @@ function pushHistory(series, value) {
if (series.length > 24) series.shift();
}
function serviceLabel(service) {
return service && service.up ? "ONLINE" : "UNAVAILABLE";
}
function setServiceState(element, service) {
if (!element) return;
const up = Boolean(service && service.up);
@@ -143,11 +135,6 @@ function renderStatus(data) {
setServiceState(fields.pipelineGiteaState, services.gitea);
setServiceState(fields.pipelineWoodpeckerState, services.woodpecker);
const giteaVersion = services.gitea && services.gitea.version
? "VERSION " + services.gitea.version
: "VERSION --";
fields.giteaVersion.textContent = giteaVersion;
fields.pipelineGiteaVersion.textContent = giteaVersion;
fields.deployedCommit.textContent = data.deployment && data.deployment.commit
? data.deployment.commit
: "-------";
@@ -159,14 +146,21 @@ function renderStatus(data) {
fields.telemetry.classList.remove("metric-error");
refreshElement.classList.remove("telemetry-error");
lastSuccessfulUpdate = Date.now();
lastSampledAt = Number(data.sampled_at) * 1000;
updateRefreshLabel();
}
function updateRefreshLabel() {
if (!lastSuccessfulUpdate) return;
const ageSeconds = Math.max(0, Math.floor((Date.now() - lastSuccessfulUpdate) / 1000));
refreshElement.textContent = "LIVE TELEMETRY | UPDATED " + String(ageSeconds).padStart(2, "0") + "s AGO";
if (!lastSampledAt) return;
const ageSeconds = Math.max(0, Math.floor((Date.now() - lastSampledAt) / 1000));
const stale = ageSeconds > 45;
refreshElement.textContent = (stale ? "TELEMETRY STALE | SAMPLE " : "LIVE TELEMETRY | SAMPLE ")
+ String(ageSeconds).padStart(2, "0") + "s AGO";
refreshElement.classList.toggle("telemetry-error", stale);
fields.telemetry.textContent = stale ? "STALE" : "LIVE";
fields.telemetry.classList.toggle("metric-error", stale);
}
async function refreshTelemetry() {
@@ -198,4 +192,3 @@ refreshTelemetry();
window.setInterval(updateClock, 1000);
window.setInterval(updateRefreshLabel, 1000);
window.setInterval(refreshTelemetry, 15000);