diff options
author | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2020-05-11 18:23:04 +0300 |
---|---|---|
committer | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2020-06-10 23:49:39 +0300 |
commit | be3af3360cec7ba3eb2921662689c437f92e2fc7 (patch) | |
tree | 7686417c8a7809f0576ad107f8f09de4817713ef /src/store/modules/Health | |
parent | f9832b0edc48b349f6de2df419815ef38a6ae469 (diff) | |
download | webui-vue-be3af3360cec7ba3eb2921662689c437f92e2fc7.tar.xz |
Add batch actions and row action to Event Logs
Adds ability to export and delete event logs by row or in a
table batch action.
- Modifications to TableRowAction component to allow single
row export functionality
Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Change-Id: Ica50dd0868ac85cc2d6925a9448858b40da9c529
Diffstat (limited to 'src/store/modules/Health')
-rw-r--r-- | src/store/modules/Health/EventLogStore.js | 63 |
1 files changed, 51 insertions, 12 deletions
diff --git a/src/store/modules/Health/EventLogStore.js b/src/store/modules/Health/EventLogStore.js index 2f0b800f..2b93ffa7 100644 --- a/src/store/modules/Health/EventLogStore.js +++ b/src/store/modules/Health/EventLogStore.js @@ -1,4 +1,5 @@ -import api from '../../api'; +import api, { getResponseCount } from '@/store/api'; +import i18n from '@/i18n'; const getHealthStatus = events => { let status = 'OK'; @@ -37,22 +38,60 @@ const EventLogStore = { return await api .get('/redfish/v1/Systems/system/LogServices/EventLog/Entries') .then(({ data: { Members = [] } = {} }) => { - const eventLogs = Members.map( - ({ Id, Severity, Created, EntryType, Message }) => { - return { - id: Id, - severity: Severity, - date: new Date(Created), - type: EntryType, - description: Message - }; - } - ); + const eventLogs = Members.map(log => { + const { Id, Severity, Created, EntryType, Message } = log; + return { + id: Id, + severity: Severity, + date: new Date(Created), + type: EntryType, + description: Message, + uri: log['@odata.id'] + }; + }); commit('setAllEvents', eventLogs); }) .catch(error => { console.log('Event Log Data:', error); }); + }, + async deleteEventLogs({ dispatch }, uris = []) { + const promises = uris.map(uri => + api.delete(uri).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.successDelete', + successCount + ); + toastMessages.push({ type: 'success', message }); + } + + if (errorCount) { + const message = i18n.tc( + 'pageEventLogs.toast.errorDelete', + errorCount + ); + toastMessages.push({ type: 'error', message }); + } + + return toastMessages; + }) + ); } } }; |