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