Skip to content

Commit

Permalink
Update fans table to use ThermalSubsytem schema (#5)
Browse files Browse the repository at this point in the history
Adds toggle switch for identify Led (LocationIndicatorActive),
adds speed percent and updates to use thermal subsystem endpoint.

Signed-off-by: Dixsie Wolmers <[email protected]>
  • Loading branch information
dixsie authored and rfrandse committed Jan 7, 2022
1 parent 395412c commit e14ea13
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@
"serviceEnabled": "Service enabled",
"serviceEntryPointUuid": "Service entry point UUID",
"sparePartNumber": "Spare part number",
"speedPercent": "Speed percent",
"statusHealthRollup": "Status (Health rollup)",
"statusState": "Status (State)",
"subModel": "Sub model",
Expand Down
66 changes: 56 additions & 10 deletions src/store/modules/HardwareStatus/FanStore.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import api from '@/store/api';
import i18n from '@/i18n';

const FanStore = {
namespaced: true,
Expand All @@ -12,38 +13,83 @@ const FanStore = {
setFanInfo: (state, data) => {
state.fans = data.map((fan) => {
const {
IndicatorLED,
LocationIndicatorActive,
Location,
MemberId,
Id,
Name,
Reading,
ReadingUnits,
SpeedPercent,
Status = {},
PartNumber,
SerialNumber,
} = fan;
return {
id: MemberId,
id: Id,
health: Status.Health,
partNumber: PartNumber,
serialNumber: SerialNumber,
healthRollup: Status.HealthRollup,
identifyLed: IndicatorLED,
identifyLed: LocationIndicatorActive,
locationNumber: Location,
name: Name,
speed: Reading + ' ' + ReadingUnits,
speedPercent: SpeedPercent.Reading,
statusState: Status.State,
uri: fan['@odata.id'],
};
});
},
},
actions: {
async getFanInfo({ commit }) {
async getChassisCollection() {
return await api
.get('/redfish/v1/Chassis/chassis/Thermal')
.then(({ data: { Fans = [] } }) => commit('setFanInfo', Fans))
.get('/redfish/v1/')
.then((response) => api.get(response.data.Chassis['@odata.id']))
.then(({ data: { Members } }) =>
Members.map((member) => member['@odata.id'])
)
.catch((error) => console.log(error));
},
async getAllFans({ dispatch }) {
const collection = await dispatch('getChassisCollection');
if (!collection) return;
return await api
.all(collection.map((chassis) => dispatch('getFanData', chassis)))
.catch((error) => console.log(error));
},
async getFanData({ commit }, id) {
return await api
.get(`${id}`)
.then((response) =>
api.get(response.data.ThermalSubsystem['@odata.id'])
)
.then((response) => api.get(response.data.Fans['@odata.id']))
.then(({ data: { Members } }) =>
Members.map((member) => member['@odata.id'])
)
.then((fanIds) => api.all(fanIds.map((fan) => api.get(fan))))
.then((fans) => {
const fansData = fans.map((fans) => fans.data);
commit('setFanInfo', fansData);
})
.catch((error) => console.log(error));
},
async updateIdentifyLedValue(_, led) {
const uri = led.uri;
const updatedIdentifyLedValue = {
LocationIndicatorActive: led.identifyLed,
};
return await api.patch(uri, updatedIdentifyLedValue).catch((error) => {
console.log(error);
if (led.identifyLed) {
throw new Error(
i18n.t('pageHardwareStatus.toast.errorEnableIdentifyLed')
);
} else {
throw new Error(
i18n.t('pageHardwareStatus.toast.errorDisableIdentifyLed')
);
}
});
},
},
};

Expand Down
44 changes: 36 additions & 8 deletions src/views/HardwareStatus/Inventory/InventoryTableFans.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<template #cell(expandRow)="row">
<b-button
variant="link"
data-test-id="hardwareStatus-button-expandFans"
data-test-id="inventory-button-expandFans"
:title="expandRowLabel"
class="btn-icon-only"
@click="toggleRowDetails(row)"
Expand All @@ -50,6 +50,21 @@
{{ value }}
</template>

<!-- Toggle identify LED -->
<template #cell(identifyLed)="row">
<b-form-checkbox
v-model="row.item.identifyLed"
name="switch"
switch
@change="toggleIdentifyLedValue(row.item)"
>
<span v-if="row.item.identifyLed">
{{ $t('global.status.on') }}
</span>
<span v-else> {{ $t('global.status.off') }} </span>
</b-form-checkbox>
</template>

<template #row-details="{ item }">
<b-container fluid>
<b-row>
Expand Down Expand Up @@ -86,6 +101,11 @@
<dt>{{ $t('pageInventory.table.statusHealthRollup') }}:</dt>
<dd>{{ dataFormatter(item.healthRollup) }}</dd>
</dl>
<dl>
<!-- Fan speed -->
<dt>{{ $t('pageInventory.table.speedPercent') }}:</dt>
<dd>{{ tableFormatter(item.speedPercent) }}</dd>
</dl>
</b-col>
</b-row>
</b-container>
Expand Down Expand Up @@ -141,15 +161,15 @@ export default {
tdClass: 'text-nowrap',
},
{
key: 'partNumber',
label: this.$t('pageInventory.table.partNumber'),
formatter: this.dataFormatter,
key: 'locationNumber',
label: this.$t('pageInventory.table.locationNumber'),
formatter: this.tableFormatter,
sortable: true,
},
{
key: 'serialNumber',
label: this.$t('pageInventory.table.serialNumber'),
formatter: this.dataFormatter,
key: 'identifyLed',
label: this.$t('pageInventory.table.identifyLed'),
formatter: this.tableFormatter,
},
],
searchFilter: searchFilter,
Expand All @@ -168,7 +188,7 @@ export default {
},
},
created() {
this.$store.dispatch('fan/getFanInfo').finally(() => {
this.$store.dispatch('fan/getAllFans').finally(() => {
// Emit initial data fetch complete to parent component
this.$root.$emit('hardware-status-fans-complete');
});
Expand All @@ -182,6 +202,14 @@ export default {
onFiltered(filteredItems) {
this.searchTotalFilteredRows = filteredItems.length;
},
toggleIdentifyLedValue(row) {
this.$store
.dispatch('fan/updateIdentifyLedValue', {
uri: row.uri,
identifyLed: row.identifyLed,
})
.catch(({ message }) => this.errorToast(message));
},
},
};
</script>

0 comments on commit e14ea13

Please sign in to comment.