mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Fix history data processing (#951)
* don't call filterchanged twice. it's already an observer. * fix data comparison Compare new data from ha-state-history-data to existing data and replace if changed * remove unnecessary styles * prevent multiple updates of chart-data * remove console * remove another console * directly binding because debouncing in history-data element shortening debounce time, works fine at 0 * remove inacurate comment
This commit is contained in:
parent
26b9ddf3ed
commit
16734c7423
@ -46,7 +46,7 @@
|
|||||||
filter-type='[[_filterType]]'
|
filter-type='[[_filterType]]'
|
||||||
start-time='[[_computeStartTime(_currentDate)]]'
|
start-time='[[_computeStartTime(_currentDate)]]'
|
||||||
end-time='[[endTime]]'
|
end-time='[[endTime]]'
|
||||||
data='{{stateHistoryInput}}'
|
data='{{stateHistory}}'
|
||||||
is-loading='{{isLoadingData}}'
|
is-loading='{{isLoadingData}}'
|
||||||
></ha-state-history-data>
|
></ha-state-history-data>
|
||||||
<app-header-layout has-scrolling-region>
|
<app-header-layout has-scrolling-region>
|
||||||
@ -83,7 +83,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<state-history-charts
|
<state-history-charts
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
history-data="[[stateHistoryOutput]]"
|
history-data="[[stateHistory]]"
|
||||||
is-loading-data="[[isLoadingData]]"
|
is-loading-data="[[isLoadingData]]"
|
||||||
end-time="[[endTime]]"
|
end-time="[[endTime]]"
|
||||||
no-single>
|
no-single>
|
||||||
@ -115,13 +115,7 @@ class HaPanelHistory extends window.hassMixins.LocalizeMixin(Polymer.Element) {
|
|||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
stateHistoryInput: {
|
stateHistory: {
|
||||||
type: Object,
|
|
||||||
value: null,
|
|
||||||
observer: 'stateHistoryObserver'
|
|
||||||
},
|
|
||||||
|
|
||||||
stateHistoryOutput: {
|
|
||||||
type: Object,
|
type: Object,
|
||||||
value: null,
|
value: null,
|
||||||
},
|
},
|
||||||
@ -199,15 +193,6 @@ class HaPanelHistory extends window.hassMixins.LocalizeMixin(Polymer.Element) {
|
|||||||
default: return 1;
|
default: return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stateHistoryObserver(newVal) {
|
|
||||||
setTimeout(() => {
|
|
||||||
if (newVal === this.stateHistoryInput) {
|
|
||||||
// Input didn't change
|
|
||||||
this.stateHistoryOutput = newVal;
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define(HaPanelHistory.is, HaPanelHistory);
|
customElements.define(HaPanelHistory.is, HaPanelHistory);
|
||||||
|
@ -10,16 +10,6 @@
|
|||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-container {
|
|
||||||
text-align: center;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loading {
|
|
||||||
height: 0px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<template is='dom-if' if='[[_computeIsEmpty(historyData)]]'>
|
<template is='dom-if' if='[[_computeIsEmpty(historyData)]]'>
|
||||||
|
@ -134,18 +134,10 @@
|
|||||||
|
|
||||||
static get observers() {
|
static get observers() {
|
||||||
return [
|
return [
|
||||||
'filterChanged(filterType, entityId, startTime, endTime, cacheConfig, localize, language)',
|
'filterChangedDebouncer(filterType, entityId, startTime, endTime, cacheConfig, localize, language)',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback() {
|
|
||||||
super.connectedCallback();
|
|
||||||
this.filterChanged(
|
|
||||||
this.filterType, this.entityId, this.startTime, this.endTime,
|
|
||||||
this.cacheConfig, this.localize, this.language
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
disconnectedCallback() {
|
disconnectedCallback() {
|
||||||
if (this._refreshTimeoutId) {
|
if (this._refreshTimeoutId) {
|
||||||
window.clearInterval(this._refreshTimeoutId);
|
window.clearInterval(this._refreshTimeoutId);
|
||||||
@ -156,13 +148,23 @@
|
|||||||
|
|
||||||
hassChanged(newHass, oldHass) {
|
hassChanged(newHass, oldHass) {
|
||||||
if (!oldHass && !this._madeFirstCall) {
|
if (!oldHass && !this._madeFirstCall) {
|
||||||
this.filterChanged(
|
this.filterChangedDebouncer(
|
||||||
this.filterType, this.entityId, this.startTime, this.endTime,
|
this.filterType, this.entityId, this.startTime, this.endTime,
|
||||||
this.cacheConfig, this.localize, this.language
|
this.cacheConfig, this.localize, this.language
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filterChangedDebouncer(...args) {
|
||||||
|
this._debounceFilterChanged = Polymer.Debouncer.debounce(
|
||||||
|
this._debounceFilterChanged,
|
||||||
|
Polymer.Async.timeOut.after(0),
|
||||||
|
() => {
|
||||||
|
this.filterChanged(...args);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
filterChanged(filterType, entityId, startTime, endTime, cacheConfig, localize, language) {
|
filterChanged(filterType, entityId, startTime, endTime, cacheConfig, localize, language) {
|
||||||
if (!this.hass) return;
|
if (!this.hass) return;
|
||||||
if (cacheConfig && !cacheConfig.cacheKey) return;
|
if (cacheConfig && !cacheConfig.cacheKey) return;
|
||||||
@ -183,7 +185,6 @@
|
|||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._setIsLoading(true);
|
this._setIsLoading(true);
|
||||||
|
|
||||||
data.then((stateHistory) => {
|
data.then((stateHistory) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user