-
Notifications
You must be signed in to change notification settings - Fork 13
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
base: 1060
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 }, | ||
issysidentifyLed: { type: Boolean, default: false }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ const FanStore = { | |
partNumber: PartNumber, | ||
serialNumber: SerialNumber, | ||
identifyLed: LocationIndicatorActive, | ||
ledStatus: LocationIndicatorActive, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use identifyLed without creating ledStatus. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,11 +21,14 @@ const SystemStore = { | |
system.sysAttentionLed = | ||
data.Oem?.IBM?.PartitionSystemAttentionIndicator || | ||
data.Oem?.IBM?.PlatformSystemAttentionIndicator; | ||
system.issysAttentionLed = system.sysAttentionLed; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issysAttentionLed -> isSysAttentionLed |
||
system.locationIndicatorActive = data.LocationIndicatorActive; | ||
system.issysidentifyLed = data.LocationIndicatorActive; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]; | ||
|
@@ -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', { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
|
@@ -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, | ||
|
@@ -194,6 +213,11 @@ export default { | |
label: this.$t('pageInventory.table.identifyLed'), | ||
formatter: this.dataFormatter, | ||
}, | ||
{ | ||
key: 'ledStatus', | ||
label: 'Physical LED State', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
@@ -260,8 +284,17 @@ export default { | |
memberId: row.id, | ||
identifyLed: row.identifyLed, | ||
}) | ||
.then((message) => this.successToast(message)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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') { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change issysAttentionLed -> isSysAttentionLed.