* Run Hass.io in an iframe * Update hass.io build script * Lint * Lint * Fix build script * Lint
114 lines
2.8 KiB
HTML
114 lines
2.8 KiB
HTML
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
|
<link rel="import" href="../../bower_components/paper-card/paper-card.html">
|
|
|
|
<link rel='import' href='../../src/util/hass-mixins.html'>
|
|
<link rel="import" href="../../src/components/buttons/ha-call-api-button.html">
|
|
|
|
<dom-module id="hassio-supervisor-info">
|
|
<template>
|
|
<style include="iron-flex ha-style">
|
|
paper-card {
|
|
display: block;
|
|
height: 100%;
|
|
}
|
|
.info {
|
|
width: 100%;
|
|
}
|
|
.info td:nth-child(2) {
|
|
text-align: right;
|
|
}
|
|
.errors {
|
|
color: var(--google-red-500);
|
|
margin-top: 16px;
|
|
}
|
|
</style>
|
|
<paper-card heading="Supervisor">
|
|
<div class="card-content">
|
|
<table class='info'>
|
|
<tr>
|
|
<td>Version</td>
|
|
<td>[[data.version]]</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Beta channel</td>
|
|
<td>[[data.beta_channel]]</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Latest available version</td>
|
|
<td>[[data.last_version]]</td>
|
|
</tr>
|
|
</table>
|
|
<template is='dom-if' if='[[errors]]'>
|
|
<div class='errors'>Error: [[errors]]</div>
|
|
</template>
|
|
</div>
|
|
<div class="card-actions">
|
|
<paper-button on-tap='supervisorLogsTapped'>View logs</paper-button>
|
|
<template is='dom-if' if='[[computeUpdateAvailable(data)]]'>
|
|
<ha-call-api-button
|
|
hass='[[hass]]'
|
|
path="hassio/supervisor/update"
|
|
>Update</ha-call-api-button>
|
|
</template>
|
|
<ha-call-api-button
|
|
class='warning'
|
|
hass='[[hass]]'
|
|
path="hassio/supervisor/reload"
|
|
>Reload</ha-call-api-button>
|
|
</div>
|
|
</paper-card>
|
|
</template>
|
|
</dom-module>
|
|
|
|
<script>
|
|
class HassioSupervisorInfo extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|
static get is() { return 'hassio-supervisor-info'; }
|
|
|
|
static get properties() {
|
|
return {
|
|
hass: {
|
|
type: Object,
|
|
},
|
|
|
|
data: {
|
|
type: Object,
|
|
value: {},
|
|
},
|
|
|
|
errors: String,
|
|
};
|
|
}
|
|
|
|
ready() {
|
|
super.ready();
|
|
this.addEventListener('hass-api-called', ev => this.apiCalled(ev));
|
|
}
|
|
|
|
apiCalled(ev) {
|
|
if (ev.detail.success) {
|
|
this.errors = null;
|
|
return;
|
|
}
|
|
|
|
var response = ev.detail.response;
|
|
|
|
if (typeof response.body === 'object') {
|
|
this.errors = response.body.message || 'Unknown error';
|
|
} else {
|
|
this.errors = response.body;
|
|
}
|
|
}
|
|
|
|
computeUpdateAvailable(data) {
|
|
return data.version !== data.last_version;
|
|
}
|
|
|
|
supervisorLogsTapped() {
|
|
history.pushState(null, null, '/hassio/supervisor');
|
|
this.fire('location-changed');
|
|
}
|
|
}
|
|
|
|
customElements.define(HassioSupervisorInfo.is, HassioSupervisorInfo);
|
|
</script>
|