mirror of https://github.com/louislam/uptime-kuma
feat: add clear events botton (#6052)
Co-authored-by: Frank Elsinga <frank@elsinga.de>pull/6086/head^2
parent
8d3649966a
commit
668636c9d5
|
@ -592,6 +592,11 @@
|
||||||
"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?",
|
||||||
"enableDefaultNotificationDescription": "This notification will be enabled by default for new monitors. You can still disable the notification separately for each monitor.",
|
"enableDefaultNotificationDescription": "This notification will be enabled by default for new monitors. You can still disable the notification separately for each monitor.",
|
||||||
|
"Clear All Events": "Clear All Events",
|
||||||
|
"clearAllEventsMsg": "Are you sure want to delete all events?",
|
||||||
|
"Events cleared successfully": "Events cleared successfully.",
|
||||||
|
"No monitors found": "No monitors found.",
|
||||||
|
"Could not clear events": "Could not clear {failed}/{total} events",
|
||||||
"clearEventsMsg": "Are you sure want to delete all events for this monitor?",
|
"clearEventsMsg": "Are you sure want to delete all events for this monitor?",
|
||||||
"clearHeartbeatsMsg": "Are you sure want to delete all heartbeats for this monitor?",
|
"clearHeartbeatsMsg": "Are you sure want to delete all heartbeats for this monitor?",
|
||||||
"confirmClearStatisticsMsg": "Are you sure you want to delete ALL statistics?",
|
"confirmClearStatisticsMsg": "Are you sure you want to delete ALL statistics?",
|
||||||
|
|
|
@ -46,6 +46,15 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="shadow-box table-shadow-box" style="overflow-x: hidden;">
|
<div class="shadow-box table-shadow-box" style="overflow-x: hidden;">
|
||||||
|
<div class="mb-3 text-end">
|
||||||
|
<button
|
||||||
|
class="btn btn-sm btn-outline-danger"
|
||||||
|
:disabled="clearingAllEvents"
|
||||||
|
@click="clearAllEventsDialog"
|
||||||
|
>
|
||||||
|
{{ $t("Clear All Events") }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<table class="table table-borderless table-hover">
|
<table class="table table-borderless table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -82,6 +91,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
|
<Confirm
|
||||||
|
ref="confirmClearEvents"
|
||||||
|
btn-style="btn-danger"
|
||||||
|
:yes-text="$t('Yes')"
|
||||||
|
:no-text="$t('No')"
|
||||||
|
@yes="clearAllEvents"
|
||||||
|
>
|
||||||
|
{{ $t("clearAllEventsMsg") }}
|
||||||
|
</Confirm>
|
||||||
<router-view ref="child" />
|
<router-view ref="child" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -89,12 +107,14 @@
|
||||||
import Status from "../components/Status.vue";
|
import Status from "../components/Status.vue";
|
||||||
import Datetime from "../components/Datetime.vue";
|
import Datetime from "../components/Datetime.vue";
|
||||||
import Pagination from "v-pagination-3";
|
import Pagination from "v-pagination-3";
|
||||||
|
import Confirm from "../components/Confirm.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Datetime,
|
Datetime,
|
||||||
Status,
|
Status,
|
||||||
Pagination,
|
Pagination,
|
||||||
|
Confirm,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
calculatedHeight: {
|
calculatedHeight: {
|
||||||
|
@ -113,6 +133,7 @@ export default {
|
||||||
},
|
},
|
||||||
importantHeartBeatListLength: 0,
|
importantHeartBeatListLength: 0,
|
||||||
displayedRecords: [],
|
displayedRecords: [],
|
||||||
|
clearingAllEvents: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -203,6 +224,43 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clearAllEventsDialog() {
|
||||||
|
this.$refs.confirmClearEvents.show();
|
||||||
|
},
|
||||||
|
clearAllEvents() {
|
||||||
|
this.clearingAllEvents = true;
|
||||||
|
const monitorIDs = Object.keys(this.$root.monitorList);
|
||||||
|
let failed = 0;
|
||||||
|
const total = monitorIDs.length;
|
||||||
|
|
||||||
|
if (total === 0) {
|
||||||
|
this.clearingAllEvents = false;
|
||||||
|
this.$root.toastError(this.$t("No monitors found"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
monitorIDs.forEach((monitorID) => {
|
||||||
|
this.$root.getSocket().emit("clearEvents", monitorID, (res) => {
|
||||||
|
if (!res || !res.ok) {
|
||||||
|
failed++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.clearingAllEvents = false;
|
||||||
|
this.page = 1;
|
||||||
|
this.getImportantHeartbeatListLength();
|
||||||
|
if (failed === 0) {
|
||||||
|
this.$root.toastSuccess(this.$t("Events cleared successfully"));
|
||||||
|
} else {
|
||||||
|
this.$root.toastError(
|
||||||
|
this.$t("Could not clear events", {
|
||||||
|
failed,
|
||||||
|
total,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -246,3 +304,4 @@ table {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue