mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-09 10:59:50 +00:00
Clean up some imports
This commit is contained in:
@@ -36,3 +36,79 @@
|
||||
</div>
|
||||
</template>
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
/*
|
||||
Leaflet clones this element before adding it to the map. This messes up
|
||||
our Poylmer object and we lose the reference to the `hass` object.
|
||||
|
||||
That's why we refer here to window.hass instead of the hass property.
|
||||
*/
|
||||
Polymer({
|
||||
is: 'ha-entity-marker',
|
||||
|
||||
properties: {
|
||||
hass: {
|
||||
type: Object,
|
||||
},
|
||||
|
||||
entityId: {
|
||||
type: String,
|
||||
value: '',
|
||||
reflectToAttribute: true,
|
||||
},
|
||||
|
||||
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: {
|
||||
tap: 'badgeTap',
|
||||
},
|
||||
|
||||
badgeTap: function (ev) {
|
||||
ev.stopPropagation();
|
||||
if (this.entityId) {
|
||||
this.async(function () {
|
||||
window.hass.moreInfoActions.selectEntity(this.entityId);
|
||||
}, 1);
|
||||
}
|
||||
},
|
||||
|
||||
computeState: function (entityId) {
|
||||
return entityId && window.hass.reactor.evaluate(window.hass.entityGetters.byId(entityId));
|
||||
},
|
||||
|
||||
computeIcon: function (state) {
|
||||
return !state && 'home';
|
||||
},
|
||||
|
||||
computeImage: function (state) {
|
||||
return state && state.attributes.entity_picture;
|
||||
},
|
||||
|
||||
computeValue: function (state) {
|
||||
return state &&
|
||||
state.entityDisplay.split(' ').map(function (part) {
|
||||
return part.substr(0, 1);
|
||||
}).join('');
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
import Polymer from '../../polymer';
|
||||
|
||||
/*
|
||||
Leaflet clones this element before adding it to the map. This messes up
|
||||
our Poylmer object and we lose the reference to the `hass` object.
|
||||
|
||||
That's why we refer here to window.hass instead of the hass property.
|
||||
*/
|
||||
|
||||
export default new Polymer({
|
||||
is: 'ha-entity-marker',
|
||||
|
||||
properties: {
|
||||
hass: {
|
||||
type: Object,
|
||||
},
|
||||
|
||||
entityId: {
|
||||
type: String,
|
||||
value: '',
|
||||
reflectToAttribute: true,
|
||||
},
|
||||
|
||||
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: {
|
||||
tap: 'badgeTap',
|
||||
},
|
||||
|
||||
badgeTap(ev) {
|
||||
ev.stopPropagation();
|
||||
if (this.entityId) {
|
||||
this.async(() => window.hass.moreInfoActions.selectEntity(this.entityId), 1);
|
||||
}
|
||||
},
|
||||
|
||||
computeState(entityId) {
|
||||
return entityId && window.hass.reactor.evaluate(window.hass.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('');
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user