ha-frontend-cdce8p/hassio/addon-view/hassio-addon-logs.html
2018-02-25 19:44:03 -08:00

60 lines
1.3 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="../../bower_components/paper-button/paper-button.html">
<link rel='import' href='../../src/resources/ha-style.html'>
<dom-module id="hassio-addon-logs">
<template>
<style include="ha-style">
:host,
paper-card {
display: block;
}
</style>
<paper-card heading='Log'>
<div class="card-content">
<pre>[[log]]</pre>
</div>
<div class="card-actions">
<paper-button on-click='refresh'>Refresh</paper-button>
</div>
</paper-card>
</template>
</dom-module>
<script>
class HassioAddonLogs extends Polymer.Element {
static get is() { return 'hassio-addon-logs'; }
static get properties() {
return {
hass: Object,
addonSlug: {
type: String,
observer: 'addonSlugChanged',
},
log: String,
};
}
addonSlugChanged(slug) {
if (!this.hass) {
setTimeout(() => { this.addonChanged(slug); }, 0);
return;
}
this.refresh();
}
refresh() {
this.hass.callApi('get', `hassio/addons/${this.addonSlug}/logs`)
.then((info) => {
this.log = info;
});
}
}
customElements.define(HassioAddonLogs.is, HassioAddonLogs);
</script>