mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Polymer .9: Fix history in more info dialogs
This commit is contained in:
parent
eb0584d466
commit
e5f0e57980
@ -36,16 +36,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var root = Polymer.dom(this);
|
var root = Polymer.dom(this);
|
||||||
var data = this.data;
|
var stateHistory = this.data;
|
||||||
|
|
||||||
while (root.lastChild) {
|
while (root.lastChild) {
|
||||||
root.removeChild(root.lastChild);
|
root.removeChild(root.lastChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.length === 0) {
|
if (!stateHistory || stateHistory.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// debugger;
|
||||||
var chart = new google.visualization.Timeline(this);
|
var chart = new google.visualization.Timeline(this);
|
||||||
var dataTable = new google.visualization.DataTable();
|
var dataTable = new google.visualization.DataTable();
|
||||||
|
|
||||||
@ -60,13 +60,13 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// people can pass in history of 1 entityId or a collection.
|
// people can pass in history of 1 entityId or a collection.
|
||||||
var stateHistory;
|
// var stateHistory;
|
||||||
if (_.isArray(data[0])) {
|
// if (_.isArray(data[0])) {
|
||||||
stateHistory = data;
|
// stateHistory = data;
|
||||||
} else {
|
// } else {
|
||||||
stateHistory = [data];
|
// stateHistory = [data];
|
||||||
isSingleDevice = true;
|
// isSingleDevice = true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
var numTimelines = 0;
|
var numTimelines = 0;
|
||||||
// stateHistory is a list of lists of sorted state objects
|
// stateHistory is a list of lists of sorted state objects
|
||||||
|
@ -79,13 +79,17 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
computeIsSingleDevice: function(stateHistory) {
|
computeIsSingleDevice: function(stateHistory) {
|
||||||
return stateHistory.length == 1;
|
return stateHistory && stateHistory.length == 1;
|
||||||
},
|
},
|
||||||
|
|
||||||
computeGroupedStateHistory: function(stateHistory) {
|
computeGroupedStateHistory: function(stateHistory) {
|
||||||
var lineChartDevices = {};
|
var lineChartDevices = {};
|
||||||
var timelineDevices = [];
|
var timelineDevices = [];
|
||||||
|
|
||||||
|
if (!stateHistory) {
|
||||||
|
return {line: unitStates, timeline: timelineDevices};
|
||||||
|
}
|
||||||
|
|
||||||
stateHistory.forEach(function(stateInfo) {
|
stateHistory.forEach(function(stateInfo) {
|
||||||
if (!stateInfo || stateInfo.length === 0) {
|
if (!stateInfo || stateInfo.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
<div>
|
<div>
|
||||||
<state-card-content state-obj="[[stateObj]]"></state-card-content>
|
<state-card-content state-obj="[[stateObj]]"></state-card-content>
|
||||||
<template is='dom-if' if="[[hasHistoryComponent]]">
|
<template is='dom-if' if="[[hasHistoryComponent]]">
|
||||||
<state-history-charts stateHistory="[[stateHistory]]"
|
<state-history-charts state-history="[[stateHistory]]"
|
||||||
isLoadingData="[[isLoadingHistoryData]]"></state-history-charts>
|
is-loading-data="[[isLoadingHistoryData]]"></state-history-charts>
|
||||||
</template>
|
</template>
|
||||||
<paper-dialog-scrollable>
|
<paper-dialog-scrollable>
|
||||||
<more-info-content state-obj="[[stateObj]]"
|
<more-info-content state-obj="[[stateObj]]"
|
||||||
@ -89,7 +89,7 @@
|
|||||||
var newHistory;
|
var newHistory;
|
||||||
|
|
||||||
if (this.hasHistoryComponent && this.entityId) {
|
if (this.hasHistoryComponent && this.entityId) {
|
||||||
newHistory = stateHistoryStore.get(this.entityId);
|
newHistory = [stateHistoryStore.get(this.entityId)];
|
||||||
} else {
|
} else {
|
||||||
newHistory = null;
|
newHistory = null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user