forked from openbmc/webui-vue
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Led's to enhance use experience
Adding custom LED component to enhance visual representation of physical LED State which will be dipict the original system LED colour and it's behaviour.
- Loading branch information
1 parent
68b0643
commit e27b5d4
Showing
19 changed files
with
4,965 additions
and
4,772 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
<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 }, | ||
health: { type: String, default: '' }, | ||
}, | ||
data() { | ||
return { | ||
checkbox: false, | ||
blinkcolour: false, | ||
btnColour: 'white', | ||
intervalId: 0, | ||
onColours: this.onColour, | ||
offColours: this.offColour, | ||
errColours: 'red', | ||
cid: this.id, | ||
//isSolidLeds: this.isSolidLed, | ||
//issysAttentionLeds: this.issysAttentionLed, | ||
//issysidentifyLeds: this.issysidentifyLed, | ||
//isServiceLeds: this.isServiceLed, | ||
}; | ||
}, | ||
mounted() { | ||
console.log( | ||
'mounted->ledValue', | ||
this.ledValue, | ||
'isSolidLed', | ||
this.isSolidLed, | ||
'this.isServiceLed', | ||
this.isServiceLed, | ||
'this.issysAttentionLed', | ||
this.issysAttentionLed, | ||
'issysidentifyLed', | ||
this.issysidentifyLed | ||
); | ||
if (this.isServiceLed && this.isSolidLed) { | ||
console.log('this is service+solid LED'); | ||
clearInterval(this.intervalId); | ||
console.log('i m in else part1', this.intervalId); | ||
if (this.ledValue === `global.status.on`) { | ||
console.log('i m in else part2'); | ||
this.turnon(); | ||
} else { | ||
console.log('i m in else part3'); | ||
this.startBlinking(); | ||
} | ||
} else if (this.isServiceLed) { | ||
console.log('this is service LED'); | ||
if (this.isServiceLed && this.issysidentifyLed) { | ||
this.issysidentifyLed ? this.turnon() : this.turnoff(); | ||
} else if (this.isServiceLed && this.issysAttentionLed) { | ||
this.issysAttentionLed ? this.turnon() : this.turnoff(); | ||
} | ||
} else { | ||
console.log('this is identify LED'); | ||
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); | ||
console.log(' this.intervalId->', this.intervalId); | ||
}, | ||
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.