88 lines
2.4 KiB
HTML
88 lines
2.4 KiB
HTML
<link rel='import' href='../bower_components/polymer/polymer.html'>
|
|
<link rel='import' href='../bower_components/paper-spinner/paper-spinner.html'>
|
|
<link rel='import' href='./util/roboto.html'>
|
|
<link rel='import' href='../bower_components/paper-styles/typography.html'>
|
|
<link rel='import' href='../bower_components/iron-flex-layout/iron-flex-layout-classes.html'>
|
|
|
|
<link rel='import' href='./util/hass-util.html'>
|
|
<link rel='import' href='./util/hass-behavior.html'>
|
|
<link rel='import' href='./layouts/login-form.html'>
|
|
<link rel='import' href='./layouts/home-assistant-main.html'>
|
|
<link rel='import' href='./resources/home-assistant-style.html'>
|
|
<link rel="import" href="./resources/panel-imports.html">
|
|
|
|
<dom-module id='home-assistant'>
|
|
<template>
|
|
<template is='dom-if' if='[[loaded]]'>
|
|
<home-assistant-main hass='[[hass]]'></home-assistant-main>
|
|
</template>
|
|
|
|
<template is='dom-if' if='[[!loaded]]'>
|
|
<login-form
|
|
hass='[[hass]]'
|
|
force-show-loading='[[computeForceShowLoading(dataLoaded, iconsLoaded)]]'>
|
|
</login-form>
|
|
</template>
|
|
</template>
|
|
</dom-module>
|
|
|
|
<script>
|
|
Polymer({
|
|
is: 'home-assistant',
|
|
|
|
hostAttributes: {
|
|
icons: null,
|
|
},
|
|
|
|
behaviors: [window.hassBehavior],
|
|
|
|
properties: {
|
|
hass: {
|
|
type: Object,
|
|
value: window.hass,
|
|
},
|
|
icons: {
|
|
type: String,
|
|
},
|
|
dataLoaded: {
|
|
type: Boolean,
|
|
bindNuclear: function (hass) { return hass.syncGetters.isDataLoaded; },
|
|
},
|
|
iconsLoaded: {
|
|
type: Boolean,
|
|
value: false,
|
|
},
|
|
loaded: {
|
|
type: Boolean,
|
|
computed: 'computeLoaded(dataLoaded, iconsLoaded)',
|
|
},
|
|
},
|
|
|
|
computeLoaded: function (dataLoaded, iconsLoaded) {
|
|
return dataLoaded && iconsLoaded;
|
|
},
|
|
|
|
computeForceShowLoading: function (dataLoaded, iconsLoaded) {
|
|
return dataLoaded && !iconsLoaded;
|
|
},
|
|
|
|
loadIcons: function () {
|
|
// If the import fails, we'll try to import again, must be a server glitch
|
|
// Since HTML imports only resolve once, we import another url.
|
|
var success = function () {
|
|
this.iconsLoaded = true;
|
|
}.bind(this);
|
|
|
|
this.importHref('/static/mdi-' + this.icons + '.html',
|
|
success,
|
|
function () {
|
|
this.importHref('/static/mdi.html', success, success);
|
|
});
|
|
},
|
|
|
|
ready: function () {
|
|
this.loadIcons();
|
|
},
|
|
});
|
|
</script>
|