-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
289 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
""" DO NOT MODIFY. Auto-generated by build_frontend script """ | ||
VERSION = "212470c7842a8715f81fba76a3bd985f" | ||
VERSION = "954620894f13782f17ae7443f0df4ffc" |
24 changes: 13 additions & 11 deletions
24
homeassistant/components/frontend/www_static/frontend.html
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
homeassistant/components/frontend/www_static/polymer/components/state-timeline.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<link rel="import" href="../bower_components/polymer/polymer.html"> | ||
|
||
<link rel="import" href="../bower_components/google-apis/google-jsapi.html"> | ||
|
||
<polymer-element name="state-timeline" attributes="stateObj api"> | ||
<template> | ||
<style> | ||
:host { | ||
display: block; | ||
} | ||
</style> | ||
|
||
<google-jsapi on-api-load="{{googleApiLoaded}}"></google-jsapi> | ||
<div id="timeline" style='width: 100%; height: auto;'></div> | ||
|
||
</template> | ||
<script> | ||
Polymer({ | ||
apiLoaded: false, | ||
stateData: null, | ||
|
||
googleApiLoaded: function() { | ||
google.load("visualization", "1", { | ||
packages: ["timeline"], | ||
callback: function() { | ||
this.apiLoaded = true; | ||
this.drawChart(); | ||
}.bind(this) | ||
}); | ||
}, | ||
|
||
stateObjChanged: function(oldVal, newVal) { | ||
// update data if we get a new stateObj | ||
if (!oldVal || (newVal && oldVal.entity_id === newVal.entity_id)) { | ||
this.drawChart(); | ||
} else { | ||
this.fetchData(); | ||
} | ||
}, | ||
|
||
fetchData: function() { | ||
if (!this.api) { | ||
return; | ||
} | ||
|
||
this.stateData = null; | ||
|
||
var url = 'history/period'; | ||
|
||
if (this.stateObj) { | ||
url += '?filter_entity_id=' + this.stateObj.entity_id; | ||
} | ||
|
||
this.api.call_api('GET', url, {}, function(stateData) { | ||
this.stateData = stateData; | ||
this.drawChart(); | ||
}.bind(this) | ||
); | ||
}, | ||
|
||
drawChart: function() { | ||
if (!this.apiLoaded || this.stateData === null) { | ||
return; | ||
} | ||
|
||
var container = this.$.timeline; | ||
var chart = new google.visualization.Timeline(container); | ||
var dataTable = new google.visualization.DataTable(); | ||
|
||
dataTable.addColumn({ type: 'string', id: 'Entity' }); | ||
dataTable.addColumn({ type: 'string', id: 'State' }); | ||
dataTable.addColumn({ type: 'date', id: 'Start' }); | ||
dataTable.addColumn({ type: 'date', id: 'End' }); | ||
|
||
var stateTimeToDate = function(time) { | ||
if (!time) return new Date(); | ||
|
||
return ha.util.parseTime(time).toDate(); | ||
}; | ||
|
||
var addRow = function(baseState, state, tillState) { | ||
tillState = tillState || {}; | ||
|
||
dataTable.addRow([ | ||
baseState.entityDisplay, state.state, | ||
stateTimeToDate(state.last_changed), | ||
stateTimeToDate(tillState.last_changed)]); | ||
}; | ||
|
||
// this.stateData is a list of lists of sorted state objects | ||
this.stateData.forEach(function(stateInfo) { | ||
var baseState = new this.api.State(stateInfo[0], this.api); | ||
|
||
var prevRow = null; | ||
|
||
stateInfo.forEach(function(state) { | ||
if (prevRow !== null && state.state !== prevRow.state) { | ||
addRow(baseState, prevRow, state); | ||
prevRow = state; | ||
} else if (prevRow === null) { | ||
prevRow = state; | ||
} | ||
}); | ||
|
||
addRow(baseState, prevRow, null); | ||
}.bind(this)); | ||
|
||
chart.draw(dataTable, { | ||
height: 55 + this.stateData.length * 42, | ||
|
||
// interactive properties require CSS, the JS api puts it on the document | ||
// instead of inside our Shadow DOM. | ||
enableInteractivity: false, | ||
|
||
timeline: { | ||
showRowLabels: this.stateData.length > 1 | ||
}, | ||
|
||
hAxis: { | ||
format: 'H:mm' | ||
}, | ||
// colors: ['#CCC', '#03a9f4'] | ||
}); | ||
}, | ||
|
||
}); | ||
</script> | ||
</polymer-element> |
37 changes: 37 additions & 0 deletions
37
homeassistant/components/frontend/www_static/polymer/dialogs/history-dialog.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<link rel="import" href="../bower_components/polymer/polymer.html"> | ||
<link rel="import" href="ha-action-dialog.html"> | ||
<link rel="import" href="../components/state-timeline.html"> | ||
|
||
<polymer-element name="history-dialog" attributes="api"> | ||
<template> | ||
<ha-action-dialog id="dialog" heading="History"> | ||
<style> | ||
#timeline { | ||
width: 614px; | ||
height: auto; | ||
display: block; | ||
} | ||
</style> | ||
|
||
<state-timeline id='timeline' api="{{api}}"></state-timeline> | ||
</ha-action-dialog> | ||
|
||
</template> | ||
<script> | ||
Polymer({ | ||
show: function() { | ||
this.$.dialog.toggle(); | ||
|
||
this.job('repositionDialogAfterRender', function() { | ||
|
||
this.$.timeline.fetchData(); | ||
|
||
this.job('repositionDialogAfterRender', function() { | ||
this.$.dialog.resizeHandler(); | ||
}.bind(this), 1000); | ||
|
||
}.bind(this)); | ||
}, | ||
}); | ||
</script> | ||
</polymer-element> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.