mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-08 18:06:36 +00:00
parent
24c9dd0472
commit
0a070a3fda
@ -23,7 +23,7 @@
|
|||||||
tail="{{_routeTail}}"
|
tail="{{_routeTail}}"
|
||||||
></app-route>
|
></app-route>
|
||||||
|
|
||||||
<template is='dom-if' if='[[account]]' restamp>
|
<template is='dom-if' if='[[_equals(routeData.page, "account")]]' restamp>
|
||||||
<ha-config-cloud-account
|
<ha-config-cloud-account
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
account='[[account]]'
|
account='[[account]]'
|
||||||
@ -31,33 +31,31 @@
|
|||||||
></ha-config-cloud-account>
|
></ha-config-cloud-account>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template is='dom-if' if='[[!account]]' restamp>
|
<template is='dom-if' if='[[_equals(_routeData.page, "login")]]' restamp>
|
||||||
<template is='dom-if' if='[[_equals(_routeData.page, "login")]]' restamp>
|
<ha-config-cloud-login
|
||||||
<ha-config-cloud-login
|
page-name='login'
|
||||||
page-name='login'
|
hass='[[hass]]'
|
||||||
hass='[[hass]]'
|
is-wide='[[isWide]]'
|
||||||
is-wide='[[isWide]]'
|
email='{{_loginEmail}}'
|
||||||
email='{{_loginEmail}}'
|
></ha-config-cloud-login>
|
||||||
></ha-config-cloud-login>
|
</template>
|
||||||
</template>
|
|
||||||
|
|
||||||
<template is='dom-if' if='[[_equals(_routeData.page, "register")]]' restamp>
|
<template is='dom-if' if='[[_equals(_routeData.page, "register")]]' restamp>
|
||||||
<ha-config-cloud-register
|
<ha-config-cloud-register
|
||||||
page-name='register'
|
page-name='register'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
is-wide='[[isWide]]'
|
is-wide='[[isWide]]'
|
||||||
email='{{_loginEmail}}'
|
email='{{_loginEmail}}'
|
||||||
></ha-config-cloud-register>
|
></ha-config-cloud-register>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template is='dom-if' if='[[_equals(_routeData.page, "forgot-password")]]' restamp>
|
<template is='dom-if' if='[[_equals(_routeData.page, "forgot-password")]]' restamp>
|
||||||
<ha-config-cloud-forgot-password
|
<ha-config-cloud-forgot-password
|
||||||
page-name='forgot-password'
|
page-name='forgot-password'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
is-wide='[[isWide]]'
|
is-wide='[[isWide]]'
|
||||||
email='{{_loginEmail}}'
|
email='{{_loginEmail}}'
|
||||||
></ha-config-cloud-forgot-password>
|
></ha-config-cloud-forgot-password>
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</dom-module>
|
</dom-module>
|
||||||
@ -98,10 +96,10 @@
|
|||||||
if (!route || route.path.substr(0, 6) !== '/cloud') return;
|
if (!route || route.path.substr(0, 6) !== '/cloud') return;
|
||||||
|
|
||||||
if (!account && ['/cloud/forgot-password', '/cloud/register'].indexOf(route.path) === -1) {
|
if (!account && ['/cloud/forgot-password', '/cloud/register'].indexOf(route.path) === -1) {
|
||||||
this.navigate('/config/cloud/login', true);
|
setTimeout(() => this.navigate('/config/cloud/login', true), 0);
|
||||||
} else if (account &&
|
} else if (account &&
|
||||||
['/cloud/login', '/cloud/register', '/cloud/forgot-password'].indexOf(route.path) !== -1) {
|
['/cloud/login', '/cloud/register', '/cloud/forgot-password'].indexOf(route.path) !== -1) {
|
||||||
this.navigate('/config/cloud/account', true);
|
setTimeout(() => this.navigate('/config/cloud/account', true), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<link rel="import" href='../../bower_components/polymer/polymer-element.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/iron-media-query/iron-media-query.html'>
|
||||||
<link rel='import' href='../../bower_components/app-route/app-route.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="../../src/layouts/hass-error-screen.html">
|
||||||
<link rel="import" href="../../src/util/hass-mixins.html">
|
<link rel="import" href="../../src/util/hass-mixins.html">
|
||||||
@ -17,11 +16,6 @@
|
|||||||
|
|
||||||
<dom-module id="ha-panel-config">
|
<dom-module id="ha-panel-config">
|
||||||
<template>
|
<template>
|
||||||
<style>
|
|
||||||
iron-pages {
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<app-route
|
<app-route
|
||||||
route='[[route]]'
|
route='[[route]]'
|
||||||
pattern='/:page'
|
pattern='/:page'
|
||||||
@ -33,30 +27,25 @@
|
|||||||
<iron-media-query query="(min-width: 1296px)" query-matches="{{wideSidebar}}">
|
<iron-media-query query="(min-width: 1296px)" query-matches="{{wideSidebar}}">
|
||||||
</iron-media-query>
|
</iron-media-query>
|
||||||
|
|
||||||
<iron-pages
|
<template is="dom-if" if='[[_equals(_routeData.page, "core")]]' restamp>
|
||||||
selected='[[_routeData.page]]'
|
<ha-config-core
|
||||||
attr-for-selected='page-name'
|
page-name='core'
|
||||||
fallback-selection='not-found'
|
hass='[[hass]]'
|
||||||
selected-attribute='visible'
|
is-wide='[[isWide]]'
|
||||||
>
|
></ha-config-core>
|
||||||
<template is="dom-if" if='[[_equals(_routeData.page, "core")]]' restamp>
|
</template>
|
||||||
<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>
|
<template is="dom-if" if='[[_equals(_routeData.page, "cloud")]]' restamp>
|
||||||
<ha-config-cloud
|
<ha-config-cloud
|
||||||
page-name='cloud'
|
page-name='cloud'
|
||||||
route='[[route]]'
|
route='[[route]]'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
is-wide='[[isWide]]'
|
is-wide='[[isWide]]'
|
||||||
account='[[account]]'
|
account='[[account]]'
|
||||||
></ha-config-cloud>
|
></ha-config-cloud>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template is="dom-if" if='[[_equals(_routeData.page, "dashboard")]]'>
|
||||||
<ha-config-dashboard
|
<ha-config-dashboard
|
||||||
page-name='dashboard'
|
page-name='dashboard'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
@ -65,59 +54,53 @@
|
|||||||
narrow='[[narrow]]'
|
narrow='[[narrow]]'
|
||||||
show-menu='[[showMenu]]'
|
show-menu='[[showMenu]]'
|
||||||
></ha-config-dashboard>
|
></ha-config-dashboard>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template is="dom-if" if='[[_equals(_routeData.page, "automation")]]' restamp>
|
<template is="dom-if" if='[[_equals(_routeData.page, "automation")]]' restamp>
|
||||||
<ha-config-automation
|
<ha-config-automation
|
||||||
page-name='automation'
|
page-name='automation'
|
||||||
route='[[route]]'
|
route='[[route]]'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
is-wide='[[isWide]]'
|
is-wide='[[isWide]]'
|
||||||
></ha-config-automation>
|
></ha-config-automation>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template is="dom-if" if='[[_equals(_routeData.page, "script")]]' restamp>
|
<template is="dom-if" if='[[_equals(_routeData.page, "script")]]' restamp>
|
||||||
<ha-config-script
|
<ha-config-script
|
||||||
page-name='script'
|
page-name='script'
|
||||||
route='[[route]]'
|
route='[[route]]'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
is-wide='[[isWide]]'
|
is-wide='[[isWide]]'
|
||||||
></ha-config-script>
|
></ha-config-script>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template is="dom-if" if='[[_equals(_routeData.page, "zwave")]]' restamp>
|
<template is="dom-if" if='[[_equals(_routeData.page, "zwave")]]' restamp>
|
||||||
<ha-config-zwave
|
<ha-config-zwave
|
||||||
page-name='zwave'
|
page-name='zwave'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
is-wide='[[isWide]]'
|
is-wide='[[isWide]]'
|
||||||
></ha-config-zwave>
|
></ha-config-zwave>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template is="dom-if" if='[[_equals(_routeData.page, "customize")]]' restamp>
|
<template is="dom-if" if='[[_equals(_routeData.page, "customize")]]' restamp>
|
||||||
<ha-config-customize
|
<ha-config-customize
|
||||||
page-name='customize'
|
page-name='customize'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
is-wide='[[isWide]]'
|
is-wide='[[isWide]]'
|
||||||
></ha-config-customize>
|
></ha-config-customize>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template is="dom-if" if='[[_equals(_routeData.page, "integrations")]]' restamp>
|
<template is="dom-if" if='[[_equals(_routeData.page, "integrations")]]' restamp>
|
||||||
<ha-config-entries
|
<ha-config-entries
|
||||||
page-name='integrations'
|
page-name='integrations'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
></ha-config-entries>
|
></ha-config-entries>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<hass-error-screen
|
|
||||||
page-name='not-found'
|
|
||||||
error='Page not found.'
|
|
||||||
title='Configuration'
|
|
||||||
></hass-error-screen>
|
|
||||||
</iron-pages>
|
|
||||||
</template>
|
</template>
|
||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
class HaPanelConfig extends window.hassMixins.EventsMixin(Polymer.Element) {
|
class HaPanelConfig extends window.hassMixins.NavigateMixin(Polymer.Element) {
|
||||||
static get is() { return 'ha-panel-config'; }
|
static get is() { return 'ha-panel-config'; }
|
||||||
|
|
||||||
static get properties() {
|
static get properties() {
|
||||||
@ -163,8 +146,7 @@ class HaPanelConfig extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|||||||
|
|
||||||
_routeChanged(route) {
|
_routeChanged(route) {
|
||||||
if (route.path === '' && route.prefix === '/config') {
|
if (route.path === '' && route.prefix === '/config') {
|
||||||
history.replaceState(null, null, '/config/dashboard');
|
this.navigate('/config/dashboard', true);
|
||||||
this.fire('location-changed');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@
|
|||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
class HaScriptEditor extends window.hassMixins.EventsMixin(Polymer.Element) {
|
class HaScriptEditor extends window.hassMixins.NavigateMixin(Polymer.Element) {
|
||||||
static get is() { return 'ha-script-editor'; }
|
static get is() { return 'ha-script-editor'; }
|
||||||
|
|
||||||
static get properties() {
|
static get properties() {
|
||||||
@ -194,7 +194,7 @@ class HaScriptEditor extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|||||||
this.config = config;
|
this.config = config;
|
||||||
this.errors = null;
|
this.errors = null;
|
||||||
this.dirty = true;
|
this.dirty = true;
|
||||||
this._updateComponent(config);
|
this._updateComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
scriptChanged(newVal, oldVal) {
|
scriptChanged(newVal, oldVal) {
|
||||||
@ -207,7 +207,7 @@ class HaScriptEditor extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.hass.callApi('get', 'config/script/config/' + window.hassUtil.computeObjectId(newVal))
|
this.hass.callApi('get', 'config/script/config/' + window.hassUtil.computeObjectId(newVal))
|
||||||
.then(function (config) {
|
.then((config) => {
|
||||||
// Normalize data: ensure sequence is a list
|
// Normalize data: ensure sequence is a list
|
||||||
// Happens when people copy paste their scripts into the config
|
// Happens when people copy paste their scripts into the config
|
||||||
var value = config.sequence;
|
var value = config.sequence;
|
||||||
@ -218,7 +218,10 @@ class HaScriptEditor extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|||||||
this.dirty = false;
|
this.dirty = false;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this._updateComponent();
|
this._updateComponent();
|
||||||
}.bind(this));
|
}, () => {
|
||||||
|
alert('Only scripts inside scripts.yaml are editable.');
|
||||||
|
history.back();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
creatingNewChanged(newVal) {
|
creatingNewChanged(newVal) {
|
||||||
@ -260,17 +263,16 @@ class HaScriptEditor extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|||||||
|
|
||||||
saveScript() {
|
saveScript() {
|
||||||
var id = this.creatingNew ? '' + Date.now() : window.hassUtil.computeObjectId(this.script);
|
var id = this.creatingNew ? '' + Date.now() : window.hassUtil.computeObjectId(this.script);
|
||||||
this.hass.callApi('post', 'config/script/config/' + id, this.config).then(function () {
|
this.hass.callApi('post', 'config/script/config/' + id, this.config).then(() => {
|
||||||
this.dirty = false;
|
this.dirty = false;
|
||||||
|
|
||||||
if (this.creatingNew) {
|
if (this.creatingNew) {
|
||||||
history.replaceState(null, null, '/config/script/edit/' + id);
|
this.navigate(`/config/script/edit/${id}`, true);
|
||||||
this.fire('location-changed');
|
|
||||||
}
|
}
|
||||||
}.bind(this), function (errors) {
|
}, (errors) => {
|
||||||
this.errors = errors.body.message;
|
this.errors = errors.body.message;
|
||||||
throw errors;
|
throw errors;
|
||||||
}.bind(this));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
computeName(script) {
|
computeName(script) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user