ha-frontend-cdce8p/panels/config/ha-panel-config.html
Paulus Schoutsen bb946d9eec
Clean up cloud routing (#909)
* Clean up cloud routing

* Lint
2018-02-21 11:48:28 -08:00

157 lines
4.4 KiB
HTML

<link rel="import" href='../../bower_components/polymer/polymer-element.html'>
<link rel='import' href='../../bower_components/iron-media-query/iron-media-query.html'>
<link rel='import' href='../../bower_components/app-route/app-route.html'>
<link rel="import" href="../../src/layouts/hass-error-screen.html">
<link rel="import" href="../../src/util/hass-mixins.html">
<link rel="import" href="./dashboard/ha-config-dashboard.html">
<link rel="import" href="./core/ha-config-core.html">
<link rel="import" href="./cloud/ha-config-cloud.html">
<link rel="import" href="./automation/ha-config-automation.html">
<link rel="import" href="./script/ha-config-script.html">
<link rel="import" href="./zwave/ha-config-zwave.html">
<link rel="import" href="./customize/ha-config-customize.html">
<link rel="import" href="./config-entries/ha-config-entries.html">
<dom-module id="ha-panel-config">
<template>
<app-route
route='[[route]]'
pattern='/:page'
data="{{_routeData}}"
></app-route>
<iron-media-query query="(min-width: 1040px)" query-matches="{{wide}}">
</iron-media-query>
<iron-media-query query="(min-width: 1296px)" query-matches="{{wideSidebar}}">
</iron-media-query>
<template is="dom-if" if='[[_equals(_routeData.page, "core")]]' restamp>
<ha-config-core
page-name='core'
hass='[[hass]]'
is-wide='[[isWide]]'
></ha-config-core>
</template>
<template is="dom-if" if='[[_equals(_routeData.page, "cloud")]]' restamp>
<ha-config-cloud
page-name='cloud'
route='[[route]]'
hass='[[hass]]'
is-wide='[[isWide]]'
account='[[account]]'
></ha-config-cloud>
</template>
<template is="dom-if" if='[[_equals(_routeData.page, "dashboard")]]'>
<ha-config-dashboard
page-name='dashboard'
hass='[[hass]]'
is-wide='[[isWide]]'
account='[[account]]'
narrow='[[narrow]]'
show-menu='[[showMenu]]'
></ha-config-dashboard>
</template>
<template is="dom-if" if='[[_equals(_routeData.page, "automation")]]' restamp>
<ha-config-automation
page-name='automation'
route='[[route]]'
hass='[[hass]]'
is-wide='[[isWide]]'
></ha-config-automation>
</template>
<template is="dom-if" if='[[_equals(_routeData.page, "script")]]' restamp>
<ha-config-script
page-name='script'
route='[[route]]'
hass='[[hass]]'
is-wide='[[isWide]]'
></ha-config-script>
</template>
<template is="dom-if" if='[[_equals(_routeData.page, "zwave")]]' restamp>
<ha-config-zwave
page-name='zwave'
hass='[[hass]]'
is-wide='[[isWide]]'
></ha-config-zwave>
</template>
<template is="dom-if" if='[[_equals(_routeData.page, "customize")]]' restamp>
<ha-config-customize
page-name='customize'
hass='[[hass]]'
is-wide='[[isWide]]'
></ha-config-customize>
</template>
<template is="dom-if" if='[[_equals(_routeData.page, "integrations")]]' restamp>
<ha-config-entries
page-name='integrations'
hass='[[hass]]'
></ha-config-entries>
</template>
</template>
</dom-module>
<script>
class HaPanelConfig extends window.hassMixins.NavigateMixin(Polymer.Element) {
static get is() { return 'ha-panel-config'; }
static get properties() {
return {
hass: Object,
narrow: Boolean,
showMenu: Boolean,
account: Object,
route: {
type: Object,
observer: '_routeChanged',
},
_routeData: Object,
wide: Boolean,
wideSidebar: Boolean,
isWide: {
type: Boolean,
computed: 'computeIsWide(showMenu, wideSidebar, wide)'
},
};
}
ready() {
super.ready();
if (window.hassUtil.isComponentLoaded(this.hass, 'cloud')) {
this.hass.callApi('get', 'cloud/account').then((account) => { this.account = account; });
}
this.addEventListener('ha-account-refreshed', (ev) => {
this.account = ev.detail.account;
});
}
computeIsWide(showMenu, wideSidebar, wide) {
return showMenu ? wideSidebar : wide;
}
_routeChanged(route) {
if (route.path === '' && route.prefix === '/config') {
this.navigate('/config/dashboard', true);
}
}
_equals(a, b) {
return a === b;
}
}
customElements.define(HaPanelConfig.is, HaPanelConfig);
</script>