From 1363aa438cab474bd7d8ba3049f3ef95468d6dc4 Mon Sep 17 00:00:00 2001 From: sbgap Date: Mon, 11 Nov 2024 16:46:21 +0100 Subject: [PATCH 1/8] feat: add confirm for closing notification rule dialog --- src/components/NotificationRuleList.vue | 45 ++++++++++++++++++------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/components/NotificationRuleList.vue b/src/components/NotificationRuleList.vue index 6d9170b5..cd684866 100644 --- a/src/components/NotificationRuleList.vue +++ b/src/components/NotificationRuleList.vue @@ -355,7 +355,7 @@ add @@ -569,7 +569,7 @@ {{ $t('Cancel') }} @@ -736,7 +736,7 @@
@@ -989,7 +989,7 @@ export default { dialog: false, active_dialog: false, headers: [ - { text: i18n.t('Acitve'), value: 'active' }, + { text: i18n.t('Active'), value: 'active' }, { text: i18n.t('Reactivate'), value: 'reactivate' }, { text: i18n.t('Customer'), value: 'customer' }, { text: i18n.t('Delay'), value: 'delay' }, @@ -1263,9 +1263,21 @@ export default { this.getUsers() this.getGroups() this.getNotificaitonGroups() - this.editedItem = Object.assign({}, this.defaultItem) + this.editedItem = Object.assign({}, JSON.parse(JSON.stringify(this.defaultItem))) + this.editedItemStart = JSON.parse(JSON.stringify(this.defaultItem)) }, methods: { + compareDict(a, b) { + if (a === null) return true + for (const key in a) { + if (b[key] === undefined) return false + if (typeof a[key] === typeof({})) { + if (!this.compareDict(a[key], b[key])) return false + } + else if (a[key] !== b[key]) return false + } + return true + }, emptyArray(arr) { for (let t in arr) { return false @@ -1329,6 +1341,7 @@ export default { editItem(item) { this.editedId = item.id this.editedItem = Object.assign({}, item) + this.editedItemStart = JSON.parse(JSON.stringify(item)) this.dialog = true }, copyItem(item) { @@ -1344,17 +1357,22 @@ export default { ) }, close() { - this.dialog = false - setTimeout(() => { - this.$refs.form.resetValidation() - this.editedItem = Object.assign({}, this.defaultItem) - this.editedId = null - }, 300) + let change = !this.compareDict(this.editedItem, this.editedItemStart) + if (this.saved || !change || confirm('Are you sure you want to close the dialog?')) { + setTimeout(() => { + this.$refs.form.resetValidation() + this.editedItem = JSON.parse(JSON.stringify(this.defaultItem)) + this.editedItemStart = JSON.parse(JSON.stringify(this.defaultItem)) + this.editedId = null + this.saved = false + }, 300) + } + else setTimeout(() => this.dialog = true, 0.1) }, close_active() { this.active_dialog = false setTimeout(() => { - this.editedItem = Object.assign({}, this.defaultItem) + this.editedItem = Object.assign({}, JSON.parse(JSON.stringify(this.defaultItem))) this.editedId = null }, 300) }, @@ -1477,7 +1495,8 @@ export default { }) ) } - this.close() + this.saved = true + this.dialog = false } } } From 6638af36e54b94dd69d33bc564c42b41ad98e108 Mon Sep 17 00:00:00 2001 From: sbgap Date: Mon, 11 Nov 2024 16:46:59 +0100 Subject: [PATCH 2/8] style: remove commented out code --- src/components/NotificationRuleList.vue | 48 ------------------------- 1 file changed, 48 deletions(-) diff --git a/src/components/NotificationRuleList.vue b/src/components/NotificationRuleList.vue index cd684866..3a37a1f4 100644 --- a/src/components/NotificationRuleList.vue +++ b/src/components/NotificationRuleList.vue @@ -795,54 +795,6 @@
- Date: Mon, 11 Nov 2024 17:09:54 +0100 Subject: [PATCH 3/8] feat: add confirm for closing escalation rule dialog --- src/components/EscalationRuleList.vue | 37 ++++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/components/EscalationRuleList.vue b/src/components/EscalationRuleList.vue index af315114..9f86da69 100644 --- a/src/components/EscalationRuleList.vue +++ b/src/components/EscalationRuleList.vue @@ -705,9 +705,21 @@ export default { this.getEnvironments() this.getServices() this.getTags() - this.editedItem = Object.assign({}, this.defaultItem) + this.editedItem = Object.assign({}, JSON.parse(JSON.stringify(this.defaultItem))) + this.editedItemStart = Object.assign({}, JSON.parse(JSON.stringify(this.defaultItem))) }, methods: { + compareDict(a, b) { + if (a === null) return true + for (const key in a) { + if (b[key] === undefined) return false + if (typeof a[key] === typeof({})) { + if (!this.compareDict(a[key], b[key])) return false + } + else if (a[key] !== b[key]) return false + } + return true + }, getEscalationRules() { this.$store.dispatch('escalationRules/getEscalationRules') }, @@ -732,7 +744,8 @@ export default { editItem(item) { this.editedId = item.id - this.editedItem = Object.assign({}, item) + this.editedItem = Object.assign({}, JSON.parse(JSON.stringify(item))) + this.editedItemStart = JSON.parse(JSON.stringify(item)) this.dialog = true }, copyItem(item) { @@ -748,12 +761,17 @@ export default { ) }, close() { - this.dialog = false - setTimeout(() => { - this.$refs.form.resetValidation() - this.editedItem = Object.assign({}, this.defaultItem) - this.editedId = null - }, 300) + let change = !this.compareDict(this.editedItem, this.editedItemStart) + if (this.saved || !change || confirm('Are you sure you want to close the dialog?')) { + setTimeout(() => { + this.$refs.form.resetValidation() + this.editedItem = JSON.parse(JSON.stringify(this.defaultItem)) + this.editedItemStart = JSON.parse(JSON.stringify(this.defaultItem)) + this.editedId = null + this.saved = false + }, 300) + } + else setTimeout(() => this.dialog = true, 0.1) }, validate() { if (this.$refs.form.validate()) { @@ -823,7 +841,8 @@ export default { }) ) } - this.close() + this.dialog = false + this.saved = true } } } From 5810ee52d22c3a2f5dde466f956f664dfda6cf36 Mon Sep 17 00:00:00 2001 From: sbgap Date: Tue, 12 Nov 2024 09:57:32 +0100 Subject: [PATCH 4/8] feat: add confirm for closing notification group dialog --- src/components/NotificationGroupList.vue | 37 ++++++++++++++++++------ 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/components/NotificationGroupList.vue b/src/components/NotificationGroupList.vue index 6ebc8709..06e2c444 100644 --- a/src/components/NotificationGroupList.vue +++ b/src/components/NotificationGroupList.vue @@ -62,7 +62,7 @@ {{ $t('Cancel') }} @@ -312,8 +312,20 @@ export default { this.getNotificationGroups() this.getUsers() this.editedItem = Object.assign({}, this.defaultItem) + this.editedItemStart = Object.assign({}, this.defaultItem) }, methods: { + compareDict(a, b) { + if (a === null) return true + for (const key in a) { + if (b[key] === undefined) return false + if (typeof a[key] === typeof({})) { + if (b[key] === null || a[key].length !== b[key].length || !this.compareDict(a[key], b[key])) return false + } + else if (a[key] !== b[key]) return false + } + return true + }, getNotificationGroups() { this.$store.dispatch('notificationGroups/getNotificationGroups') }, @@ -327,6 +339,7 @@ export default { editItem(item) { this.editedId = item.id this.editedItem = Object.assign({}, item) + this.editedItemStart = Object.assign({}, item) this.dialog = true }, copyItem(item) { @@ -337,14 +350,19 @@ export default { deleteItem(item) { confirm(i18n.t('ConfirmDelete')) && this.$store.dispatch('notificationGroups/deleteNotificationGroup', item.id) - }, + }, close() { - this.dialog = false - setTimeout(() => { - this.$refs.form.resetValidation() - this.editedItem = Object.assign({}, this.defaultItem) - this.editedId = null - }, 300) + let change = !this.compareDict(this.editedItem, this.editedItemStart) + if (this.saved || !change || confirm('Are you sure you want to close the dialog?')) { + setTimeout(() => { + this.$refs.form.resetValidation() + this.editedItem = Object.assign({}, this.defaultItem) + this.editedItemStart = Object.assign({}, this.defaultItem) + this.editedId = null + this.saved = false + }, 300) + } + else setTimeout(() => this.dialog = true, 0.1) }, validate() { if (this.$refs.form.validate()) { @@ -371,7 +389,8 @@ export default { }) ) } - this.close() + this.dialog = false + this.saved = true } } } From 000f9d91cfe276ce627fba5846722175989e5163 Mon Sep 17 00:00:00 2001 From: sbgap Date: Tue, 12 Nov 2024 10:14:29 +0100 Subject: [PATCH 5/8] feat: add confirm for closing on call dialog --- src/components/OnCallList.vue | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/components/OnCallList.vue b/src/components/OnCallList.vue index 294a8138..5916aae4 100644 --- a/src/components/OnCallList.vue +++ b/src/components/OnCallList.vue @@ -238,7 +238,7 @@ {{ $t('Cancel') }} @@ -646,8 +646,20 @@ export default { this.getUsers() this.getGroups() this.editedItem = Object.assign({}, this.defaultItem) + this.editedItemStart = Object.assign({}, this.defaultItem) }, methods: { + compareDict(a, b) { + if (a === null) return true + for (const key in a) { + if (b[key] === undefined) return false + if (a[key] !== null && typeof a[key] === typeof({})) { + if (b[key] === null || a[key].length !== b[key].length || !this.compareDict(a[key], b[key])) return false + } + else if (a[key] !== b[key]) return false + } + return true + }, selectOdd(e) { const filtered_items = e.items.filter((value, index) => index % 2 == 0) e.internalValue = e.items.filter((value, index) => index % 2 == 0) @@ -674,6 +686,7 @@ export default { editItem(item) { this.editedId = item.id this.editedItem = Object.assign({}, item) + this.editedItemStart = Object.assign({}, item) this.dialog = true }, copyItem(item) { @@ -686,12 +699,17 @@ export default { this.$store.dispatch('onCalls/deleteOnCall', item.id) }, close() { - this.dialog = false - setTimeout(() => { - this.$refs.form.resetValidation() - this.editedItem = Object.assign({}, this.defaultItem) - this.editedId = null - }, 300) + let change = !this.compareDict(this.editedItem, this.editedItemStart) + if (this.saved || !change || confirm('Are you sure you want to close the dialog?')) { + setTimeout(() => { + this.$refs.form.resetValidation() + this.editedItem = Object.assign({}, this.defaultItem) + this.editedItemStart = Object.assign({}, this.defaultItem) + this.editedId = null + this.saved = false + }, 300) + } + else setTimeout(() => this.dialog = true, 0.1) }, validate() { if (this.$refs.form.validate()) { @@ -735,7 +753,8 @@ export default { }) ) } - this.close() + this.dialog = false + this.saved = true } } } From 851777cd33bf0a2a6704759727bdde4c53ecc1a3 Mon Sep 17 00:00:00 2001 From: sbgap Date: Tue, 12 Nov 2024 10:27:05 +0100 Subject: [PATCH 6/8] feat: add confirm for closing blackouts dialog --- src/components/BlackoutList.vue | 39 +++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/components/BlackoutList.vue b/src/components/BlackoutList.vue index 73656c8c..f97a7669 100644 --- a/src/components/BlackoutList.vue +++ b/src/components/BlackoutList.vue @@ -207,7 +207,7 @@ {{ $t('Cancel') }} @@ -635,9 +635,22 @@ export default { this.getServices() this.getTags() this.editedItem = Object.assign({}, this.defaultItem) + this.editedItemStart = Object.assign({}, this.defaultItem) this.editedItem.period = this.defaultTimes() + this.editedItemStart.period = JSON.parse(JSON.stringify(this.editedItem.period)) }, methods: { + compareDict(a, b) { + if (a === null) return true + for (const key in a) { + if (b[key] === undefined) return false + if (a[key] !== null && typeof a[key] === typeof({})) { + if (b[key] === null || a[key].length !== b[key].length || !this.compareDict(a[key], b[key])) return false + } + else if (a[key] !== b[key]) return false + } + return true + }, getBlackouts() { this.$store.dispatch('blackouts/getBlackouts') }, @@ -696,6 +709,7 @@ export default { editItem(item) { this.editedId = item.id this.editedItem = Object.assign({}, item) + this.editedItemStart = JSON.parse(JSON.stringify(item)) this.dialog = true }, copyItem(item) { @@ -709,13 +723,19 @@ export default { this.$store.dispatch('blackouts/deleteBlackout', item.id) }, close() { - this.dialog = false - setTimeout(() => { - this.$refs.form.resetValidation() - this.editedItem = Object.assign({}, this.defaultItem) - this.editedItem.period = this.defaultTimes() - this.editedId = null - }, 300) + let change = !this.compareDict(this.editedItem, this.editedItemStart) + if (this.saved || !change || confirm('Are you sure you want to close the dialog?')) { + setTimeout(() => { + this.$refs.form.resetValidation() + this.editedItem = Object.assign({}, this.defaultItem) + this.editedItemStart = Object.assign({}, this.defaultItem) + this.editedItem.period = this.defaultTimes() + this.editedItemStart.period = JSON.parse(JSON.stringify(this.editedItem.period)) + this.editedId = null + this.saved = false + }, 300) + } + else setTimeout(() => this.dialog = true, 0.1) }, validate() { if (this.$refs.form.validate()) { @@ -763,7 +783,8 @@ export default { }) ) } - this.close() + this.dialog = false + this.saved = true } } } From f4b31180d02c19644b0760bec91c284059b59b67 Mon Sep 17 00:00:00 2001 From: sbgap Date: Tue, 12 Nov 2024 10:35:11 +0100 Subject: [PATCH 7/8] feat: add confirm for closing notification channel dialog --- src/components/NotificationChannelList.vue | 35 +++++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/components/NotificationChannelList.vue b/src/components/NotificationChannelList.vue index 8df26d2d..2be0f15d 100644 --- a/src/components/NotificationChannelList.vue +++ b/src/components/NotificationChannelList.vue @@ -135,7 +135,7 @@ {{ $t('Cancel') }} @@ -519,8 +519,20 @@ export default { this.getEncryptionKey() this.getCustomers() this.editedItem = Object.assign({}, this.defaultItem) + this.editedItemStart = Object.assign({}, this.defaultItem) }, methods: { + compareDict(a, b) { + if (a === null) return true + for (const key in a) { + if (b[key] === undefined) return false + if (a[key] !== null && typeof a[key] === typeof({})) { + if (b[key] === null || a[key].length !== b[key].length || !this.compareDict(a[key], b[key])) return false + } + else if (a[key] !== b[key]) return false + } + return true + }, getEncryptionKey() { this.$store.dispatch('notificationChannels/getEncryptionKey') }, @@ -539,6 +551,7 @@ export default { editItem(item) { this.editedId = item.id this.editedItem = Object.assign({}, item) + this.editedItemStart = Object.assign({}, item) this.dialog = true }, testItem(item) { @@ -558,12 +571,17 @@ export default { ) }, close() { - this.dialog = false - setTimeout(() => { - this.$refs.form.resetValidation() - this.editedItem = Object.assign({}, this.defaultItem) - this.editedId = null - }, 300) + let change = !this.compareDict(this.editedItem, this.editedItemStart) + if (this.saved || !change || confirm('Are you sure you want to close the dialog?')) { + setTimeout(() => { + this.$refs.form.resetValidation() + this.editedItem = Object.assign({}, this.defaultItem) + this.editedItemStart = Object.assign({}, this.defaultItem) + this.editedId = null + this.saved = false + }, 300) + } + else setTimeout(() => this.dialog = true, 0.1) }, closeTest() { this.testDialog = false @@ -600,7 +618,8 @@ export default { this.editedItem ) } - this.close() + this.dialog = false + this.saved = true } } } From ce23190b2cab6abb0f3613d28af9cd0fe18ea41b Mon Sep 17 00:00:00 2001 From: sbgap Date: Tue, 12 Nov 2024 10:38:59 +0100 Subject: [PATCH 8/8] fix: add latest compareDict function --- src/components/EscalationRuleList.vue | 4 ++-- src/components/NotificationGroupList.vue | 2 +- src/components/NotificationRuleList.vue | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/EscalationRuleList.vue b/src/components/EscalationRuleList.vue index 9f86da69..01471ac5 100644 --- a/src/components/EscalationRuleList.vue +++ b/src/components/EscalationRuleList.vue @@ -713,8 +713,8 @@ export default { if (a === null) return true for (const key in a) { if (b[key] === undefined) return false - if (typeof a[key] === typeof({})) { - if (!this.compareDict(a[key], b[key])) return false + if (a[key] !== null && typeof a[key] === typeof({})) { + if (b[key] === null || a[key].length !== b[key].length || !this.compareDict(a[key], b[key])) return false } else if (a[key] !== b[key]) return false } diff --git a/src/components/NotificationGroupList.vue b/src/components/NotificationGroupList.vue index 06e2c444..89168501 100644 --- a/src/components/NotificationGroupList.vue +++ b/src/components/NotificationGroupList.vue @@ -319,7 +319,7 @@ export default { if (a === null) return true for (const key in a) { if (b[key] === undefined) return false - if (typeof a[key] === typeof({})) { + if (a[key] !== null && typeof a[key] === typeof({})) { if (b[key] === null || a[key].length !== b[key].length || !this.compareDict(a[key], b[key])) return false } else if (a[key] !== b[key]) return false diff --git a/src/components/NotificationRuleList.vue b/src/components/NotificationRuleList.vue index 3a37a1f4..a7153de1 100644 --- a/src/components/NotificationRuleList.vue +++ b/src/components/NotificationRuleList.vue @@ -1223,8 +1223,8 @@ export default { if (a === null) return true for (const key in a) { if (b[key] === undefined) return false - if (typeof a[key] === typeof({})) { - if (!this.compareDict(a[key], b[key])) return false + if (a[key] !== null && typeof a[key] === typeof({})) { + if (b[key] === null || a[key].length !== b[key].length || !this.compareDict(a[key], b[key])) return false } else if (a[key] !== b[key]) return false }