Skip to content

Commit

Permalink
Add functionality for lamp test (#1)
Browse files Browse the repository at this point in the history
- This feature adds the ability for the user to activate and deactivate
lamp test and will be a downstream only feature.

Signed-off-by: Sukanya Pandey <[email protected]>
  • Loading branch information
Sukanya Pandey authored and rfrandse committed Jan 28, 2022
1 parent 447fb25 commit 4aac0d5
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 12 deletions.
9 changes: 7 additions & 2 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,11 @@
"assemblies": "Assemblies",
"systemIndicator": {
"powerStatus": "Power status",
"attentionLed": "System attention LED",
"identifyLed": "System identify LED",
"sectionTitle": "LED light control"
"lampTest": "Lamp test",
"tooltipInfo": "Changes all indicators controlled by the BMC and hypervisor to the ON state for four minutes.",
"sectionTitle": "System attention indicators"
},
"table": {
"assetTag": "Asset tag",
Expand Down Expand Up @@ -441,7 +444,9 @@
},
"toast": {
"errorDisableIdentifyLed": "Error disabling Identify LED.",
"errorEnableIdentifyLed": "Error enabling Identify LED."
"errorEnableIdentifyLed": "Error enabling Identify LED.",
"errorDisableLampTest": "Error disabling Lamp test.",
"errorEnableLampTest": "Error enabling Lamp test."
}
},
"pageKvm": {
Expand Down
24 changes: 24 additions & 0 deletions src/store/modules/HardwareStatus/SystemStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const SystemStore = {
system.health = data.Status?.Health;
system.totalSystemMemoryGiB = data.MemorySummary?.TotalSystemMemoryGiB;
system.id = data.Id;
system.lampTest = data.Oem?.IBM?.LampTest;
system.locationIndicatorActive = data.LocationIndicatorActive;
system.locationNumber = data.Location?.PartLocation?.ServiceLabel;
system.manufacturer = data.Manufacturer;
Expand Down Expand Up @@ -71,6 +72,29 @@ const SystemStore = {
}
});
},
async changeLampTestState({ commit }, lampTestState) {
return await api
.patch('/redfish/v1/Systems/system', {
Oem: {
IBM: {
LampTest: lampTestState,
},
},
})
.catch((error) => {
commit('setSystemInfo', this.state.system.systems[0]);
console.log('error', error);
if (lampTestState) {
throw new Error(
i18n.t('pageHardwareStatus.toast.errorEnableLampTest')
);
} else {
throw new Error(
i18n.t('pageHardwareStatus.toast.errorDisableLampTest')
);
}
});
},
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/views/HardwareStatus/Inventory/Inventory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

<script>
import PageTitle from '@/components/Global/PageTitle';
import ServiceIndicator from './InventoryServiceIndicator';
import TableSystem from './InventoryTableSystem';
import TablePowerSupplies from './InventoryTablePowerSupplies';
import TableDimmSlot from './InventoryTableDimmSlot';
Expand All @@ -61,6 +60,7 @@ import TableProcessors from './InventoryTableProcessors';
import TableAssembly from './InventoryTableAssembly';
import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
import PageSection from '@/components/Global/PageSection';
import ServiceIndicator from './InventoryServiceIndicator';
import JumpLink16 from '@carbon/icons-vue/es/jump-link/16';
import JumpLinkMixin from '@/components/Mixins/JumpLinkMixin';
import { chunk } from 'lodash';
Expand Down
70 changes: 61 additions & 9 deletions src/views/HardwareStatus/Inventory/InventoryServiceIndicator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<page-section
:section-title="$t('pageInventory.systemIndicator.sectionTitle')"
>
<div class="form-background pl-4 pt-4 pb-1">
<b-row>
<div class="form-background">
<b-row class="pl-4 pt-4 pb-1">
<b-col sm="6" md="3">
<dl>
<dt>{{ $t('pageInventory.systemIndicator.powerStatus') }}</dt>
Expand Down Expand Up @@ -33,17 +33,68 @@
</dd>
</dl>
</b-col>
<b-col sm="6" md="3">
<dl>
<dt>
{{ $t('pageInventory.systemIndicator.attentionLed') }}
</dt>
<dd>
<b-form-checkbox
v-if="false"
id="attentionLedSwitch"
data-test-id="hardwareStatus-toggle-attentionLed"
switch
>
<span class="sr-only">
{{ $t('pageInventory.systemIndicator.attentionLed') }}
</span>
<span>
{{ $t('global.status.on') }}
</span>
</b-form-checkbox>
<span v-else>{{ $t('global.status.off') }}</span>
</dd>
</dl>
</b-col>
<b-col sm="6" md="3">
<dl>
<dt>
{{ $t('pageInventory.systemIndicator.lampTest') }}
<info-tooltip
:title="$t('pageInventory.systemIndicator.tooltipInfo')"
/>
</dt>
<dd>
<b-form-checkbox
id="lampSwitch"
v-model="systems.lampTest"
data-test-id="hardwareStatus-toggle-lampTest"
switch
@change="toggleLampTestSwitch"
>
<span class="sr-only">
{{ $t('pageInventory.systemIndicator.lampTest') }}
</span>
<span v-if="systems.lampTest">
{{ $t('global.status.on') }}
</span>
<span v-else>{{ $t('global.status.off') }}</span>
</b-form-checkbox>
</dd>
</dl>
</b-col>
</b-row>
</div>
</page-section>
</template>
<script>
import InfoTooltip from '@/components/Global/InfoTooltip';
import PageSection from '@/components/Global/PageSection';
import BVToastMixin from '@/components/Mixins/BVToastMixin';
import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
export default {
components: { PageSection },
mixins: [BVToastMixin],
components: { InfoTooltip, PageSection },
mixins: [BVToastMixin, TableDataFormatterMixin],
computed: {
systems() {
let systemData = this.$store.getters['system/systems'][0];
Expand All @@ -66,10 +117,11 @@ export default {
});
},
methods: {
toggleIdentifyLedSwitch(state) {
this.$store
.dispatch('system/changeIdentifyLedState', state)
.catch(({ message }) => this.errorToast(message));
toggleIdentifyLedSwitch(ledState) {
this.$store.dispatch('system/changeIdentifyLedState', ledState);
},
toggleLampTestSwitch(lampTestState) {
this.$store.dispatch('system/changeLampTestState', lampTestState);
},
},
};
Expand Down

0 comments on commit 4aac0d5

Please sign in to comment.