Added clear all db statistics function

This commit is contained in:
Ponkhy 2021-09-01 00:36:24 +02:00
parent 1341d220ed
commit 7b92166d18
6 changed files with 48 additions and 8 deletions

View File

@ -566,7 +566,6 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
callback({ callback({
ok: true, ok: true,
msg: "Events Successfully Cleared.",
}); });
} catch (e) { } catch (e) {
@ -589,7 +588,26 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
callback({ callback({
ok: true, ok: true,
msg: "Heartbeats Successfully Cleared.", });
} catch (e) {
callback({
ok: false,
msg: e.message,
});
}
});
socket.on("clearStatistics", async (callback) => {
try {
checkLogin(socket)
console.log(`Clear Statistics User ID: ${socket.userID}`)
await R.exec("DELETE FROM heartbeat");
callback({
ok: true,
}); });
} catch (e) { } catch (e) {

View File

@ -104,9 +104,10 @@ export default {
rrtypeDescription: "Wähle den RR-Typ aus, welchen du überwachen möchtest.", rrtypeDescription: "Wähle den RR-Typ aus, welchen du überwachen möchtest.",
"Last Result": "Letztes Ergebnis", "Last Result": "Letztes Ergebnis",
pauseMonitorMsg: "Bist du sicher das du den Monitor pausieren möchtest?", pauseMonitorMsg: "Bist du sicher das du den Monitor pausieren möchtest?",
clearEventsMsg: "Bist du sicher das du alle Ereignisse löschen möchtest?", clearEventsMsg: "Bist du sicher das du alle Ereignisse für diesen Monitor löschen möchtest?",
clearHeartbeatsMsg: "Bist du sicher das du alle Statistiken löschen möchtest?", clearHeartbeatsMsg: "Bist du sicher das du alle Statistiken für diesen Monitor löschen möchtest?",
"Clear Data": "Lösche Daten", "Clear Data": "Lösche Daten",
"Events": "Ereignisse", "Events": "Ereignisse",
"Heartbeats": "Statistiken", "Heartbeats": "Statistiken",
confirmClearStatisticsMsg: "Bist du sicher das du ALLE Statistiken löschen möchtest?",
} }

View File

@ -16,6 +16,7 @@ export default {
resoverserverDescription: "Cloudflare is the default server, you can change the resolver server anytime.", resoverserverDescription: "Cloudflare is the default server, you can change the resolver server anytime.",
rrtypeDescription: "Select the RR-Type you want to monitor", rrtypeDescription: "Select the RR-Type you want to monitor",
pauseMonitorMsg: "Are you sure want to pause?", pauseMonitorMsg: "Are you sure want to pause?",
clearEventsMsg: "Are you sure want to delete all events?", clearEventsMsg: "Are you sure want to delete all events for this monitor?",
clearHeartbeatsMsg: "Are you sure want to delete all heartbeats?", clearHeartbeatsMsg: "Are you sure want to delete all heartbeats for this monitor?",
confirmClearStatisticsMsg: "Are you sure want to delete ALL statistics?",
} }

View File

@ -261,6 +261,10 @@ export default {
clearHeartbeats(monitorID, callback) { clearHeartbeats(monitorID, callback) {
socket.emit("clearHeartbeats", monitorID, callback) socket.emit("clearHeartbeats", monitorID, callback)
}, },
clearStatistics(callback) {
socket.emit("clearStatistics", callback)
},
}, },
computed: { computed: {

View File

@ -360,7 +360,6 @@ export default {
clearEvents() { clearEvents() {
this.$root.clearEvents(this.monitor.id, (res) => { this.$root.clearEvents(this.monitor.id, (res) => {
if (res.ok) { if (res.ok) {
toast.success(res.msg);
this.$router.go(); this.$router.go();
} else { } else {
toast.error(res.msg); toast.error(res.msg);
@ -371,7 +370,6 @@ export default {
clearHeartbeats() { clearHeartbeats() {
this.$root.clearHeartbeats(this.monitor.id, (res) => { this.$root.clearHeartbeats(this.monitor.id, (res) => {
if (res.ok) { if (res.ok) {
toast.success(res.msg);
this.$router.go(); this.$router.go();
} else { } else {
toast.error(res.msg); toast.error(res.msg);

View File

@ -126,6 +126,7 @@
<button v-if="settings.disableAuth" class="btn btn-outline-primary me-1" @click="enableAuth">{{ $t("Enable Auth") }}</button> <button v-if="settings.disableAuth" class="btn btn-outline-primary me-1" @click="enableAuth">{{ $t("Enable Auth") }}</button>
<button v-if="! settings.disableAuth" class="btn btn-primary me-1" @click="confirmDisableAuth">{{ $t("Disable Auth") }}</button> <button v-if="! settings.disableAuth" class="btn btn-primary me-1" @click="confirmDisableAuth">{{ $t("Disable Auth") }}</button>
<button v-if="! settings.disableAuth" class="btn btn-danger me-1" @click="$root.logout">{{ $t("Logout") }}</button> <button v-if="! settings.disableAuth" class="btn btn-danger me-1" @click="$root.logout">{{ $t("Logout") }}</button>
<button class="btn btn-outline-danger me-1" @click="confirmClearStatistics">{{ $t("Clear all Statistics") }}</button>
</div> </div>
</template> </template>
</div> </div>
@ -184,6 +185,10 @@
<p>Bitte mit Vorsicht nutzen.</p> <p>Bitte mit Vorsicht nutzen.</p>
</template> </template>
</Confirm> </Confirm>
<Confirm ref="confirmClearStatistics" btn-style="btn-danger" :yes-text="$t('Yes')" :no-text="$t('No')" @yes="clearStatistics">
{{ $t("confirmClearStatisticsMsg") }}
</Confirm>
</div> </div>
</transition> </transition>
</template> </template>
@ -282,6 +287,10 @@ export default {
this.$refs.confirmDisableAuth.show(); this.$refs.confirmDisableAuth.show();
}, },
confirmClearStatistics() {
this.$refs.confirmClearStatistics.show();
},
disableAuth() { disableAuth() {
this.settings.disableAuth = true; this.settings.disableAuth = true;
this.saveSettings(); this.saveSettings();
@ -293,6 +302,15 @@ export default {
this.$root.storage().removeItem("token"); this.$root.storage().removeItem("token");
}, },
clearStatistics() {
this.$root.clearStatistics((res) => {
if (res.ok) {
this.$router.go();
} else {
toast.error(res.msg);
}
})
},
}, },
} }
</script> </script>