feat: Decouple Clear All Events from heartbeat msg deletion (#7293)#7295
feat: Decouple Clear All Events from heartbeat msg deletion (#7293)#7295himax12 wants to merge 2 commits intolouislam:masterfrom
Conversation
…eartbeat msg data Decouples the UI timeline clear from database msg deletion as requested in issue louislam#7293. Changes: - Added ClearEventsConfirm.vue component with checkbox option - Modified clearEvents socket handler to accept optional clearMsg parameter - Default behavior now preserves msg data (clear timeline only) - Users can opt-in to also delete msg data for disk space savings - Fixed event listener memory leak (cleanup in beforeUnmount) New i18n keys added: - clearAllEventsMsgTimelineOnly: Timeline cleanup description - clearAllEventsMsgDataWarning: Data deletion warning - Also clear historical event data: Checkbox label
There was a problem hiding this comment.
Pull request overview
This PR updates the “Clear All Events” flow to default to clearing only timeline-visible events while optionally allowing users to also purge stored heartbeat msg payloads, addressing #7293.
Changes:
- Adds a dedicated
ClearEventsConfirmmodal with a checkbox controlling whether heartbeatmsgdata is also cleared. - Extends the
clearEventsSocket.IO handler to accept an optionalclearMsgparameter. - Updates the dashboard to use the new modal and pass the checkbox state to the backend.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/pages/DashboardHome.vue |
Swaps the generic confirm modal for ClearEventsConfirm and sends clearMsg to the backend when clearing events. |
src/components/ClearEventsConfirm.vue |
New Bootstrap modal component that collects the “also clear msg data” choice and emits it to the parent. |
server/server.js |
Changes clearEvents handler behavior based on clearMsg (timeline-only vs. also clear heartbeat msg). |
src/lang/en.json |
Adds new i18n strings for the updated modal copy. |
Comments suppressed due to low confidence (1)
src/pages/DashboardHome.vue:291
failedis incremented inside the Socket.IO acknowledgement callback, but success/error toasts andclearingAllEventsare set immediately afterforEach. This means the UI will almost always report success (and stop showing the loading state) before any responses arrive. Consider awaiting all acknowledgements (e.g., wrap emits in Promises andawait Promise.all) before computingfailedand clearing the loading flag.
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,
| </div> | ||
| </div> | ||
| <div class="modal-footer"> | ||
| <button type="button" class="btn btn-secondary" @click="close"> |
There was a problem hiding this comment.
The checkbox label/text implies "clear historical event data", but the actual behavior behind clearMsg is deleting the heartbeat msg payload (not clearing events/heartbeats themselves). This mismatch can mislead users about what will be removed; please align the wording (label + warning text) with the actual destructive action (e.g., explicitly mention clearing heartbeat message/payload data).
| "clearAllEventsMsgDataWarning": "Also delete all msg data from heartbeats. This cannot be undone.", | ||
| "Also clear historical event data": "Also clear historical event data", |
There was a problem hiding this comment.
User-facing copy uses the internal column name "msg" ("Also delete all msg data...") and doesn’t clearly explain what data is being removed. Consider rewording to something like "heartbeat message/payload data" (and keep it consistent with the checkbox label) so non-technical users understand the impact.
| "clearAllEventsMsgDataWarning": "Also delete all msg data from heartbeats. This cannot be undone.", | |
| "Also clear historical event data": "Also clear historical event data", | |
| "clearAllEventsMsgDataWarning": "Also delete heartbeat message/payload data. This cannot be undone.", | |
| "Also clear historical event data": "Also clear heartbeat message/payload data", |
| socket.on("clearEvents", async (monitorID, clearMsg, callback) => { | ||
| try { | ||
| checkLogin(socket); | ||
|
|
||
| log.info("manage", `Clear Events Monitor: ${monitorID} User ID: ${socket.userID}`); | ||
|
|
||
| await R.exec("UPDATE heartbeat SET msg = ?, important = ? WHERE monitor_id = ? ", ["", "0", monitorID]); | ||
| if (clearMsg) { | ||
| // Clear both msg and important flag (original behavior) | ||
| await R.exec("UPDATE heartbeat SET msg = ?, important = ? WHERE monitor_id = ?", [ | ||
| "", | ||
| "0", | ||
| monitorID, | ||
| ]); |
There was a problem hiding this comment.
clearEvents socket handler signature change is not backward-compatible: existing clients still emit clearEvents as (monitorID, callback). In that case clearMsg becomes the callback function (truthy), callback is undefined, and the handler will both wipe msg unexpectedly and throw when calling callback(...). Please support both call shapes (e.g., if typeof clearMsg === "function" then treat it as callback and default clearMsg to false) and guard against missing callbacks.
|
Hello @himax12 #7293 as this issue states there is no need to over enginner the flow (as your pr) we just need to inform the user |
|
yea, as said: lets just add a better warning to the confirmation modal (i think there should be one?) |
|
Heyy then tell me exactly what can I rectify in it
…On Mon, 20 Apr 2026, 11:37 Frank Elsinga, ***@***.***> wrote:
*CommanderStorm* left a comment (louislam/uptime-kuma#7295)
<#7295?email_source=notifications&email_token=A5IBYFCMED5GCZ3XPKK4MND4WW5BLA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMRXHAZDKOBYHE42M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJNLQOJPWG33NNVSW45C7N5YGK3S7MNWGSY3L#issuecomment-4278258899>
yea, as said: lets just add a better warning to the confirmation modal (i
think there should be one?)
—
Reply to this email directly, view it on GitHub
<#7295?email_source=notifications&email_token=A5IBYFCMED5GCZ3XPKK4MND4WW5BLA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMRXHAZDKOBYHE42M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJNLQOJPWG33NNVSW45C7N5YGK3S7MNWGSY3L#issuecomment-4278258899>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5IBYFFQFVZAOXXT6CSM5HT4WW5BLAVCNFSM6AAAAACX62K7TWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DENZYGI2TQOBZHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
We have merged a competing PR that was simpler. |
Summary
In this pull request, the following changes are made:
Added
ClearEventsConfirm.vuecomponent with checkbox option to let users choose whether to also purge heartbeat msg dataModified
clearEventssocket handler to accept optionalclearMsgparameter (default: false - preserves msg)Updated
DashboardHome.vueto use the new modal componentAdded proper event listener cleanup in
beforeUnmountto fix potential memory leakRelates to Feature Request: Decouple "Clear All Events" from heartbeat msg payload deletion (or add UI warning) #7293
Resolves Feature Request: Decouple "Clear All Events" from heartbeat msg payload deletion (or add UI warning) #7293
Please follow this checklist to avoid unnecessary back and forth (click to expand)
I understand that I am responsible for and able to explain every line of code I submit.
Screenshots for Visual Changes
The new confirmation modal appears when clicking "Clear All Events":
UI Modifications:
ClearEventsConfirm.vuecomponentConfirm.vueusage inDashboardHome.vuewith new componentBefore: Single button click immediately deleted msg data silently
After: Modal with checkbox gives user explicit choice
Testing
Code Explanation
I reviewed and understand all changes:
server/server.js: The
clearEventshandler now takes a second boolean parameterclearMsg. When false/undefined, only theimportantflag is cleared (timeline cleanup). When true, bothmsgandimportantare cleared (original destructive behavior).src/components/ClearEventsConfirm.vue: New modal component following existing Bootstrap Modal patterns. Added
beforeUnmountlifecycle hook to properly clean up event listeners and dispose the Bootstrap modal instance (addressing Copilot review feedback).src/pages/DashboardHome.vue: Changed to use the new
ClearEventsConfirmcomponent instead of genericConfirm. TheclearAllEventsmethod now passes the checkbox state to the backend.src/lang/en.json: Added three new translation keys for the modal text.