Add missed mixin to ha-call-api-button (#620)

This commit is contained in:
Andrey 2017-11-13 18:28:28 +02:00 committed by Paulus Schoutsen
parent 056e9e0d74
commit a4bcf062d5

View File

@ -1,5 +1,6 @@
<link rel="import" href="../../../bower_components/polymer/polymer-element.html">
<link rel="import" href="./ha-progress-button.html">
<link rel='import' href='../../util/hass-mixins.html'>
<dom-module id='ha-call-api-button'>
<template>
@ -13,23 +14,19 @@
</dom-module>
<script>
class HaCallApiButton extends Polymer.Element {
class HaCallApiButton extends window.hassMixins.EventsMixin(Polymer.Element) {
static get is() { return 'ha-call-api-button'; }
static get properties() {
return {
hass: {
type: Object,
},
hass: Object,
progress: {
type: Boolean,
value: false,
},
path: {
type: String,
},
path: String,
method: {
type: String,
@ -50,26 +47,25 @@ class HaCallApiButton extends Polymer.Element {
buttonTapped() {
this.progress = true;
var el = this;
var eventData = {
const eventData = {
method: this.method,
path: this.path,
data: this.data,
};
this.hass.callApi(this.method, this.path, this.data)
.then(function (resp) {
el.progress = false;
el.$.progress.actionSuccess();
.then((resp) => {
this.progress = false;
this.$.progress.actionSuccess();
eventData.success = true;
eventData.response = resp;
}, function (resp) {
el.progress = false;
el.$.progress.actionError();
}, (resp) => {
this.progress = false;
this.$.progress.actionError();
eventData.success = false;
eventData.response = resp;
}).then(function () {
el.fire('hass-api-called', eventData);
}).then(() => {
this.fire('hass-api-called', eventData);
});
}
}