mirror of
https://github.com/logos-storage/logos-storage-app-skeleton.git
synced 2026-06-13 20:09:28 +00:00
Add Health indicator
This commit is contained in:
parent
0a4fcca520
commit
e2be44cc08
@ -135,6 +135,7 @@ qt_add_qml_module(appqml
|
||||
LogosStorageLayout.qml
|
||||
PortForwarding.qml
|
||||
ErrorToast.qml
|
||||
HealthIndicator.qml
|
||||
)
|
||||
|
||||
# Set up QML module directory for runtime
|
||||
|
||||
78
src/qml/HealthIndicator.qml
Normal file
78
src/qml/HealthIndicator.qml
Normal 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)
|
||||
}
|
||||
}
|
||||
@ -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"
|
||||
|
||||
@ -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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user