diff --git a/src/App.vue b/src/App.vue index cac2218f..67057f82 100644 --- a/src/App.vue +++ b/src/App.vue @@ -695,8 +695,10 @@ export default { this.$store.dispatch('alerts/updateSelected', []) }, takeBulkAction(action) { - this.selected.map(a => this.$store.dispatch('alerts/takeAction', [a.id, action, ''])) - .reduce(() => this.clearSelected()) + Promise.all(this.selected.map(a => this.$store.dispatch('alerts/takeAction', [a.id, action, '']))).then(() => { + this.clearSelected() + this.$store.dispatch('alerts/getAlerts') + }) }, bulkAckAlert() { this.selected.map(a => { @@ -711,7 +713,7 @@ export default { .reduce(() => this.clearSelected()) }, bulkShelveAlert() { - this.selected.map(a => { + Promise.all(this.selected.map(a => { this.$store .dispatch('alerts/takeAction', [ a.id, @@ -719,21 +721,27 @@ export default { '', this.shelveTimeout ]) + })).then(() => { + this.clearSelected() + this.$store.dispatch('alerts/getAlerts') }) - .reduce(() => this.clearSelected()) }, isWatched(tags) { const tag = `watch:${this.username}` return tags ? tags.indexOf(tag) > -1 : false }, toggleWatch() { + var map if (this.selected.some(x => !this.isWatched(x.tags))) { - this.selected.map(a => this.watchAlert(a.id)) - .reduce(() => this.clearSelected()) + map = this.selected.map(a => this.watchAlert(a.id)) } else { - this.selected.map(a => this.unwatchAlert(a.id)) - .reduce(() => this.clearSelected()) + map = this.selected.map(a => this.unwatchAlert(a.id)) } + + Promise.all(map).then(() => { + this.clearSelected() + this.$store.dispatch('alerts/getAlerts') + }) }, watchAlert(id) { this.$store.dispatch('alerts/watchAlert', id) @@ -743,8 +751,10 @@ export default { }, bulkDeleteAlert() { confirm(i18n.t('ConfirmDelete')) && - this.selected.map(a => this.$store.dispatch('alerts/deleteAlert', a.id)) - .reduce(() => this.clearSelected()) + Promise.all(this.selected.map(a => this.$store.dispatch('alerts/deleteAlert', a.id, false))).then(() => { + this.clearSelected() + this.$store.dispatch('alerts/getAlerts') + }) }, toggle(sw, value) { this.$store.dispatch('alerts/toggle', [sw, value]) diff --git a/src/components/AlertList.vue b/src/components/AlertList.vue index df26f005..0b2b562e 100644 --- a/src/components/AlertList.vue +++ b/src/components/AlertList.vue @@ -617,7 +617,9 @@ export default { }, takeAction: debounce(function(id, action) { this.$store - .dispatch('alerts/takeAction', [id, action, '']) + .dispatch('alerts/takeAction', [id, action, '']).then(() => { + this.$store.dispatch('alerts/getAlerts') + }) }, 200, {leading: true, trailing: false}), ackAlert: debounce(function(id) { this.$store @@ -639,15 +641,21 @@ export default { }, 200, {leading: true, trailing: false}), watchAlert: debounce(function(id) { this.$store - .dispatch('alerts/watchAlert', id) + .dispatch('alerts/watchAlert', id).then(() => { + this.$store.dispatch('alerts/getAlerts') + }) }, 200, {leading: true, trailing: false}), unwatchAlert: debounce(function(id) { this.$store - .dispatch('alerts/unwatchAlert', id) + .dispatch('alerts/unwatchAlert', id).then(() => { + this.$store.dispatch('alerts/getAlerts') + }) }, 200, {leading: true, trailing: false}), deleteAlert: debounce(function(id) { confirm(i18n.t('ConfirmDelete')) && - this.$store.dispatch('alerts/deleteAlert', id) + this.$store.dispatch('alerts/deleteAlert', id).then(() => { + this.$store.dispatch('alerts/getAlerts') + }) }, 200, {leading: true, trailing: false}), } } diff --git a/src/store/modules/alerts.store.ts b/src/store/modules/alerts.store.ts index 54377663..07a29da7 100644 --- a/src/store/modules/alerts.store.ts +++ b/src/store/modules/alerts.store.ts @@ -178,33 +178,25 @@ const actions = { watchAlert({ commit, dispatch, rootState}, alertId) { const username = rootState.auth.payload.preferred_username const tag = `watch:${username}` - return AlertsApi.tagAlert(alertId, {tags: [tag]}).then(response => - dispatch('getAlerts') - ) + return AlertsApi.tagAlert(alertId, {tags: [tag]}) }, unwatchAlert({ commit, dispatch, rootState}, alertId) { const username = rootState.auth.payload.preferred_username const tag = `watch:${username}` - return AlertsApi.untagAlert(alertId, {tags: [tag]}).then(response => - dispatch('getAlerts') - ) + return AlertsApi.untagAlert(alertId, {tags: [tag]}) }, takeAction({ commit, dispatch }, [alertId, action, text, timeout]) { return AlertsApi.actionAlert(alertId, { action: action, text: text, timeout: timeout - }).then(response => dispatch('getAlerts')) + }) }, tagAlert({ commit, dispatch }, [alertId, tags]) { - return AlertsApi.tagAlert(alertId, tags).then(response => - dispatch('getAlerts') - ) + return AlertsApi.tagAlert(alertId, tags) }, untagAlert({ commit, dispatch }, [alertId, tags]) { - return AlertsApi.untagAlert(alertId, tags).then(response => - dispatch('getAlerts') - ) + return AlertsApi.untagAlert(alertId, tags) }, addNote({ commit, dispatch }, [alertId, note]) { @@ -229,9 +221,7 @@ const actions = { }, deleteAlert({ commit, dispatch }, alertId) { - return AlertsApi.deleteAlert(alertId).then(response => - dispatch('getAlerts') - ) + return AlertsApi.deleteAlert(alertId) }, getEnvironments({ commit }) {