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