Clean up frontend

This commit is contained in:
Paulus Schoutsen 2015-02-19 23:08:53 -08:00
parent 8b590a43be
commit ff4c3f791c
15 changed files with 73 additions and 71 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 = "516c0ee306fbd56fb3867e23dafdd7a6" VERSION = "9d3e518a6c0516a3543fe6b364e4307b"

File diff suppressed because one or more lines are too long

View File

@ -31,22 +31,22 @@
</div> </div>
</template> </template>
<script> <script>
Polymer({ var storeListenerMixIn = window.hass.storeListenerMixIn;
Polymer(Polymer.mixin({
cbEventClicked: null, cbEventClicked: null,
states: [], states: [],
ready: function() { attached: function() {
this.statesUpdated = this.statesUpdated.bind(this); this.listenToStores(true);
window.hass.stateStore.addChangeListener(this.statesUpdated);
this.statesUpdated();
}, },
detached: function() { detached: function() {
window.hass.stateStore.removeChangeListener(this.statesUpdated); this.stopListeningToStores();
}, },
statesUpdated: function() { stateStoreChanged: function(stateStore) {
this.states = window.hass.stateStore.all(); this.states = stateStore.all();
}, },
handleClick: function(ev) { handleClick: function(ev) {
@ -55,6 +55,6 @@
} }
}, },
}); }, storeListenerMixIn));
</script> </script>
</polymer-element> </polymer-element>

View File

@ -33,22 +33,22 @@
</div> </div>
</template> </template>
<script> <script>
Polymer({ var storeListenerMixIn = window.hass.storeListenerMixIn;
Polymer(Polymer.mixin({
cbEventClicked: null, cbEventClicked: null,
events: [], events: [],
ready: function() { attached: function() {
this.eventsUpdated = this.eventsUpdated.bind(this); this.listenToStores(true);
window.hass.eventStore.addChangeListener(this.eventsUpdated);
this.eventsUpdated();
}, },
detached: function() { detached: function() {
window.hass.eventStore.removeChangeListener(this.eventsUpdated); this.stopListeningToStores();
}, },
eventsUpdated: function() { eventStoreChanged: function(eventStore) {
this.events = window.hass.eventStore.all(); this.events = eventStore.all();
}, },
handleClick: function(ev) { handleClick: function(ev) {
@ -57,6 +57,6 @@
} }
}, },
}); }, storeListenerMixIn));
</script> </script>
</polymer-element> </polymer-element>

View File

@ -47,26 +47,26 @@
</div> </div>
</template> </template>
<script> <script>
Polymer({ var storeListenerMixIn = window.hass.storeListenerMixIn;
Polymer(Polymer.mixin({
services: [], services: [],
cbServiceClicked: null, cbServiceClicked: null,
ready: function() { attached: function() {
this.servicesUpdated = this.servicesUpdated.bind(this); this.listenToStores(true);
window.hass.serviceStore.addChangeListener(this.servicesUpdated);
this.servicesUpdated();
}, },
detached: function() { detached: function() {
window.hass.serviceStore.removeChangeListener(this.servicesUpdated); this.stopListeningToStores();
}, },
getIcon: function(domain) { getIcon: function(domain) {
return (new DomainIcon()).icon(domain); return (new DomainIcon()).icon(domain);
}, },
servicesUpdated: function() { serviceStoreChanged: function(serviceStore) {
this.services = window.hass.serviceStore.all(); this.services = serviceStore.all();
}, },
serviceClicked: function(ev) { serviceClicked: function(ev) {
@ -79,6 +79,6 @@
} }
} }
}); }, storeListenerMixIn));
</script> </script>
</polymer-element> </polymer-element>

View File

@ -2,7 +2,7 @@
<link rel="import" href="../cards/state-card.html"> <link rel="import" href="../cards/state-card.html">
<polymer-element name="state-cards" attributes="states"> <polymer-element name="state-cards" attributes="states" noscript>
<template> <template>
<style> <style>
:host { :host {
@ -53,8 +53,4 @@
</div> </div>
</template> </template>
<script>
Polymer({
});
</script>
</polymer-element> </polymer-element>

View File

@ -33,7 +33,7 @@
icon: "swap-vert-circle", icon: "swap-vert-circle",
color: 'red', color: 'red',
ready: function() { attached: function() {
this.listenToStores(true); this.listenToStores(true);
}, },

View File

@ -8,20 +8,13 @@
<polymer-element name="more-info-dialog"> <polymer-element name="more-info-dialog">
<template> <template>
<ha-dialog id="dialog"> <ha-dialog id="dialog">
<style>
.title-card {
margin-bottom: 24px;
}
</style>
<div> <div>
<state-card-content stateObj="{{stateObj}}" class='title-card'> <state-card-content stateObj="{{stateObj}}" style='margin-bottom: 24px;'>
</state-card-content> </state-card-content>
<state-timeline stateHistory="{{stateHistory}}"></state-timeline> <state-timeline stateHistory="{{stateHistory}}"></state-timeline>
<more-info-content stateObj="{{stateObj}}"></more-info-content> <more-info-content stateObj="{{stateObj}}"></more-info-content>
</div> </div>
</ha-dialog> </ha-dialog>
</template> </template>
<script> <script>
var storeListenerMixIn = window.hass.storeListenerMixIn; var storeListenerMixIn = window.hass.storeListenerMixIn;
@ -39,7 +32,7 @@ Polymer(Polymer.mixin({
'stateObj.attributes': 'reposition' 'stateObj.attributes': 'reposition'
}, },
ready: function() { attached: function() {
this.listenToStores(true); this.listenToStores(true);
}, },
@ -104,7 +97,6 @@ Polymer(Polymer.mixin({
this.$.dialog.toggle(); this.$.dialog.toggle();
}.bind(this)); }.bind(this));
}, },
}, storeListenerMixIn)); }, storeListenerMixIn));
</script> </script>
</polymer-element> </polymer-element>

@ -1 +1 @@
Subproject commit 83d86a9328a79bfb73da16787d8b59862a83fa98 Subproject commit 6222eedb4e042fa08c2393ab465bb4e8c8afd5fd

View File

@ -156,7 +156,7 @@ Polymer(Polymer.mixin({
isStreaming: false, isStreaming: false,
hasStreamError: false, hasStreamError: false,
ready: function() { attached: function() {
this.togglePanel = this.togglePanel.bind(this); this.togglePanel = this.togglePanel.bind(this);
this.listenToStores(true); this.listenToStores(true);

View File

@ -71,12 +71,9 @@
spinnerMessage: "", spinnerMessage: "",
ready: function() {
this.listenToStores(true);
},
attached: function() { attached: function() {
this.focusPassword(); this.focusPassword();
this.listenToStores(true);
}, },
detached: function() { detached: function() {

View File

@ -37,7 +37,7 @@
Polymer(Polymer.mixin({ Polymer(Polymer.mixin({
stateHistory: null, stateHistory: null,
ready: function() { attached: function() {
this.listenToStores(true); this.listenToStores(true);
}, },

View File

@ -38,7 +38,7 @@
isFetching: false, isFetching: false,
isStreaming: false, isStreaming: false,
ready: function() { attached: function() {
this.listenToStores(true); this.listenToStores(true);
}, },

View File

@ -13,7 +13,6 @@
display: block; display: block;
} }
</style> </style>
<div id='moreInfoContainer' class='{{classNames}}'></div> <div id='moreInfoContainer' class='{{classNames}}'></div>
</template> </template>
<script> <script>
@ -56,7 +55,6 @@ Polymer({
this.classNames = Object.keys(newVal).map( this.classNames = Object.keys(newVal).map(
function(key) { return "has-" + key; }).join(' '); function(key) { return "has-" + key; }).join(' ');
}, },
}); });
</script> </script>
</polymer-element> </polymer-element>

View File

@ -20,14 +20,33 @@
</template> </template>
</template> </template>
<script> <script>
Polymer({ var storeListenerMixIn = window.hass.storeListenerMixIn;
observe: { var stateStore = window.hass.stateStore;
'stateObj.attributes.entity_id': 'updateStates'
Polymer(Polymer.mixin({
attached: function() {
this.listenToStores(true);
},
detached: function() {
this.stopListeningToStores();
},
stateStoreChanged: function() {
this.updateStates();
},
stateObjChanged: function() {
this.updateStates();
}, },
updateStates: function() { updateStates: function() {
this.states = window.hass.stateStore.gets(this.stateObj.attributes.entity_id); if (this.stateObj && this.stateObj.attributes.entity_id) {
} this.states = stateStore.gets(this.stateObj.attributes.entity_id);
}); } else {
this.states = [];
}
},
}, storeListenerMixIn));
</script> </script>
</polymer-element> </polymer-element>