Add more-info card for group domain

This commit is contained in:
Paulus Schoutsen 2015-01-01 19:42:20 -08:00
parent 85f5df55e9
commit dec12be52e
5 changed files with 73 additions and 5 deletions

View file

@ -5,6 +5,12 @@
<polymer-element name="state-card-content" attributes="api stateObj" noscript> <polymer-element name="state-card-content" attributes="api stateObj" noscript>
<template> <template>
<style>
:host {
display: block;
}
</style>
<template id="state-card-display"> <template id="state-card-display">
<state-card-display <state-card-display
stateObj="{{stateObj}}"> stateObj="{{stateObj}}">

View file

@ -14,12 +14,14 @@
<core-style ref='ha-dialog'></core-style> <core-style ref='ha-dialog'></core-style>
<style> <style>
.title-card {
margin-bottom: 24px;
}
</style> </style>
<div> <div>
<state-card-content stateObj="{{stateObj}}" api="{{api}}"></state-card-content> <state-card-content stateObj="{{stateObj}}" api="{{api}}" class='title-card'>
<br /> </state-card-content>
<more-info-content stateObj="{{stateObj}}" api="{{api}}"></more-info-content> <more-info-content stateObj="{{stateObj}}" api="{{api}}"></more-info-content>
</div> </div>

View file

@ -77,8 +77,8 @@
// how to render the more info of this state // how to render the more info of this state
moreInfoType: { moreInfoType: {
get: function() { get: function() {
if(this.domain === 'light') { if(this.domain === 'light' || this.domain === 'group') {
return 'light'; return this.domain;
} else { } else {
return 'default'; return 'default';
} }
@ -110,6 +110,19 @@
return found.length > 0 ? found[0] : null; return found.length > 0 ? found[0] : null;
}, },
getStates: function(entityIds) {
var states = [];
var state;
for(var i = 0; i < entityIds.length; i++) {
state = this.getState(entityIds[i]);
if(state !== null) {
states.push(state);
}
}
return states;
},
hasService: function(domain, service) { hasService: function(domain, service) {
var found = this.services.filter(function(serv) { var found = this.services.filter(function(serv) {
return serv.domain == domain && serv.services.indexOf(service) !== -1; return serv.domain == domain && serv.services.indexOf(service) !== -1;

View file

@ -2,9 +2,16 @@
<link rel="import" href="more-info-default.html"> <link rel="import" href="more-info-default.html">
<link rel="import" href="more-info-light.html"> <link rel="import" href="more-info-light.html">
<link rel="import" href="more-info-group.html">
<polymer-element name="more-info-content" attributes="api stateObj" noscript> <polymer-element name="more-info-content" attributes="api stateObj" noscript>
<template> <template>
<style>
:host {
display: block;
}
</style>
<template id="more-info-light"> <template id="more-info-light">
<more-info-light <more-info-light
api="{{api}}" api="{{api}}"
@ -12,6 +19,13 @@
</more-info-light> </more-info-light>
</template> </template>
<template id="more-info-group">
<more-info-group
api="{{api}}"
stateObj="{{stateObj}}">
</more-info-group>
</template>
<template id="more-info-default"> <template id="more-info-default">
<more-info-default stateObj="{{stateObj}}"></more-info-default> <more-info-default stateObj="{{stateObj}}"></more-info-default>
</template> </template>

View file

@ -0,0 +1,33 @@
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../cards/state-card-content.html">
<polymer-element name="more-info-group" attributes="stateObj api">
<template>
<style>
.child-card {
margin-bottom: 8px;
}
.child-card:last-child {
margin-bottom: 0;
}
</style>
<template repeat="{{states as state}}">
<state-card-content stateObj="{{state}}" api="{{api}}" class='child-card'>
</state-card-content>
</template>
</template>
<script>
Polymer({
observe: {
'stateObj.attributes.entity_id': 'updateStates'
},
updateStates: function() {
this.states = this.api.getStates(this.stateObj.attributes.entity_id);
}
});
</script>
</polymer-element>