From 60eb731f271f4b760ef26c24ea0c0af902185bcb Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 28 May 2016 16:03:51 -0700 Subject: [PATCH] Break up app in core + ui and inline some scripts --- .eslintrc | 11 +- src/app-core.js | 23 +++ src/cards/ha-card-chooser.js | 1 - src/cards/ha-entities-card.js | 1 - src/cards/ha-introduction-card.html | 21 ++- src/cards/ha-introduction-card.js | 18 --- src/components/entity-list.html | 31 +++++ src/components/entity-list.js | 26 ---- src/components/entity/ha-entity-marker.js | 2 - src/components/entity/ha-state-label-badge.js | 2 - src/components/events-list.html | 31 +++++ src/components/events-list.js | 26 ---- src/components/ha-card.html | 20 +++ src/components/ha-card.js | 19 --- src/components/ha-cards.js | 4 +- src/components/ha-color-picker.html | 131 ++++++++++++++++++ src/components/ha-color-picker.js | 130 ----------------- src/components/ha-demo-badge.html | 6 + src/components/ha-demo-badge.js | 7 - src/components/ha-label-badge.html | 51 +++++++ src/components/ha-label-badge.js | 50 ------- src/components/ha-logbook.html | 23 ++- src/components/ha-logbook.js | 18 --- src/components/ha-sidebar.html | 83 +++++++++++ src/components/ha-sidebar.js | 80 ----------- src/components/ha-view-tabs.html | 55 ++++++++ src/components/ha-view-tabs.js | 49 ------- src/components/loading-box.html | 6 + src/components/loading-box.js | 5 - src/components/logbook-entry.js | 1 - src/components/relative-ha-datetime.html | 57 ++++++++ src/components/relative-ha-datetime.js | 57 -------- src/components/state-history-charts.js | 1 - src/components/state-info.js | 1 - src/components/stream-status.html | 32 +++++ src/components/stream-status.js | 31 ----- src/home-assistant.html | 94 ++++++++++++- src/home-assistant.js | 98 ------------- src/layouts/home-assistant-main.js | 15 +- src/layouts/login-form.html | 92 ++++++++++++ src/layouts/login-form.js | 93 ------------- src/layouts/partial-cards.js | 1 - src/layouts/partial-dev-call-service.html | 2 +- src/layouts/partial-dev-fire-event.html | 2 +- src/layouts/partial-dev-fire-event.js | 1 - src/layouts/partial-dev-set-state.html | 2 +- src/layouts/partial-dev-set-state.js | 1 - src/layouts/partial-logbook.html | 2 +- src/layouts/partial-logbook.js | 3 +- src/more-infos/more-info-camera.html | 33 ++++- src/more-infos/more-info-camera.js | 26 ---- src/more-infos/more-info-configurator.js | 2 - src/more-infos/more-info-content.js | 1 - src/more-infos/more-info-light.js | 2 - src/util/hass-behavior.html | 36 +++++ src/util/hass-behavior.js | 44 ------ src/util/remove-init-message.js | 7 - src/util/validate-auth.js | 6 - webpack.config.js | 1 + 59 files changed, 839 insertions(+), 835 deletions(-) create mode 100644 src/app-core.js delete mode 100644 src/cards/ha-introduction-card.js delete mode 100644 src/components/entity-list.js delete mode 100644 src/components/events-list.js delete mode 100644 src/components/ha-card.js delete mode 100644 src/components/ha-color-picker.js delete mode 100644 src/components/ha-demo-badge.js delete mode 100644 src/components/ha-label-badge.js delete mode 100644 src/components/ha-logbook.js delete mode 100644 src/components/ha-sidebar.js delete mode 100644 src/components/ha-view-tabs.js delete mode 100644 src/components/loading-box.js delete mode 100644 src/components/relative-ha-datetime.js delete mode 100644 src/components/stream-status.js delete mode 100644 src/layouts/login-form.js delete mode 100644 src/more-infos/more-info-camera.js create mode 100644 src/util/hass-behavior.html delete mode 100644 src/util/hass-behavior.js delete mode 100644 src/util/remove-init-message.js delete mode 100644 src/util/validate-auth.js diff --git a/.eslintrc b/.eslintrc index 6ad290e9a3..6f8231d069 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,6 +2,15 @@ "extends": "airbnb-base", "globals": { "__DEV__": false, - "__DEMO__": false + "Polymer": true + }, + "rules": { + "new-cap": 0, + "prefer-template": 0, + "object-shorthand": 0, + "func-names": 0, + "prefer-arrow-callback": 0, + "no-underscore-dangle": 0, + "no-var": 0 } } diff --git a/src/app-core.js b/src/app-core.js new file mode 100644 index 0000000000..a4fbd6c17f --- /dev/null +++ b/src/app-core.js @@ -0,0 +1,23 @@ +import moment from 'moment'; + +import HomeAssistant from 'home-assistant-js'; + +window.moment = moment; + +// While we figure out how ha-entity-marker can keep it's references +window.hass = new HomeAssistant(); + +window.validateAuth = function validateAuth(hass, authToken, rememberAuth) { + hass.authActions.validate(authToken, { + rememberAuth, + useStreaming: hass.localStoragePreferences.useStreaming, + }); +}; + +window.removeInitMsg = function removeInitMessage() { + // remove the HTML init message + const initMsg = document.getElementById('ha-init-skeleton'); + if (initMsg) { + initMsg.parentElement.removeChild(initMsg); + } +}; diff --git a/src/cards/ha-card-chooser.js b/src/cards/ha-card-chooser.js index bcbb06b0d1..a9de619d92 100644 --- a/src/cards/ha-card-chooser.js +++ b/src/cards/ha-card-chooser.js @@ -4,7 +4,6 @@ import dynamicContentUpdater from '../util/dynamic-content-updater'; require('./ha-camera-card'); require('./ha-entities-card'); -require('./ha-introduction-card'); require('./ha-media_player-card'); export default new Polymer({ diff --git a/src/cards/ha-entities-card.js b/src/cards/ha-entities-card.js index bced27b17e..9d99a3702f 100644 --- a/src/cards/ha-entities-card.js +++ b/src/cards/ha-entities-card.js @@ -1,7 +1,6 @@ import Polymer from '../polymer'; import canToggle from '../util/can-toggle'; -require('../components/ha-card'); require('../components/entity/ha-entity-toggle'); require('../state-summary/state-card-content'); diff --git a/src/cards/ha-introduction-card.html b/src/cards/ha-introduction-card.html index b8d1d7f0ae..64780d21fb 100644 --- a/src/cards/ha-introduction-card.html +++ b/src/cards/ha-introduction-card.html @@ -30,7 +30,7 @@ + + \ No newline at end of file diff --git a/src/components/ha-card.js b/src/components/ha-card.js deleted file mode 100644 index 27600ea03b..0000000000 --- a/src/components/ha-card.js +++ /dev/null @@ -1,19 +0,0 @@ -import Polymer from '../polymer'; - -export default new Polymer({ - is: 'ha-card', - - properties: { - header: { - type: String, - }, - /** - * The z-depth of the card, from 0-5. - */ - elevation: { - type: Number, - value: 1, - reflectToAttribute: true, - }, - }, -}); diff --git a/src/components/ha-cards.js b/src/components/ha-cards.js index 61f40c857b..52d4488176 100644 --- a/src/components/ha-cards.js +++ b/src/components/ha-cards.js @@ -1,6 +1,5 @@ import Polymer from '../polymer'; -require('.//ha-demo-badge'); require('../cards/ha-badges-card'); require('../cards/ha-card-chooser'); @@ -109,8 +108,9 @@ export default new Polymer({ } if (showIntroduction) { cards.columns[getIndex(5)].push({ + hass, cardType: 'introduction', - showHideInstruction: states.size > 0 && !__DEMO__, + showHideInstruction: states.size > 0 && !hass.demo, }); } diff --git a/src/components/ha-color-picker.html b/src/components/ha-color-picker.html index 1bc8574d45..7eb6747be0 100644 --- a/src/components/ha-color-picker.html +++ b/src/components/ha-color-picker.html @@ -10,3 +10,134 @@ + + diff --git a/src/components/ha-color-picker.js b/src/components/ha-color-picker.js deleted file mode 100644 index 63eb3c7369..0000000000 --- a/src/components/ha-color-picker.js +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Color-picker custom element - * Originally created by bbrewer97202 (Ben Brewer). MIT Licensed. - * https://github.com/bbrewer97202/color-picker-element - * - * Adapted to work with Polymer. - */ -import Polymer from '../polymer'; - -export default new Polymer({ - is: 'ha-color-picker', - - properties: { - color: { - type: Object, - }, - - width: { - type: Number, - }, - - height: { - type: Number, - }, - }, - - listeners: { - mousedown: 'onMouseDown', - mouseup: 'onMouseUp', - touchstart: 'onTouchStart', - touchend: 'onTouchEnd', - }, - - onMouseDown(ev) { - this.onMouseMove(ev); - this.addEventListener('mousemove', this.onMouseMove); - }, - - onMouseUp() { - this.removeEventListener('mousemove', this.onMouseMove); - }, - - onTouchStart(ev) { - this.onTouchMove(ev); - this.addEventListener('touchmove', this.onTouchMove); - }, - - onTouchEnd() { - this.removeEventListener('touchmove', this.onTouchMove); - }, - - onTouchMove(ev) { - if (!this.mouseMoveIsThrottled) { - return; - } - this.mouseMoveIsThrottled = false; - this.processColorSelect(ev.touches[0]); - this.async(() => { this.mouseMoveIsThrottled = true; }, 100); - }, - - onMouseMove(ev) { - if (!this.mouseMoveIsThrottled) { - return; - } - this.mouseMoveIsThrottled = false; - this.processColorSelect(ev); - this.async(() => { this.mouseMoveIsThrottled = true; }, 100); - }, - - processColorSelect(ev) { - const rect = this.canvas.getBoundingClientRect(); - - // boundary check because people can move off-canvas. - if (ev.clientX < rect.left || ev.clientX >= rect.left + rect.width || - ev.clientY < rect.top || ev.clientY >= rect.top + rect.height) { - return; - } - - this.onColorSelect(ev.clientX - rect.left, ev.clientY - rect.top); - }, - - onColorSelect(x, y) { - const data = this.context.getImageData(x, y, 1, 1).data; - - this.setColor({ r: data[0], g: data[1], b: data[2] }); - }, - - setColor(rgb) { - this.color = rgb; - - this.fire('colorselected', { rgb: this.color }); - }, - - ready() { - this.setColor = this.setColor.bind(this); - this.mouseMoveIsThrottled = true; - this.canvas = this.children[0]; - this.context = this.canvas.getContext('2d'); - this.drawGradient(); - }, - - drawGradient() { - let style; - if (!this.width || !this.height) { - style = getComputedStyle(this); - } - const width = this.width || parseInt(style.width, 10); - const height = this.height || parseInt(style.height, 10); - - const colorGradient = this.context.createLinearGradient(0, 0, width, 0); - colorGradient.addColorStop(0, 'rgb(255,0,0)'); - colorGradient.addColorStop(0.16, 'rgb(255,0,255)'); - colorGradient.addColorStop(0.32, 'rgb(0,0,255)'); - colorGradient.addColorStop(0.48, 'rgb(0,255,255)'); - colorGradient.addColorStop(0.64, 'rgb(0,255,0)'); - colorGradient.addColorStop(0.80, 'rgb(255,255,0)'); - colorGradient.addColorStop(1, 'rgb(255,0,0)'); - this.context.fillStyle = colorGradient; - this.context.fillRect(0, 0, width, height); - - const bwGradient = this.context.createLinearGradient(0, 0, 0, height); - bwGradient.addColorStop(0, 'rgba(255,255,255,1)'); - bwGradient.addColorStop(0.5, 'rgba(255,255,255,0)'); - bwGradient.addColorStop(0.5, 'rgba(0,0,0,0)'); - bwGradient.addColorStop(1, 'rgba(0,0,0,1)'); - - this.context.fillStyle = bwGradient; - this.context.fillRect(0, 0, width, height); - }, -}); diff --git a/src/components/ha-demo-badge.html b/src/components/ha-demo-badge.html index 810bb47acd..5f84c73385 100644 --- a/src/components/ha-demo-badge.html +++ b/src/components/ha-demo-badge.html @@ -16,3 +16,9 @@ > + + diff --git a/src/components/ha-demo-badge.js b/src/components/ha-demo-badge.js deleted file mode 100644 index 6732f80e39..0000000000 --- a/src/components/ha-demo-badge.js +++ /dev/null @@ -1,7 +0,0 @@ -import Polymer from '../polymer'; - -require('./ha-label-badge'); - -export default new Polymer({ - is: 'ha-demo-badge', -}); diff --git a/src/components/ha-label-badge.html b/src/components/ha-label-badge.html index c20d827af6..52a2f569c7 100644 --- a/src/components/ha-label-badge.html +++ b/src/components/ha-label-badge.html @@ -83,3 +83,54 @@ + + \ No newline at end of file diff --git a/src/components/ha-label-badge.js b/src/components/ha-label-badge.js deleted file mode 100644 index ead99ea720..0000000000 --- a/src/components/ha-label-badge.js +++ /dev/null @@ -1,50 +0,0 @@ -import Polymer from '../polymer'; - -// Beware: Polymer will not call computeHideIcon and computeHideValue if any of -// the parameters are undefined. Set to null if not using. -export default new Polymer({ - is: 'ha-label-badge', - - properties: { - value: { - type: String, - value: null, - }, - - icon: { - type: String, - value: null, - }, - - label: { - type: String, - value: null, - }, - - description: { - type: String, - }, - - image: { - type: String, - value: null, - observer: 'imageChanged', - }, - }, - - computeClasses(value) { - return value && value.length > 4 ? 'value big' : 'value'; - }, - - computeHideIcon(icon, value, image) { - return !icon || value || image; - }, - - computeHideValue(value, image) { - return !value || image; - }, - - imageChanged(newVal) { - this.$.badge.style.backgroundImage = newVal ? `url(${newVal})` : ''; - }, -}); diff --git a/src/components/ha-logbook.html b/src/components/ha-logbook.html index c5b7da5e26..4408fe155f 100644 --- a/src/components/ha-logbook.html +++ b/src/components/ha-logbook.html @@ -14,7 +14,28 @@ No logbook entries found. + + diff --git a/src/components/ha-logbook.js b/src/components/ha-logbook.js deleted file mode 100644 index c72dc609ab..0000000000 --- a/src/components/ha-logbook.js +++ /dev/null @@ -1,18 +0,0 @@ -import Polymer from '../polymer'; - -require('./logbook-entry'); - -export default new Polymer({ - is: 'ha-logbook', - - properties: { - entries: { - type: Object, - value: [], - }, - }, - - noEntries(entries) { - return !entries.length; - }, -}); diff --git a/src/components/ha-sidebar.html b/src/components/ha-sidebar.html index 281d521e75..a6c61a2874 100644 --- a/src/components/ha-sidebar.html +++ b/src/components/ha-sidebar.html @@ -169,3 +169,86 @@ + + diff --git a/src/components/ha-sidebar.js b/src/components/ha-sidebar.js deleted file mode 100644 index 5480baa13f..0000000000 --- a/src/components/ha-sidebar.js +++ /dev/null @@ -1,80 +0,0 @@ -import Polymer from '../polymer'; - -require('./stream-status'); - -export default new Polymer({ - is: 'ha-sidebar', - - behaviors: [window.hassBehavior], - - properties: { - hass: { - type: Object, - }, - - menuShown: { - type: Boolean, - }, - - menuSelected: { - type: String, - }, - - narrow: { - type: Boolean, - }, - - selected: { - type: String, - bindNuclear: hass => hass.navigationGetters.activePane, - }, - - hasHistoryComponent: { - type: Boolean, - bindNuclear: hass => hass.configGetters.isComponentLoaded('history'), - }, - - hasLogbookComponent: { - type: Boolean, - bindNuclear: hass => hass.configGetters.isComponentLoaded('logbook'), - }, - }, - - menuSelect() { - this.debounce('updateStyles', () => this.updateStyles(), 1); - }, - - menuClicked(ev) { - let target = ev.target; - let checks = 5; - - // find panel to select - while (checks && !target.getAttribute('data-panel')) { - target = target.parentElement; - checks--; - } - - if (checks) { - this.selectPanel(target.getAttribute('data-panel')); - } - }, - - toggleMenu() { - this.fire('close-menu'); - }, - - selectPanel(newChoice) { - if (newChoice === this.selected) { - return; - } else if (newChoice === 'logout') { - this.handleLogOut(); - return; - } - this.hass.navigationActions.navigate.apply(null, newChoice.split('/')); - this.debounce('updateStyles', () => this.updateStyles(), 1); - }, - - handleLogOut() { - this.hass.authActions.logOut(); - }, -}); diff --git a/src/components/ha-view-tabs.html b/src/components/ha-view-tabs.html index f61e4f2f80..ba7cd2391e 100644 --- a/src/components/ha-view-tabs.html +++ b/src/components/ha-view-tabs.html @@ -23,3 +23,58 @@ + + diff --git a/src/components/ha-view-tabs.js b/src/components/ha-view-tabs.js deleted file mode 100644 index 3b36af8632..0000000000 --- a/src/components/ha-view-tabs.js +++ /dev/null @@ -1,49 +0,0 @@ -import Polymer from '../polymer'; - -export default new Polymer({ - is: 'ha-view-tabs', - - behaviors: [window.hassBehavior], - - properties: { - hass: { - type: Object, - }, - - locationName: { - type: String, - bindNuclear: hass => hass.configGetters.locationName, - }, - - currentView: { - type: String, - bindNuclear: hass => [ - hass.viewGetters.currentView, - view => view || '', - ], - }, - - views: { - type: Array, - bindNuclear: hass => [ - hass.viewGetters.views, - views => views.valueSeq() - .sortBy(view => view.attributes.order) - .toArray(), - ], - }, - }, - - viewTapped() { - this.fire('view-tapped'); - }, - - viewSelected(ev) { - const view = ev.detail.item.getAttribute('data-entity') || null; - const current = this.currentView || null; - this.expectChange = true; - if (view !== current) { - this.async(() => this.hass.viewActions.selectView(view), 0); - } - }, -}); diff --git a/src/components/loading-box.html b/src/components/loading-box.html index 2084f3a285..245b3800d6 100644 --- a/src/components/loading-box.html +++ b/src/components/loading-box.html @@ -18,3 +18,9 @@ + + diff --git a/src/components/loading-box.js b/src/components/loading-box.js deleted file mode 100644 index 06087b4929..0000000000 --- a/src/components/loading-box.js +++ /dev/null @@ -1,5 +0,0 @@ -import Polymer from '../polymer'; - -export default new Polymer({ - is: 'loading-box', -}); diff --git a/src/components/logbook-entry.js b/src/components/logbook-entry.js index c1bd5c21b6..afbfa20674 100644 --- a/src/components/logbook-entry.js +++ b/src/components/logbook-entry.js @@ -2,7 +2,6 @@ import Polymer from '../polymer'; require('./domain-icon'); require('./display-time'); -require('./relative-ha-datetime'); export default new Polymer({ is: 'logbook-entry', diff --git a/src/components/relative-ha-datetime.html b/src/components/relative-ha-datetime.html index 25317437f1..9377a01b99 100644 --- a/src/components/relative-ha-datetime.html +++ b/src/components/relative-ha-datetime.html @@ -5,3 +5,60 @@ [[relativeTime]] + + diff --git a/src/components/relative-ha-datetime.js b/src/components/relative-ha-datetime.js deleted file mode 100644 index ff40b96a70..0000000000 --- a/src/components/relative-ha-datetime.js +++ /dev/null @@ -1,57 +0,0 @@ -import Polymer from '../polymer'; - -const UPDATE_INTERVAL = 60000; // 60 seconds - -export default new Polymer({ - is: 'relative-ha-datetime', - - properties: { - datetime: { - type: String, - observer: 'datetimeChanged', - }, - - datetimeObj: { - type: Object, - observer: 'datetimeObjChanged', - }, - - parsedDateTime: { - type: Object, - }, - - relativeTime: { - type: String, - value: 'not set', - }, - }, - - created() { - this.updateRelative = this.updateRelative.bind(this); - }, - - attached() { - this.updateInterval = setInterval(this.updateRelative, UPDATE_INTERVAL); - }, - - detached() { - clearInterval(this.updateInterval); - }, - - datetimeChanged(newVal) { - this.parsedDateTime = newVal ? new Date(newVal) : null; - - this.updateRelative(); - }, - - datetimeObjChanged(newVal) { - this.parsedDateTime = newVal; - - this.updateRelative(); - }, - - updateRelative() { - this.relativeTime = this.parsedDateTime ? - window.moment(this.parsedDateTime).fromNow() : ''; - }, -}); diff --git a/src/components/state-history-charts.js b/src/components/state-history-charts.js index 1ae24f803c..6ab7996797 100644 --- a/src/components/state-history-charts.js +++ b/src/components/state-history-charts.js @@ -1,6 +1,5 @@ import Polymer from '../polymer'; -require('./loading-box'); require('./state-history-chart-timeline'); require('./state-history-chart-line'); diff --git a/src/components/state-info.js b/src/components/state-info.js index 9370f0a80f..3da8bd3338 100644 --- a/src/components/state-info.js +++ b/src/components/state-info.js @@ -1,7 +1,6 @@ import Polymer from '../polymer'; require('./entity/state-badge'); -require('./relative-ha-datetime'); export default new Polymer({ is: 'state-info', diff --git a/src/components/stream-status.html b/src/components/stream-status.html index 31b210f4a3..cf10d2dd4b 100644 --- a/src/components/stream-status.html +++ b/src/components/stream-status.html @@ -25,3 +25,35 @@ + + diff --git a/src/components/stream-status.js b/src/components/stream-status.js deleted file mode 100644 index 03ef56a8a6..0000000000 --- a/src/components/stream-status.js +++ /dev/null @@ -1,31 +0,0 @@ -import Polymer from '../polymer'; - -export default new Polymer({ - is: 'stream-status', - - behaviors: [window.hassBehavior], - - properties: { - hass: { - type: Object, - }, - - isStreaming: { - type: Boolean, - bindNuclear: hass => hass.streamGetters.isStreamingEvents, - }, - - hasError: { - type: Boolean, - bindNuclear: hass => hass.streamGetters.hasStreamingEventsError, - }, - }, - - toggleChanged() { - if (this.isStreaming) { - this.hass.streamActions.stop(); - } else { - this.hass.streamActions.start(); - } - }, -}); diff --git a/src/home-assistant.html b/src/home-assistant.html index 423aaa5941..ca567c2061 100644 --- a/src/home-assistant.html +++ b/src/home-assistant.html @@ -1,14 +1,17 @@ + + + + - - + + + \ No newline at end of file diff --git a/src/more-infos/more-info-camera.js b/src/more-infos/more-info-camera.js deleted file mode 100644 index 965d04003a..0000000000 --- a/src/more-infos/more-info-camera.js +++ /dev/null @@ -1,26 +0,0 @@ -import Polymer from '../polymer'; - -export default new Polymer({ - is: 'more-info-camera', - - properties: { - stateObj: { - type: Object, - }, - }, - - imageLoaded() { - this.fire('iron-resize'); - }, - - computeCameraImageUrl(stateObj) { - if (__DEMO__) { - return '/demo/webcam.jpg'; - } else if (stateObj) { - return `/api/camera_proxy_stream/${stateObj.entityId}` + - `?token=${stateObj.attributes.access_token}`; - } - // Return an empty image if no stateObj (= dialog not open) - return 'data:image/gif;base64,R0lGODlhAQABAAAAACw='; - }, -}); diff --git a/src/more-infos/more-info-configurator.js b/src/more-infos/more-info-configurator.js index 224fd915ae..2319d8f279 100644 --- a/src/more-infos/more-info-configurator.js +++ b/src/more-infos/more-info-configurator.js @@ -1,7 +1,5 @@ import Polymer from '../polymer'; -require('../components/loading-box'); - export default new Polymer({ is: 'more-info-configurator', diff --git a/src/more-infos/more-info-content.js b/src/more-infos/more-info-content.js index 3c4436d0ab..7816f8b9c9 100644 --- a/src/more-infos/more-info-content.js +++ b/src/more-infos/more-info-content.js @@ -11,7 +11,6 @@ require('./more-info-thermostat'); require('./more-info-script'); require('./more-info-light'); require('./more-info-media_player'); -require('./more-info-camera'); require('./more-info-updater'); require('./more-info-alarm_control_panel'); require('./more-info-lock'); diff --git a/src/more-infos/more-info-light.js b/src/more-infos/more-info-light.js index 1f12929e93..0178630301 100644 --- a/src/more-infos/more-info-light.js +++ b/src/more-infos/more-info-light.js @@ -1,8 +1,6 @@ import Polymer from '../polymer'; import attributeClassNames from '../util/attribute-class-names'; -require('../components/ha-color-picker'); - const ATTRIBUTE_CLASSES = ['brightness', 'rgb_color', 'color_temp']; function pickColor(hass, entityId, color) { diff --git a/src/util/hass-behavior.html b/src/util/hass-behavior.html new file mode 100644 index 0000000000..86f09ee48d --- /dev/null +++ b/src/util/hass-behavior.html @@ -0,0 +1,36 @@ + diff --git a/src/util/hass-behavior.js b/src/util/hass-behavior.js deleted file mode 100644 index e8d340ecad..0000000000 --- a/src/util/hass-behavior.js +++ /dev/null @@ -1,44 +0,0 @@ -export default { - - attached() { - const hass = this.hass; - - if (!hass) { - throw new Error(`No hass property found on ${this.nodeName}`); - } - - this.nuclearUnwatchFns = Object.keys(this.properties).reduce( - (unwatchFns, key) => { - if (!('bindNuclear' in this.properties[key])) { - return unwatchFns; - } - - let getter = this.properties[key].bindNuclear; - - if (typeof getter !== 'function') { - /* eslint-disable no-console */ - console.warn(`Component ${this.nodeName} uses old style bindNuclear`); - /* eslint-enable no-console */ - } else { - getter = getter(hass); - } - - if (!getter) { - throw new Error(`Undefined getter specified for key ${key}`); - } - - this[key] = hass.reactor.evaluate(getter); - - return unwatchFns.concat(hass.reactor.observe(getter, (val) => { - this[key] = val; - })); - }, []); - }, - - detached() { - while (this.nuclearUnwatchFns.length) { - this.nuclearUnwatchFns.shift()(); - } - }, - -}; diff --git a/src/util/remove-init-message.js b/src/util/remove-init-message.js deleted file mode 100644 index 2c80816fb4..0000000000 --- a/src/util/remove-init-message.js +++ /dev/null @@ -1,7 +0,0 @@ -export default function removeInitMessage() { - // remove the HTML init message - const initMsg = document.getElementById('ha-init-skeleton'); - if (initMsg) { - initMsg.parentElement.removeChild(initMsg); - } -} diff --git a/src/util/validate-auth.js b/src/util/validate-auth.js deleted file mode 100644 index 9e3dc27961..0000000000 --- a/src/util/validate-auth.js +++ /dev/null @@ -1,6 +0,0 @@ -export default function (hass, authToken, rememberAuth) { - hass.authActions.validate(authToken, { - rememberAuth, - useStreaming: hass.localStoragePreferences.useStreaming, - }); -} diff --git a/webpack.config.js b/webpack.config.js index e4fa335dc8..0cdee2a711 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,6 +9,7 @@ var definePlugin = new webpack.DefinePlugin({ module.exports = { entry: { _app_compiled: './src/home-assistant.js', + _app_core_compiled: './src/app-core.js', }, output: { path: 'build',