diff --git a/src/cards/ha-history_graph-card.html b/src/cards/ha-history_graph-card.html index 8a3cd11e2..98f364293 100644 --- a/src/cards/ha-history_graph-card.html +++ b/src/cards/ha-history_graph-card.html @@ -22,8 +22,7 @@ @apply --paper-font-common-nowrap; } paper-card[dialog] .header { - padding-top: 0; - padding-left: 0; + display: none; } requestAnimationFrame(() => this.onPropsChange())); } this._resizeListener = () => { this._debouncer = Polymer.Debouncer.debounce( diff --git a/src/dialogs/more-info-dialog.html b/src/dialogs/more-info-dialog.html index 8faaaa855..d61fc39c5 100644 --- a/src/dialogs/more-info-dialog.html +++ b/src/dialogs/more-info-dialog.html @@ -4,11 +4,12 @@ - - + + + - - - - - - - - - - + + + + + + - - - @@ -86,111 +85,72 @@ class MoreInfoDialog extends window.hassMixins.EventsMixin(Polymer.Element) { stateObj: { type: Object, - computed: 'computeStateObj(hass)', - observer: 'stateObjChanged', + computed: '_computeStateObj(hass)', + observer: '_stateObjChanged', }, - stateHistory: Object, - - stateHistoryLoading: Boolean, - - isLoadingHistoryData: { - type: Boolean, - computed: 'computeIsLoadingHistoryData(delayedDialogOpen, stateHistoryLoading)', - }, - - hasHistoryComponent: { - type: Boolean, - computed: 'computeHasHistoryComponent(hass)', - }, - - showHistoryComponent: { + _dialogOpen: { type: Boolean, value: false, - computed: 'computeShowHistoryComponent(hasHistoryComponent, stateObj)', + observer: '_dialogOpenChanged', }, - dialogOpen: { - type: Boolean, - value: false, - observer: 'dialogOpenChanged', - }, + _dialogElement: Object, + _registryInfo: Object, - delayedDialogOpen: { - type: Boolean, - value: false, - }, - - cacheConfig: { - type: Object, - value: { - refresh: 60, - cacheKey: null, - hoursToShow: 24, - }, + _page: { + type: String, + value: null, }, }; } - connectedCallback() { - super.connectedCallback(); - this.$.scrollable.dialogElement = this.$.dialog; + ready() { + super.ready(); + this._dialogElement = this.$.dialog; + this.addEventListener('more-info-page', (ev) => { this._page = ev.detail.page; }); } - computeDomain(stateObj) { + _computeDomain(stateObj) { return stateObj ? window.hassUtil.computeDomain(stateObj) : ''; } - computeStateObj(hass) { + _computeStateObj(hass) { return hass.states[hass.moreInfoEntityId] || null; } - /** - * We depend on a delayed dialogOpen value to tell the chart component - * that the data is there. Otherwise the chart component will render - * before the dialog is attached to the screen and is unable to determine - * graph size resulting in scroll bars. - */ - computeIsLoadingHistoryData(delayedDialogOpen, stateHistoryLoading) { - return !delayedDialogOpen || stateHistoryLoading; - } - - computeHasHistoryComponent(hass) { - return window.hassUtil.isComponentLoaded(hass, 'history'); - } - - computeShowHistoryComponent(hasHistoryComponent, stateObj) { - return this.hasHistoryComponent && stateObj && - window.hassUtil.DOMAINS_WITH_NO_HISTORY - .indexOf(window.hassUtil.computeDomain(stateObj)) === -1; - } - - stateObjChanged(newVal) { + _stateObjChanged(newVal, oldVal) { if (!newVal) { - this.dialogOpen = false; + this._dialogOpen = false; + this._page = null; + this._registryInfo = null; return; } - window.setTimeout(() => { - // allow dialog to render content before showing it so it is + if (window.hassUtil.isComponentLoaded(this.hass, 'config.entity_registry') && + (!oldVal || oldVal.entity_id !== newVal.entity_id)) { + this.hass.callApi('get', `config/entity_registry/${newVal.entity_id}`) + .then( + (info) => { this._registryInfo = info; }, + () => { this._registryInfo = false; } + ); + } + + requestAnimationFrame(() => requestAnimationFrame(() => { + // allow dialog to render content before showing it so it will be // positioned correctly. - this.dialogOpen = true; - }, 10); - if (this.cacheConfig.cacheKey !== `more_info.${newVal.entity_id}`) { - this.cacheConfig = Object.assign( - {}, this.cacheConfig, - { cacheKey: `more_info.${newVal.entity_id}` } - ); + this._dialogOpen = true; + })); + } + + _dialogOpenChanged(newVal) { + if (!newVal && this.stateObj) { + this.fire('hass-more-info', { entityId: null }); } } - dialogOpenChanged(newVal) { - if (newVal) { - window.setTimeout(() => { this.delayedDialogOpen = true; }, 100); - } else if (!newVal && this.stateObj) { - this.fire('hass-more-info', { entityId: null }); - this.delayedDialogOpen = false; - } + _equals(a, b) { + return a === b; } } customElements.define(MoreInfoDialog.is, MoreInfoDialog); diff --git a/src/more-infos/more-info-alarm_control_panel.html b/src/dialogs/more-info/controls/more-info-alarm_control_panel.html similarity index 89% rename from src/more-infos/more-info-alarm_control_panel.html rename to src/dialogs/more-info/controls/more-info-alarm_control_panel.html index f299f474c..38bf0443e 100644 --- a/src/more-infos/more-info-alarm_control_panel.html +++ b/src/dialogs/more-info/controls/more-info-alarm_control_panel.html @@ -1,11 +1,10 @@ - + + - + + - - - - + diff --git a/src/more-infos/more-info-automation.html b/src/dialogs/more-info/controls/more-info-automation.html similarity index 72% rename from src/more-infos/more-info-automation.html rename to src/dialogs/more-info/controls/more-info-automation.html index 79878831e..4018cd093 100644 --- a/src/more-infos/more-info-automation.html +++ b/src/dialogs/more-info/controls/more-info-automation.html @@ -1,10 +1,10 @@ - + - + - + - + diff --git a/src/more-infos/more-info-camera.html b/src/dialogs/more-info/controls/more-info-camera.html similarity index 91% rename from src/more-infos/more-info-camera.html rename to src/dialogs/more-info/controls/more-info-camera.html index aa6a2862d..bb6dc95e6 100644 --- a/src/more-infos/more-info-camera.html +++ b/src/dialogs/more-info/controls/more-info-camera.html @@ -1,6 +1,6 @@ - + - + diff --git a/src/more-infos/more-info-climate.html b/src/dialogs/more-info/controls/more-info-climate.html similarity index 94% rename from src/more-infos/more-info-climate.html rename to src/dialogs/more-info/controls/more-info-climate.html index 8563421bc..db611e8fe 100644 --- a/src/more-infos/more-info-climate.html +++ b/src/dialogs/more-info/controls/more-info-climate.html @@ -1,17 +1,17 @@ - - + + - + - - - - - + + + + + - + - + diff --git a/src/more-infos/more-info-configurator.html b/src/dialogs/more-info/controls/more-info-configurator.html similarity index 83% rename from src/more-infos/more-info-configurator.html rename to src/dialogs/more-info/controls/more-info-configurator.html index b4549d380..b14fef2aa 100644 --- a/src/more-infos/more-info-configurator.html +++ b/src/dialogs/more-info/controls/more-info-configurator.html @@ -1,11 +1,11 @@ - - - - - - + + + + + + - + diff --git a/src/more-infos/more-info-content.html b/src/dialogs/more-info/controls/more-info-content.html similarity index 95% rename from src/more-infos/more-info-content.html rename to src/dialogs/more-info/controls/more-info-content.html index 90a78ed80..f2e3b03c5 100644 --- a/src/more-infos/more-info-content.html +++ b/src/dialogs/more-info/controls/more-info-content.html @@ -1,4 +1,4 @@ - + diff --git a/src/more-infos/more-info-cover.html b/src/dialogs/more-info/controls/more-info-cover.html similarity index 86% rename from src/more-infos/more-info-cover.html rename to src/dialogs/more-info/controls/more-info-cover.html index 0539f7b25..27353dfd9 100644 --- a/src/more-infos/more-info-cover.html +++ b/src/dialogs/more-info/controls/more-info-cover.html @@ -1,10 +1,10 @@ - + - - - + + + - + diff --git a/src/more-infos/more-info-default.html b/src/dialogs/more-info/controls/more-info-default.html similarity index 73% rename from src/more-infos/more-info-default.html rename to src/dialogs/more-info/controls/more-info-default.html index 25abfd5cc..f469b7db2 100644 --- a/src/more-infos/more-info-default.html +++ b/src/dialogs/more-info/controls/more-info-default.html @@ -1,6 +1,6 @@ - + - + diff --git a/src/more-infos/more-info-fan.html b/src/dialogs/more-info/controls/more-info-fan.html similarity index 84% rename from src/more-infos/more-info-fan.html rename to src/dialogs/more-info/controls/more-info-fan.html index c8a0500d6..7b67c78ff 100644 --- a/src/more-infos/more-info-fan.html +++ b/src/dialogs/more-info/controls/more-info-fan.html @@ -1,15 +1,15 @@ - + - - - - - - + + + + + + - + - + diff --git a/src/more-infos/more-info-group.html b/src/dialogs/more-info/controls/more-info-group.html similarity index 94% rename from src/more-infos/more-info-group.html rename to src/dialogs/more-info/controls/more-info-group.html index 43dc9682c..a03feb780 100644 --- a/src/more-infos/more-info-group.html +++ b/src/dialogs/more-info/controls/more-info-group.html @@ -1,6 +1,6 @@ - + - + diff --git a/src/more-infos/more-info-history_graph.html b/src/dialogs/more-info/controls/more-info-history_graph.html similarity index 74% rename from src/more-infos/more-info-history_graph.html rename to src/dialogs/more-info/controls/more-info-history_graph.html index caed29b39..3b9abf086 100644 --- a/src/more-infos/more-info-history_graph.html +++ b/src/dialogs/more-info/controls/more-info-history_graph.html @@ -1,8 +1,8 @@ - + - + - + diff --git a/src/more-infos/more-info-input_datetime.html b/src/dialogs/more-info/controls/more-info-input_datetime.html similarity index 90% rename from src/more-infos/more-info-input_datetime.html rename to src/dialogs/more-info/controls/more-info-input_datetime.html index 4399c0240..fad93ad0b 100644 --- a/src/more-infos/more-info-input_datetime.html +++ b/src/dialogs/more-info/controls/more-info-input_datetime.html @@ -1,8 +1,8 @@ - - - - - + + + + + diff --git a/src/more-infos/more-info-light.html b/src/dialogs/more-info/controls/more-info-light.html similarity index 90% rename from src/more-infos/more-info-light.html rename to src/dialogs/more-info/controls/more-info-light.html index 9cbfb6dd1..2632d864a 100644 --- a/src/more-infos/more-info-light.html +++ b/src/dialogs/more-info/controls/more-info-light.html @@ -1,15 +1,15 @@ - + - - - - + + + + - + - - - + + + diff --git a/src/more-infos/more-info-lock.html b/src/dialogs/more-info/controls/more-info-lock.html similarity index 82% rename from src/more-infos/more-info-lock.html rename to src/dialogs/more-info/controls/more-info-lock.html index bf2d24bc8..7395dfab8 100644 --- a/src/more-infos/more-info-lock.html +++ b/src/dialogs/more-info/controls/more-info-lock.html @@ -1,8 +1,8 @@ - + - - - + + + diff --git a/src/more-infos/more-info-media_player.html b/src/dialogs/more-info/controls/more-info-media_player.html similarity index 93% rename from src/more-infos/more-info-media_player.html rename to src/dialogs/more-info/controls/more-info-media_player.html index 01a67d66a..ba93143f0 100644 --- a/src/more-infos/more-info-media_player.html +++ b/src/dialogs/more-info/controls/more-info-media_player.html @@ -1,16 +1,16 @@ - + - + - + - - - - - + + + + + - + diff --git a/src/more-infos/more-info-script.html b/src/dialogs/more-info/controls/more-info-script.html similarity index 77% rename from src/more-infos/more-info-script.html rename to src/dialogs/more-info/controls/more-info-script.html index c6fe688c8..c09d76e04 100644 --- a/src/more-infos/more-info-script.html +++ b/src/dialogs/more-info/controls/more-info-script.html @@ -1,6 +1,6 @@ - + - + diff --git a/src/more-infos/more-info-sun.html b/src/dialogs/more-info/controls/more-info-sun.html similarity index 87% rename from src/more-infos/more-info-sun.html rename to src/dialogs/more-info/controls/more-info-sun.html index 4a17e8604..dfe47b747 100644 --- a/src/more-infos/more-info-sun.html +++ b/src/dialogs/more-info/controls/more-info-sun.html @@ -1,8 +1,8 @@ - + - + - + diff --git a/src/more-infos/more-info-updater.html b/src/dialogs/more-info/controls/more-info-updater.html similarity index 74% rename from src/more-infos/more-info-updater.html rename to src/dialogs/more-info/controls/more-info-updater.html index a60130fa7..b69fd758d 100644 --- a/src/more-infos/more-info-updater.html +++ b/src/dialogs/more-info/controls/more-info-updater.html @@ -1,4 +1,4 @@ - + @@ -9,7 +9,7 @@ - Update Instructions + Update Instructions diff --git a/src/more-infos/more-info-vacuum.html b/src/dialogs/more-info/controls/more-info-vacuum.html similarity index 88% rename from src/more-infos/more-info-vacuum.html rename to src/dialogs/more-info/controls/more-info-vacuum.html index 58e8e5255..0f0c5e8d9 100644 --- a/src/more-infos/more-info-vacuum.html +++ b/src/dialogs/more-info/controls/more-info-vacuum.html @@ -1,15 +1,15 @@ - + - + - + - - - - + + + + - + diff --git a/src/dialogs/more-info/more-info-controls.html b/src/dialogs/more-info/more-info-controls.html new file mode 100644 index 000000000..516ef89f7 --- /dev/null +++ b/src/dialogs/more-info/more-info-controls.html @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + [[_computeStateName(stateObj)]] + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/dialogs/more-info/more-info-settings.html b/src/dialogs/more-info/more-info-settings.html new file mode 100644 index 000000000..d5b1e3589 --- /dev/null +++ b/src/dialogs/more-info/more-info-settings.html @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + [[_computeStateName(stateObj)]] + Save + + + + + + + + +