|
@@ -24,26 +24,33 @@ function setupSections () {
|
|
|
|
|
|
|
|
function refreshLoop () {
|
|
function refreshLoop () {
|
|
|
if (window.websocketAvailable) {
|
|
if (window.websocketAvailable) {
|
|
|
- document.querySelector('#serverConnection').classList.remove('error')
|
|
|
|
|
- document.querySelector('#serverConnection').innerText = 'websocket'
|
|
|
|
|
-
|
|
|
|
|
// Websocket updates are streamed live, not updated on a loop.
|
|
// Websocket updates are streamed live, not updated on a loop.
|
|
|
} else if (window.restAvailable) {
|
|
} else if (window.restAvailable) {
|
|
|
// Fallback to rest, but try to reconnect the websocket anyway.
|
|
// Fallback to rest, but try to reconnect the websocket anyway.
|
|
|
|
|
|
|
|
fetchGetDashboardComponents()
|
|
fetchGetDashboardComponents()
|
|
|
|
|
+ fetchGetLogs()
|
|
|
|
|
+
|
|
|
checkWebsocketConnection()
|
|
checkWebsocketConnection()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // Still try to fetch the dashboard, if successfull window.restAvailable = true
|
|
|
|
|
+ fetchGetDashboardComponents()
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- document.querySelector('#serverConnection').classList.remove('error')
|
|
|
|
|
- document.querySelector('#serverConnection').innerText = 'rest'
|
|
|
|
|
|
|
+ refreshServerConnectionLabel()
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- fetchGetLogs()
|
|
|
|
|
|
|
+function refreshServerConnectionLabel () {
|
|
|
|
|
+ if (window.restAvailable) {
|
|
|
|
|
+ document.querySelector('#serverConnectionRest').classList.remove('error')
|
|
|
} else {
|
|
} else {
|
|
|
- document.querySelector('#serverConnection').innerText = 'disconnected, trying to reconnect...'
|
|
|
|
|
- document.querySelector('#serverConnection').classList.add('error')
|
|
|
|
|
|
|
+ document.querySelector('#serverConnectionRest').classList.add('error')
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // Still try to fetch the dashboard, if successfull window.restAvailable = true
|
|
|
|
|
- fetchGetDashboardComponents()
|
|
|
|
|
|
|
+ if (window.websocketAvailable) {
|
|
|
|
|
+ document.querySelector('#serverConnectionWebSocket').classList.remove('error')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ document.querySelector('#serverConnectionWebSocket').classList.add('error')
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -53,11 +60,17 @@ function fetchGetDashboardComponents () {
|
|
|
}).then(res => {
|
|
}).then(res => {
|
|
|
return res.json()
|
|
return res.json()
|
|
|
}).then(res => {
|
|
}).then(res => {
|
|
|
|
|
+ if (!window.restAvailable) {
|
|
|
|
|
+ window.clearBigErrors('fetch-buttons')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
window.restAvailable = true
|
|
window.restAvailable = true
|
|
|
marshalActionButtonsJsonToHtml(res)
|
|
marshalActionButtonsJsonToHtml(res)
|
|
|
- }).catch(() => { // err is 1st arg
|
|
|
|
|
|
|
+
|
|
|
|
|
+ refreshServerConnectionLabel() // in-case it changed, update the label quicker
|
|
|
|
|
+ }).catch((err) => { // err is 1st arg
|
|
|
window.restAvailable = false
|
|
window.restAvailable = false
|
|
|
- // window.showBigError('fetch-buttons', 'getting buttons', err, 'blat')
|
|
|
|
|
|
|
+ window.showBigError('fetch-buttons', 'getting buttons', err, 'blat')
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|