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({
ok: true,
msg: "Events Successfully Cleared.",
});
} catch (e) {
@ -589,7 +588,26 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
callback({
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) {

View File

@ -104,9 +104,10 @@ export default {
rrtypeDescription: "Wähle den RR-Typ aus, welchen du überwachen möchtest.",
"Last Result": "Letztes Ergebnis",
pauseMonitorMsg: "Bist du sicher das du den Monitor pausieren möchtest?",
clearEventsMsg: "Bist du sicher das du alle Ereignisse löschen möchtest?",
clearHeartbeatsMsg: "Bist du sicher das du alle Statistiken 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 für diesen Monitor löschen möchtest?",
"Clear Data": "Lösche Daten",
"Events": "Ereignisse",
"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.",
rrtypeDescription: "Select the RR-Type you want to monitor",
pauseMonitorMsg: "Are you sure want to pause?",
clearEventsMsg: "Are you sure want to delete all events?",
clearHeartbeatsMsg: "Are you sure want to delete all heartbeats?",
clearEventsMsg: "Are you sure want to delete all events for this monitor?",
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) {
socket.emit("clearHeartbeats", monitorID, callback)
},
clearStatistics(callback) {
socket.emit("clearStatistics", callback)
},
},
computed: {

View File

@ -360,7 +360,6 @@ export default {
clearEvents() {
this.$root.clearEvents(this.monitor.id, (res) => {
if (res.ok) {
toast.success(res.msg);
this.$router.go();
} else {
toast.error(res.msg);
@ -371,7 +370,6 @@ export default {
clearHeartbeats() {
this.$root.clearHeartbeats(this.monitor.id, (res) => {
if (res.ok) {
toast.success(res.msg);
this.$router.go();
} else {
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-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 class="btn btn-outline-danger me-1" @click="confirmClearStatistics">{{ $t("Clear all Statistics") }}</button>
</div>
</template>
</div>
@ -184,6 +185,10 @@
<p>Bitte mit Vorsicht nutzen.</p>
</template>
</Confirm>
<Confirm ref="confirmClearStatistics" btn-style="btn-danger" :yes-text="$t('Yes')" :no-text="$t('No')" @yes="clearStatistics">
{{ $t("confirmClearStatisticsMsg") }}
</Confirm>
</div>
</transition>
</template>
@ -282,6 +287,10 @@ export default {
this.$refs.confirmDisableAuth.show();
},
confirmClearStatistics() {
this.$refs.confirmClearStatistics.show();
},
disableAuth() {
this.settings.disableAuth = true;
this.saveSettings();
@ -293,6 +302,15 @@ export default {
this.$root.storage().removeItem("token");
},
clearStatistics() {
this.$root.clearStatistics((res) => {
if (res.ok) {
this.$router.go();
} else {
toast.error(res.msg);
}
})
},
},
}
</script>