144 lines
3.7 KiB
HTML
144 lines
3.7 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="../../bower_components/iron-pages/iron-pages.html">
|
|
|
|
<link rel="import" href="../../src/layouts/hass-error-screen.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">
|
|
|
|
<dom-module id="ha-panel-config">
|
|
<template>
|
|
<style>
|
|
iron-pages {
|
|
height: 100%;
|
|
}
|
|
</style>
|
|
<app-route
|
|
route='[[route]]'
|
|
pattern='/:page'
|
|
data="{{_routeData}}"
|
|
tail="{{_routeTail}}"
|
|
></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>
|
|
|
|
<iron-pages
|
|
selected='[[_routeData.page]]'
|
|
attr-for-selected='page-name'
|
|
fallback-selection='not-found'
|
|
selected-attribute='visible'
|
|
>
|
|
<ha-config-core
|
|
page-name='core'
|
|
hass='[[hass]]'
|
|
is-wide='[[isWide]]'
|
|
></ha-config-core>
|
|
|
|
<ha-config-cloud
|
|
page-name='cloud'
|
|
hass='[[hass]]'
|
|
is-wide='[[isWide]]'
|
|
account='[[account]]'
|
|
></ha-config-cloud>
|
|
|
|
<ha-config-dashboard
|
|
page-name='dashboard'
|
|
hass='[[hass]]'
|
|
is-wide='[[isWide]]'
|
|
account='[[account]]'
|
|
></ha-config-dashboard>
|
|
|
|
<ha-config-automation
|
|
page-name='automation'
|
|
route='[[_routeTail]]'
|
|
hass='[[hass]]'
|
|
is-wide='[[isWide]]'
|
|
></ha-config-automation>
|
|
|
|
<ha-config-script
|
|
page-name='script'
|
|
route='[[_routeTail]]'
|
|
hass='[[hass]]'
|
|
is-wide='[[isWide]]'
|
|
></ha-config-script>
|
|
|
|
<ha-config-zwave
|
|
page-name='zwave'
|
|
hass='[[hass]]'
|
|
is-wide='[[isWide]]'
|
|
></ha-config-zwave>
|
|
|
|
<hass-error-screen
|
|
page-name='not-found'
|
|
error='Page not found.'
|
|
title='Configuration'
|
|
></hass-error-screen>
|
|
</iron-pages>
|
|
</template>
|
|
</dom-module>
|
|
|
|
<script>
|
|
class HaPanelConfig extends window.hassMixins.EventsMixin(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,
|
|
_routeTail: 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') {
|
|
history.replaceState(null, null, '/config/dashboard');
|
|
this.fire('location-changed');
|
|
}
|
|
}
|
|
}
|
|
|
|
customElements.define(HaPanelConfig.is, HaPanelConfig);
|
|
</script>
|