mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Hassio: New API for HassOS (#1319)
* Hassio: New API for HassOS * Fix * Use async await
This commit is contained in:
parent
7e0be4a2f6
commit
c83184654e
@ -67,14 +67,17 @@ class HassioHostInfo extends EventsMixin(PolymerElement) {
|
|||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<template is="dom-if" if="[[computeRebootAvailable(data)]]">
|
<template is="dom-if" if="[[_featureAvailable(data, 'reboot')]]">
|
||||||
<ha-call-api-button class="warning" hass="[[hass]]" path="hassio/host/reboot">Reboot</ha-call-api-button>
|
<ha-call-api-button class="warning" hass="[[hass]]" path="hassio/host/reboot">Reboot</ha-call-api-button>
|
||||||
</template>
|
</template>
|
||||||
<template is="dom-if" if="[[computeShutdownAvailable(data)]]">
|
<template is="dom-if" if="[[_featureAvailable(data, 'shutdown')]]">
|
||||||
<ha-call-api-button class="warning" hass="[[hass]]" path="hassio/host/shutdown">Shutdown</ha-call-api-button>
|
<ha-call-api-button class="warning" hass="[[hass]]" path="hassio/host/shutdown">Shutdown</ha-call-api-button>
|
||||||
</template>
|
</template>
|
||||||
<template is="dom-if" if="[[computeUpdateAvailable(data)]]">
|
<template is="dom-if" if="[[_featureAvailable(data, 'hassos')]]">
|
||||||
<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/hassos/config/sync">Load host configs from USB</ha-call-api-button>
|
||||||
|
</template>
|
||||||
|
<template is="dom-if" if="[[_computeUpdateAvailable(_hassOs)]]">
|
||||||
|
<ha-call-api-button hass="[[hass]]" path="hassio/hassos/update">Update</ha-call-api-button>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</paper-card>
|
||||||
@ -84,8 +87,12 @@ class HassioHostInfo extends EventsMixin(PolymerElement) {
|
|||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
hass: Object,
|
hass: Object,
|
||||||
data: Object,
|
data: {
|
||||||
|
type: Object,
|
||||||
|
observer: '_dataChanged'
|
||||||
|
},
|
||||||
errors: String,
|
errors: String,
|
||||||
|
_hassOs: Object
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,16 +116,19 @@ class HassioHostInfo extends EventsMixin(PolymerElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
computeUpdateAvailable(data) {
|
async _dataChanged(data) {
|
||||||
return data.version !== data.last_version;
|
if (!data.features || !data.features.includes('hassos')) return;
|
||||||
|
|
||||||
|
const resp = await this.hass.callApi('get', 'hassio/hassos/info');
|
||||||
|
this._hassOs = resp.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
computeRebootAvailable(data) {
|
_computeUpdateAvailable(data) {
|
||||||
return data.features && data.features.includes('reboot');
|
return data && data.version !== data.version_latest;
|
||||||
}
|
}
|
||||||
|
|
||||||
computeShutdownAvailable(data) {
|
_featureAvailable(data, feature) {
|
||||||
return data.features && data.features.includes('shutdown');
|
return data && data.features && data.features.includes(feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
_showHardware() {
|
_showHardware() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user