summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFarah Rasheed <Farah.Rasheed1@dell.com>2024-07-25 22:04:18 +0300
committerSurya Venkatesan <suryav@ami.com>2024-09-04 14:51:09 +0300
commit9b0f9c9b7105b6f2554eed415e7fd69140e62475 (patch)
treea284b8cff114cbe2877a835047332f2781f8218d
parentbfe7ad811bea38f414103363e8c9054e45a8cd89 (diff)
downloadwebui-vue-9b0f9c9b7105b6f2554eed415e7fd69140e62475.tar.xz
Add status state info to inventory tables
Add status state information to the inventory tables for fans and power supplies. Also updates sortCompare to be able to sort by the state. Change-Id: Ic830dd0867daee0bf6052a5d1cff5592b98fc009 Signed-off-by: Farah Rasheed <Farah.Rasheed1@dell.com> Signed-off-by: Surya Venkatesan <suryav@ami.com>
-rw-r--r--src/views/HardwareStatus/Inventory/InventoryTableFans.vue41
-rw-r--r--src/views/HardwareStatus/Inventory/InventoryTablePowerSupplies.vue39
2 files changed, 80 insertions, 0 deletions
diff --git a/src/views/HardwareStatus/Inventory/InventoryTableFans.vue b/src/views/HardwareStatus/Inventory/InventoryTableFans.vue
index f8db745e..4a540e04 100644
--- a/src/views/HardwareStatus/Inventory/InventoryTableFans.vue
+++ b/src/views/HardwareStatus/Inventory/InventoryTableFans.vue
@@ -51,6 +51,12 @@
{{ value }}
</template>
+ <!-- StatusState -->
+ <template #cell(statusState)="{ value }">
+ <status-icon :status="statusStateIcon(value)" />
+ {{ value }}
+ </template>
+
<template #row-details="{ item }">
<b-container fluid>
<b-row>
@@ -149,6 +155,12 @@ export default {
tdClass: 'text-nowrap',
},
{
+ key: 'statusState',
+ label: i18n.global.t('pageInventory.table.state'),
+ formatter: this.dataFormatter,
+ tdClass: 'text-nowrap',
+ },
+ {
key: 'partNumber',
label: i18n.global.t('pageInventory.table.partNumber'),
formatter: this.dataFormatter,
@@ -186,11 +198,40 @@ export default {
sortCompare(a, b, key) {
if (key === 'health') {
return this.sortStatus(a, b, key);
+ } else if (key === 'statusState') {
+ return this.sortStatusState(a, b, key);
}
},
onFiltered(filteredItems) {
this.searchTotalFilteredRows = filteredItems.length;
},
+ /**
+ * Returns the appropriate icon based on the given status.
+ *
+ * @param {string} status - The status to determine the icon for.
+ * @return {string} The icon corresponding to the given status.
+ */
+ statusStateIcon(status) {
+ switch (status) {
+ case 'Enabled':
+ return 'success';
+ case 'Absent':
+ return 'warning';
+ default:
+ return '';
+ }
+ },
+ /**
+ * Sorts the status state of two objects based on the provided key.
+ *
+ * @param {Object} a - The first object to compare.
+ * @param {Object} b - The second object to compare.
+ * @param {string} key - The key to use for comparison.
+ */
+ sortStatusState(a, b, key) {
+ const statusState = ['Enabled', 'Absent'];
+ return statusState.indexOf(a[key]) - statusState.indexOf(b[key]);
+ },
},
};
</script>
diff --git a/src/views/HardwareStatus/Inventory/InventoryTablePowerSupplies.vue b/src/views/HardwareStatus/Inventory/InventoryTablePowerSupplies.vue
index ac64673b..ddc3333c 100644
--- a/src/views/HardwareStatus/Inventory/InventoryTablePowerSupplies.vue
+++ b/src/views/HardwareStatus/Inventory/InventoryTablePowerSupplies.vue
@@ -51,6 +51,12 @@
{{ value }}
</template>
+ <!-- StatusState -->
+ <template #cell(statusState)="{ value }">
+ <status-icon :status="statusStateIcon(value)" />
+ {{ value }}
+ </template>
+
<template #row-details="{ item }">
<b-container fluid>
<b-row>
@@ -170,6 +176,12 @@ export default {
tdClass: 'text-nowrap',
},
{
+ key: 'statusState',
+ label: i18n.global.t('pageInventory.table.state'),
+ formatter: this.dataFormatter,
+ tdClass: 'text-nowrap',
+ },
+ {
key: 'locationNumber',
label: i18n.global.t('pageInventory.table.locationNumber'),
formatter: this.dataFormatter,
@@ -207,11 +219,38 @@ export default {
sortCompare(a, b, key) {
if (key === 'health') {
return this.sortStatus(a, b, key);
+ } else if (key === 'statusState') {
+ return this.sortStatusState(a, b, key);
}
},
onFiltered(filteredItems) {
this.searchTotalFilteredRows = filteredItems.length;
},
+ /**
+ * Returns the icon to use for status state based on the given status.
+ * @param {string} status The status to determine the icon for.
+ * @return {string} The icon for the given status.
+ */
+ statusStateIcon(status) {
+ switch (status) {
+ case 'Enabled':
+ return 'success';
+ case 'Absent':
+ return 'warning';
+ default:
+ return '';
+ }
+ },
+ /**
+ * Sorts the status state of two objects based on the provided key.
+ * @param {Object} a The first object to compare.
+ * @param {Object} b The second object to compare.
+ * @param {string} key The key to use for comparison.
+ */
+ sortStatusState(a, b, key) {
+ const statusState = ['Enabled', 'Absent'];
+ return statusState.indexOf(a[key]) - statusState.indexOf(b[key]);
+ },
},
};
</script>