0.1.2: backup in giorni interi, verde 1-3 / giallo 4-6 / rosso 7+

This commit is contained in:
Carlo Baratto committed 2026-10-29 07:40:19 +01:00
1 parent f2e4f5ebfc
commit c73af11575
4 files changed
+24 -9

No files matched your search

+16 -5
View File
@@ -39,13 +39,21 @@ Page {
}
function backupAge() { var d = statusClient.data; return (d && d.backups && d.backups.age_hours !== null && d.backups.age_hours !== undefined) ? d.backups.age_hours : -1 }
function backupResult() { var d = statusClient.data; return (d && d.backups && d.backups.result) ? d.backups.result : "" }
// Giorni INTERI: il valore mostrato e il colore devono raccontare la stessa
// cosa, quindi si arrotonda all'intero piu' vicino (3,6 g -> 4 = giallo).
function backupDays() {
var a = backupAge()
if (a < 0) return -1
return Math.floor(a / 24 + 0.5)
}
// Soglie (decisione utente): verde 1-3 giorni, giallo 4-6, rosso da 7 in su.
function backupLevel() {
if (backupResult() === "") return 1
if (backupResult() !== "success") return 2
var age = backupAge()
if (age < 0) return 1
if (age > 72) return 2
if (age > 36) return 1
var g = backupDays()
if (g < 0) return 1
if (g >= 7) return 2
if (g >= 4) return 1
return 0
}
function failedServices() { var d = statusClient.data; return (d && d.services && d.services.failed) ? d.services.failed.length : 0 }
@@ -186,7 +194,10 @@ Page {
x: Theme.paddingLarge
width: parent.width - 2 * Theme.paddingLarge
title: qsTr("Backup")
value: backupAge() < 0 ? "—" : statusClient.fmtAge(backupAge())
value: backupDays() < 0 ? "—"
: (backupDays() === 0 ? qsTr("meno di 1 giorno")
: (backupDays() === 1 ? qsTr("1 giorno")
: backupDays() + " " + qsTr("giorni")))
detail: backupResult() === "" ? qsTr("nessun dato") : "borg · " + backupResult()
progress: -1
level: backupLevel()