diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue
new file mode 100644
index 0000000..6df3c3f
--- /dev/null
+++ b/src/components/NotificationDialog.vue
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
diff --git a/src/mixins/socket.js b/src/mixins/socket.js
index 1592e70..6093a53 100644
--- a/src/mixins/socket.js
+++ b/src/mixins/socket.js
@@ -13,15 +13,14 @@ export default {
token: null,
firstConnect: true,
connected: false,
+ connectCount: 0,
},
allowLoginDialog: false, // Allowed to show login dialog, but "loggedIn" have to be true too. This exists because prevent the login dialog show 0.1s in first before the socket server auth-ed.
loggedIn: false,
monitorList: [
],
- importantHeartbeatList: [
- ],
heartbeatList: {
},
@@ -38,7 +37,6 @@ export default {
});
socket.on('heartbeat', (data) => {
-
if (! (data.monitorID in this.heartbeatList)) {
this.heartbeatList[data.monitorID] = [];
}
@@ -46,14 +44,30 @@ export default {
this.heartbeatList[data.monitorID].push(data)
});
+ socket.on('heartbeatList', (monitorID, data) => {
+ if (! (monitorID in this.heartbeatList)) {
+ this.heartbeatList[monitorID] = data;
+ } else {
+ this.heartbeatList[monitorID] = data.concat(this.heartbeatList[monitorID])
+ }
+ });
+
socket.on('disconnect', () => {
+ console.log("disconnect")
this.socket.connected = false;
});
socket.on('connect', () => {
+ console.log("connect")
+ this.socket.connectCount++;
this.socket.connected = true;
- this.socket.firstConnect = false;
+
+ // Reset Heartbeat list if it is re-connect
+ if (this.socket.connectCount >= 2) {
+ console.log("reset heartbeat list")
+ this.heartbeatList = {}
+ }
if (storage.token) {
this.loginByToken(storage.token)
@@ -61,6 +75,7 @@ export default {
this.allowLoginDialog = true;
}
+ this.socket.firstConnect = false;
});
},
@@ -113,10 +128,9 @@ export default {
logout() {
storage.removeItem("token");
this.socket.token = null;
- this.loggedIn = false;
socket.emit("logout", () => {
- toast.success("Logout Successfully")
+ window.location.reload()
})
},
@@ -142,6 +156,26 @@ export default {
return result;
},
+ // TODO: handle history + real time
+ importantHeartbeatList() {
+ let result = {}
+
+ for (let monitorID in this.heartbeatList) {
+ result[monitorID] = [];
+
+ let index = this.heartbeatList[monitorID].length - 1;
+ let list = this.heartbeatList[monitorID];
+
+ for (let heartbeat of list) {
+ if (heartbeat.important) {
+ result[monitorID].push(heartbeat)
+ }
+ }
+ }
+
+ return result;
+ },
+
statusList() {
let result = {}
diff --git a/src/pages/DashboardHome.vue b/src/pages/DashboardHome.vue
index 80b1db7..396afdd 100644
--- a/src/pages/DashboardHome.vue
+++ b/src/pages/DashboardHome.vue
@@ -134,8 +134,6 @@ export default {
result.unknown++;
}
} else {
- console.log(monitorID + " Unknown?")
- console.log(beat)
result.unknown++;
}
}
diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue
index 1bc16bb..63aa290 100644
--- a/src/pages/EditMonitor.vue
+++ b/src/pages/EditMonitor.vue
@@ -40,23 +40,24 @@
Notifications
-
Not available, please setup in Settings page.
-
Go to Settings
+
Not available, please setup.
+
-
+