From 1cbe0b7b9f47a815591af588a9fe0213fd07ddf1 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 7 Aug 2018 23:11:57 +0200 Subject: [PATCH] Don't put components in entrypoint (#1548) * Don't put components in entrypoint * Remove extra deps --- src/auth/ha-authorize.js | 96 ++++++++++++++++++++++++++++++++++++ src/entrypoints/authorize.js | 94 +---------------------------------- 2 files changed, 97 insertions(+), 93 deletions(-) create mode 100644 src/auth/ha-authorize.js diff --git a/src/auth/ha-authorize.js b/src/auth/ha-authorize.js new file mode 100644 index 0000000000..d0f1663e14 --- /dev/null +++ b/src/auth/ha-authorize.js @@ -0,0 +1,96 @@ +import '@polymer/iron-flex-layout/iron-flex-layout-classes.js'; +import '@polymer/polymer/lib/elements/dom-if.js'; +import '@polymer/polymer/lib/elements/dom-repeat.js'; +import { html } from '@polymer/polymer/lib/utils/html-tag.js'; +import { PolymerElement } from '@polymer/polymer/polymer-element.js'; + +import '../auth/ha-auth-flow.js'; +import '../auth/ha-pick-auth-provider.js'; + +class HaAuthorize extends PolymerElement { + static get template() { + return html` + + +
+
+ + Home Assistant +
+ +

Logging in to [[clientId]].

+ + + +
+`; + } + + static get properties() { + return { + _authProvider: { + type: String, + value: null, + }, + clientId: String, + redirectUri: String, + oauth2State: String, + }; + } + ready() { + super.ready(); + const query = {}; + const values = location.search.substr(1).split('&'); + for (let i = 0; i < values.length; i++) { + const value = values[i].split('='); + if (value.length > 1) { + query[decodeURIComponent(value[0])] = decodeURIComponent(value[1]); + } + } + const props = {}; + if (query.client_id) props.clientId = query.client_id; + if (query.redirect_uri) props.redirectUri = query.redirect_uri; + if (query.state) props.oauth2State = query.state; + this.setProperties(props); + } + _handleAuthProviderPick(ev) { + this._authProvider = ev.detail; + } + _handleReset() { + this._authProvider = null; + } +} +customElements.define('ha-authorize', HaAuthorize); diff --git a/src/entrypoints/authorize.js b/src/entrypoints/authorize.js index 9427983493..35706102eb 100644 --- a/src/entrypoints/authorize.js +++ b/src/entrypoints/authorize.js @@ -1,103 +1,11 @@ -import '@polymer/iron-flex-layout/iron-flex-layout-classes.js'; import '@polymer/polymer/lib/elements/dom-if.js'; import '@polymer/polymer/lib/elements/dom-repeat.js'; -import { html } from '@polymer/polymer/lib/utils/html-tag.js'; -import { PolymerElement } from '@polymer/polymer/polymer-element.js'; import '../components/ha-iconset-svg.js'; import '../resources/ha-style.js'; import '../resources/roboto.js'; -import '../auth/ha-auth-flow.js'; -import '../auth/ha-pick-auth-provider.js'; +import '../auth/ha-authorize.js'; /* polyfill for paper-dropdown */ import(/* webpackChunkName: "polyfill-web-animations-next" */ 'web-animations-js/web-animations-next-lite.min.js'); - -class HaAuthorize extends PolymerElement { - static get template() { - return html` - - -
-
- - Home Assistant -
- -

Logging in to [[clientId]].

- - - -
-`; - } - - static get properties() { - return { - _authProvider: { - type: String, - value: null, - }, - clientId: String, - redirectUri: String, - oauth2State: String, - }; - } - ready() { - super.ready(); - const query = {}; - const values = location.search.substr(1).split('&'); - for (let i = 0; i < values.length; i++) { - const value = values[i].split('='); - if (value.length > 1) { - query[decodeURIComponent(value[0])] = decodeURIComponent(value[1]); - } - } - const props = {}; - if (query.client_id) props.clientId = query.client_id; - if (query.redirect_uri) props.redirectUri = query.redirect_uri; - if (query.state) props.oauth2State = query.state; - this.setProperties(props); - } - _handleAuthProviderPick(ev) { - this._authProvider = ev.detail; - } - _handleReset() { - this._authProvider = null; - } -} -customElements.define('ha-authorize', HaAuthorize);