From aa5e950b219343fff77ddde855088e694806edf8 Mon Sep 17 00:00:00 2001 From: Yoshie Muranaka Date: Tue, 23 Feb 2021 11:23:52 -0800 Subject: 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 Change-Id: Ia5ad76235e00127281f3fa564cb89ec2ca2e0f25 --- src/env/components/Dumps/Dumps.vue | 332 --------------------- src/env/components/Dumps/DumpsForm.vue | 95 ------ .../components/Dumps/DumpsModalConfirmation.vue | 75 ----- src/env/components/Dumps/index.js | 2 - src/env/router/ibm.js | 2 +- src/env/store/Dumps/DumpsStore.js | 117 -------- src/env/store/ibm.js | 2 +- src/store/modules/Health/DumpsStore.js | 117 ++++++++ src/views/Health/Dumps/Dumps.vue | 332 +++++++++++++++++++++ src/views/Health/Dumps/DumpsForm.vue | 95 ++++++ src/views/Health/Dumps/DumpsModalConfirmation.vue | 75 +++++ src/views/Health/Dumps/index.js | 2 + 12 files changed, 623 insertions(+), 623 deletions(-) delete mode 100644 src/env/components/Dumps/Dumps.vue delete mode 100644 src/env/components/Dumps/DumpsForm.vue delete mode 100644 src/env/components/Dumps/DumpsModalConfirmation.vue delete mode 100644 src/env/components/Dumps/index.js delete mode 100644 src/env/store/Dumps/DumpsStore.js create mode 100644 src/store/modules/Health/DumpsStore.js create mode 100644 src/views/Health/Dumps/Dumps.vue create mode 100644 src/views/Health/Dumps/DumpsForm.vue create mode 100644 src/views/Health/Dumps/DumpsModalConfirmation.vue create mode 100644 src/views/Health/Dumps/index.js (limited to 'src') diff --git a/src/env/components/Dumps/Dumps.vue b/src/env/components/Dumps/Dumps.vue deleted file mode 100644 index 8181c5ba..00000000 --- a/src/env/components/Dumps/Dumps.vue +++ /dev/null @@ -1,332 +0,0 @@ - - - diff --git a/src/env/components/Dumps/DumpsForm.vue b/src/env/components/Dumps/DumpsForm.vue deleted file mode 100644 index 02ec1864..00000000 --- a/src/env/components/Dumps/DumpsForm.vue +++ /dev/null @@ -1,95 +0,0 @@ - - - diff --git a/src/env/components/Dumps/DumpsModalConfirmation.vue b/src/env/components/Dumps/DumpsModalConfirmation.vue deleted file mode 100644 index f8e20cfd..00000000 --- a/src/env/components/Dumps/DumpsModalConfirmation.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - diff --git a/src/env/components/Dumps/index.js b/src/env/components/Dumps/index.js deleted file mode 100644 index 65525fb0..00000000 --- a/src/env/components/Dumps/index.js +++ /dev/null @@ -1,2 +0,0 @@ -import Dumps from './Dumps.vue'; -export default Dumps; diff --git a/src/env/router/ibm.js b/src/env/router/ibm.js index c4e1a698..317125e2 100644 --- a/src/env/router/ibm.js +++ b/src/env/router/ibm.js @@ -27,7 +27,7 @@ import SslCertificates from '@/views/AccessControl/SslCertificates'; import i18n from '@/i18n'; // Custom components -import Dumps from '../components/Dumps'; +import Dumps from '@/views/Health/Dumps'; const routes = [ { diff --git a/src/env/store/Dumps/DumpsStore.js b/src/env/store/Dumps/DumpsStore.js deleted file mode 100644 index 3b91354b..00000000 --- a/src/env/store/Dumps/DumpsStore.js +++ /dev/null @@ -1,117 +0,0 @@ -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; diff --git a/src/env/store/ibm.js b/src/env/store/ibm.js index 980236fc..ff20b9cf 100644 --- a/src/env/store/ibm.js +++ b/src/env/store/ibm.js @@ -1,5 +1,5 @@ import store from '@/store'; -import DumpsStore from './Dumps/DumpsStore'; +import DumpsStore from '@/store/modules/Health/DumpsStore'; store.unregisterModule('virtualMedia'); 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; diff --git a/src/views/Health/Dumps/Dumps.vue b/src/views/Health/Dumps/Dumps.vue new file mode 100644 index 00000000..8181c5ba --- /dev/null +++ b/src/views/Health/Dumps/Dumps.vue @@ -0,0 +1,332 @@ + + + diff --git a/src/views/Health/Dumps/DumpsForm.vue b/src/views/Health/Dumps/DumpsForm.vue new file mode 100644 index 00000000..02ec1864 --- /dev/null +++ b/src/views/Health/Dumps/DumpsForm.vue @@ -0,0 +1,95 @@ + + + diff --git a/src/views/Health/Dumps/DumpsModalConfirmation.vue b/src/views/Health/Dumps/DumpsModalConfirmation.vue new file mode 100644 index 00000000..f8e20cfd --- /dev/null +++ b/src/views/Health/Dumps/DumpsModalConfirmation.vue @@ -0,0 +1,75 @@ + + + diff --git a/src/views/Health/Dumps/index.js b/src/views/Health/Dumps/index.js new file mode 100644 index 00000000..65525fb0 --- /dev/null +++ b/src/views/Health/Dumps/index.js @@ -0,0 +1,2 @@ +import Dumps from './Dumps.vue'; +export default Dumps; -- cgit v1.2.3