|
|
@ -1,5 +1,6 @@
|
|
|
|
import { io } from "socket.io-client";
|
|
|
|
import { io } from "socket.io-client";
|
|
|
|
import { useToast } from "vue-toastification";
|
|
|
|
import { useToast } from "vue-toastification";
|
|
|
|
|
|
|
|
import Favico from "favico.js";
|
|
|
|
const toast = useToast();
|
|
|
|
const toast = useToast();
|
|
|
|
|
|
|
|
|
|
|
|
let socket;
|
|
|
|
let socket;
|
|
|
@ -10,6 +11,12 @@ const noSocketIOPages = [
|
|
|
|
"/"
|
|
|
|
"/"
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const favicon = new Favico({
|
|
|
|
|
|
|
|
animation: "none"
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let downMonitors = [];
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
|
|
|
|
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
@ -118,10 +125,14 @@ export default {
|
|
|
|
if (data.important) {
|
|
|
|
if (data.important) {
|
|
|
|
|
|
|
|
|
|
|
|
if (data.status === 0) {
|
|
|
|
if (data.status === 0) {
|
|
|
|
|
|
|
|
downMonitors.push(data.monitorID);
|
|
|
|
|
|
|
|
favicon.badge(downMonitors.length);
|
|
|
|
toast.error(`[${this.monitorList[data.monitorID].name}] [DOWN] ${data.msg}`, {
|
|
|
|
toast.error(`[${this.monitorList[data.monitorID].name}] [DOWN] ${data.msg}`, {
|
|
|
|
timeout: false,
|
|
|
|
timeout: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (data.status === 1) {
|
|
|
|
} else if (data.status === 1) {
|
|
|
|
|
|
|
|
downMonitors = downMonitors.filter(monitor => monitor !== data.monitorID);
|
|
|
|
|
|
|
|
favicon.badge(downMonitors.length);
|
|
|
|
toast.success(`[${this.monitorList[data.monitorID].name}] [Up] ${data.msg}`, {
|
|
|
|
toast.success(`[${this.monitorList[data.monitorID].name}] [Up] ${data.msg}`, {
|
|
|
|
timeout: 20000,
|
|
|
|
timeout: 20000,
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -138,6 +149,11 @@ export default {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
socket.on("heartbeatList", (monitorID, data, overwrite = false) => {
|
|
|
|
socket.on("heartbeatList", (monitorID, data, overwrite = false) => {
|
|
|
|
|
|
|
|
const lastElement = data.at(-1);
|
|
|
|
|
|
|
|
if (lastElement.status === 0) {
|
|
|
|
|
|
|
|
downMonitors.push(monitorID);
|
|
|
|
|
|
|
|
favicon.badge(downMonitors.length);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (! (monitorID in this.heartbeatList) || overwrite) {
|
|
|
|
if (! (monitorID in this.heartbeatList) || overwrite) {
|
|
|
|
this.heartbeatList[monitorID] = data;
|
|
|
|
this.heartbeatList[monitorID] = data;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -304,11 +320,15 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
deleteMonitor(monitorID, callback) {
|
|
|
|
deleteMonitor(monitorID, callback) {
|
|
|
|
|
|
|
|
downMonitors = downMonitors.filter(monitor => monitor !== monitorID);
|
|
|
|
|
|
|
|
favicon.badge(downMonitors.length);
|
|
|
|
socket.emit("deleteMonitor", monitorID, callback);
|
|
|
|
socket.emit("deleteMonitor", monitorID, callback);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
clearData() {
|
|
|
|
clearData() {
|
|
|
|
console.log("reset heartbeat list");
|
|
|
|
console.log("reset heartbeat list");
|
|
|
|
|
|
|
|
downMonitors = [];
|
|
|
|
|
|
|
|
favicon.badge(0);
|
|
|
|
this.heartbeatList = {};
|
|
|
|
this.heartbeatList = {};
|
|
|
|
this.importantHeartbeatList = {};
|
|
|
|
this.importantHeartbeatList = {};
|
|
|
|
},
|
|
|
|
},
|
|
|
|