From 27d68affdeaba25f011aef52ccbe56506e63d92c Mon Sep 17 00:00:00 2001 From: Dixsie Wolmers Date: Sun, 2 May 2021 18:20:27 -0500 Subject: Add event log resolve and unresolve log functionality Displays resolved or unresolved status, adds ability to filter by resolved or unresolved, and adds ability to resolve or unresolve one or more logs. Move event type table field to expanded row. Signed-off-by: Dixsie Wolmers Change-Id: Ie5761753a7660a714f98c238d8d89aa018719dcf --- src/components/Global/TableToolbar.vue | 2 +- src/locales/en-US.json | 14 ++++- src/store/modules/Health/EventLogStore.js | 92 +++++++++++++++++++++++++++++++ src/views/Health/EventLogs/EventLogs.vue | 85 +++++++++++++++++++++++++--- src/views/Health/Sensors/Sensors.vue | 2 +- 5 files changed, 185 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/components/Global/TableToolbar.vue b/src/components/Global/TableToolbar.vue index a9281748..5235feae 100644 --- a/src/components/Global/TableToolbar.vue +++ b/src/components/Global/TableToolbar.vue @@ -6,6 +6,7 @@ {{ selectedItemsCount }} {{ $t('global.action.selected') }}

+ {{ action.label }} - + api.patch(log.uri, { Resolved: true }).catch((error) => { + console.log(error); + return error; + }) + ); + return await api + .all(promises) + .then((response) => { + dispatch('getEventLogData'); + return response; + }) + .then( + api.spread((...responses) => { + const { successCount, errorCount } = getResponseCount(responses); + const toastMessages = []; + if (successCount) { + const message = i18n.tc( + 'pageEventLogs.toast.successResolveLogs', + successCount + ); + toastMessages.push({ type: 'success', message }); + } + if (errorCount) { + const message = i18n.tc( + 'pageEventLogs.toast.errorResolveLogs', + errorCount + ); + toastMessages.push({ type: 'error', message }); + } + return toastMessages; + }) + ); + }, + async unresolveEventLogs({ dispatch }, logs) { + const promises = logs.map((log) => + api.patch(log.uri, { Resolved: false }).catch((error) => { + console.log(error); + return error; + }) + ); + return await api + .all(promises) + .then((response) => { + dispatch('getEventLogData'); + return response; + }) + .then( + api.spread((...responses) => { + const { successCount, errorCount } = getResponseCount(responses); + const toastMessages = []; + if (successCount) { + const message = i18n.tc( + 'pageEventLogs.toast.successUnresolveLogs', + successCount + ); + toastMessages.push({ type: 'success', message }); + } + if (errorCount) { + const message = i18n.tc( + 'pageEventLogs.toast.errorUnresolveLogs', + errorCount + ); + toastMessages.push({ type: 'error', message }); + } + return toastMessages; + }) + ); + }, + async updateEventLogStatus({ dispatch }, log) { + const updatedEventLogStatus = log.status; + return await api + .patch(log.uri, { Resolved: updatedEventLogStatus }) + .then(() => { + dispatch('getEventLogData'); + }) + .then(() => { + if (log.status) { + return i18n.t('pageEventLogs.toast.successResolveLog'); + } else { + return i18n.t('pageEventLogs.toast.successUnresolveLog'); + } + }) + .catch((error) => { + console.log(error); + throw new Error(i18n.t('pageEventLogs.toast.errorLogStatusUpdate')); + }); + }, }, }; diff --git a/src/views/Health/EventLogs/EventLogs.vue b/src/views/Health/EventLogs/EventLogs.vue index 69545a57..64e2adb9 100644 --- a/src/views/Health/EventLogs/EventLogs.vue +++ b/src/views/Health/EventLogs/EventLogs.vue @@ -34,7 +34,13 @@ @clear-selected="clearSelectedRows($refs.table)" @batch-action="onBatchAction" > -