Upgrade to latest home assistant js

This commit is contained in:
Paulus Schoutsen 2015-03-14 00:00:51 -07:00
parent 6242b856b4
commit 284500ff21
9 changed files with 118 additions and 92 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 = "b0c85f68d338fcd776ae95ef23ac61fd" VERSION = "08fb2ffccc72d7bfa0ad3478f2e8cfe7"

File diff suppressed because one or more lines are too long

View File

@ -5,63 +5,20 @@
<polymer-element name="domain-icon" <polymer-element name="domain-icon"
attributes="domain state" constructor="DomainIcon"> attributes="domain state" constructor="DomainIcon">
<template> <template>
<core-icon icon="{{icon(domain, state)}}"></core-icon> <core-icon icon="{{icon}}"></core-icon>
</template> </template>
<script> <script>
Polymer({ Polymer({
icon: '',
icon: function(domain, state) { observe: {
switch(domain) { 'domain': 'updateIcon',
case "homeassistant": 'state' : 'updateIcon',
return "home"; },
case "group":
return "homeassistant-24:group";
case "device_tracker":
return "social:person";
case "switch":
return "image:flash-on";
case "media_player":
var icon = "hardware:cast";
if (state !== "idle") {
icon += "-connected";
}
return icon;
case "sun":
return "image:wb-sunny";
case "light":
return "image:wb-incandescent";
case "simple_alarm":
return "social:notifications";
case "notify":
return "announcement";
case "thermostat":
return "homeassistant-100:thermostat";
case "sensor":
return "visibility";
case "configurator":
return "settings";
case "conversation":
return "av:hearing";
default:
return "bookmark-outline";
}
}
updateIcon: function() {
this.icon = window.hass.uiUtil.domainIcon(this.domain, this.state);
},
}); });
</script> </script>
</polymer-element> </polymer-element>

View File

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

View File

@ -7,35 +7,37 @@
{{ relativeTime }} {{ relativeTime }}
</template> </template>
<script> <script>
var UPDATE_INTERVAL = 60000; // 60 seconds (function() {
var UPDATE_INTERVAL = 60000; // 60 seconds
var parseDateTime = window.hass.util.parseDateTime; var parseDateTime = window.hass.util.parseDateTime;
Polymer({ Polymer({
relativeTime: "", relativeTime: "",
parsedDateTime: null, parsedDateTime: null,
created: function() { created: function() {
this.updateRelative = this.updateRelative.bind(this); this.updateRelative = this.updateRelative.bind(this);
}, },
attached: function() { attached: function() {
this._interval = setInterval(this.updateRelative, UPDATE_INTERVAL); this._interval = setInterval(this.updateRelative, UPDATE_INTERVAL);
}, },
detached: function() { detached: function() {
clearInterval(this._interval); clearInterval(this._interval);
}, },
datetimeChanged: function(oldVal, newVal) { datetimeChanged: function(oldVal, newVal) {
this.parsedDateTime = newVal ? parseDateTime(newVal) : null; this.parsedDateTime = newVal ? parseDateTime(newVal) : null;
this.updateRelative(); this.updateRelative();
}, },
updateRelative: function() { updateRelative: function() {
this.relativeTime = this.parsedDateTime ? moment(this.parsedDateTime).fromNow() : ""; this.relativeTime = this.parsedDateTime ? moment(this.parsedDateTime).fromNow() : "";
}, },
}); });
})();
</script> </script>
</polymer-element> </polymer-element>

View File

@ -34,10 +34,12 @@
<div> <div>
<core-menu selected="0"> <core-menu selected="0">
<template repeat="{{serv in services}}"> <template repeat="{{domain in domains}}">
<core-submenu icon="{{serv.domain | getIcon}}" label="{{serv.domain}}"> <core-submenu icon="{{domain | getIcon}}" label="{{domain}}">
<template repeat="{{service in serv.services}}"> <template repeat="{{service in domain | getServices}}">
<a on-click={{serviceClicked}} data-domain={{serv.domain}}>{{service}}</a> <a on-click={{serviceClicked}} data-domain={{domain}}>
{{service}}
</a>
</template> </template>
</core-submenu> </core-submenu>
</template> </template>
@ -50,7 +52,8 @@
var storeListenerMixIn = window.hass.storeListenerMixIn; var storeListenerMixIn = window.hass.storeListenerMixIn;
Polymer(Polymer.mixin({ Polymer(Polymer.mixin({
services: [], domains: [],
services: null,
cbServiceClicked: null, cbServiceClicked: null,
attached: function() { attached: function() {
@ -62,11 +65,16 @@
}, },
getIcon: function(domain) { getIcon: function(domain) {
return (new DomainIcon()).icon(domain); return hass.uiUtil.domainIcon(domain);
},
getServices: function(domain) {
return this.services.get(domain).toArray();
}, },
serviceStoreChanged: function(serviceStore) { serviceStoreChanged: function(serviceStore) {
this.services = serviceStore.all; this.services = serviceStore.all;
this.domains = this.services.keySeq().sort().toArray();
}, },
serviceClicked: function(ev) { serviceClicked: function(ev) {

@ -1 +1 @@
Subproject commit 5b0a96c67fb3182c811f800df107c1c833a395f0 Subproject commit 642a83e437fed356db3e13d5a5b0c28d4b3fb713

View File

@ -32,3 +32,57 @@
</defs></svg> </defs></svg>
</core-iconset-svg> </core-iconset-svg>
<script>
window.hass.uiUtil.domainIcon = function(domain, state) {
switch(domain) {
case "homeassistant":
return "home";
case "group":
return "homeassistant-24:group";
case "device_tracker":
return "social:person";
case "switch":
return "image:flash-on";
case "media_player":
var icon = "hardware:cast";
if (state !== "idle") {
icon += "-connected";
}
return icon;
case "sun":
return "image:wb-sunny";
case "light":
return "image:wb-incandescent";
case "simple_alarm":
return "social:notifications";
case "notify":
return "announcement";
case "thermostat":
return "homeassistant-100:thermostat";
case "sensor":
return "visibility";
case "configurator":
return "settings";
case "conversation":
return "av:hearing";
default:
return "bookmark-outline";
}
}
</script>

View File

@ -68,5 +68,8 @@
}); });
}, },
}; };
// UI specific util methods
window.hass.uiUtil = {}
})(); })();
</script> </script>