Polymer .9: Fix history in more info dialogs

This commit is contained in:
Paulus Schoutsen 2015-05-26 23:32:11 -07:00
parent eb0584d466
commit e5f0e57980
3 changed files with 18 additions and 14 deletions

View File

@ -36,16 +36,16 @@
}
var root = Polymer.dom(this);
var data = this.data;
var stateHistory = this.data;
while (root.lastChild) {
root.removeChild(root.lastChild);
}
if (data.length === 0) {
if (!stateHistory || stateHistory.length === 0) {
return;
}
// debugger;
var chart = new google.visualization.Timeline(this);
var dataTable = new google.visualization.DataTable();
@ -60,13 +60,13 @@
};
// people can pass in history of 1 entityId or a collection.
var stateHistory;
if (_.isArray(data[0])) {
stateHistory = data;
} else {
stateHistory = [data];
isSingleDevice = true;
}
// var stateHistory;
// if (_.isArray(data[0])) {
// stateHistory = data;
// } else {
// stateHistory = [data];
// isSingleDevice = true;
// }
var numTimelines = 0;
// stateHistory is a list of lists of sorted state objects

View File

@ -79,13 +79,17 @@
},
computeIsSingleDevice: function(stateHistory) {
return stateHistory.length == 1;
return stateHistory && stateHistory.length == 1;
},
computeGroupedStateHistory: function(stateHistory) {
var lineChartDevices = {};
var timelineDevices = [];
if (!stateHistory) {
return {line: unitStates, timeline: timelineDevices};
}
stateHistory.forEach(function(stateInfo) {
if (!stateInfo || stateInfo.length === 0) {
return;

View File

@ -20,8 +20,8 @@
<div>
<state-card-content state-obj="[[stateObj]]"></state-card-content>
<template is='dom-if' if="[[hasHistoryComponent]]">
<state-history-charts stateHistory="[[stateHistory]]"
isLoadingData="[[isLoadingHistoryData]]"></state-history-charts>
<state-history-charts state-history="[[stateHistory]]"
is-loading-data="[[isLoadingHistoryData]]"></state-history-charts>
</template>
<paper-dialog-scrollable>
<more-info-content state-obj="[[stateObj]]"
@ -89,7 +89,7 @@
var newHistory;
if (this.hasHistoryComponent && this.entityId) {
newHistory = stateHistoryStore.get(this.entityId);
newHistory = [stateHistoryStore.get(this.entityId)];
} else {
newHistory = null;
}