mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-15 21:36:36 +00:00
Refresh hassio data after API call
This commit is contained in:
parent
928be4eed5
commit
f255e6c7bf
@ -12,6 +12,7 @@
|
||||
</style>
|
||||
<template>
|
||||
<hassio-data
|
||||
id='data'
|
||||
hass='[[hass]]'
|
||||
supervisor='{{supervisorInfo}}'
|
||||
homeassistant='{{hassInfo}}'
|
||||
@ -100,6 +101,11 @@ Polymer({
|
||||
|
||||
listeners: {
|
||||
'hassio-select-addon': 'addonSelected',
|
||||
'hass-api-called': 'apiCalled',
|
||||
},
|
||||
|
||||
apiCalled: function (ev) {
|
||||
this.$.data.refresh();
|
||||
},
|
||||
|
||||
computeIsLoaded: function (supervisorInfo, hostInfo, hassInfo, forceLoading) {
|
||||
|
@ -234,6 +234,14 @@ Polymer({
|
||||
},
|
||||
},
|
||||
|
||||
listeners: {
|
||||
'hass-api-called': 'apiCalled',
|
||||
},
|
||||
|
||||
apiCalled: function (ev) {
|
||||
this.addonChanged(this.addon);
|
||||
},
|
||||
|
||||
addonChanged: function (addon) {
|
||||
if (!this.hass) {
|
||||
setTimeout(function () { this.addonChanged(addon); }.bind(this), 0);
|
||||
@ -242,10 +250,9 @@ Polymer({
|
||||
|
||||
this.hass.callApi('get', 'hassio/addons/' + addon + '/info')
|
||||
.then(function (info) {
|
||||
// Error if addon not installed.
|
||||
if (info.result !== 'error') {
|
||||
this.addonState = info.data;
|
||||
}
|
||||
this.addonState = info.data;
|
||||
}.bind(this), function (info) {
|
||||
this.addonState = null;
|
||||
}.bind(this));
|
||||
this.refreshLogs();
|
||||
},
|
||||
|
@ -25,6 +25,10 @@ Polymer({
|
||||
},
|
||||
|
||||
attached: function () {
|
||||
this.refresh();
|
||||
},
|
||||
|
||||
refresh: function () {
|
||||
this.fetchSupervisorInfo();
|
||||
this.fetchHostInfo();
|
||||
this.fetchHassInfo();
|
||||
|
@ -49,14 +49,23 @@ Polymer({
|
||||
buttonTapped: function () {
|
||||
this.progress = true;
|
||||
var el = this;
|
||||
var eventData = {
|
||||
method: this.method,
|
||||
path: this.path,
|
||||
data: this.data,
|
||||
};
|
||||
|
||||
this.hass.callApi(this.method, this.path, this.data)
|
||||
.then(function () {
|
||||
el.progress = false;
|
||||
el.$.progress.actionSuccess();
|
||||
eventData.success = true;
|
||||
}, function () {
|
||||
el.progress = false;
|
||||
el.$.progress.actionError();
|
||||
eventData.success = false;
|
||||
}).then(function () {
|
||||
el.fire('hass-api-called', eventData);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -42,14 +42,23 @@ Polymer({
|
||||
buttonTapped: function () {
|
||||
this.progress = true;
|
||||
var el = this;
|
||||
var eventData = {
|
||||
domain: this.domain,
|
||||
service: this.service,
|
||||
serviceData: this.serviceData,
|
||||
};
|
||||
|
||||
this.hass.callService(this.domain, this.service, this.serviceData)
|
||||
.then(function () {
|
||||
el.progress = false;
|
||||
el.$.progress.actionSuccess();
|
||||
eventData.success = true;
|
||||
}, function () {
|
||||
el.progress = false;
|
||||
el.$.progress.actionError();
|
||||
eventData.success = false;
|
||||
}).then(function () {
|
||||
el.fire('hass-service-called', eventData);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user