Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Led's to enhance use experience #122

Open
wants to merge 1 commit into
base: 1060
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions src/components/Global/LedComponent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<template>
<button class="ui button toggle mybtn" :class="[btnColour, 'mybtn']"></button>
</template>
<script>
export default {
name: 'LedComponent',
props: {
id: { type: String, default: '' },
onColour: { type: String, default: 'green' },
offColour: { type: String, default: 'white' },
errColour: { type: String, default: 'amber' },
ledValue: { type: Boolean, default: false },
isSolidLed: { type: Boolean, default: false },
isServiceLed: { type: Boolean, default: false },
issysAttentionLed: { type: Boolean, default: false },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change issysAttentionLed -> isSysAttentionLed.

issysidentifyLed: { type: Boolean, default: false },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change issysidentifyLed -> isSysIdentifyLed

health: { type: String, default: '' },
},
data() {
return {
checkbox: false,
blinkcolour: false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blinkcolour -> blinkColour

btnColour: 'white',
intervalId: 0,
onColours: this.onColour,
offColours: this.offColour,
errColours: 'red',
cid: this.id,
};
},
mounted() {
if (this.isServiceLed && this.isSolidLed) {
clearInterval(this.intervalId);
if (this.ledValue === `global.status.on`) {
this.turnon();
} else {
this.startBlinking();
}
} else if (this.isServiceLed) {
if (this.isServiceLed && this.issysidentifyLed) {
this.issysidentifyLed ? this.turnon() : this.turnoff();
} else if (this.isServiceLed && this.issysAttentionLed) {
this.issysAttentionLed ? this.turnon() : this.turnoff();
}
} else {
if (!(this.health === 'Critical')) {
if (this.ledValue) {
this.startBlinking();
} else {
this.stopBlinking();
}
} else {
this.turnon();
}
}
},
methods: {
myFunction() {
if (this.blinkcolour) {
this.turnoff();
} else {
this.turnon();
}
},
turnoff() {
this.blinkcolour = false;
this.btnColour = this.offColour;
},
turnon() {
this.blinkcolour = true;
this.btnColour = this.onColour;
},

toggleCheckbox() {
this.checkbox = true;
if (this.blinkcolour) {
this.turnoff();
this.blinkcolour = false;
} else {
this.turnon();
this.blinkcolour = true;
}
this.intervalId = setInterval(this.myFunction, 500);
},

turnErrorColor() {
if (this.checkbox) {
this.stopBlinking();
}
this.blinkcolour = true;
this.btnColour = this.errColours;
},

stopBlinking() {
clearInterval(this.intervalId);
this.turnoff();
this.checkbox = false;
},
startBlinking() {
if (!this.checkbox) this.toggleCheckbox();
},
},
};
</script>

<style scoped>
.mybtn {
border-radius: 50%;
padding: 12px;
border-color: black;
color: black;
outline-color: black;
}

.green {
background-color: green;
}
.blue {
background-color: #0029e0;
}
.amber {
background-color: #ffb300;
}
.red {
background-color: red;
}
.white {
background-color: white;
}
.lightgrey {
background-color: lightgrey;
}
</style>
1 change: 1 addition & 0 deletions src/store/modules/HardwareStatus/BmcStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const BmcStore = {
bmc.health = data.Status.Health;
bmc.id = data.Id;
bmc.identifyLed = data.LocationIndicatorActive;
bmc.ledStatus = data.LocationIndicatorActive;
bmc.locationNumber = data.Location?.PartLocation?.ServiceLabel;
bmc.model = data.Model;
bmc.name = data.Name;
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/HardwareStatus/FanStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const FanStore = {
partNumber: PartNumber,
serialNumber: SerialNumber,
identifyLed: LocationIndicatorActive,
ledStatus: LocationIndicatorActive,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use identifyLed without creating ledStatus.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

each LED is attached with unique ledStatus, so mentioned separately.

locationNumber: Location?.PartLocation?.ServiceLabel,
model: Model,
name: Name,
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/HardwareStatus/PcieSlotsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const PcieSlotsStore = {
return {
type: SlotType,
identifyLed: LocationIndicatorActive,
ledStatus: LocationIndicatorActive,
locationNumber: Location?.PartLocation?.ServiceLabel,
};
});
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/HardwareStatus/PowerSupplyStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const PowerSupplyStore = {
serialNumber: SerialNumber,
firmwareVersion: FirmwareVersion,
identifyLed: LocationIndicatorActive,
ledStatus: LocationIndicatorActive,
locationNumber: Location?.PartLocation?.ServiceLabel,
model: Model,
name: Name,
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/HardwareStatus/ProcessorStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const ProcessorStore = {
totalCores: TotalCores,
locationNumber: Location?.PartLocation?.ServiceLabel,
identifyLed: LocationIndicatorActive,
ledStatus: LocationIndicatorActive,
uri: processor['@odata.id'],
};
});
Expand Down
29 changes: 29 additions & 0 deletions src/store/modules/HardwareStatus/SystemStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ const SystemStore = {
system.sysAttentionLed =
data.Oem?.IBM?.PartitionSystemAttentionIndicator ||
data.Oem?.IBM?.PlatformSystemAttentionIndicator;
system.issysAttentionLed = system.sysAttentionLed;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issysAttentionLed -> isSysAttentionLed

system.locationIndicatorActive = data.LocationIndicatorActive;
system.issysidentifyLed = data.LocationIndicatorActive;
Copy link
Collaborator

@Nikhil-Ashoka Nikhil-Ashoka Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change issysidentifyLed to isSysIdentifyLed

system.model = data.Model;
system.processorSummaryCoreCount = data.ProcessorSummary?.CoreCount;
system.processorSummaryCount = data.ProcessorSummary?.Count;
system.powerState = data.PowerState;
system.powerLedStatus = data.PowerState;
system.serialNumber = data.SerialNumber;
system.statusState = data.Status?.State;
state.systems = [system];
Expand Down Expand Up @@ -67,6 +70,32 @@ const SystemStore = {
}
});
},
async PowerStatusLedState({ commit }, ledState) {
return await api
.patch('/redfish/v1/Systems/system', {
powerLedStatus: ledState,
})
.then(() => {
if (ledState) {
return i18n.t('pageInventory.toast.successEnableIdentifyLed');
} else {
return i18n.t('pageInventory.toast.successDisableIdentifyLed');
}
})
.catch((error) => {
commit('setSystemInfo', this.state.system.systems[0]);
console.log('error', error);
if (ledState) {
throw new Error(
i18n.t('pageInventory.toast.errorEnableIdentifyLed')
);
} else {
throw new Error(
i18n.t('pageInventory.toast.errorDisableIdentifyLed')
);
}
});
},
async changeSystemAttentionLedState({ commit }, ledState) {
return await api
.patch('/redfish/v1/Systems/system', {
Expand Down
39 changes: 36 additions & 3 deletions src/views/HardwareStatus/Inventory/InventoryFabricAdapters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@
</b-form-checkbox>
<div v-else>--</div>
</template>

<template #cell(ledStatus)="row">
<led-component
v-if="hasIdentifyLed(row.item.identifyLed)"
:ref="`identifyfabricLedRef${row.item.name}`"
:led-value="row.item.identifyLed"
off-colour="white"
on-colour="amber"
></led-component>
<div v-else>--</div>
</template>

<template #row-details="{ item }">
<b-container fluid>
<b-row>
Expand Down Expand Up @@ -136,9 +148,16 @@ import TableRowExpandMixin, {
expandRowLabel,
} from '@/components/Mixins/TableRowExpandMixin';
import BVToastMixin from '@/components/Mixins/BVToastMixin';
import LedComponent from '@/components/Global/LedComponent';

export default {
components: { IconChevron, PageSection, Search, TableCellCount },
components: {
IconChevron,
PageSection,
Search,
TableCellCount,
LedComponent,
},
mixins: [
BVToastMixin,
TableRowExpandMixin,
Expand Down Expand Up @@ -194,6 +213,11 @@ export default {
label: this.$t('pageInventory.table.identifyLed'),
formatter: this.dataFormatter,
},
{
key: 'ledStatus',
label: 'Physical LED State',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Label should be taken from the translation file

formatter: this.dataFormatter,
},
],
searchFilter: searchFilter,
searchTotalFilteredRows: 0,
Expand Down Expand Up @@ -260,8 +284,17 @@ export default {
memberId: row.id,
identifyLed: row.identifyLed,
})
.then((message) => this.successToast(message))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

success toast message will still be needed

.catch(({ message }) => this.errorToast(message));
.then(() => {
if (row.identifyLed) {
this.$refs['identifyfabricLedRef' + `${row.name}`].startBlinking();
} else {
this.$refs['identifyfabricLedRef' + `${row.name}`].stopBlinking();
}
})
.catch(({ message }) => {
this.$refs['identifyfabricLedRef' + `${row.name}`].turnErrorColor();
this.errorToast(message);
});
},
sortCompare(a, b, key) {
if (key === 'health') {
Expand Down
Loading