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)
|
|
|
|
}
|
|
|
|
|
|
|
|
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-01 20:59:08 +00:00
|
|
|
function onNetworkConnectionStatusUpdate(website: string, completelyDown: bool, connectionState: int, chainIds: string, lastCheckedAt: int, timeToAutoRetryInSecs: int, withCache: bool) {
|
|
|
|
if (website === websiteDown) {
|
|
|
|
root.connectionState = connectionState
|
|
|
|
root.autoTryTimerInSecs = timeToAutoRetryInSecs
|
|
|
|
root.chainIdsDown = chainIds.split(";")
|
|
|
|
root.completelyDown = completelyDown
|
|
|
|
root.withCache = withCache
|
|
|
|
root.lastCheckedAt = LocaleUtils.formatDateTime(new Date(lastCheckedAt*1000))
|
|
|
|
root.updateBanner()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|