No longer fetch customui element (#414)

This commit is contained in:
Andrey 2017-08-29 10:07:56 +03:00 committed by Paulus Schoutsen
parent 0508a6bf2e
commit 206f624fb6

View File

@ -1,4 +1,4 @@
<link rel="import" href="../../bower_components/polymer/polymer.html"> <link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel="import" href="state-card-climate.html"> <link rel="import" href="state-card-climate.html">
<link rel="import" href="state-card-configurator.html"> <link rel="import" href="state-card-configurator.html">
@ -12,56 +12,49 @@
<link rel="import" href="state-card-toggle.html"> <link rel="import" href="state-card-toggle.html">
<link rel="import" href="state-card-weblink.html"> <link rel="import" href="state-card-weblink.html">
<script> <link rel="import" href="../util/hass-util.html">
Polymer({
is: 'state-card-content',
properties: { <script>
hass: { class StateCardContent extends Polymer.Element {
type: Object,
}, static get is() { return 'state-card-content'; }
static get properties() {
return {
hass: Object,
inDialog: { inDialog: {
type: Boolean, type: Boolean,
value: false, value: false,
}, },
stateObj: { stateObj: Object,
type: Object, };
}, }
},
observers: [ static get observers() {
return [
'inputChanged(hass, inDialog, stateObj)', 'inputChanged(hass, inDialog, stateObj)',
], ];
}
_ensureCustomUILoaded: function (stateType) { inputChanged(hass, inDialog, stateObj) {
this.importHref( let stateCardType;
'/local/custom_ui/state-card-' + stateType + '.html',
function () {},
/* eslint-disable no-console */
function () { console.error('Error loading %s from /local/custom_ui/state-card-%s.html', stateType, stateType); },
/* eslint-enable no-console */
true);
},
inputChanged: function (hass, inDialog, stateObj) {
var stateCardType;
if (!stateObj || !hass) return; if (!stateObj || !hass) return;
if (stateObj.attributes && 'custom_ui_state_card' in stateObj.attributes) { if (stateObj.attributes && 'custom_ui_state_card' in stateObj.attributes) {
stateCardType = stateObj.attributes.custom_ui_state_card; stateCardType = stateObj.attributes.custom_ui_state_card;
this._ensureCustomUILoaded(stateCardType);
} else { } else {
stateCardType = window.hassUtil.stateCardType(hass, stateObj); stateCardType = 'state-card-' + window.hassUtil.stateCardType(hass, stateObj);
} }
window.hassUtil.dynamicContentUpdater( window.hassUtil.dynamicContentUpdater(
this, this,
('STATE-CARD-' + stateCardType.toUpperCase()), stateCardType.toUpperCase(),
{ {
hass: hass, hass: hass,
stateObj: stateObj, stateObj: stateObj,
inDialog: inDialog, inDialog: inDialog,
}); });
}, }
}); }
customElements.define(StateCardContent.is, StateCardContent);
</script> </script>