Add VirtualMedia page

More info: https://github.com/openbmc/webui-vue/issues/7

Signed-off-by: Mateusz Gapski <mateuszx.gapski@intel.com>
Change-Id: I68f2074e77301c68c425f1e661988c751224b713
diff --git a/src/store/modules/Control/ControlStore.js b/src/store/modules/Control/ControlStore.js
index 82dbdcc..c06ff4f 100644
--- a/src/store/modules/Control/ControlStore.js
+++ b/src/store/modules/Control/ControlStore.js
@@ -1,4 +1,4 @@
-import api from '../../api';
+import api from '@/store/api';
 import i18n from '../../../i18n';
 
 /**
diff --git a/src/store/modules/Control/VirtualMediaStore.js b/src/store/modules/Control/VirtualMediaStore.js
new file mode 100644
index 0000000..e01cfce
--- /dev/null
+++ b/src/store/modules/Control/VirtualMediaStore.js
@@ -0,0 +1,80 @@
+import api from '../../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 => {
+            return {
+              id: device.data?.Id,
+              transferProtocolType: device.data?.TransferProtocolType,
+              websocket: device.data?.Oem?.OpenBMC?.WebSocketEndpoint
+            };
+          });
+          const proxyDevices = deviceData
+            .filter(d => d.transferProtocolType === 'OEM')
+            .map(device => {
+              return {
+                ...device,
+                file: null,
+                isActive: false
+              };
+            });
+          const legacyDevices = deviceData
+            .filter(d => !d.transferProtocolType)
+            .map(device => {
+              return {
+                ...device,
+                address: ''
+              };
+            });
+          commit('setProxyDevicesData', proxyDevices);
+          commit('setLegacyDevicesData', legacyDevices);
+        })
+        .catch(error => {
+          console.log('Virtual Media:', error);
+        });
+    }
+  }
+};
+
+export default VirtualMediaStore;