summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaksim Zakharov <m.zakharov@IBS.RU>2022-08-18 17:33:32 +0300
committerMaksim Zakharov <m.zakharov@IBS.RU>2022-08-18 17:33:32 +0300
commit51afd867f9ae51c6c11c48bdfec91d4988f35397 (patch)
tree5606931783d8724a01bd2418f9986ffc26451334
parentefbb9eab830830923ef1afea8fc8b70974772373 (diff)
downloadwebui-vue-51afd867f9ae51c6c11c48bdfec91d4988f35397.tar.xz
add status for pci devises
-rw-r--r--src/locales/en-US.json2
-rw-r--r--src/locales/ru-RU.json4
-rw-r--r--src/store/modules/HardwareStatus/PciStore.js76
-rw-r--r--src/views/_sila/PciDevices/PciDevices.vue39
4 files changed, 85 insertions, 36 deletions
diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index c6f209c4..9e5322c8 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -1107,6 +1107,8 @@
"table": {
"id": "ID",
"name": "Name",
+ "health": "Health",
+ "health_d": "OK",
"type": "Type",
"model": "Model",
"manufacturer": "Manufacturer",
diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json
index 621ef62e..66bfc489 100644
--- a/src/locales/ru-RU.json
+++ b/src/locales/ru-RU.json
@@ -1106,7 +1106,9 @@
"title": "Установленые PCI-устройства",
"table": {
"id": "Идентификатор",
- "name": "Имя устройства",
+ "health": "Состояние",
+ "health_d": "Работоспособен",
+ "name": "Имя",
"type": "Тип устройства",
"model": "Модель",
"manufacturer": "Производитель",
diff --git a/src/store/modules/HardwareStatus/PciStore.js b/src/store/modules/HardwareStatus/PciStore.js
index baeaaadf..e49e452c 100644
--- a/src/store/modules/HardwareStatus/PciStore.js
+++ b/src/store/modules/HardwareStatus/PciStore.js
@@ -19,25 +19,64 @@ const PciStore = {
return {
id: Id,
name: Name,
- type: DeviceType,
+ DeviceType: DeviceType,
manufacturer: Manufacturer,
PCIeFunction: PCIeFunctions,
};
});
},
- setSecondPciDevises: (state, data) => {
+ setPciDevisesMembers: (state, data) => {
state.pci = data.map((item, index) => {
const {
value: {
- data: { ClassCode, DeviceClass, DeviceId, FunctionType },
+ data: { Members },
},
} = item;
return {
...state.pci[index],
- classCode: ClassCode,
- deviceClass: DeviceClass,
- deviceId: DeviceId,
- functionType: FunctionType,
+ Members: Members,
+ };
+ });
+ },
+ setFunctionDevices: (state, data) => {
+ let count = 0;
+ const newData = state.pci.map((item) => {
+ const result = data.slice(count, count + item.Members.length);
+ count += item.Members.length;
+ return result;
+ });
+ state.pci = newData.map((item, index) => {
+ const functions = item.map((item) => {
+ const {
+ value: {
+ data: {
+ ClassCode,
+ DeviceClass,
+ DeviceId,
+ FunctionType,
+ DeviceName,
+ },
+ },
+ } = item;
+ return {
+ classCode: ClassCode,
+ deviceClass: DeviceClass,
+ deviceId: DeviceId,
+ functionType: FunctionType,
+ DeviceName: DeviceName,
+ };
+ });
+
+ if (item.length > 1) {
+ return {
+ ...state.pci[index],
+ Functions: functions,
+ };
+ }
+
+ return {
+ ...state.pci[index],
+ ...functions[0],
};
});
},
@@ -55,22 +94,25 @@ const PciStore = {
})
.catch((error) => console.log(error));
},
- async getFunctionDevices({ commit, state }) {
- const functions = state.pci.map((item) =>
+ async getDevicesMembers({ commit, state }) {
+ const Members = state.pci.map((item) =>
api.get(item.PCIeFunction['@odata.id'])
);
- Promise.allSettled(functions)
- .then((response) => {
- const data = response.map((item) =>
- api.get(item.value.data.Members[0]['@odata.id'])
- );
- return Promise.allSettled(data);
- })
+ return Promise.allSettled(Members)
.then((response) => {
- commit('setSecondPciDevises', response);
+ commit('setPciDevisesMembers', response);
})
.catch((error) => console.log(error));
},
+ async getFunctionDevices({ commit, state }) {
+ const Functions = state.pci
+ .map((item) => item.Members)
+ .flat(Infinity)
+ .map((item) => api.get(item['@odata.id']));
+ return Promise.allSettled(Functions).then((response) =>
+ commit('setFunctionDevices', response)
+ );
+ },
},
};
diff --git a/src/views/_sila/PciDevices/PciDevices.vue b/src/views/_sila/PciDevices/PciDevices.vue
index 77f40b66..fc3e4527 100644
--- a/src/views/_sila/PciDevices/PciDevices.vue
+++ b/src/views/_sila/PciDevices/PciDevices.vue
@@ -22,46 +22,46 @@ import PageSection from '@/components/_sila/Global/PageSection';
import DataFormatterMixin from '@/components/_sila/Mixins/DataFormatterMixin';
import LoadingBarMixin from '@/components/_sila/Mixins/LoadingBarMixin';
+import TableRowExpandMixin, {
+ expandRowLabel,
+} from '@/components/_ibs/Mixins/TableRowExpandMixin';
export default {
components: { PageTitle, PageSection },
- mixins: [DataFormatterMixin, LoadingBarMixin],
+ mixins: [DataFormatterMixin, LoadingBarMixin, TableRowExpandMixin],
data() {
return {
isBusy: true,
fields: [
{
- key: 'id',
- label: this.$t('pagePci.table.id'),
- formatter: this.dataFormatter,
- tdClass: 'text-nowrap',
+ key: 'expandRow',
+ label: '',
+ tdClass: 'table-row-expand',
+ sortable: false,
},
{
- key: 'name',
+ key: 'DeviceName',
label: this.$t('pagePci.table.name'),
formatter: this.dataFormatter,
},
{
- key: 'type',
- label: this.$t('pagePci.table.type'),
- formatter: this.dataFormatter,
- },
- {
- key: 'manufacturer',
- label: this.$t('pagePci.table.manufacturer'),
+ key: 'health',
+ label: this.$t('pagePci.table.health'),
formatter: this.dataFormatter,
+ tdClass: 'text-nowrap',
},
{
- key: 'classCode',
- label: this.$t('pagePci.table.classCode'),
+ key: 'deviceClass',
+ label: this.$t('pagePci.table.type'),
formatter: this.dataFormatter,
},
{
- key: 'deviceClass',
- label: this.$t('pagePci.table.deviceClass'),
+ key: 'manufacturer',
+ label: this.$t('pagePci.table.manufacturer'),
formatter: this.dataFormatter,
},
],
+ expandRowLabel: expandRowLabel,
};
},
@@ -73,9 +73,12 @@ export default {
created() {
this.startLoader();
- this.$store
+ return this.$store
.dispatch('pci/getDevices')
.then(() => {
+ return this.$store.dispatch('pci/getDevicesMembers');
+ })
+ .then(() => {
this.$store.dispatch('pci/getFunctionDevices');
})
.finally(() => {