mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-14 21:06:34 +00:00
code review fixes
This commit is contained in:
parent
9197d358d2
commit
87067ea16f
@ -24,6 +24,10 @@
|
||||
.has-volume_level .volume {
|
||||
max-height: 40px;
|
||||
}
|
||||
|
||||
.source-input {
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div class$='[[computeClassNames(stateObj)]]'>
|
||||
@ -65,9 +69,9 @@
|
||||
</paper-slider>
|
||||
</div>
|
||||
<div class='controls layout horizontal justified' hidden$='[[!supportsSelectSource]]'>
|
||||
<paper-icon-button icon="mdi:login-variant"></paper-icon-button>
|
||||
<paper-dropdown-menu style="margin-left: 10px;" no-label-float selected-item-label='{{selectedSource}}' on-tap='stopPropagation'>
|
||||
<paper-menu class="dropdown-content" selected="[[computeSelectedSource(stateObj)]]">
|
||||
<iron-icon icon="mdi:login-variant"></iron-icon>
|
||||
<paper-dropdown-menu class="source-input" no-label-float label='[[source]]'>
|
||||
<paper-menu class="dropdown-content" selected="{{sourceIndex}}">
|
||||
<template is='dom-repeat' items='[[stateObj.attributes.source_list]]'>
|
||||
<paper-item>[[item]]</paper-item>
|
||||
</template>
|
||||
|
@ -30,6 +30,17 @@ export default new Polymer({
|
||||
value: false,
|
||||
},
|
||||
|
||||
source: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
|
||||
sourceIndex: {
|
||||
type: Number,
|
||||
value: 0,
|
||||
observer: 'handleSourceChanged',
|
||||
},
|
||||
|
||||
volumeSliderValue: {
|
||||
type: Number,
|
||||
value: 0,
|
||||
@ -85,11 +96,6 @@ export default new Polymer({
|
||||
value: false,
|
||||
},
|
||||
|
||||
selectedSource: {
|
||||
type: String,
|
||||
observer: 'handleSourceChanged',
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
stateObjChanged(newVal) {
|
||||
@ -101,6 +107,8 @@ export default new Polymer({
|
||||
this.hasMediaControl = hasMediaStates.indexOf(newVal.state) !== -1;
|
||||
this.volumeSliderValue = newVal.attributes.volume_level * 100;
|
||||
this.isMuted = newVal.attributes.is_volume_muted;
|
||||
this.source = newVal.attributes.source;
|
||||
this.sourceIndex = newVal.attributes.source_list.indexOf(this.source)
|
||||
this.supportsPause = (newVal.attributes.supported_media_commands & 1) !== 0;
|
||||
this.supportsVolumeSet = (newVal.attributes.supported_media_commands & 4) !== 0;
|
||||
this.supportsVolumeMute = (newVal.attributes.supported_media_commands & 8) !== 0;
|
||||
@ -166,11 +174,20 @@ export default new Polymer({
|
||||
this.callService('media_next_track');
|
||||
},
|
||||
|
||||
handleSourceChanged(sourceInput) {
|
||||
handleSourceChanged(sourceIndex) {
|
||||
// Selected Option will transition to '' before transitioning to new value
|
||||
if (sourceInput === '' || sourceInput === this.stateObj.attributes.source) {
|
||||
if (!this.stateObj
|
||||
|| sourceIndex < 0
|
||||
|| sourceIndex >= this.stateObj.attributes.source_list.length
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
var sourceInput = this.stateObj.attributes.source_list[sourceIndex];
|
||||
if (sourceInput == this.stateObj.attributes.source) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.callService('select_source', { source: sourceInput });
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user