summaryrefslogtreecommitdiff
path: root/src/store/modules/HardwareStatus
diff options
context:
space:
mode:
Diffstat (limited to 'src/store/modules/HardwareStatus')
-rw-r--r--src/store/modules/HardwareStatus/PciStore.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/store/modules/HardwareStatus/PciStore.js b/src/store/modules/HardwareStatus/PciStore.js
new file mode 100644
index 00000000..ae72ce12
--- /dev/null
+++ b/src/store/modules/HardwareStatus/PciStore.js
@@ -0,0 +1,44 @@
+import api from '@/store/api';
+
+const PciStore = {
+ namespaced: true,
+ state: {
+ pci: [],
+ },
+ getters: {
+ pciDevices: (state) => state.pci,
+ },
+ mutations: {
+ setPciDevises: (state, data) => {
+ state.pci = data.map((item) => {
+ const {
+ value: {
+ data: { Id, Name, Manufacturer, DeviceType },
+ },
+ } = item;
+ return {
+ id: Id,
+ name: Name,
+ type: DeviceType,
+ manufacturer: Manufacturer,
+ };
+ });
+ },
+ },
+ actions: {
+ async getDevices({ commit }) {
+ return await api
+ .get('/redfish/v1/Systems/system/PCIeDevices')
+ .then(({ data: { Members = [] } }) => {
+ const devices = Members.map((item) => api.get(item['@odata.id']));
+ return Promise.allSettled(devices);
+ })
+ .then((response) => {
+ commit('setPciDevises', response);
+ })
+ .catch((error) => console.log(error));
+ },
+ },
+};
+
+export default PciStore;