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
diff --git a/src/store/modules/Health/EventLogStore.js b/src/store/modules/Health/EventLogStore.js
index eaec749..2b6d5f9 100644
--- a/src/store/modules/Health/EventLogStore.js
+++ b/src/store/modules/Health/EventLogStore.js
@@ -51,6 +51,7 @@
Message,
Name,
Modified,
+ Resolved,
} = log;
return {
id: Id,
@@ -61,6 +62,8 @@
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 @@
})
);
},
+ 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'));
+ });
+ },
},
};