Only show update/reboot for host card if available

https://www.pivotaltracker.com/story/show/145135469
This commit is contained in:
Paulus Schoutsen 2017-05-11 20:59:51 -07:00
parent 1946f6c1f0
commit 031e2af311

View File

@ -43,15 +43,19 @@
</table>
</div>
<div class="card-actions">
<ha-call-api-button
hass='[[hass]]'
path="hassio/host/update"
>Update</ha-call-api-button>
<ha-call-api-button
class='warning'
hass='[[hass]]'
path="hassio/host/reboot"
>Reboot</ha-call-api-button>
<template is='dom-if' if='[[computeUpdateAvailable(data)]]'>
<ha-call-api-button
hass='[[hass]]'
path="hassio/host/update"
>Update</ha-call-api-button>
</template>
<template is='dom-if' if='[[computeRebootAvailable(data)]]'>
<ha-call-api-button
class='warning'
hass='[[hass]]'
path="hassio/host/reboot"
>Reboot</ha-call-api-button>
</template>
</div>
</paper-card>
</template>
@ -71,5 +75,13 @@ Polymer({
value: {},
},
},
computeUpdateAvailable: function (data) {
return data.version !== data.last_version;
},
computeRebootAvailable: function (data) {
return data.features && data.features.indexOf("reboot") !== -1;
},
});
</script>