Add Health indicator

This commit is contained in:
Arnaud 2026-02-20 14:23:26 +04:00
parent 0a4fcca520
commit e2be44cc08
No known key found for this signature in database
GPG Key ID: 20E40A5D3110766F
4 changed files with 86 additions and 6 deletions

View File

@ -135,6 +135,7 @@ qt_add_qml_module(appqml
LogosStorageLayout.qml
PortForwarding.qml
ErrorToast.qml
HealthIndicator.qml
)
# Set up QML module directory for runtime

View File

@ -0,0 +1,78 @@
import QtQuick
Item {
id: root
property bool nodeIsUp: false
property var backend: mockBackend
readonly property int running: 2
Timer {
readonly property int threeMinutes: 180000
interval: threeMinutes
repeat: true
running: root.backend.status == root.running
triggeredOnStart: true
onTriggered: root.backend.checkNodeIsUp()
}
Connections {
target: root.backend
function onNodeIsUp() {
root.nodeIsUp = true
}
function onNodeIsntUp(reason) {
root.nodeIsUp = false
}
function onStatusChanged() {
if (root.backend.status !== root.running) {
root.nodeIsUp = false
}
}
}
property bool blinkOn: true
Timer {
interval: 600
repeat: true
running: true
onTriggered: root.blinkOn = !root.blinkOn
}
Row {
id: nodeStatusBadge
anchors.top: parent.top
anchors.right: parent.right
anchors.topMargin: 18
anchors.rightMargin: 20
spacing: 7
Rectangle {
width: 10
height: 10
radius: 5
anchors.verticalCenter: parent.verticalCenter
color: root.nodeIsUp ? "#4CAF50" : "#f44336"
opacity: root.blinkOn ? 1.0 : 0.15
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: root.nodeIsUp ? "Node reachable" : "Node unreachable"
color: root.nodeIsUp ? "#4CAF50" : "#f44336"
font.pixelSize: 12
}
}
QtObject {
id: mockBackend
signal nodeIsUp
signal nodeIsntUp(string reason)
}
}

View File

@ -5,13 +5,8 @@ import QtQuick.Layouts
import QtCore
// qmllint disable unqualified
Rectangle {
LogosStorageLayout {
id: root
Layout.fillWidth: true
Layout.fillHeight: true
implicitWidth: 800
implicitHeight: 800
color: "#000000"
property var backend: mockBackend
readonly property int stopped: 0
@ -92,6 +87,11 @@ Rectangle {
return (bytes / (1024 * 1024 * 1024)).toFixed(2) + " GB"
}
HealthIndicator {
backend: root.backend
anchors.fill: parent
}
Text {
id: statusTextElement
objectName: "status"

View File

@ -9,5 +9,6 @@
<file alias="LogosStorageLayout.qml">qml/LogosStorageLayout.qml</file>
<file alias="PortForwarding.qml">qml/PortForwarding.qml</file>
<file alias="ErrorToast.qml">qml/ErrorToast.qml</file>
<file alias="HealthIndicator.qml">qml/HealthIndicator.qml</file>
</qresource>
</RCC>