Frontend cleanup and bug fixes

This commit is contained in:
Paulus Schoutsen 2015-06-25 00:04:32 -07:00
parent 3f56b7e131
commit 5e79a8080b
13 changed files with 1398 additions and 4672 deletions

View File

@ -1,2 +1,2 @@
""" DO NOT MODIFY. Auto-generated by build_frontend script """ """ DO NOT MODIFY. Auto-generated by build_frontend script """
VERSION = "a44970ec771fb08baa6b54ff00a4e223" VERSION = "9e4807d493dcb52e24dcd5163e6a2d4b"

File diff suppressed because one or more lines are too long

View File

@ -37,8 +37,8 @@
"layout": "Polymer/layout", "layout": "Polymer/layout",
"color-picker-element": "~0.0.3", "color-picker-element": "~0.0.3",
"paper-styles": "polymerelements/paper-styles#^1.0.0", "paper-styles": "polymerelements/paper-styles#^1.0.0",
"paper-date-picker": "vsimonian/paper-date-picker#master", "lodash": "~3.9.3",
"lodash": "~3.9.3" "pikaday": "~1.3.2"
}, },
"resolutions": { "resolutions": {
"polymer": "^1.0.0", "polymer": "^1.0.0",

View File

@ -10,13 +10,11 @@
} }
</style> </style>
<template> <template>
<template is='dom-if' if='[[!entries]]'> <template is='dom-if' if='[[noEntries(entries)]]'>
No logbook entries found. No logbook entries found.
</template> </template>
<template is='dom-if' if='[[entries]]'> <template is='dom-repeat' items="[[entries]]">
<template is='dom-repeat' items="[[entries]]"> <logbook-entry entry-obj="[[item]]"></logbook-entry>
<logbook-entry entry-obj="[[item]]"></logbook-entry>
</template>
</template> </template>
</template> </template>
</dom-module> </dom-module>
@ -32,6 +30,10 @@
value: [], value: [],
}, },
}, },
noEntries: function(entries) {
return !entries.length;
}
}); });
})(); })();
</script> </script>

View File

@ -9,16 +9,6 @@
<link rel='import' href='../bower_components/paper-item/paper-icon-item.html'> <link rel='import' href='../bower_components/paper-item/paper-icon-item.html'>
<link rel='import' href='../bower_components/paper-icon-button/paper-icon-button.html'> <link rel='import' href='../bower_components/paper-icon-button/paper-icon-button.html'>
<link rel='import' href='../layouts/partial-states.html'>
<link rel='import' href='../layouts/partial-logbook.html'>
<link rel='import' href='../layouts/partial-history.html'>
<link rel='import' href='../layouts/partial-dev-call-service.html'>
<link rel='import' href='../layouts/partial-dev-fire-event.html'>
<link rel='import' href='../layouts/partial-dev-set-state.html'>
<link rel='import' href='../managers/notification-manager.html'>
<link rel='import' href='../managers/modal-manager.html'>
<link rel='import' href='../components/stream-status.html'> <link rel='import' href='../components/stream-status.html'>
<dom-module id='ha-sidebar'> <dom-module id='ha-sidebar'>
@ -64,9 +54,9 @@
<div class="title">Home Assistant</div> <div class="title">Home Assistant</div>
</paper-toolbar> </paper-toolbar>
<paper-menu id='menu' <paper-menu id='menu' on-iron-select='menuSelect'
selectable='[data-panel]' attr-for-selected='data-panel' selectable='[data-panel]' attr-for-selected='data-panel'
on-iron-select='menuSelect' selected='[[selected]]'> selected='[[selected]]'>
<paper-icon-item data-panel='states'> <paper-icon-item data-panel='states'>
<iron-icon item-icon icon='apps'></iron-icon> States <iron-icon item-icon icon='apps'></iron-icon> States
</paper-icon-item> </paper-icon-item>
@ -123,7 +113,6 @@
<script> <script>
(function() { (function() {
var configGetters = window.hass.configGetters; var configGetters = window.hass.configGetters;
var entityGetters = window.hass.entityGetters;
var navigationGetters = window.hass.navigationGetters; var navigationGetters = window.hass.navigationGetters;
var authActions = window.hass.authActions; var authActions = window.hass.authActions;
@ -140,13 +129,7 @@
properties: { properties: {
selected: { selected: {
type: String, type: String,
bindNuclear: [ bindNuclear: navigationGetters.activePage,
navigationGetters.activePane,
navigationGetters.activeFilter,
function(pane, filter) {
return filter ? pane + '/' + filter : pane;
},
],
}, },
possibleFilters: { possibleFilters: {
@ -170,7 +153,7 @@
}, },
menuSelect: function(ev, detail, sender) { menuSelect: function(ev, detail, sender) {
this.selectPanel(this.$.menu.selected); this.selectPanel(ev.target.selected);
}, },
handleDevClick: function(ev, detail, sender) { handleDevClick: function(ev, detail, sender) {
@ -180,15 +163,13 @@
}, },
selectPanel: function(newChoice) { selectPanel: function(newChoice) {
if (newChoice == 'logout') { if(newChoice === this.selected) {
return;
} else if (newChoice == 'logout') {
this.handleLogOut(); this.handleLogOut();
return; return;
} else if(newChoice == this.selected) {
return;
} }
navigationActions.navigate.apply(null, newChoice.split('/'));
navigationActions.navigate.apply(
null, newChoice.split('/'));
}, },
handleLogOut: function() { handleLogOut: function() {

View File

@ -31,7 +31,7 @@
</style> </style>
<template> <template>
<!-- entry-animation='slide-up-animation' exit-animation='slide-down-animation' --> <!-- entry-animation='slide-up-animation' exit-animation='slide-down-animation' -->
<paper-dialog id="dialog" with-backdrop> <paper-dialog id="dialog" with-backdrop opened='{{dialogOpen}}'>
<h2><state-card-content state-obj="[[stateObj]]"></state-card-content></h2> <h2><state-card-content state-obj="[[stateObj]]"></state-card-content></h2>
<div> <div>
<template is='dom-if' if="[[hasHistoryComponent]]"> <template is='dom-if' if="[[hasHistoryComponent]]">
@ -66,7 +66,7 @@
stateObj: { stateObj: {
type: Object, type: Object,
bindNuclear: moreInfoGetters.currentEntity, bindNuclear: moreInfoGetters.currentEntity,
observer: 'fetchHistoryData', observer: 'stateObjChanged',
}, },
stateHistory: { stateHistory: {
@ -99,34 +99,34 @@
dialogOpen: { dialogOpen: {
type: Boolean, type: Boolean,
value: false, value: false,
observer: 'dialogOpenChanged',
}, },
}, },
listeners: { fetchHistoryData: function() {
'iron-overlay-opened': 'onIronOverlayOpened',
'iron-overlay-closed': 'onIronOverlayClosed'
},
fetchHistoryData: function(newVal) {
if (this.stateObj && this.hasHistoryComponent && if (this.stateObj && this.hasHistoryComponent &&
this.shouldFetchHistory) { this.shouldFetchHistory) {
entityHistoryActions.fetchRecent(this.stateObj.entityId); entityHistoryActions.fetchRecent(this.stateObj.entityId);
} }
}, },
onIronOverlayOpened: function() { stateObjChanged: function(newVal) {
this.dialogOpen = true; if (!newVal) {
this.dialogOpen = false;
return;
}
this.fetchHistoryData();
window.requestAnimationFrame(function() {
this.dialogOpen = true;
}.bind(this));
}, },
onIronOverlayClosed: function() { dialogOpenChanged: function(newVal) {
this.dialogOpen = false; if (!newVal) {
moreInfoActions.deselectEntity(); moreInfoActions.deselectEntity();
}, }
show: function() {
this.debounce('showDialogAfterRender', function() {
this.$.dialog.open();
}.bind(this), 1);
}, },
}); });
})(); })();

@ -1 +1 @@
Subproject commit 8242a36234b4fc55c8baec79f8ca72a86ca22751 Subproject commit f8fb1d0440ac0d7aebbed3b43dd100462487c228

View File

@ -11,14 +11,14 @@
<link rel='import' href='../layouts/partial-dev-set-state.html'> <link rel='import' href='../layouts/partial-dev-set-state.html'>
<link rel='import' href='../managers/notification-manager.html'> <link rel='import' href='../managers/notification-manager.html'>
<link rel='import' href='../managers/modal-manager.html'> <link rel="import" href="../dialogs/more-info-dialog.html">
<link rel='import' href='../components/ha-sidebar.html'> <link rel='import' href='../components/ha-sidebar.html'>
<dom-module id='home-assistant-main'> <dom-module id='home-assistant-main'>
<template> <template>
<notification-manager></notification-manager> <notification-manager></notification-manager>
<modal-manager></modal-manager> <more-info-dialog></more-info-dialog>
<paper-drawer-panel id='drawer' narrow='{{narrow}}'> <paper-drawer-panel id='drawer' narrow='{{narrow}}'>
<ha-sidebar drawer></ha-sidebar> <ha-sidebar drawer></ha-sidebar>

View File

@ -6,6 +6,8 @@
<link rel="import" href="../components/state-history-charts.html"> <link rel="import" href="../components/state-history-charts.html">
<link rel="import" href="../resources/pikaday-js.html">
<dom-module id="partial-history"> <dom-module id="partial-history">
<style> <style>
.content { .content {
@ -32,7 +34,7 @@
on-click="handleRefreshClick"></paper-icon-button> on-click="handleRefreshClick"></paper-icon-button>
<div class$="[[computeContentClasses(narrow)]]"> <div class$="[[computeContentClasses(narrow)]]">
<paper-input label='Showing entries for' on-click='handleShowDatePicker' <paper-input label='Showing entries for' id='datePicker'
value='[[selectedDate]]'></paper-input> value='[[selectedDate]]'></paper-input>
<state-history-charts state-history="[[stateHistory]]" <state-history-charts state-history="[[stateHistory]]"
@ -90,10 +92,20 @@
entityHistoryActions.fetchSelectedDate(); entityHistoryActions.fetchSelectedDate();
}, },
handleShowDatePicker: function() { datepickerFocus: function() {
uiActions.showDatePicker( this.datePicker.adjustPosition();
entityHistoryActions.changeCurrentDate, this.datePicker.gotoDate(moment('2015-06-30').toDate());
this.selectedDate); },
attached: function() {
this.datePicker = new Pikaday({
field: this.$.datePicker.inputElement,
onSelect: entityHistoryActions.changeCurrentDate,
});
},
detached: function() {
this.datePicker.destroy();
}, },
computeContentClasses: function(narrow) { computeContentClasses: function(narrow) {

View File

@ -8,6 +8,8 @@
<link rel="import" href="../components/ha-logbook.html"> <link rel="import" href="../components/ha-logbook.html">
<link rel="import" href="../components/loading-box.html"> <link rel="import" href="../components/loading-box.html">
<link rel="import" href="../resources/pikaday-js.html">
<dom-module id="partial-logbook"> <dom-module id="partial-logbook">
<style> <style>
.selected-date-container { .selected-date-container {
@ -27,8 +29,8 @@
<div> <div>
<div class='selected-date-container'> <div class='selected-date-container'>
<paper-input label='Showing entries for' on-click='handleShowDatePicker' <paper-input label='Showing entries for' id='datePicker'
value='[[selectedDate]]'></paper-input> value='[[selectedDate]]' on-focus='datepickerFocus'></paper-input>
<loading-box hidden$='[[!isLoading]]'>Loading logbook entries</loading-box> <loading-box hidden$='[[!isLoading]]'>Loading logbook entries</loading-box>
</div> </div>
@ -79,6 +81,10 @@
function(entries) { return entries.toArray(); }, function(entries) { return entries.toArray(); },
], ],
}, },
datePicker: {
type: Object,
},
}, },
isStaleChanged: function(newVal) { isStaleChanged: function(newVal) {
@ -90,15 +96,25 @@
} }
}, },
handleShowDatePicker: function() {
uiActions.showDatePicker(
logbookActions.changeCurrentDate,
this.selectedDate);
},
handleRefresh: function() { handleRefresh: function() {
logbookActions.fetchDate(this.selectedDate); logbookActions.fetchDate(this.selectedDate);
}, },
datepickerFocus: function() {
this.datePicker.adjustPosition();
this.datePicker.gotoDate(moment('2015-06-30').toDate());
},
attached: function() {
this.datePicker = new Pikaday({
field: this.$.datePicker.inputElement,
onSelect: logbookActions.changeCurrentDate,
});
},
detached: function() {
this.datePicker.destroy();
},
}); });
})(); })();
</script> </script>

View File

@ -1,56 +0,0 @@
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/paper-date-picker/paper-date-picker-dialog.html">
<link rel="import" href="../dialogs/more-info-dialog.html">
<dom-module id="modal-manager">
<template>
<more-info-dialog id="moreInfoDialog"></more-info-dialog>
<paper-date-picker-dialog id="datePicker"
on-value-changed='datePickerValueChanged'></paper-date-picker-dialog>
</template>
</dom-module>
<script>
(function() {
var moreInfoGetters = window.hass.moreInfoGetters;
var uiActions = window.hass.uiActions;
Polymer({
is: 'modal-manager',
behaviors: [nuclearObserver],
properties: {
moreInfoEntityId: {
type: String,
observer: 'moreInfoEntityIdChanged',
bindNuclear: moreInfoGetters.currentEntityId,
},
datePickerCallback: {
type: Function,
value: null,
},
},
moreInfoEntityIdChanged: function(newVal) {
if (newVal) {
this.$.moreInfoDialog.show(newVal);
}
},
ready: function() {
uiActions.showDatePicker = function(dateSelectedCallback, startDate) {
this.datePickerCallback = dateSelectedCallback;
this.$.date = startDate;
this.$.datePicker.toggle();
}.bind(this);
},
datePickerValueChanged: function(ev) {
this.datePickerCallback(ev.target.value);
},
});
})();
</script>

View File

@ -2,7 +2,7 @@
Wrapping JS in an HTML file will prevent it from being loaded twice. Wrapping JS in an HTML file will prevent it from being loaded twice.
--> -->
<script src="../bower_components/moment/moment.js"></script> <script src="../bower_components/moment/min/moment.min.js"></script>
<script> <script>
window.hass.uiUtil.formatTime = function(dateObj) { window.hass.uiUtil.formatTime = function(dateObj) {

View File

@ -0,0 +1,2 @@
<script src="../bower_components/pikaday/pikaday.js"></script>
<link href="../bower_components/pikaday/css/pikaday.css" media="all" rel="stylesheet" />