Prima release dell'app Sailfish: schermata unica con CPU, memoria, disco, container, backup, servizi, SSH, aggiornamenti e VPN, letti da un endpoint read-only /v1/status. Soglie giallo/rosso, aggiornamento ogni 60 s, copertina, impostazioni con indirizzo e token.
53 lines
1.6 KiB
QML
53 lines
1.6 KiB
QML
import QtQuick 2.0
|
|
import Sailfish.Silica 1.0
|
|
|
|
CoverBackground {
|
|
id: cover
|
|
|
|
// Guardie: quando lo snapshot non è ancora arrivato i campi mancano e in
|
|
// JS leggere una proprietà di undefined solleva un'eccezione.
|
|
function num(v, fallback) {
|
|
return (v === undefined || v === null) ? fallback : v
|
|
}
|
|
|
|
Column {
|
|
anchors.centerIn: parent
|
|
width: parent.width - 2 * Theme.paddingLarge
|
|
spacing: Theme.paddingSmall
|
|
|
|
Label {
|
|
text: "Server"
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
color: Theme.secondaryColor
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
}
|
|
|
|
Label {
|
|
text: statusClient.error !== "" ? "—" : statusClient.fmtNum(num(statusClient.data.cpu ? statusClient.data.cpu.percent : undefined, -1), 0) + " %"
|
|
font.pixelSize: Theme.fontSizeExtraLarge
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
}
|
|
|
|
Label {
|
|
text: "CPU"
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
color: Theme.secondaryColor
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
}
|
|
|
|
Label {
|
|
text: statusClient.fetchedAt !== "" ? statusClient.fetchedAt : ""
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
color: Theme.secondaryColor
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
}
|
|
}
|
|
|
|
CoverActionList {
|
|
CoverAction {
|
|
iconSource: "image://theme/icon-cover-refresh"
|
|
onTriggered: statusClient.refresh()
|
|
}
|
|
}
|
|
}
|