Merge branch 'master' into restructure-status-page

# Conflicts:
#	src/pages/StatusPage.vue
This commit is contained in:
Louis Lam 2022-03-12 15:50:42 +08:00
commit d765b1c57a
7 changed files with 106 additions and 40 deletions

View file

@ -1,6 +1,7 @@
import { io } from "socket.io-client";
import { useToast } from "vue-toastification";
import jwt_decode from "jwt-decode";
import Favico from "favico.js";
const toast = useToast();
let socket;
@ -11,6 +12,10 @@ const noSocketIOPages = [
"/"
];
const favicon = new Favico({
animation: "none"
});
export default {
data() {
@ -398,10 +403,50 @@ export default {
return result;
},
stats() {
let result = {
up: 0,
down: 0,
unknown: 0,
pause: 0,
};
for (let monitorID in this.$root.monitorList) {
let beat = this.$root.lastHeartbeatList[monitorID];
let monitor = this.$root.monitorList[monitorID];
if (monitor && ! monitor.active) {
result.pause++;
} else if (beat) {
if (beat.status === 1) {
result.up++;
} else if (beat.status === 0) {
result.down++;
} else if (beat.status === 2) {
result.up++;
} else {
result.unknown++;
}
} else {
result.unknown++;
}
}
return result;
},
},
watch: {
// Update Badge
"stats.down"(to, from) {
if (to !== from) {
favicon.badge(to);
console.log(to);
}
},
// Reload the SPA if the server version is changed.
"info.version"(to, from) {
if (from && from !== to) {