2023-03-01 20:59:08 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
2023-03-15 09:17:25 +00:00
|
|
|
import shared.stores 1.0
|
2023-03-01 20:59:08 +00:00
|
|
|
|
|
|
|
ModuleWarning {
|
|
|
|
id: root
|
|
|
|
|
2023-03-15 09:17:25 +00:00
|
|
|
readonly property NetworkConnectionStore networkConnectionStore: NetworkConnectionStore {}
|
|
|
|
readonly property string jointChainIdString: networkConnectionStore.getChainIdsJointString(chainIdsDown)
|
2023-03-01 20:59:08 +00:00
|
|
|
property string websiteDown
|
|
|
|
property int connectionState: -1
|
|
|
|
property int autoTryTimerInSecs: 0
|
|
|
|
property var chainIdsDown: []
|
|
|
|
property bool completelyDown: false
|
|
|
|
property string lastCheckedAt
|
|
|
|
property bool withCache: false
|
|
|
|
property Timer updateTimer: Timer {
|
|
|
|
interval: 1000
|
|
|
|
repeat: true
|
|
|
|
onTriggered: {
|
|
|
|
if (root.autoTryTimerInSecs === 0) {
|
|
|
|
stop()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
root.autoTryTimerInSecs = root.autoTryTimerInSecs - 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateBanner() {
|
|
|
|
hide()
|
|
|
|
if (connectionState === Constants.ConnectionStatus.Failure)
|
|
|
|
show()
|
|
|
|
else
|
|
|
|
showFor(3000)
|
|
|
|
}
|
|
|
|
|
2023-03-23 10:23:02 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
property bool isOnline: networkConnectionStore.isOnline
|
|
|
|
onIsOnlineChanged: if(!isOnline) root.hide()
|
|
|
|
}
|
|
|
|
|
2023-03-01 20:59:08 +00:00
|
|
|
type: connectionState === Constants.ConnectionStatus.Success ? ModuleWarning.Success : ModuleWarning.Danger
|
|
|
|
buttonText: connectionState === Constants.ConnectionStatus.Failure ? qsTr("Retry now") : ""
|
|
|
|
|
2023-03-15 09:17:25 +00:00
|
|
|
onClicked: networkConnectionStore.retryConnection(websiteDown)
|
2023-03-01 20:59:08 +00:00
|
|
|
onCloseClicked: hide()
|
|
|
|
|
|
|
|
Connections {
|
2023-03-15 09:17:25 +00:00
|
|
|
target: networkConnectionStore.networkConnectionModuleInst
|
2023-03-23 10:23:02 +00:00
|
|
|
function onNetworkConnectionStatusUpdate(website: string, completelyDown: bool, connectionState: int, chainIds: string, lastCheckedAt: int, timeToAutoRetryInSecs: int) {
|
2023-03-01 20:59:08 +00:00
|
|
|
if (website === websiteDown) {
|
|
|
|
root.connectionState = connectionState
|
|
|
|
root.autoTryTimerInSecs = timeToAutoRetryInSecs
|
|
|
|
root.chainIdsDown = chainIds.split(";")
|
|
|
|
root.completelyDown = completelyDown
|
|
|
|
root.lastCheckedAt = LocaleUtils.formatDateTime(new Date(lastCheckedAt*1000))
|
|
|
|
root.updateBanner()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|