0.1.5: card UPS; backup con marcatore robusto ai riavvii

This commit is contained in:
Carlo Baratto committed 2026-10-31 13:38:40 +01:00
1 parent 29a63a74d4
commit 8ed183c1fc
6 files changed
+186 -18

No files matched your search

+61 -1
View File
@@ -77,6 +77,56 @@ Page {
parts.push(qsTr("liste apt: ") + statusClient.fmtStamp(d.updates.lists_updated_at))
return parts.join(" · ")
}
function backupEnough() { return backupAge() >= 0 }
function backupDetail() {
var d = statusClient.data
if (!d || !d.backups) return ""
var r = backupResult()
var base = r === "" ? qsTr("nessun dato") : "borg · " + r
// Senza marcatore né timestamp dell'unit non si conosce l'ora del giro
// (dopo un riavvio systemd azzera i suoi timestamp): dirlo, invece di
// far sembrare che il backup non sia mai stato fatto.
if (!backupEnough()) base += " · " + qsTr("ora del giro non registrata")
return base
}
function ups() {
var d = statusClient.data
return (d && d.ups && d.ups.available) ? d.ups : null
}
function upsStatus() {
var u = ups()
return (u && u.status) ? u.status.toUpperCase() : ""
}
function upsLabel() {
var s = upsStatus()
if (s === "") return "—"
if (s.indexOf("OB") >= 0) return qsTr("a batteria")
if (s.indexOf("OL") >= 0) return qsTr("rete")
return s
}
function upsLevel() {
var u = ups()
if (!u) return 1
var s = upsStatus()
if (s.indexOf("ALARM") >= 0 || s.indexOf("FSD") >= 0 || s.indexOf("LB") >= 0) return 2
if (u.charge_pct !== null && u.charge_pct !== undefined && u.charge_pct < 50) return 2
if (u.load_pct !== null && u.load_pct !== undefined && u.load_pct > 85) return 1
return 0
}
function upsDetail() {
var u = ups()
if (!u) return qsTr("nessun UPS rilevato")
var parts = []
if (u.charge_pct !== null && u.charge_pct !== undefined)
parts.push(qsTr("carica ") + statusClient.fmtNum(u.charge_pct, 0) + "%")
if (u.runtime_s)
parts.push(qsTr("autonomia ") + Math.round(u.runtime_s / 60) + " min")
if (u.load_pct !== null && u.load_pct !== undefined)
parts.push(qsTr("carico ") + statusClient.fmtNum(u.load_pct, 0) + "%")
if (u.input_voltage)
parts.push(statusClient.fmtNum(u.input_voltage, 0) + " V")
return parts.join(" · ")
}
function vpnText() {
var d = statusClient.data
if (!d || !d.net || !d.net.interfaces || d.net.interfaces.length === 0) return "nessuna"
@@ -198,11 +248,21 @@ Page {
: (backupDays() === 0 ? qsTr("meno di 1 giorno")
: (backupDays() === 1 ? qsTr("1 giorno")
: backupDays() + " " + qsTr("giorni")))
detail: backupResult() === "" ? qsTr("nessun dato") : "borg · " + backupResult()
detail: backupDetail()
progress: -1
level: backupLevel()
}
MetricCard {
x: Theme.paddingLarge
width: parent.width - 2 * Theme.paddingLarge
title: qsTr("UPS")
value: upsLabel()
detail: upsDetail()
progress: -1
level: upsLevel()
}
MetricCard {
x: Theme.paddingLarge
width: parent.width - 2 * Theme.paddingLarge