summaryrefslogtreecommitdiff
path: root/src/store/modules
diff options
context:
space:
mode:
authorYoshie Muranaka <yoshiemuranaka@gmail.com>2021-02-23 22:23:52 +0300
committerDerick Montague <derick.montague@ibm.com>2021-03-01 16:45:05 +0300
commitaa5e950b219343fff77ddde855088e694806edf8 (patch)
tree76aa992e83f422fa8e5474b01e77b35a8a4838bb /src/store/modules
parent33d755f4e62beff72101f6ca07e4d31b04e13826 (diff)
downloadwebui-vue-aa5e950b219343fff77ddde855088e694806edf8.tar.xz
Move Dumps page components to main view and store directories
This commit will move away from storing env specific component views and store modules in the env directory. This will help simplify the file structure for dotenv customizations. The env directory will only store modifications to the main store register, router definitions, and app navigation. Pages that are "hidden" by default, like dumps, would still need to be imported and registered in the specific environments. Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com> Change-Id: Ia5ad76235e00127281f3fa564cb89ec2ca2e0f25
Diffstat (limited to 'src/store/modules')
-rw-r--r--src/store/modules/Health/DumpsStore.js117
1 files changed, 117 insertions, 0 deletions
diff --git a/src/store/modules/Health/DumpsStore.js b/src/store/modules/Health/DumpsStore.js
new file mode 100644
index 00000000..3b91354b
--- /dev/null
+++ b/src/store/modules/Health/DumpsStore.js
@@ -0,0 +1,117 @@
+import api, { getResponseCount } from '@/store/api';
+import i18n from '@/i18n';
+
+const DumpsStore = {
+ namespaced: true,
+ state: {
+ bmcDumps: [],
+ },
+ getters: {
+ bmcDumps: (state) => state.bmcDumps,
+ },
+ mutations: {
+ setBmcDumps: (state, dumps) => {
+ state.bmcDumps = dumps.map((dump) => ({
+ data: dump.AdditionalDataURI,
+ dateTime: new Date(dump.Created),
+ dumpType: dump.Name,
+ id: dump.Id,
+ location: dump['@odata.id'],
+ size: dump.AdditionalDataSizeBytes,
+ }));
+ },
+ },
+ actions: {
+ async getBmcDumps({ commit }) {
+ return await api
+ .get('/redfish/v1/Managers/bmc/LogServices/Dump/Entries')
+ .then(({ data = {} }) => commit('setBmcDumps', data.Members || []))
+ .catch((error) => console.log(error));
+ },
+ async createBmcDump() {
+ return await api
+ .post(
+ '/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData',
+ {
+ DiagnosticDataType: 'Manager',
+ OEMDiagnosticDataType: '',
+ }
+ )
+ .catch((error) => {
+ console.log(error);
+ throw new Error(i18n.t('pageDumps.toast.errorStartBmcDump'));
+ });
+ },
+ async createSystemDump() {
+ return await api
+ .post(
+ '/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.CollectDiagnosticData',
+ {
+ DiagnosticDataType: 'OEM',
+ OEMDiagnosticDataType: 'System',
+ }
+ )
+ .catch((error) => {
+ console.log(error);
+ throw new Error(i18n.t('pageDumps.toast.errorStartSystemDump'));
+ });
+ },
+ async deleteDumps({ dispatch }, dumps) {
+ const promises = dumps.map(({ location }) =>
+ api.delete(location).catch((error) => {
+ console.log(error);
+ return error;
+ })
+ );
+ return await api
+ .all(promises)
+ .then((response) => {
+ dispatch('getBmcDumps');
+ return response;
+ })
+ .then(
+ api.spread((...responses) => {
+ const { successCount, errorCount } = getResponseCount(responses);
+ const toastMessages = [];
+
+ if (successCount) {
+ const message = i18n.tc(
+ 'pageDumps.toast.successDeleteDump',
+ successCount
+ );
+ toastMessages.push({ type: 'success', message });
+ }
+
+ if (errorCount) {
+ const message = i18n.tc(
+ 'pageDumps.toast.errorDeleteDump',
+ errorCount
+ );
+ toastMessages.push({ type: 'error', message });
+ }
+
+ return toastMessages;
+ })
+ );
+ },
+ async deleteAllDumps({ commit, state }) {
+ const totalDumpCount = state.bmcDumps.length;
+ return await api
+ .post(
+ '/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.ClearLog'
+ )
+ .then(() => {
+ commit('setBmcDumps', []);
+ return i18n.tc('pageDumps.toast.successDeleteDump', totalDumpCount);
+ })
+ .catch((error) => {
+ console.log(error);
+ throw new Error(
+ i18n.tc('pageDumps.toast.errorDeleteDump', totalDumpCount)
+ );
+ });
+ },
+ },
+};
+
+export default DumpsStore;