Replace service and delivery screenshots with live status
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
const livePanelStyles=document.createElement("link");livePanelStyles.rel="stylesheet";livePanelStyles.href="live-panels.css";document.head.appendChild(livePanelStyles);
|
||||
|
||||
const timeElement = document.querySelector("#local-time");
|
||||
const refreshElement = document.querySelector("#refresh-indicator");
|
||||
|
||||
@@ -13,6 +15,15 @@ const fields = {
|
||||
opsUptime: document.querySelector("#ops-uptime-value"),
|
||||
opsContainers: document.querySelector("#ops-containers-value"),
|
||||
opsTargets: document.querySelector("#ops-targets-value"),
|
||||
healthGitea: document.querySelector("#health-gitea"),
|
||||
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"),
|
||||
};
|
||||
|
||||
const telemetryHistory = {
|
||||
@@ -56,6 +67,22 @@ function setUnavailable() {
|
||||
fields.opsUptime.textContent = "--";
|
||||
fields.opsContainers.textContent = "--";
|
||||
fields.opsTargets.textContent = "--";
|
||||
for (const element of [
|
||||
fields.healthGitea,
|
||||
fields.healthWoodpecker,
|
||||
fields.healthKuma,
|
||||
fields.healthPrometheus,
|
||||
fields.pipelineGiteaState,
|
||||
fields.pipelineWoodpeckerState,
|
||||
]) {
|
||||
if (element) {
|
||||
element.textContent = "UNAVAILABLE";
|
||||
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");
|
||||
}
|
||||
@@ -77,6 +104,17 @@ 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);
|
||||
element.textContent = up ? "ONLINE" : "UNAVAILABLE";
|
||||
element.classList.toggle("status-down", !up);
|
||||
}
|
||||
|
||||
function renderStatus(data) {
|
||||
const cpu = Number(data.host.cpu_percent);
|
||||
const memory = Number(data.host.memory_percent);
|
||||
@@ -97,6 +135,23 @@ function renderStatus(data) {
|
||||
fields.opsContainers.textContent = containers;
|
||||
fields.opsTargets.textContent = targets;
|
||||
|
||||
const services = data.services || {};
|
||||
setServiceState(fields.healthGitea, services.gitea);
|
||||
setServiceState(fields.healthWoodpecker, services.woodpecker);
|
||||
setServiceState(fields.healthKuma, services.uptime_kuma);
|
||||
setServiceState(fields.healthPrometheus, services.prometheus);
|
||||
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
|
||||
: "-------";
|
||||
|
||||
pushHistory(telemetryHistory.cpu, cpu);
|
||||
pushHistory(telemetryHistory.memory, memory);
|
||||
renderOpsBars("#ops-cpu-bars", telemetryHistory.cpu);
|
||||
@@ -143,3 +198,4 @@ refreshTelemetry();
|
||||
window.setInterval(updateClock, 1000);
|
||||
window.setInterval(updateRefreshLabel, 1000);
|
||||
window.setInterval(refreshTelemetry, 15000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user