summaryrefslogtreecommitdiff
path: root/src/store/modules/Health/EventLogStore.js
diff options
context:
space:
mode:
authorDixsie Wolmers <dixsie@ibm.com>2021-05-03 02:20:27 +0300
committerDerick Montague <derick.montague@ibm.com>2021-06-09 15:04:53 +0300
commit27d68affdeaba25f011aef52ccbe56506e63d92c (patch)
tree66ed00b677c37df41bf484110c0fb1182b116d4c /src/store/modules/Health/EventLogStore.js
parentdca9b0a5baddfec7ea0ea5e4bdb63c2dd0be27b2 (diff)
downloadwebui-vue-27d68affdeaba25f011aef52ccbe56506e63d92c.tar.xz
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 <dixsie@ibm.com> Change-Id: Ie5761753a7660a714f98c238d8d89aa018719dcf
Diffstat (limited to 'src/store/modules/Health/EventLogStore.js')
-rw-r--r--src/store/modules/Health/EventLogStore.js92
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'));
+ });
+ },
},
};