Files
ha-frontend-cdce8p/panels/hassio/hassio-data.html
T
Adam Mills fb0b1286d2 Convert remaining elements to ES6 classes (#538)
* Convert remaining elements to ES6 classes

* Use native DOM methods for tests

* Fix Polymer 2 debounce call
2017-10-29 21:47:03 -07:00

66 lines
1.3 KiB
HTML

<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<script>
class HassioData extends Polymer.Element {
static get is() { return 'hassio-data'; }
static get properties() {
return {
supervisor: {
type: Object,
value: {},
notify: true,
},
host: {
type: Object,
value: {},
notify: true,
},
homeassistant: {
type: Object,
value: {},
notify: true,
},
};
}
connectedCallback() {
super.connectedCallback();
this.refresh();
}
refresh() {
return Promise.all([
this.fetchSupervisorInfo(),
this.fetchHostInfo(),
this.fetchHassInfo(),
]);
}
fetchSupervisorInfo() {
return this.hass.callApi('get', 'hassio/supervisor/info')
.then(function (info) {
this.supervisor = info.data;
}.bind(this));
}
fetchHostInfo() {
return this.hass.callApi('get', 'hassio/host/info')
.then(function (info) {
this.host = info.data;
}.bind(this));
}
fetchHassInfo() {
return this.hass.callApi('get', 'hassio/homeassistant/info')
.then(function (info) {
this.homeassistant = info.data;
}.bind(this));
}
}
customElements.define(HassioData.is, HassioData);
</script>