From 8af4e6eb3f54f0e6ffc55915ea32499c4b02b5ee Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 28 May 2016 11:16:40 -0700 Subject: [PATCH] Migrate behavior to global object --- src/components/entity-list.js | 3 +-- src/components/events-list.js | 3 +-- src/components/ha-sidebar.js | 3 +-- src/components/ha-view-tabs.js | 3 +-- src/components/services-list.js | 3 +-- src/components/stream-status.js | 3 +-- src/dialogs/ha-voice-command-dialog.js | 3 +-- src/dialogs/more-info-dialog.js | 3 +-- src/home-assistant.js | 7 +++++-- src/layouts/home-assistant-main.js | 3 +-- src/layouts/login-form.js | 3 +-- src/layouts/partial-cards.js | 3 +-- src/layouts/partial-dev-info.js | 3 +-- src/layouts/partial-dev-template.js | 3 +-- src/layouts/partial-history.js | 3 +-- src/layouts/partial-logbook.js | 3 +-- src/layouts/partial-map.js | 3 +-- src/managers/notification-manager.js | 3 +-- src/more-infos/more-info-configurator.js | 3 +-- src/more-infos/more-info-group.js | 3 +-- src/util/bound-nuclear-behavior.js | 3 --- src/util/{nuclear-behavior.js => hass-behavior.js} | 2 ++ 22 files changed, 26 insertions(+), 43 deletions(-) delete mode 100644 src/util/bound-nuclear-behavior.js rename src/util/{nuclear-behavior.js => hass-behavior.js} (92%) diff --git a/src/components/entity-list.js b/src/components/entity-list.js index 66d5d3c977..72b6ccc43f 100644 --- a/src/components/entity-list.js +++ b/src/components/entity-list.js @@ -1,10 +1,9 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; export default new Polymer({ is: 'entity-list', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/components/events-list.js b/src/components/events-list.js index 0be6e4f76c..0b4579ce41 100644 --- a/src/components/events-list.js +++ b/src/components/events-list.js @@ -1,10 +1,9 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; export default new Polymer({ is: 'events-list', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/components/ha-sidebar.js b/src/components/ha-sidebar.js index f3d25d4f7f..5480baa13f 100644 --- a/src/components/ha-sidebar.js +++ b/src/components/ha-sidebar.js @@ -1,12 +1,11 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; require('./stream-status'); export default new Polymer({ is: 'ha-sidebar', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/components/ha-view-tabs.js b/src/components/ha-view-tabs.js index 2d16893a52..3b36af8632 100644 --- a/src/components/ha-view-tabs.js +++ b/src/components/ha-view-tabs.js @@ -1,10 +1,9 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; export default new Polymer({ is: 'ha-view-tabs', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/components/services-list.js b/src/components/services-list.js index e8b41cff31..2b6c303722 100644 --- a/src/components/services-list.js +++ b/src/components/services-list.js @@ -1,12 +1,11 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; require('./domain-icon'); export default new Polymer({ is: 'services-list', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/components/stream-status.js b/src/components/stream-status.js index 4773ef5459..03ef56a8a6 100644 --- a/src/components/stream-status.js +++ b/src/components/stream-status.js @@ -1,10 +1,9 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; export default new Polymer({ is: 'stream-status', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/dialogs/ha-voice-command-dialog.js b/src/dialogs/ha-voice-command-dialog.js index 58a8ec65ad..5b6fa73ba0 100644 --- a/src/dialogs/ha-voice-command-dialog.js +++ b/src/dialogs/ha-voice-command-dialog.js @@ -1,10 +1,9 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; export default new Polymer({ is: 'ha-voice-command-dialog', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/dialogs/more-info-dialog.js b/src/dialogs/more-info-dialog.js index c6eb37a81c..9a7917752d 100644 --- a/src/dialogs/more-info-dialog.js +++ b/src/dialogs/more-info-dialog.js @@ -1,5 +1,4 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; require('../state-summary/state-card-content'); require('../components/state-history-charts'); @@ -10,7 +9,7 @@ const DOMAINS_WITH_NO_HISTORY = ['camera', 'configurator', 'scene']; export default new Polymer({ is: 'more-info-dialog', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { stateObj: { diff --git a/src/home-assistant.js b/src/home-assistant.js index a6e5eac3cc..89804c1251 100644 --- a/src/home-assistant.js +++ b/src/home-assistant.js @@ -2,13 +2,16 @@ import moment from 'moment'; import Polymer from './polymer'; import HomeAssistant from 'home-assistant-js'; -import nuclearObserver from './util/bound-nuclear-behavior'; import validateAuth from './util/validate-auth'; +import hassBehavior from './util/hass-behavior'; + +window.hassBehavior = hassBehavior; window.moment = moment; require('./layouts/login-form'); require('./layouts/home-assistant-main'); +// While we figure out how ha-entity-marker can keep it's references window.hass = new HomeAssistant(); export default new Polymer({ @@ -19,7 +22,7 @@ export default new Polymer({ icons: null, }, - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/layouts/home-assistant-main.js b/src/layouts/home-assistant-main.js index cb6f2a6843..8d9a87057c 100644 --- a/src/layouts/home-assistant-main.js +++ b/src/layouts/home-assistant-main.js @@ -1,6 +1,5 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; import removeInitMsg from '../util/remove-init-message'; require('../components/ha-sidebar'); @@ -27,7 +26,7 @@ require('../dialogs/ha-voice-command-dialog'); export default new Polymer({ is: 'home-assistant-main', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/layouts/login-form.js b/src/layouts/login-form.js index 1fee55dd26..f81d053588 100644 --- a/src/layouts/login-form.js +++ b/src/layouts/login-form.js @@ -1,13 +1,12 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; import validateAuth from '../util/validate-auth'; import removeInitMsg from '../util/remove-init-message'; export default new Polymer({ is: 'login-form', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/layouts/partial-cards.js b/src/layouts/partial-cards.js index 92db45a39a..b587c6282f 100644 --- a/src/layouts/partial-cards.js +++ b/src/layouts/partial-cards.js @@ -1,5 +1,4 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; require('./partial-base'); require('../components/ha-cards'); @@ -8,7 +7,7 @@ require('../components/ha-view-tabs'); export default new Polymer({ is: 'partial-cards', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/layouts/partial-dev-info.js b/src/layouts/partial-dev-info.js index 893b54dc46..68f873da69 100644 --- a/src/layouts/partial-dev-info.js +++ b/src/layouts/partial-dev-info.js @@ -1,12 +1,11 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; require('./partial-base'); export default new Polymer({ is: 'partial-dev-info', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/layouts/partial-dev-template.js b/src/layouts/partial-dev-template.js index 55e88c6085..5a0e905a54 100644 --- a/src/layouts/partial-dev-template.js +++ b/src/layouts/partial-dev-template.js @@ -1,12 +1,11 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; require('./partial-base'); export default new Polymer({ is: 'partial-dev-template', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/layouts/partial-history.js b/src/layouts/partial-history.js index e570cdaa72..e4bd0b1e15 100644 --- a/src/layouts/partial-history.js +++ b/src/layouts/partial-history.js @@ -1,5 +1,4 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; require('./partial-base'); require('../components/state-history-charts'); @@ -7,7 +6,7 @@ require('../components/state-history-charts'); export default new Polymer({ is: 'partial-history', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/layouts/partial-logbook.js b/src/layouts/partial-logbook.js index 138185a259..1b500668fc 100644 --- a/src/layouts/partial-logbook.js +++ b/src/layouts/partial-logbook.js @@ -1,5 +1,4 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; require('./partial-base'); require('../components/ha-logbook'); @@ -8,7 +7,7 @@ require('../components/loading-box'); export default new Polymer({ is: 'partial-logbook', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/layouts/partial-map.js b/src/layouts/partial-map.js index c0302cc1cb..b5768c9d3a 100644 --- a/src/layouts/partial-map.js +++ b/src/layouts/partial-map.js @@ -1,5 +1,4 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; require('../components/entity/ha-entity-marker'); @@ -8,7 +7,7 @@ window.L.Icon.Default.imagePath = '/static/images/leaflet'; export default new Polymer({ is: 'partial-map', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/managers/notification-manager.js b/src/managers/notification-manager.js index 6052776dd9..eeaa0cb266 100644 --- a/src/managers/notification-manager.js +++ b/src/managers/notification-manager.js @@ -1,10 +1,9 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; export default new Polymer({ is: 'notification-manager', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/more-infos/more-info-configurator.js b/src/more-infos/more-info-configurator.js index e95b91d220..224fd915ae 100644 --- a/src/more-infos/more-info-configurator.js +++ b/src/more-infos/more-info-configurator.js @@ -1,12 +1,11 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; require('../components/loading-box'); export default new Polymer({ is: 'more-info-configurator', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { stateObj: { diff --git a/src/more-infos/more-info-group.js b/src/more-infos/more-info-group.js index 1490007dff..1cc37e0b7e 100644 --- a/src/more-infos/more-info-group.js +++ b/src/more-infos/more-info-group.js @@ -1,5 +1,4 @@ import Polymer from '../polymer'; -import nuclearObserver from '../util/bound-nuclear-behavior'; import dynamicContentUpdater from '../util/dynamic-content-updater'; import stateMoreInfoType from '../util/state-more-info-type'; @@ -8,7 +7,7 @@ require('../state-summary/state-card-content'); export default new Polymer({ is: 'more-info-group', - behaviors: [nuclearObserver], + behaviors: [window.hassBehavior], properties: { hass: { diff --git a/src/util/bound-nuclear-behavior.js b/src/util/bound-nuclear-behavior.js deleted file mode 100644 index 4943e28732..0000000000 --- a/src/util/bound-nuclear-behavior.js +++ /dev/null @@ -1,3 +0,0 @@ -import nuclearObserver from './nuclear-behavior'; - -export default nuclearObserver; diff --git a/src/util/nuclear-behavior.js b/src/util/hass-behavior.js similarity index 92% rename from src/util/nuclear-behavior.js rename to src/util/hass-behavior.js index b85c662bca..e8d340ecad 100644 --- a/src/util/nuclear-behavior.js +++ b/src/util/hass-behavior.js @@ -16,7 +16,9 @@ export default { 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); }