mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-08 18:06:36 +00:00
parent
ea57e71c8b
commit
bb946d9eec
@ -132,7 +132,7 @@ class HaConfigCloudAccount extends window.hassMixins.EventsMixin(Polymer.Element
|
||||
}
|
||||
|
||||
_accountChanged(newAccount) {
|
||||
if (newAccount.cloud !== 'connecting') {
|
||||
if (!newAccount || newAccount.cloud !== 'connecting') {
|
||||
if (this._accountUpdater) {
|
||||
clearTimeout(this._accountUpdater);
|
||||
this._accountUpdater = null;
|
||||
|
@ -11,11 +11,6 @@
|
||||
|
||||
<dom-module id="ha-config-cloud">
|
||||
<template>
|
||||
<style>
|
||||
iron-pages {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
<app-route
|
||||
route='[[route]]'
|
||||
pattern='/cloud/:page'
|
||||
@ -23,7 +18,7 @@
|
||||
tail="{{_routeTail}}"
|
||||
></app-route>
|
||||
|
||||
<template is='dom-if' if='[[_equals(routeData.page, "account")]]' restamp>
|
||||
<template is='dom-if' if='[[_equals(_routeData.page, "account")]]' restamp>
|
||||
<ha-config-cloud-account
|
||||
hass='[[hass]]'
|
||||
account='[[account]]'
|
||||
@ -62,6 +57,15 @@
|
||||
|
||||
<script>
|
||||
{
|
||||
const LOGGED_IN_URLS = [
|
||||
'/cloud/account',
|
||||
];
|
||||
const NOT_LOGGED_IN_URLS = [
|
||||
'/cloud/login',
|
||||
'/cloud/register',
|
||||
'/cloud/forgot-password',
|
||||
];
|
||||
|
||||
class HaConfigCloud extends window.hassMixins.NavigateMixin(Polymer.Element) {
|
||||
static get is() { return 'ha-config-cloud'; }
|
||||
|
||||
@ -75,7 +79,6 @@
|
||||
},
|
||||
account: {
|
||||
type: Object,
|
||||
value: null,
|
||||
},
|
||||
|
||||
route: Object,
|
||||
@ -92,15 +95,20 @@
|
||||
];
|
||||
}
|
||||
|
||||
_checkRoute(route, account) {
|
||||
_checkRoute(route) {
|
||||
if (!route || route.path.substr(0, 6) !== '/cloud') return;
|
||||
|
||||
if (!account && ['/cloud/forgot-password', '/cloud/register'].indexOf(route.path) === -1) {
|
||||
setTimeout(() => this.navigate('/config/cloud/login', true), 0);
|
||||
} else if (account &&
|
||||
['/cloud/login', '/cloud/register', '/cloud/forgot-password'].indexOf(route.path) !== -1) {
|
||||
setTimeout(() => this.navigate('/config/cloud/account', true), 0);
|
||||
}
|
||||
this._debouncer = Polymer.Debouncer.debounce(
|
||||
this._debouncer,
|
||||
Polymer.Async.timeOut.after(0),
|
||||
() => {
|
||||
if (!this.account && !NOT_LOGGED_IN_URLS.includes(route.path)) {
|
||||
this.navigate('/config/cloud/login', true);
|
||||
} else if (this.account && !LOGGED_IN_URLS.includes(route.path)) {
|
||||
this.navigate('/config/cloud/account', true);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
_equals(a, b) {
|
||||
|
@ -108,10 +108,7 @@ class HaPanelConfig extends window.hassMixins.NavigateMixin(Polymer.Element) {
|
||||
hass: Object,
|
||||
narrow: Boolean,
|
||||
showMenu: Boolean,
|
||||
account: {
|
||||
type: Object,
|
||||
value: null,
|
||||
},
|
||||
account: Object,
|
||||
|
||||
route: {
|
||||
type: Object,
|
||||
|
Loading…
x
Reference in New Issue
Block a user