2023-03-01 20:59:08 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
2023-04-03 17:13:23 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2023-03-01 20:59:08 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
2023-04-03 17:13:23 +00:00
|
|
|
Loader {
|
2023-03-01 20:59:08 +00:00
|
|
|
id: root
|
2023-04-03 17:13:23 +00:00
|
|
|
active: false
|
2023-03-01 20:59:08 +00:00
|
|
|
|
2023-04-03 17:13:23 +00:00
|
|
|
property var networkConnectionStore
|
2023-03-15 09:17:25 +00:00
|
|
|
readonly property string jointChainIdString: networkConnectionStore.getChainIdsJointString(chainIdsDown)
|
2023-03-01 20:59:08 +00:00
|
|
|
property string websiteDown
|
|
|
|
property int connectionState: -1
|
|
|
|
property var chainIdsDown: []
|
|
|
|
property bool completelyDown: false
|
|
|
|
property string lastCheckedAt
|
|
|
|
property bool withCache: false
|
2023-04-03 17:13:23 +00:00
|
|
|
property string tooltipMessage
|
|
|
|
property string toastText
|
2023-03-01 20:59:08 +00:00
|
|
|
|
|
|
|
function updateBanner() {
|
2023-04-03 17:13:23 +00:00
|
|
|
root.active = true
|
2023-03-01 20:59:08 +00:00
|
|
|
if (connectionState === Constants.ConnectionStatus.Failure)
|
2023-04-03 17:13:23 +00:00
|
|
|
item.show()
|
2023-03-01 20:59:08 +00:00
|
|
|
else
|
2023-04-03 17:13:23 +00:00
|
|
|
item.showFor(3000)
|
2023-03-01 20:59:08 +00:00
|
|
|
}
|
|
|
|
|
2023-04-03 17:13:23 +00:00
|
|
|
sourceComponent: ModuleWarning {
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
readonly property bool isOnline: networkConnectionStore.isOnline
|
|
|
|
onIsOnlineChanged: if(!isOnline) hide()
|
|
|
|
}
|
|
|
|
|
|
|
|
onHideFinished: root.active = false
|
2023-03-23 10:23:02 +00:00
|
|
|
|
2023-04-03 17:13:23 +00:00
|
|
|
text: root.toastText
|
|
|
|
type: connectionState === Constants.ConnectionStatus.Success ? ModuleWarning.Success : ModuleWarning.Danger
|
|
|
|
buttonText: connectionState === Constants.ConnectionStatus.Failure ? qsTr("Retry now") : ""
|
2023-03-01 20:59:08 +00:00
|
|
|
|
2023-04-03 17:13:23 +00:00
|
|
|
onClicked: networkConnectionStore.retryConnection(websiteDown)
|
|
|
|
onCloseClicked: hide()
|
|
|
|
|
|
|
|
onLinkActivated: {
|
|
|
|
toolTip.show(root.tooltipMessage, 3000)
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusToolTip {
|
|
|
|
id: toolTip
|
|
|
|
orientation: StatusToolTip.Orientation.Bottom
|
|
|
|
maxWidth: 300
|
|
|
|
}
|
|
|
|
}
|
2023-03-01 20:59:08 +00:00
|
|
|
|
|
|
|
Connections {
|
2023-03-15 09:17:25 +00:00
|
|
|
target: networkConnectionStore.networkConnectionModuleInst
|
2023-04-03 17:13:23 +00:00
|
|
|
function onNetworkConnectionStatusUpdate(website: string, completelyDown: bool, connectionState: int, chainIds: string, lastCheckedAt: int) {
|
2023-03-01 20:59:08 +00:00
|
|
|
if (website === websiteDown) {
|
|
|
|
root.connectionState = connectionState
|
|
|
|
root.chainIdsDown = chainIds.split(";")
|
|
|
|
root.completelyDown = completelyDown
|
|
|
|
root.lastCheckedAt = LocaleUtils.formatDateTime(new Date(lastCheckedAt*1000))
|
|
|
|
root.updateBanner()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|