mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
adjusted health status check
This commit is contained in:
parent
13e5f98b06
commit
3c9c115931
5 changed files with 24 additions and 15 deletions
|
@ -6,15 +6,8 @@ setActivePinia(pinia);
|
||||||
import { useStateStore } from "../store/stateStore.js";
|
import { useStateStore } from "../store/stateStore.js";
|
||||||
const state = useStateStore(pinia);
|
const state = useStateStore(pinia);
|
||||||
|
|
||||||
function getOverallHealth() {
|
import { getOverallHealth } from "../js/eventHandler.js"
|
||||||
//Return a number indicating health for icon bg color; lower the number the healthier
|
|
||||||
let health = 0;
|
|
||||||
if (state.modem_connection !== "connected") health += 5;
|
|
||||||
if (!state.is_modem_running) health += 3;
|
|
||||||
if (state.radio_status === false) health += 2;
|
|
||||||
if (process.env.FDUpdateAvail === "1") health += 1;
|
|
||||||
return health;
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<a
|
<a
|
||||||
|
|
|
@ -19,7 +19,7 @@ async function apiGet(endpoint) {
|
||||||
}
|
}
|
||||||
return await response.json();
|
return await response.json();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error getting from REST:", error);
|
//console.error("Error getting from REST:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ export function eventDispatcher(data) {
|
||||||
displayToast("success", "bi-ethernet", message, 5000);
|
displayToast("success", "bi-ethernet", message, 5000);
|
||||||
stateStore.modem_connection = "connected";
|
stateStore.modem_connection = "connected";
|
||||||
getModemState();
|
getModemState();
|
||||||
|
getOverallHealth();
|
||||||
getConfig();
|
getConfig();
|
||||||
getAudioDevices();
|
getAudioDevices();
|
||||||
getSerialDevices();
|
getSerialDevices();
|
||||||
|
@ -318,3 +319,18 @@ function build_HSL() {
|
||||||
}
|
}
|
||||||
stateStore.heard_stations.sort((a, b) => b.timestamp - a.timestamp); // b - a for reverse sort
|
stateStore.heard_stations.sort((a, b) => b.timestamp - a.timestamp); // b - a for reverse sort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getOverallHealth() {
|
||||||
|
//Return a number indicating health for icon bg color; lower the number the healthier
|
||||||
|
let health = 0;
|
||||||
|
if (stateStore.modem_connection !== "connected") {
|
||||||
|
health += 5;
|
||||||
|
stateStore.is_modem_running = false;
|
||||||
|
stateStore.radio_status = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!stateStore.is_modem_running) health += 3;
|
||||||
|
if (stateStore.radio_status === false) health += 2;
|
||||||
|
if (process.env.FDUpdateAvail === "1") health += 1;
|
||||||
|
return health;
|
||||||
|
}
|
|
@ -19,7 +19,7 @@ function connect(endpoint, dispatcher) {
|
||||||
|
|
||||||
// handle opening
|
// handle opening
|
||||||
socket.addEventListener("open", function (event) {
|
socket.addEventListener("open", function (event) {
|
||||||
console.log("Connected to the WebSocket server: " + endpoint);
|
//console.log("Connected to the WebSocket server: " + endpoint);
|
||||||
});
|
});
|
||||||
|
|
||||||
// handle data
|
// handle data
|
||||||
|
@ -30,18 +30,18 @@ function connect(endpoint, dispatcher) {
|
||||||
|
|
||||||
// handle errors
|
// handle errors
|
||||||
socket.addEventListener("error", function (event) {
|
socket.addEventListener("error", function (event) {
|
||||||
console.error("WebSocket error:", event);
|
//console.error("WebSocket error:", event);
|
||||||
connectionFailed(endpoint, event);
|
connectionFailed(endpoint, event);
|
||||||
});
|
});
|
||||||
|
|
||||||
// handle closing and reconnect
|
// handle closing and reconnect
|
||||||
socket.addEventListener("close", function (event) {
|
socket.addEventListener("close", function (event) {
|
||||||
console.log("WebSocket connection closed:", event.code);
|
//console.log("WebSocket connection closed:", event.code);
|
||||||
|
|
||||||
// Reconnect handler
|
// Reconnect handler
|
||||||
if (!event.wasClean) {
|
if (!event.wasClean) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
console.log("Reconnecting to websocket");
|
//console.log("Reconnecting to websocket");
|
||||||
connect(endpoint, dispatcher);
|
connect(endpoint, dispatcher);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,4 +127,4 @@ export function getAppDataPath() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return appDataPath;
|
return appDataPath;
|
||||||
}
|
}
|
Loading…
Reference in a new issue