diff options
author | Sandeepa Singh <sandeepa.singh@ibm.com> | 2021-07-14 13:32:22 +0300 |
---|---|---|
committer | Derick Montague <derick.montague@ibm.com> | 2021-08-10 22:20:42 +0300 |
commit | 68cbbe9014cbdcf7229a878f564d38f6d6199f25 (patch) | |
tree | cd7138959f405cb44b5d62000da9d364ed238b91 /src/store/modules/Operations/VirtualMediaStore.js | |
parent | 7affc529b7fba41193c4d48764707e9961cdd22d (diff) | |
download | webui-vue-68cbbe9014cbdcf7229a878f564d38f6d6199f25.tar.xz |
IA update: Update control section to operations
This is the third update to the information architecture changes and
has the following changes:
- The control section has been updated to operations
- The server led page has been removed
- The firmware page is moved to operations section
Signed-off-by: Sandeepa Singh <sandeepa.singh@ibm.com>
Change-Id: I2e23da447890d7bee51892e1f782d5f2db6dded4
Diffstat (limited to 'src/store/modules/Operations/VirtualMediaStore.js')
-rw-r--r-- | src/store/modules/Operations/VirtualMediaStore.js | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/src/store/modules/Operations/VirtualMediaStore.js b/src/store/modules/Operations/VirtualMediaStore.js new file mode 100644 index 00000000..7c183b0e --- /dev/null +++ b/src/store/modules/Operations/VirtualMediaStore.js @@ -0,0 +1,105 @@ +import api from '@/store/api'; +import i18n from '@/i18n'; + +const VirtualMediaStore = { + namespaced: true, + state: { + proxyDevices: [], + legacyDevices: [], + connections: [], + }, + getters: { + proxyDevices: (state) => state.proxyDevices, + legacyDevices: (state) => state.legacyDevices, + }, + mutations: { + setProxyDevicesData: (state, deviceData) => + (state.proxyDevices = deviceData), + setLegacyDevicesData: (state, deviceData) => + (state.legacyDevices = deviceData), + }, + actions: { + async getData({ commit }) { + const virtualMediaListEnabled = + process.env.VUE_APP_VIRTUAL_MEDIA_LIST_ENABLED === 'true' + ? true + : false; + if (!virtualMediaListEnabled) { + const device = { + id: i18n.t('pageVirtualMedia.defaultDeviceName'), + websocket: '/vm/0/0', + file: null, + transferProtocolType: 'OEM', + isActive: false, + }; + commit('setProxyDevicesData', [device]); + return; + } + + return await api + .get('/redfish/v1/Managers/bmc/VirtualMedia') + .then((response) => + response.data.Members.map((virtualMedia) => virtualMedia['@odata.id']) + ) + .then((devices) => api.all(devices.map((device) => api.get(device)))) + .then((devices) => { + const deviceData = devices.map((device) => { + const isActive = device.data?.Inserted === true ? true : false; + return { + id: device.data?.Id, + transferProtocolType: device.data?.TransferProtocolType, + websocket: device.data?.Oem?.OpenBMC?.WebSocketEndpoint, + isActive: isActive, + }; + }); + const proxyDevices = deviceData + .filter((d) => d.transferProtocolType === 'OEM') + .map((device) => { + return { + ...device, + file: null, + }; + }); + const legacyDevices = deviceData + .filter((d) => !d.transferProtocolType) + .map((device) => { + return { + ...device, + serverUri: '', + username: '', + password: '', + isRW: false, + }; + }); + commit('setProxyDevicesData', proxyDevices); + commit('setLegacyDevicesData', legacyDevices); + }) + .catch((error) => { + console.log('Virtual Media:', error); + }); + }, + async mountImage(_, { id, data }) { + return await api + .post( + `/redfish/v1/Managers/bmc/VirtualMedia/${id}/Actions/VirtualMedia.InsertMedia`, + data + ) + .catch((error) => { + console.log('Mount image:', error); + throw new Error(); + }); + }, + async unmountImage(_, id) { + return await api + .post( + `/redfish/v1/Managers/bmc/VirtualMedia/${id}/Actions/VirtualMedia.EjectMedia` + ) + .catch((error) => { + console.log('Unmount image:', error); + throw new Error(); + }); + }, + }, +}; + +export default VirtualMediaStore; |