diff options
Diffstat (limited to 'src/store/modules/Health')
-rw-r--r-- | src/store/modules/Health/EventLogStore.js | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/store/modules/Health/EventLogStore.js b/src/store/modules/Health/EventLogStore.js index eaec7490..2b6d5f94 100644 --- a/src/store/modules/Health/EventLogStore.js +++ b/src/store/modules/Health/EventLogStore.js @@ -51,6 +51,7 @@ const EventLogStore = { Message, Name, Modified, + Resolved, } = log; return { id: Id, @@ -61,6 +62,8 @@ const EventLogStore = { name: Name, modifiedDate: new Date(Modified), uri: log['@odata.id'], + filterByStatus: Resolved ? 'Resolved' : 'Unresolved', + status: Resolved, //true or false }; }); commit('setAllEvents', eventLogs); @@ -119,6 +122,95 @@ const EventLogStore = { }) ); }, + async resolveEventLogs({ dispatch }, logs) { + const promises = logs.map((log) => + 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')); + }); + }, }, }; |