1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00
Files
frontend/src/components/entity/ha-entity-marker.js
Paulus Schoutsen d8d693d72e Remove unused import
2015-09-25 13:43:10 -07:00

68 lines
1.2 KiB
JavaScript

import Polymer from '../../polymer';
import {
reactor,
entityGetters,
moreInfoActions,
} from '../../util/home-assistant-js-instance';
require('../../components/ha-label-badge');
export default new Polymer({
is: 'ha-entity-marker',
properties: {
entityId: {
type: String,
value: '',
},
state: {
type: Object,
computed: 'computeState(entityId)',
},
icon: {
type: Object,
computed: 'computeIcon(state)',
},
image: {
type: Object,
computed: 'computeImage(state)',
},
value: {
type: String,
computed: 'computeValue(state)',
},
},
listeners: {
'click': 'badgeTap',
},
badgeTap(ev) {
ev.stopPropagation();
if (this.entityId) {
this.async(() => moreInfoActions.selectEntity(this.entityId), 1);
}
},
computeState(entityId) {
return entityId && reactor.evaluate(entityGetters.byId(entityId));
},
computeIcon(state) {
return !state && 'home';
},
computeImage(state) {
return state && state.attributes.entity_picture;
},
computeValue(state) {
return state &&
state.entityDisplay.split(' ').map(part => part.substr(0, 1)).join('');
},
});