mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 10:16:46 +00:00
Clean up some imports
This commit is contained in:
parent
6b226c02da
commit
cf83fe5759
@ -36,3 +36,79 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</dom-module>
|
</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('');
|
|
||||||
},
|
|
||||||
});
|
|
@ -3,8 +3,6 @@
|
|||||||
<link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
|
<link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
|
||||||
<link rel="import" href="../../bower_components/paper-toggle-button/paper-toggle-button.html">
|
<link rel="import" href="../../bower_components/paper-toggle-button/paper-toggle-button.html">
|
||||||
|
|
||||||
<link rel="import" href="../../bower_components/iron-icons/notification-icons.html">
|
|
||||||
|
|
||||||
<dom-module id="stream-status">
|
<dom-module id="stream-status">
|
||||||
<style>
|
<style>
|
||||||
:host {
|
:host {
|
||||||
|
@ -82,3 +82,94 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.L.Icon.Default.imagePath = '/static/images/leaflet';
|
||||||
|
|
||||||
|
Polymer({
|
||||||
|
is: 'partial-map',
|
||||||
|
|
||||||
|
behaviors: [window.hassBehavior],
|
||||||
|
|
||||||
|
properties: {
|
||||||
|
hass: {
|
||||||
|
type: Object,
|
||||||
|
},
|
||||||
|
|
||||||
|
locationGPS: {
|
||||||
|
type: Number,
|
||||||
|
bindNuclear: function (hass) {
|
||||||
|
return hass.configGetters.locationGPS;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
locationName: {
|
||||||
|
type: String,
|
||||||
|
bindNuclear: function (hass) {
|
||||||
|
return hass.configGetters.locationName;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
locationEntities: {
|
||||||
|
type: Array,
|
||||||
|
bindNuclear: function (hass) {
|
||||||
|
return [
|
||||||
|
hass.entityGetters.visibleEntityMap,
|
||||||
|
function (entities) {
|
||||||
|
return entities.valueSeq().filter(
|
||||||
|
function (entity) {
|
||||||
|
return entity.attributes.latitude && entity.state !== 'home';
|
||||||
|
}
|
||||||
|
).toArray();
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
zoneEntities: {
|
||||||
|
type: Array,
|
||||||
|
bindNuclear: function (hass) {
|
||||||
|
return [
|
||||||
|
hass.entityGetters.entityMap,
|
||||||
|
function (entities) {
|
||||||
|
return entities.valueSeq()
|
||||||
|
.filter(function (entity) {
|
||||||
|
return entity.domain === 'zone' && !entity.attributes.passive;
|
||||||
|
}).toArray();
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
narrow: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
|
||||||
|
showMenu: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
attached: function () {
|
||||||
|
// On Safari, iPhone 5, 5s and some 6 I have observed that the user would be
|
||||||
|
// unable to pan on initial load. This fixes it.
|
||||||
|
if (window.L.Browser.mobileWebkit || window.L.Browser.webkit) {
|
||||||
|
this.async(() => {
|
||||||
|
const map = this.$.map;
|
||||||
|
const prev = map.style.display;
|
||||||
|
map.style.display = 'none';
|
||||||
|
this.async(() => { map.style.display = prev; }, 1);
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
computeMenuButtonClass: function (narrow, showMenu) {
|
||||||
|
return !narrow && showMenu ? 'menu-icon invisible' : 'menu-icon';
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleMenu: function () {
|
||||||
|
this.fire('open-menu');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
import Polymer from '../polymer';
|
|
||||||
|
|
||||||
import '../components/entity/ha-entity-marker';
|
|
||||||
|
|
||||||
window.L.Icon.Default.imagePath = '/static/images/leaflet';
|
|
||||||
|
|
||||||
export default new Polymer({
|
|
||||||
is: 'partial-map',
|
|
||||||
|
|
||||||
behaviors: [window.hassBehavior],
|
|
||||||
|
|
||||||
properties: {
|
|
||||||
hass: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
locationGPS: {
|
|
||||||
type: Number,
|
|
||||||
bindNuclear: hass => hass.configGetters.locationGPS,
|
|
||||||
},
|
|
||||||
|
|
||||||
locationName: {
|
|
||||||
type: String,
|
|
||||||
bindNuclear: hass => hass.configGetters.locationName,
|
|
||||||
},
|
|
||||||
|
|
||||||
locationEntities: {
|
|
||||||
type: Array,
|
|
||||||
bindNuclear: hass => [
|
|
||||||
hass.entityGetters.visibleEntityMap,
|
|
||||||
entities => entities.valueSeq().filter(
|
|
||||||
entity => entity.attributes.latitude && entity.state !== 'home'
|
|
||||||
).toArray(),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
|
|
||||||
zoneEntities: {
|
|
||||||
type: Array,
|
|
||||||
bindNuclear: hass => [
|
|
||||||
hass.entityGetters.entityMap,
|
|
||||||
entities => entities.valueSeq()
|
|
||||||
.filter(entity => entity.domain === 'zone' &&
|
|
||||||
!entity.attributes.passive)
|
|
||||||
.toArray(),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
|
|
||||||
narrow: {
|
|
||||||
type: Boolean,
|
|
||||||
},
|
|
||||||
|
|
||||||
showMenu: {
|
|
||||||
type: Boolean,
|
|
||||||
value: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
attached() {
|
|
||||||
// On Safari, iPhone 5, 5s and some 6 I have observed that the user would be
|
|
||||||
// unable to pan on initial load. This fixes it.
|
|
||||||
if (window.L.Browser.mobileWebkit || window.L.Browser.webkit) {
|
|
||||||
this.async(() => {
|
|
||||||
const map = this.$.map;
|
|
||||||
const prev = map.style.display;
|
|
||||||
map.style.display = 'none';
|
|
||||||
this.async(() => { map.style.display = prev; }, 1);
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computeMenuButtonClass(narrow, showMenu) {
|
|
||||||
return !narrow && showMenu ? 'menu-icon invisible' : 'menu-icon';
|
|
||||||
},
|
|
||||||
|
|
||||||
toggleMenu() {
|
|
||||||
this.fire('open-menu');
|
|
||||||
},
|
|
||||||
});
|
|
Loading…
x
Reference in New Issue
Block a user