From 751ffd8e72a330afddaf431486555483fbff3d80 Mon Sep 17 00:00:00 2001 From: Teodor Moquist Date: Mon, 10 Nov 2025 19:22:14 +0100 Subject: [PATCH] feat: Added option to clone a existing maintenance (#6330) --- src/lang/en.json | 6 ++++++ src/pages/EditMaintenance.vue | 21 ++++++++++++++++++--- src/pages/ManageMaintenance.vue | 12 ++++++++---- src/router.js | 4 ++++ 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/lang/en.json b/src/lang/en.json index df1677290..84ff347a3 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -518,6 +518,12 @@ "Effective Date Range": "Effective Date Range (Optional)", "Schedule Maintenance": "Schedule Maintenance", "Edit Maintenance": "Edit Maintenance", + "Clone Maintenance": "Clone Maintenance", + "ariaPauseMaintenance": "Pause this maintenance schedule", + "ariaResumeMaintenance": "Resume this maintenance schedule", + "ariaCloneMaintenance": "Create a copy of this maintenance schedule", + "ariaEditMaintenance": "Edit this maintenance schedule", + "ariaDeleteMaintenance": "Delete this maintenance schedule", "Date and Time": "Date and Time", "DateTime Range": "DateTime Range", "loadingError": "Cannot fetch the data, please try again later.", diff --git a/src/pages/EditMaintenance.vue b/src/pages/EditMaintenance.vue index 6341c5bed..70742a9c6 100644 --- a/src/pages/EditMaintenance.vue +++ b/src/pages/EditMaintenance.vue @@ -354,7 +354,14 @@ export default { }, pageName() { - return this.$t((this.isAdd) ? "Schedule Maintenance" : "Edit Maintenance"); + let name = "Schedule Maintenance"; + + if (this.isEdit) { + name = "Edit Maintenance"; + } else if (this.isClone) { + name = "Clone Maintenance"; + } + return this.$t(name); }, isAdd() { @@ -365,6 +372,9 @@ export default { return this.$route.path.startsWith("/maintenance/edit"); }, + isClone() { + return this.$route.path.startsWith("/maintenance/clone"); + } }, watch: { "$route.fullPath"() { @@ -443,11 +453,16 @@ export default { daysOfMonth: [], timezoneOption: null, }; - } else if (this.isEdit) { + } else if (this.isEdit || this.isClone) { this.$root.getSocket().emit("getMaintenance", this.$route.params.id, (res) => { if (res.ok) { this.maintenance = res.maintenance; + if (this.isClone) { + this.maintenance.id = undefined; // Remove id when cloning as we want a new id + this.maintenance.title = this.$t("cloneOf", [ this.maintenance.title ]); + } + this.$root.getSocket().emit("getMonitorMaintenance", this.$route.params.id, (res) => { if (res.ok) { Object.values(res.monitors).map(monitor => { @@ -491,7 +506,7 @@ export default { return this.processing = false; } - if (this.isAdd) { + if (this.isAdd || this.isClone) { this.$root.addMaintenance(this.maintenance, async (res) => { if (res.ok) { await this.addMonitorMaintenance(res.maintenanceID, async () => { diff --git a/src/pages/ManageMaintenance.vue b/src/pages/ManageMaintenance.vue index 8378736a7..dc457d8db 100644 --- a/src/pages/ManageMaintenance.vue +++ b/src/pages/ManageMaintenance.vue @@ -41,19 +41,23 @@ {{ $t("Details") }}
- - - + + {{ $t("Clone") }} + + + {{ $t("Edit") }} -
diff --git a/src/router.js b/src/router.js index bda5078e1..716202d50 100644 --- a/src/router.js +++ b/src/router.js @@ -162,6 +162,10 @@ const routes = [ path: "/maintenance/edit/:id", component: EditMaintenance, }, + { + path: "/maintenance/clone/:id", + component: EditMaintenance, + } ], }, ],