From de2d4bcb7897a09ec1833c25cd358e4c310a4d2d Mon Sep 17 00:00:00 2001 From: Ian Richardson Date: Thu, 1 Nov 2018 21:53:49 -0500 Subject: [PATCH 1/5] Remove .js from lovelace Also cleaned up some trailing whitespace --- .../lovelace/cards/hui-alarm-panel-card.js | 516 ++++++------ .../lovelace/cards/hui-conditional-card.ts | 166 ++-- .../lovelace/cards/hui-entities-card.ts | 374 ++++----- .../lovelace/cards/hui-entity-button-card.ts | 406 ++++----- .../lovelace/cards/hui-entity-filter-card.js | 154 ++-- src/panels/lovelace/cards/hui-gauge-card.ts | 546 ++++++------ src/panels/lovelace/cards/hui-glance-card.ts | 432 +++++----- .../lovelace/cards/hui-history-graph-card.js | 172 ++-- .../cards/hui-horizontal-stack-card.ts | 100 +-- src/panels/lovelace/cards/hui-iframe-card.ts | 160 ++-- .../lovelace/cards/hui-legacy-wrapper-card.js | 114 +-- src/panels/lovelace/cards/hui-light-card.ts | 654 +++++++-------- src/panels/lovelace/cards/hui-map-card.js | 610 +++++++------- .../lovelace/cards/hui-markdown-card.ts | 186 ++--- .../lovelace/cards/hui-media-control-card.js | 22 +- src/panels/lovelace/cards/hui-picture-card.js | 134 +-- .../cards/hui-picture-elements-card.ts | 222 ++--- .../lovelace/cards/hui-picture-entity-card.js | 402 ++++----- .../lovelace/cards/hui-picture-glance-card.js | 390 ++++----- .../lovelace/cards/hui-plant-status-card.js | 22 +- src/panels/lovelace/cards/hui-sensor-card.js | 584 ++++++------- src/panels/lovelace/cards/hui-stack-card.ts | 132 +-- .../lovelace/cards/hui-thermostat-card.ts | 780 +++++++++--------- .../lovelace/cards/hui-vertical-stack-card.ts | 100 +-- .../cards/hui-weather-forecast-card.js | 30 +- .../lovelace/common/compute-notifications.js | 14 +- .../lovelace/common/create-card-element.js | 224 ++--- .../lovelace/common/create-hui-element.js | 158 ++-- .../lovelace/common/create-row-element.js | 234 +++--- .../lovelace/common/entity/toggle-entity.js | 14 +- .../common/entity/turn-on-off-entities.js | 68 +- .../common/entity/turn-on-off-entity.js | 40 +- src/panels/lovelace/common/handle-click.ts | 2 +- .../common/process-config-entities.js | 76 +- .../lovelace/components/hui-card-options.ts | 136 +-- .../components/hui-entities-toggle.js | 114 +-- .../components/hui-generic-entity-row.js | 274 +++--- src/panels/lovelace/components/hui-image.js | 396 ++++----- .../hui-configurator-notification-item.js | 124 +-- .../notifications/hui-notification-drawer.js | 350 ++++---- .../hui-notification-item-template.js | 98 +-- .../notifications/hui-notification-item.js | 70 +- .../notifications/hui-notifications-button.js | 124 +-- .../hui-persistent-notification-item.js | 178 ++-- .../lovelace/editor/hui-dialog-edit-card.ts | 244 +++--- .../lovelace/editor/hui-yaml-card-preview.ts | 104 +-- src/panels/lovelace/editor/hui-yaml-editor.ts | 82 +- .../lovelace/elements/hui-icon-element.ts | 136 +-- .../lovelace/elements/hui-image-element.ts | 6 +- .../elements/hui-service-button-element.ts | 6 +- .../elements/hui-state-badge-element.ts | 6 +- .../elements/hui-state-icon-element.ts | 6 +- .../elements/hui-state-label-element.ts | 156 ++-- .../entity-rows/hui-climate-entity-row.ts | 8 +- .../entity-rows/hui-cover-entity-row.js | 148 ++-- .../entity-rows/hui-group-entity-row.js | 156 ++-- .../hui-input-number-entity-row.js | 340 ++++---- .../hui-input-select-entity-row.js | 214 ++--- .../entity-rows/hui-input-text-entity-row.js | 146 ++-- .../entity-rows/hui-lock-entity-row.js | 166 ++-- .../hui-media-player-entity-row.js | 324 ++++---- .../entity-rows/hui-scene-entity-row.js | 140 ++-- .../entity-rows/hui-script-entity-row.js | 156 ++-- .../entity-rows/hui-text-entity-row.js | 140 ++-- .../entity-rows/hui-timer-entity-row.js | 206 ++--- .../entity-rows/hui-toggle-entity-row.js | 152 ++-- src/panels/lovelace/ha-panel-lovelace.js | 250 +++--- src/panels/lovelace/hui-root.js | 760 ++++++++--------- src/panels/lovelace/hui-unused-entities.js | 122 +-- src/panels/lovelace/hui-view.js | 436 +++++----- .../special-rows/hui-call-service-row.ts | 10 +- .../lovelace/special-rows/hui-section-row.ts | 2 +- .../lovelace/special-rows/hui-weblink-row.ts | 2 +- 73 files changed, 7363 insertions(+), 7363 deletions(-) diff --git a/src/panels/lovelace/cards/hui-alarm-panel-card.js b/src/panels/lovelace/cards/hui-alarm-panel-card.js index f14ac4b801d7..967234d73710 100644 --- a/src/panels/lovelace/cards/hui-alarm-panel-card.js +++ b/src/panels/lovelace/cards/hui-alarm-panel-card.js @@ -1,258 +1,258 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/ha-card.js"; - -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; -import "../../../components/ha-label-badge.js"; - -/* - * @appliesMixin EventsMixin - */ - -const Icons = { - armed_away: "hass:security-lock", - armed_custom_bypass: "hass:security", - armed_home: "hass:security-home", - armed_night: "hass:security-home", - disarmed: "hass:verified", - pending: "hass:shield-outline", - triggered: "hass:bell-ring", -}; - -class HuiAlarmPanelCard extends LocalizeMixin(EventsMixin(PolymerElement)) { - static get template() { - return html` - - - - - - `; - } - - static get properties() { - return { - hass: { - type: Object, - }, - _config: Object, - _stateObj: { - type: Object, - computed: "_computeStateObj(hass.states, _config.entity)", - }, - _value: { - type: String, - value: "", - }, - }; - } - - getCardSize() { - return 4; - } - - setConfig(config) { - if ( - !config || - !config.entity || - config.entity.split(".")[0] !== "alarm_control_panel" - ) { - throw new Error("Invalid card configuration"); - } - - const defaults = { - states: ["arm_away", "arm_home"], - }; - - this._config = { ...defaults, ...config }; - this._icons = Icons; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - _computeHeader(localize, stateObj) { - if (!stateObj) return ""; - return this._config.title - ? this._config.title - : this._label(localize, stateObj.state); - } - - _computeIcon(stateObj) { - return this._icons[stateObj.state] || "hass:shield-outline"; - } - - _label(localize, state) { - return ( - localize(`state.alarm_control_panel.${state}`) || - localize(`ui.card.alarm_control_panel.${state}`) - ); - } - - _stateIconLabel(state) { - const stateLabel = state.split("_").pop(); - return stateLabel === "disarmed" || stateLabel === "triggered" - ? "" - : stateLabel; - } - - _showActionToggle(state) { - return state === "disarmed"; - } - - _computeClassName(stateObj) { - if (!stateObj) return "not-found"; - return ""; - } - - _handlePadClick(e) { - const val = e.target.getAttribute("value"); - this._value = val === "clear" ? "" : this._value + val; - } - - _handleActionClick(e) { - this.hass.callService("alarm_control_panel", "alarm_" + e.target.id, { - entity_id: this._stateObj.entity_id, - code: this._value, - }); - this._value = ""; - } -} - -customElements.define("hui-alarm-panel-card", HuiAlarmPanelCard); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/ha-card"; + +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; +import "../../../components/ha-label-badge"; + +/* + * @appliesMixin EventsMixin + */ + +const Icons = { + armed_away: "hass:security-lock", + armed_custom_bypass: "hass:security", + armed_home: "hass:security-home", + armed_night: "hass:security-home", + disarmed: "hass:verified", + pending: "hass:shield-outline", + triggered: "hass:bell-ring", +}; + +class HuiAlarmPanelCard extends LocalizeMixin(EventsMixin(PolymerElement)) { + static get template() { + return html` + + + + + + `; + } + + static get properties() { + return { + hass: { + type: Object, + }, + _config: Object, + _stateObj: { + type: Object, + computed: "_computeStateObj(hass.states, _config.entity)", + }, + _value: { + type: String, + value: "", + }, + }; + } + + getCardSize() { + return 4; + } + + setConfig(config) { + if ( + !config || + !config.entity || + config.entity.split(".")[0] !== "alarm_control_panel" + ) { + throw new Error("Invalid card configuration"); + } + + const defaults = { + states: ["arm_away", "arm_home"], + }; + + this._config = { ...defaults, ...config }; + this._icons = Icons; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + _computeHeader(localize, stateObj) { + if (!stateObj) return ""; + return this._config.title + ? this._config.title + : this._label(localize, stateObj.state); + } + + _computeIcon(stateObj) { + return this._icons[stateObj.state] || "hass:shield-outline"; + } + + _label(localize, state) { + return ( + localize(`state.alarm_control_panel.${state}`) || + localize(`ui.card.alarm_control_panel.${state}`) + ); + } + + _stateIconLabel(state) { + const stateLabel = state.split("_").pop(); + return stateLabel === "disarmed" || stateLabel === "triggered" + ? "" + : stateLabel; + } + + _showActionToggle(state) { + return state === "disarmed"; + } + + _computeClassName(stateObj) { + if (!stateObj) return "not-found"; + return ""; + } + + _handlePadClick(e) { + const val = e.target.getAttribute("value"); + this._value = val === "clear" ? "" : this._value + val; + } + + _handleActionClick(e) { + this.hass.callService("alarm_control_panel", "alarm_" + e.target.id, { + entity_id: this._stateObj.entity_id, + code: this._value, + }); + this._value = ""; + } +} + +customElements.define("hui-alarm-panel-card", HuiAlarmPanelCard); diff --git a/src/panels/lovelace/cards/hui-conditional-card.ts b/src/panels/lovelace/cards/hui-conditional-card.ts index 508cf50df535..08524836431b 100644 --- a/src/panels/lovelace/cards/hui-conditional-card.ts +++ b/src/panels/lovelace/cards/hui-conditional-card.ts @@ -1,83 +1,83 @@ -import computeCardSize from "../common/compute-card-size.js"; -import createCardElement from "../common/create-card-element.js"; -import { HomeAssistant } from "../../../types.js"; -import { LovelaceCard, LovelaceConfig } from "../types.js"; - -interface Condition { - entity: string; - state?: string; - state_not?: string; -} - -interface Config extends LovelaceConfig { - card: LovelaceConfig; - conditions: Condition[]; -} - -class HuiConditionalCard extends HTMLElement implements LovelaceCard { - private _hass?: HomeAssistant; - private _config?: Config; - private _card?: LovelaceCard; - - public setConfig(config) { - if ( - !config.card || - !config.conditions || - !Array.isArray(config.conditions) || - !config.conditions.every((c) => c.entity && (c.state || c.state_not)) - ) { - throw new Error("Error in card configuration."); - } - - if (this._card && this._card.parentElement) { - this.removeChild(this._card); - } - - this._config = config; - this._card = createCardElement(config.card); - if (this._hass) { - this.hass = this._hass; - } - } - - set hass(hass: HomeAssistant) { - this._hass = hass; - - if (!this._card) { - return; - } - - const visible = - this._config && - this._config.conditions.every((c) => { - if (!(c.entity in hass.states)) { - return false; - } - if (c.state) { - return hass.states[c.entity].state === c.state; - } - return hass.states[c.entity].state !== c.state_not; - }); - - if (visible) { - this._card.hass = hass; - if (!this._card.parentElement) { - this.appendChild(this._card); - } - } else if (this._card.parentElement) { - this.removeChild(this._card); - } - } - - public getCardSize() { - return computeCardSize(this._card); - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-conditional-card": HuiConditionalCard; - } -} - -customElements.define("hui-conditional-card", HuiConditionalCard); +import computeCardSize from "../common/compute-card-size"; +import createCardElement from "../common/create-card-element"; +import { HomeAssistant } from "../../../types"; +import { LovelaceCard, LovelaceConfig } from "../types"; + +interface Condition { + entity: string; + state?: string; + state_not?: string; +} + +interface Config extends LovelaceConfig { + card: LovelaceConfig; + conditions: Condition[]; +} + +class HuiConditionalCard extends HTMLElement implements LovelaceCard { + private _hass?: HomeAssistant; + private _config?: Config; + private _card?: LovelaceCard; + + public setConfig(config) { + if ( + !config.card || + !config.conditions || + !Array.isArray(config.conditions) || + !config.conditions.every((c) => c.entity && (c.state || c.state_not)) + ) { + throw new Error("Error in card configuration."); + } + + if (this._card && this._card.parentElement) { + this.removeChild(this._card); + } + + this._config = config; + this._card = createCardElement(config.card); + if (this._hass) { + this.hass = this._hass; + } + } + + set hass(hass: HomeAssistant) { + this._hass = hass; + + if (!this._card) { + return; + } + + const visible = + this._config && + this._config.conditions.every((c) => { + if (!(c.entity in hass.states)) { + return false; + } + if (c.state) { + return hass.states[c.entity].state === c.state; + } + return hass.states[c.entity].state !== c.state_not; + }); + + if (visible) { + this._card.hass = hass; + if (!this._card.parentElement) { + this.appendChild(this._card); + } + } else if (this._card.parentElement) { + this.removeChild(this._card); + } + } + + public getCardSize() { + return computeCardSize(this._card); + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-conditional-card": HuiConditionalCard; + } +} + +customElements.define("hui-conditional-card", HuiConditionalCard); diff --git a/src/panels/lovelace/cards/hui-entities-card.ts b/src/panels/lovelace/cards/hui-entities-card.ts index d8288198ddfb..2a27b2923f34 100644 --- a/src/panels/lovelace/cards/hui-entities-card.ts +++ b/src/panels/lovelace/cards/hui-entities-card.ts @@ -1,187 +1,187 @@ -import { - html, - LitElement, - PropertyDeclarations, - PropertyValues, -} from "@polymer/lit-element"; -import { TemplateResult } from "lit-html"; - -import "../../../components/ha-card.js"; -import "../components/hui-entities-toggle.js"; - -import { fireEvent } from "../../../common/dom/fire_event.js"; -import { DOMAINS_HIDE_MORE_INFO } from "../../../common/const.js"; -import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; -import { HomeAssistant } from "../../../types.js"; -import { EntityConfig, EntityRow } from "../entity-rows/types.js"; -import { LovelaceCard, LovelaceConfig } from "../types.js"; -import processConfigEntities from "../common/process-config-entities"; -import createRowElement from "../common/create-row-element.js"; -import computeDomain from "../../../common/entity/compute_domain.js"; -import applyThemesOnElement from "../../../common/dom/apply_themes_on_element.js"; - -interface ConfigEntity extends EntityConfig { - type?: string; - secondary_info: "entity-id" | "last-changed"; - action_name?: string; - service?: string; - service_data?: object; - url?: string; -} - -interface Config extends LovelaceConfig { - show_header_toggle?: boolean; - title?: string; - entities: ConfigEntity[]; - theme?: string; -} - -class HuiEntitiesCard extends hassLocalizeLitMixin(LitElement) - implements LovelaceCard { - protected _hass?: HomeAssistant; - protected _config?: Config; - protected _configEntities?: ConfigEntity[]; - - set hass(hass: HomeAssistant) { - this._hass = hass; - this.shadowRoot!.querySelectorAll("#states > div > *").forEach( - (element: unknown) => { - (element as EntityRow).hass = hass; - } - ); - const entitiesToggle = this.shadowRoot!.querySelector( - "hui-entities-toggle" - ); - if (entitiesToggle) { - (entitiesToggle as any).hass = hass; - } - } - - static get properties(): PropertyDeclarations { - return { - _config: {}, - }; - } - - public getCardSize(): number { - if (!this._config) { - return 0; - } - // +1 for the header - return (this._config.title ? 1 : 0) + this._config.entities.length; - } - - public setConfig(config: Config): void { - const entities = processConfigEntities(config.entities); - - this._config = { theme: "default", ...config }; - this._configEntities = entities; - } - - protected updated(_changedProperties: PropertyValues): void { - if (this._hass && this._config) { - applyThemesOnElement(this, this._hass.themes, this._config.theme); - } - } - - protected render(): TemplateResult { - if (!this._config || !this._hass) { - return html``; - } - const { show_header_toggle, title } = this._config; - - return html` - ${this.renderStyle()} - - ${ - !title && !show_header_toggle - ? html`` - : html` -
-
${title}
- ${ - show_header_toggle === false - ? html`` - : html` - ` - } -
` - } -
- ${this._configEntities!.map((entityConf) => - this.renderEntity(entityConf) - )} -
-
- `; - } - - private renderStyle(): TemplateResult { - return html` - - `; - } - - private renderEntity(entityConf: ConfigEntity): TemplateResult { - const element = createRowElement(entityConf); - if (this._hass) { - element.hass = this._hass; - } - if ( - entityConf.entity && - !DOMAINS_HIDE_MORE_INFO.includes(computeDomain(entityConf.entity)) - ) { - element.classList.add("state-card-dialog"); - element.addEventListener("click", () => this._handleClick(entityConf)); - } - - return html`
${element}
`; - } - - private _handleClick(entityConf: ConfigEntity): void { - const entityId = entityConf.entity; - fireEvent(this, "hass-more-info", { entityId }); - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-entities-card": HuiEntitiesCard; - } -} - -customElements.define("hui-entities-card", HuiEntitiesCard); +import { + html, + LitElement, + PropertyDeclarations, + PropertyValues, +} from "@polymer/lit-element"; +import { TemplateResult } from "lit-html"; + +import "../../../components/ha-card"; +import "../components/hui-entities-toggle"; + +import { fireEvent } from "../../../common/dom/fire_event"; +import { DOMAINS_HIDE_MORE_INFO } from "../../../common/const"; +import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; +import { HomeAssistant } from "../../../types"; +import { EntityConfig, EntityRow } from "../entity-rows/types"; +import { LovelaceCard, LovelaceConfig } from "../types"; +import processConfigEntities from "../common/process-config-entities"; +import createRowElement from "../common/create-row-element"; +import computeDomain from "../../../common/entity/compute_domain"; +import applyThemesOnElement from "../../../common/dom/apply_themes_on_element"; + +interface ConfigEntity extends EntityConfig { + type?: string; + secondary_info: "entity-id" | "last-changed"; + action_name?: string; + service?: string; + service_data?: object; + url?: string; +} + +interface Config extends LovelaceConfig { + show_header_toggle?: boolean; + title?: string; + entities: ConfigEntity[]; + theme?: string; +} + +class HuiEntitiesCard extends hassLocalizeLitMixin(LitElement) + implements LovelaceCard { + protected _hass?: HomeAssistant; + protected _config?: Config; + protected _configEntities?: ConfigEntity[]; + + set hass(hass: HomeAssistant) { + this._hass = hass; + this.shadowRoot!.querySelectorAll("#states > div > *").forEach( + (element: unknown) => { + (element as EntityRow).hass = hass; + } + ); + const entitiesToggle = this.shadowRoot!.querySelector( + "hui-entities-toggle" + ); + if (entitiesToggle) { + (entitiesToggle as any).hass = hass; + } + } + + static get properties(): PropertyDeclarations { + return { + _config: {}, + }; + } + + public getCardSize(): number { + if (!this._config) { + return 0; + } + // +1 for the header + return (this._config.title ? 1 : 0) + this._config.entities.length; + } + + public setConfig(config: Config): void { + const entities = processConfigEntities(config.entities); + + this._config = { theme: "default", ...config }; + this._configEntities = entities; + } + + protected updated(_changedProperties: PropertyValues): void { + if (this._hass && this._config) { + applyThemesOnElement(this, this._hass.themes, this._config.theme); + } + } + + protected render(): TemplateResult { + if (!this._config || !this._hass) { + return html``; + } + const { show_header_toggle, title } = this._config; + + return html` + ${this.renderStyle()} + + ${ + !title && !show_header_toggle + ? html`` + : html` +
+
${title}
+ ${ + show_header_toggle === false + ? html`` + : html` + ` + } +
` + } +
+ ${this._configEntities!.map((entityConf) => + this.renderEntity(entityConf) + )} +
+
+ `; + } + + private renderStyle(): TemplateResult { + return html` + + `; + } + + private renderEntity(entityConf: ConfigEntity): TemplateResult { + const element = createRowElement(entityConf); + if (this._hass) { + element.hass = this._hass; + } + if ( + entityConf.entity && + !DOMAINS_HIDE_MORE_INFO.includes(computeDomain(entityConf.entity)) + ) { + element.classList.add("state-card-dialog"); + element.addEventListener("click", () => this._handleClick(entityConf)); + } + + return html`
${element}
`; + } + + private _handleClick(entityConf: ConfigEntity): void { + const entityId = entityConf.entity; + fireEvent(this, "hass-more-info", { entityId }); + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-entities-card": HuiEntitiesCard; + } +} + +customElements.define("hui-entities-card", HuiEntitiesCard); diff --git a/src/panels/lovelace/cards/hui-entity-button-card.ts b/src/panels/lovelace/cards/hui-entity-button-card.ts index 0aa86b7762b6..6f8b0925e3c3 100644 --- a/src/panels/lovelace/cards/hui-entity-button-card.ts +++ b/src/panels/lovelace/cards/hui-entity-button-card.ts @@ -1,203 +1,203 @@ -import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; -import { fireEvent } from "../../../common/dom/fire_event.js"; - -import "../../../components/ha-card.js"; - -import toggleEntity from "../common/entity/toggle-entity.js"; -import isValidEntityId from "../../../common/entity/valid_entity_id.js"; -import stateIcon from "../../../common/entity/state_icon.js"; -import computeStateDomain from "../../../common/entity/compute_state_domain.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import applyThemesOnElement from "../../../common/dom/apply_themes_on_element.js"; -import { styleMap } from "lit-html/directives/styleMap.js"; -import { HomeAssistant } from "../../../types.js"; -import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; -import { LovelaceCard, LovelaceConfig } from "../types.js"; -import { longPress } from "../common/directives/long-press-directive"; - -interface Config extends LovelaceConfig { - entity: string; - name?: string; - icon?: string; - theme?: string; - tap_action?: "toggle" | "call-service" | "more-info"; - hold_action?: "toggle" | "call-service" | "more-info"; - service?: string; - service_data?: object; -} - -class HuiEntityButtonCard extends hassLocalizeLitMixin(LitElement) - implements LovelaceCard { - public hass?: HomeAssistant; - protected config?: Config; - - static get properties(): PropertyDeclarations { - return { - hass: {}, - config: {}, - }; - } - - public getCardSize() { - return 2; - } - - public setConfig(config: Config) { - if (!isValidEntityId(config.entity)) { - throw new Error("Invalid Entity"); - } - - this.config = { theme: "default", ...config }; - - if (this.hass) { - this.requestUpdate(); - } - } - - protected render() { - if (!this.config) { - return html``; - } - const stateObj = this.hass!.states[this.config.entity]; - - applyThemesOnElement(this, this.hass!.themes, this.config.theme); - - return html` - ${this.renderStyle()} - - ${ - !stateObj - ? html`
Entity not available: ${ - this.config.entity - }
` - : html` - -
- - - ${ - this.config.name - ? this.config.name - : computeStateName(stateObj) - } - -
-
- ` - } -
- `; - } - - private renderStyle() { - return html` - - `; - } - - private _computeBrightness(stateObj) { - if (!stateObj.attributes.brightness) { - return ""; - } - const brightness = stateObj.attributes.brightness; - return `brightness(${(brightness + 245) / 5}%)`; - } - - private _computeColor(stateObj) { - if (!stateObj.attributes.hs_color) { - return ""; - } - const hue = stateObj.attributes.hs_color[0]; - const sat = stateObj.attributes.hs_color[1]; - if (sat <= 10) { - return ""; - } - return `hsl(${hue}, 100%, ${100 - sat / 2}%)`; - } - - private handleClick(hold) { - const config = this.config; - if (!config) { - return; - } - const stateObj = this.hass!.states[config.entity]; - if (!stateObj) { - return; - } - const entityId = stateObj.entity_id; - const action = hold ? config.hold_action : config.tap_action || "more-info"; - switch (action) { - case "toggle": - toggleEntity(this.hass, entityId); - break; - case "call-service": - if (!config.service) { - return; - } - const [domain, service] = config.service.split(".", 2); - const serviceData = { entity_id: entityId, ...config.service_data }; - this.hass!.callService(domain, service, serviceData); - break; - case "more-info": - fireEvent(this, "hass-more-info", { entityId }); - break; - default: - } - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-entity-button-card": HuiEntityButtonCard; - } -} - -customElements.define("hui-entity-button-card", HuiEntityButtonCard); +import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; +import { fireEvent } from "../../../common/dom/fire_event"; + +import "../../../components/ha-card"; + +import toggleEntity from "../common/entity/toggle-entity"; +import isValidEntityId from "../../../common/entity/valid_entity_id"; +import stateIcon from "../../../common/entity/state_icon"; +import computeStateDomain from "../../../common/entity/compute_state_domain"; +import computeStateName from "../../../common/entity/compute_state_name"; +import applyThemesOnElement from "../../../common/dom/apply_themes_on_element"; +import { styleMap } from "lit-html/directives/styleMap"; +import { HomeAssistant } from "../../../types"; +import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; +import { LovelaceCard, LovelaceConfig } from "../types"; +import { longPress } from "../common/directives/long-press-directive"; + +interface Config extends LovelaceConfig { + entity: string; + name?: string; + icon?: string; + theme?: string; + tap_action?: "toggle" | "call-service" | "more-info"; + hold_action?: "toggle" | "call-service" | "more-info"; + service?: string; + service_data?: object; +} + +class HuiEntityButtonCard extends hassLocalizeLitMixin(LitElement) + implements LovelaceCard { + public hass?: HomeAssistant; + protected config?: Config; + + static get properties(): PropertyDeclarations { + return { + hass: {}, + config: {}, + }; + } + + public getCardSize() { + return 2; + } + + public setConfig(config: Config) { + if (!isValidEntityId(config.entity)) { + throw new Error("Invalid Entity"); + } + + this.config = { theme: "default", ...config }; + + if (this.hass) { + this.requestUpdate(); + } + } + + protected render() { + if (!this.config) { + return html``; + } + const stateObj = this.hass!.states[this.config.entity]; + + applyThemesOnElement(this, this.hass!.themes, this.config.theme); + + return html` + ${this.renderStyle()} + + ${ + !stateObj + ? html`
Entity not available: ${ + this.config.entity + }
` + : html` + +
+ + + ${ + this.config.name + ? this.config.name + : computeStateName(stateObj) + } + +
+
+ ` + } +
+ `; + } + + private renderStyle() { + return html` + + `; + } + + private _computeBrightness(stateObj) { + if (!stateObj.attributes.brightness) { + return ""; + } + const brightness = stateObj.attributes.brightness; + return `brightness(${(brightness + 245) / 5}%)`; + } + + private _computeColor(stateObj) { + if (!stateObj.attributes.hs_color) { + return ""; + } + const hue = stateObj.attributes.hs_color[0]; + const sat = stateObj.attributes.hs_color[1]; + if (sat <= 10) { + return ""; + } + return `hsl(${hue}, 100%, ${100 - sat / 2}%)`; + } + + private handleClick(hold) { + const config = this.config; + if (!config) { + return; + } + const stateObj = this.hass!.states[config.entity]; + if (!stateObj) { + return; + } + const entityId = stateObj.entity_id; + const action = hold ? config.hold_action : config.tap_action || "more-info"; + switch (action) { + case "toggle": + toggleEntity(this.hass, entityId); + break; + case "call-service": + if (!config.service) { + return; + } + const [domain, service] = config.service.split(".", 2); + const serviceData = { entity_id: entityId, ...config.service_data }; + this.hass!.callService(domain, service, serviceData); + break; + case "more-info": + fireEvent(this, "hass-more-info", { entityId }); + break; + default: + } + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-entity-button-card": HuiEntityButtonCard; + } +} + +customElements.define("hui-entity-button-card", HuiEntityButtonCard); diff --git a/src/panels/lovelace/cards/hui-entity-filter-card.js b/src/panels/lovelace/cards/hui-entity-filter-card.js index 9924e5614241..c76299b00b5b 100644 --- a/src/panels/lovelace/cards/hui-entity-filter-card.js +++ b/src/panels/lovelace/cards/hui-entity-filter-card.js @@ -1,77 +1,77 @@ -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import createCardElement from "../common/create-card-element.js"; -import processConfigEntities from "../common/process-config-entities.js"; - -function getEntities(hass, filterState, entities) { - return entities.filter((entityConf) => { - const stateObj = hass.states[entityConf.entity]; - return stateObj && filterState.includes(stateObj.state); - }); -} - -class HuiEntitiesCard extends PolymerElement { - static get properties() { - return { - hass: { - type: Object, - observer: "_hassChanged", - }, - }; - } - - getCardSize() { - return this.lastChild ? this.lastChild.getCardSize() : 1; - } - - setConfig(config) { - if (!config.state_filter || !Array.isArray(config.state_filter)) { - throw new Error("Incorrect filter config."); - } - - this._config = config; - this._configEntities = processConfigEntities(config.entities); - - if (this.lastChild) { - this.removeChild(this.lastChild); - this._element = null; - } - - const card = "card" in config ? { ...config.card } : {}; - if (!card.type) card.type = "entities"; - card.entities = []; - - const element = createCardElement(card); - element._filterRawConfig = card; - this._updateCardConfig(element); - - this._element = element; - } - - _hassChanged() { - this._updateCardConfig(this._element); - } - - _updateCardConfig(element) { - if (!element || element.tagName === "HUI-ERROR-CARD" || !this.hass) return; - const entitiesList = getEntities( - this.hass, - this._config.state_filter, - this._configEntities - ); - - if (entitiesList.length === 0 && this._config.show_empty === false) { - this.style.display = "none"; - return; - } - - this.style.display = "block"; - element.setConfig({ ...element._filterRawConfig, entities: entitiesList }); - element.isPanel = this.isPanel; - element.hass = this.hass; - - // Attach element if it has never been attached. - if (!this.lastChild) this.appendChild(element); - } -} -customElements.define("hui-entity-filter-card", HuiEntitiesCard); +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import createCardElement from "../common/create-card-element"; +import processConfigEntities from "../common/process-config-entities"; + +function getEntities(hass, filterState, entities) { + return entities.filter((entityConf) => { + const stateObj = hass.states[entityConf.entity]; + return stateObj && filterState.includes(stateObj.state); + }); +} + +class HuiEntitiesCard extends PolymerElement { + static get properties() { + return { + hass: { + type: Object, + observer: "_hassChanged", + }, + }; + } + + getCardSize() { + return this.lastChild ? this.lastChild.getCardSize() : 1; + } + + setConfig(config) { + if (!config.state_filter || !Array.isArray(config.state_filter)) { + throw new Error("Incorrect filter config."); + } + + this._config = config; + this._configEntities = processConfigEntities(config.entities); + + if (this.lastChild) { + this.removeChild(this.lastChild); + this._element = null; + } + + const card = "card" in config ? { ...config.card } : {}; + if (!card.type) card.type = "entities"; + card.entities = []; + + const element = createCardElement(card); + element._filterRawConfig = card; + this._updateCardConfig(element); + + this._element = element; + } + + _hassChanged() { + this._updateCardConfig(this._element); + } + + _updateCardConfig(element) { + if (!element || element.tagName === "HUI-ERROR-CARD" || !this.hass) return; + const entitiesList = getEntities( + this.hass, + this._config.state_filter, + this._configEntities + ); + + if (entitiesList.length === 0 && this._config.show_empty === false) { + this.style.display = "none"; + return; + } + + this.style.display = "block"; + element.setConfig({ ...element._filterRawConfig, entities: entitiesList }); + element.isPanel = this.isPanel; + element.hass = this.hass; + + // Attach element if it has never been attached. + if (!this.lastChild) this.appendChild(element); + } +} +customElements.define("hui-entity-filter-card", HuiEntitiesCard); diff --git a/src/panels/lovelace/cards/hui-gauge-card.ts b/src/panels/lovelace/cards/hui-gauge-card.ts index 4f04285ce8bf..5061ad26bace 100644 --- a/src/panels/lovelace/cards/hui-gauge-card.ts +++ b/src/panels/lovelace/cards/hui-gauge-card.ts @@ -1,273 +1,273 @@ -import { - html, - LitElement, - PropertyDeclarations, - PropertyValues, -} from "@polymer/lit-element"; -import { LovelaceCard, LovelaceConfig } from "../types.js"; -import { HomeAssistant } from "../../../types.js"; -import { fireEvent } from "../../../common/dom/fire_event.js"; -import { TemplateResult } from "lit-html"; -import isValidEntityId from "../../../common/entity/valid_entity_id.js"; - -import "../../../components/ha-card.js"; - -interface Config extends LovelaceConfig { - entity: string; - title?: string; - unit_of_measurement?: string; - min?: number; - max?: number; - severity?: object; -} - -const severityMap = { - red: "var(--label-badge-red)", - green: "var(--label-badge-green)", - yellow: "var(--label-badge-yellow)", - normal: "var(--label-badge-blue)", -}; - -class HuiGaugeCard extends LitElement implements LovelaceCard { - public hass?: HomeAssistant; - private _config?: Config; - - static get properties(): PropertyDeclarations { - return { - hass: {}, - _config: {}, - }; - } - - public getCardSize(): number { - return 2; - } - - public setConfig(config: Config): void { - if (!config || !config.entity) { - throw new Error("Invalid card configuration"); - } - if (!isValidEntityId(config.entity)) { - throw new Error("Invalid Entity"); - } - this._config = { min: 0, max: 100, ...config }; - } - - protected render(): TemplateResult { - if (!this._config || !this.hass) { - return html``; - } - const stateObj = this.hass.states[this._config.entity]; - let error; - if (!stateObj) { - error = "Entity not available: " + this._config.entity; - } else if (isNaN(Number(stateObj.state))) { - error = "Entity is non-numeric: " + this._config.entity; - } - - return html` - ${this.renderStyle()} - - ${ - error - ? html`
${error}
` - : html` -
-
-
-
-
-
${stateObj.state} - ${this._config.unit_of_measurement || - stateObj.attributes.unit_of_measurement || - ""} -
-
${this._config.title} - -
-
-
- ` - } -
- `; - } - - protected shouldUpdate(changedProps: PropertyValues): boolean { - if (changedProps.get("hass")) { - return ( - (changedProps.get("hass") as any).states[this._config!.entity] !== - this.hass!.states[this._config!.entity] - ); - } - if (changedProps.get("_config")) { - return changedProps.get("_config") !== this._config; - } - return true; - } - - protected updated(): void { - if ( - !this._config || - !this.hass || - !this.shadowRoot!.getElementById("gauge") - ) { - return; - } - const stateObj = this.hass.states[this._config.entity]; - if (isNaN(Number(stateObj.state))) { - return; - } - - const turn = this._translateTurn(Number(stateObj.state), this._config); - - this.shadowRoot!.getElementById( - "gauge" - )!.style.cssText = `transform: rotate(${turn}turn); background-color: ${this._computeSeverity( - stateObj.state, - this._config.severity! - )}`; - - (this.shadowRoot!.querySelector( - "ha-card" - )! as HTMLElement).style.setProperty( - "--base-unit", - this._computeBaseUnit() - ); - } - - private renderStyle(): TemplateResult { - return html` - - `; - } - - private _computeSeverity(stateValue: string, sections: object): string { - const numberValue = Number(stateValue); - - if (!sections) { - return severityMap.normal; - } - - const sectionsArray = Object.keys(sections); - const sortable = sectionsArray.map((severity) => [ - severity, - sections[severity], - ]); - - for (const severity of sortable) { - if (severityMap[severity[0]] == null || isNaN(severity[1])) { - return severityMap.normal; - } - } - sortable.sort((a, b) => a[1] - b[1]); - - if (numberValue >= sortable[0][1] && numberValue < sortable[1][1]) { - return severityMap[sortable[0][0]]; - } - if (numberValue >= sortable[1][1] && numberValue < sortable[2][1]) { - return severityMap[sortable[1][0]]; - } - if (numberValue >= sortable[2][1]) { - return severityMap[sortable[2][0]]; - } - return severityMap.normal; - } - - private _translateTurn(value: number, config: Config): number { - const maxTurnValue = Math.min(Math.max(value, config.min!), config.max!); - return ( - (5 * (maxTurnValue - config.min!)) / (config.max! - config.min!) / 10 - ); - } - - private _computeBaseUnit(): string { - return this.clientWidth < 200 ? this.clientWidth / 5 + "px" : "50px"; - } - - private _handleClick(): void { - fireEvent(this, "hass-more-info", { entityId: this._config!.entity }); - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-gauge-card": HuiGaugeCard; - } -} - -customElements.define("hui-gauge-card", HuiGaugeCard); +import { + html, + LitElement, + PropertyDeclarations, + PropertyValues, +} from "@polymer/lit-element"; +import { LovelaceCard, LovelaceConfig } from "../types"; +import { HomeAssistant } from "../../../types"; +import { fireEvent } from "../../../common/dom/fire_event"; +import { TemplateResult } from "lit-html"; +import isValidEntityId from "../../../common/entity/valid_entity_id"; + +import "../../../components/ha-card"; + +interface Config extends LovelaceConfig { + entity: string; + title?: string; + unit_of_measurement?: string; + min?: number; + max?: number; + severity?: object; +} + +const severityMap = { + red: "var(--label-badge-red)", + green: "var(--label-badge-green)", + yellow: "var(--label-badge-yellow)", + normal: "var(--label-badge-blue)", +}; + +class HuiGaugeCard extends LitElement implements LovelaceCard { + public hass?: HomeAssistant; + private _config?: Config; + + static get properties(): PropertyDeclarations { + return { + hass: {}, + _config: {}, + }; + } + + public getCardSize(): number { + return 2; + } + + public setConfig(config: Config): void { + if (!config || !config.entity) { + throw new Error("Invalid card configuration"); + } + if (!isValidEntityId(config.entity)) { + throw new Error("Invalid Entity"); + } + this._config = { min: 0, max: 100, ...config }; + } + + protected render(): TemplateResult { + if (!this._config || !this.hass) { + return html``; + } + const stateObj = this.hass.states[this._config.entity]; + let error; + if (!stateObj) { + error = "Entity not available: " + this._config.entity; + } else if (isNaN(Number(stateObj.state))) { + error = "Entity is non-numeric: " + this._config.entity; + } + + return html` + ${this.renderStyle()} + + ${ + error + ? html`
${error}
` + : html` +
+
+
+
+
+
${stateObj.state} + ${this._config.unit_of_measurement || + stateObj.attributes.unit_of_measurement || + ""} +
+
${this._config.title} + +
+
+
+ ` + } +
+ `; + } + + protected shouldUpdate(changedProps: PropertyValues): boolean { + if (changedProps.get("hass")) { + return ( + (changedProps.get("hass") as any).states[this._config!.entity] !== + this.hass!.states[this._config!.entity] + ); + } + if (changedProps.get("_config")) { + return changedProps.get("_config") !== this._config; + } + return true; + } + + protected updated(): void { + if ( + !this._config || + !this.hass || + !this.shadowRoot!.getElementById("gauge") + ) { + return; + } + const stateObj = this.hass.states[this._config.entity]; + if (isNaN(Number(stateObj.state))) { + return; + } + + const turn = this._translateTurn(Number(stateObj.state), this._config); + + this.shadowRoot!.getElementById( + "gauge" + )!.style.cssText = `transform: rotate(${turn}turn); background-color: ${this._computeSeverity( + stateObj.state, + this._config.severity! + )}`; + + (this.shadowRoot!.querySelector( + "ha-card" + )! as HTMLElement).style.setProperty( + "--base-unit", + this._computeBaseUnit() + ); + } + + private renderStyle(): TemplateResult { + return html` + + `; + } + + private _computeSeverity(stateValue: string, sections: object): string { + const numberValue = Number(stateValue); + + if (!sections) { + return severityMap.normal; + } + + const sectionsArray = Object.keys(sections); + const sortable = sectionsArray.map((severity) => [ + severity, + sections[severity], + ]); + + for (const severity of sortable) { + if (severityMap[severity[0]] == null || isNaN(severity[1])) { + return severityMap.normal; + } + } + sortable.sort((a, b) => a[1] - b[1]); + + if (numberValue >= sortable[0][1] && numberValue < sortable[1][1]) { + return severityMap[sortable[0][0]]; + } + if (numberValue >= sortable[1][1] && numberValue < sortable[2][1]) { + return severityMap[sortable[1][0]]; + } + if (numberValue >= sortable[2][1]) { + return severityMap[sortable[2][0]]; + } + return severityMap.normal; + } + + private _translateTurn(value: number, config: Config): number { + const maxTurnValue = Math.min(Math.max(value, config.min!), config.max!); + return ( + (5 * (maxTurnValue - config.min!)) / (config.max! - config.min!) / 10 + ); + } + + private _computeBaseUnit(): string { + return this.clientWidth < 200 ? this.clientWidth / 5 + "px" : "50px"; + } + + private _handleClick(): void { + fireEvent(this, "hass-more-info", { entityId: this._config!.entity }); + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-gauge-card": HuiGaugeCard; + } +} + +customElements.define("hui-gauge-card", HuiGaugeCard); diff --git a/src/panels/lovelace/cards/hui-glance-card.ts b/src/panels/lovelace/cards/hui-glance-card.ts index 594effabfa0a..c760d70511c7 100644 --- a/src/panels/lovelace/cards/hui-glance-card.ts +++ b/src/panels/lovelace/cards/hui-glance-card.ts @@ -1,216 +1,216 @@ -import { html, LitElement } from "@polymer/lit-element"; -import { classMap } from "lit-html/directives/classMap.js"; - -import computeStateDisplay from "../../../common/entity/compute_state_display.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import processConfigEntities from "../common/process-config-entities"; -import applyThemesOnElement from "../../../common/dom/apply_themes_on_element.js"; - -import toggleEntity from "../common/entity/toggle-entity.js"; - -import "../../../components/entity/state-badge.js"; -import "../../../components/ha-card.js"; -import "../../../components/ha-icon.js"; - -import { fireEvent } from "../../../common/dom/fire_event.js"; -import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; -import { HomeAssistant } from "../../../types.js"; -import { LovelaceCard, LovelaceConfig } from "../types.js"; -import { longPress } from "../common/directives/long-press-directive"; - -interface EntityConfig { - name: string; - icon: string; - entity: string; - tap_action: "toggle" | "call-service" | "more-info"; - hold_action?: "toggle" | "call-service" | "more-info"; - service?: string; - service_data?: object; -} - -interface Config extends LovelaceConfig { - show_name?: boolean; - show_state?: boolean; - title?: string; - theme?: string; - entities: EntityConfig[]; - columns?: number; -} - -export class HuiGlanceCard extends hassLocalizeLitMixin(LitElement) - implements LovelaceCard { - public hass?: HomeAssistant; - protected config?: Config; - protected configEntities?: EntityConfig[]; - - static get properties() { - return { - hass: {}, - config: {}, - }; - } - - public getCardSize() { - const columns = - this.config!.columns || Math.min(this.config!.entities.length, 5); - return ( - (this.config!.title ? 1 : 0) + - 2 * Math.ceil(this.configEntities!.length / columns) - ); - } - - public setConfig(config: Config) { - this.config = { theme: "default", ...config }; - const entities = processConfigEntities(config.entities); - - for (const entity of entities) { - if ( - (entity.tap_action === "call-service" || - entity.hold_action === "call-service") && - !entity.service - ) { - throw new Error( - 'Missing required property "service" when tap_action or hold_action is call-service' - ); - } - } - - const columns = config.columns || Math.min(config.entities.length, 5); - this.style.setProperty("--glance-column-width", `${100 / columns}%`); - - this.configEntities = entities; - - if (this.hass) { - this.requestUpdate(); - } - } - - protected render() { - if (!this.config || !this.hass) { - return html``; - } - const { title } = this.config; - - applyThemesOnElement(this, this.hass!.themes, this.config.theme); - - return html` - ${this.renderStyle()} - -
- ${this.configEntities!.map((entityConf) => - this.renderEntity(entityConf) - )} -
-
- `; - } - - private renderStyle() { - return html` - - `; - } - - private renderEntity(entityConf) { - const stateObj = this.hass!.states[entityConf.entity]; - - if (!stateObj) { - return html`
${ - entityConf.entity - }
Entity Not Available
`; - } - - return html` -
- ${ - this.config!.show_name !== false - ? html`
${ - "name" in entityConf - ? entityConf.name - : computeStateName(stateObj) - }
` - : "" - } - - ${ - this.config!.show_state !== false - ? html`
${computeStateDisplay(this.localize, stateObj)}
` - : "" - } -
- `; - } - - private handleClick(ev: MouseEvent, hold) { - const config = (ev.currentTarget as any).entityConf as EntityConfig; - const entityId = config.entity; - const action = hold ? config.hold_action : config.tap_action || "more-info"; - switch (action) { - case "toggle": - toggleEntity(this.hass, entityId); - break; - case "call-service": - const [domain, service] = config.service!.split(".", 2); - const serviceData = { entity_id: entityId, ...config.service_data }; - this.hass!.callService(domain, service, serviceData); - break; - case "more-info": - fireEvent(this, "hass-more-info", { entityId }); - break; - default: - } - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-glance-card": HuiGlanceCard; - } -} - -customElements.define("hui-glance-card", HuiGlanceCard); +import { html, LitElement } from "@polymer/lit-element"; +import { classMap } from "lit-html/directives/classMap"; + +import computeStateDisplay from "../../../common/entity/compute_state_display"; +import computeStateName from "../../../common/entity/compute_state_name"; +import processConfigEntities from "../common/process-config-entities"; +import applyThemesOnElement from "../../../common/dom/apply_themes_on_element"; + +import toggleEntity from "../common/entity/toggle-entity"; + +import "../../../components/entity/state-badge"; +import "../../../components/ha-card"; +import "../../../components/ha-icon"; + +import { fireEvent } from "../../../common/dom/fire_event"; +import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; +import { HomeAssistant } from "../../../types"; +import { LovelaceCard, LovelaceConfig } from "../types"; +import { longPress } from "../common/directives/long-press-directive"; + +interface EntityConfig { + name: string; + icon: string; + entity: string; + tap_action: "toggle" | "call-service" | "more-info"; + hold_action?: "toggle" | "call-service" | "more-info"; + service?: string; + service_data?: object; +} + +interface Config extends LovelaceConfig { + show_name?: boolean; + show_state?: boolean; + title?: string; + theme?: string; + entities: EntityConfig[]; + columns?: number; +} + +export class HuiGlanceCard extends hassLocalizeLitMixin(LitElement) + implements LovelaceCard { + public hass?: HomeAssistant; + protected config?: Config; + protected configEntities?: EntityConfig[]; + + static get properties() { + return { + hass: {}, + config: {}, + }; + } + + public getCardSize() { + const columns = + this.config!.columns || Math.min(this.config!.entities.length, 5); + return ( + (this.config!.title ? 1 : 0) + + 2 * Math.ceil(this.configEntities!.length / columns) + ); + } + + public setConfig(config: Config) { + this.config = { theme: "default", ...config }; + const entities = processConfigEntities(config.entities); + + for (const entity of entities) { + if ( + (entity.tap_action === "call-service" || + entity.hold_action === "call-service") && + !entity.service + ) { + throw new Error( + 'Missing required property "service" when tap_action or hold_action is call-service' + ); + } + } + + const columns = config.columns || Math.min(config.entities.length, 5); + this.style.setProperty("--glance-column-width", `${100 / columns}%`); + + this.configEntities = entities; + + if (this.hass) { + this.requestUpdate(); + } + } + + protected render() { + if (!this.config || !this.hass) { + return html``; + } + const { title } = this.config; + + applyThemesOnElement(this, this.hass!.themes, this.config.theme); + + return html` + ${this.renderStyle()} + +
+ ${this.configEntities!.map((entityConf) => + this.renderEntity(entityConf) + )} +
+
+ `; + } + + private renderStyle() { + return html` + + `; + } + + private renderEntity(entityConf) { + const stateObj = this.hass!.states[entityConf.entity]; + + if (!stateObj) { + return html`
${ + entityConf.entity + }
Entity Not Available
`; + } + + return html` +
+ ${ + this.config!.show_name !== false + ? html`
${ + "name" in entityConf + ? entityConf.name + : computeStateName(stateObj) + }
` + : "" + } + + ${ + this.config!.show_state !== false + ? html`
${computeStateDisplay(this.localize, stateObj)}
` + : "" + } +
+ `; + } + + private handleClick(ev: MouseEvent, hold) { + const config = (ev.currentTarget as any).entityConf as EntityConfig; + const entityId = config.entity; + const action = hold ? config.hold_action : config.tap_action || "more-info"; + switch (action) { + case "toggle": + toggleEntity(this.hass, entityId); + break; + case "call-service": + const [domain, service] = config.service!.split(".", 2); + const serviceData = { entity_id: entityId, ...config.service_data }; + this.hass!.callService(domain, service, serviceData); + break; + case "more-info": + fireEvent(this, "hass-more-info", { entityId }); + break; + default: + } + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-glance-card": HuiGlanceCard; + } +} + +customElements.define("hui-glance-card", HuiGlanceCard); diff --git a/src/panels/lovelace/cards/hui-history-graph-card.js b/src/panels/lovelace/cards/hui-history-graph-card.js index 7a3f4dfdb8a4..66e56b326d52 100644 --- a/src/panels/lovelace/cards/hui-history-graph-card.js +++ b/src/panels/lovelace/cards/hui-history-graph-card.js @@ -1,86 +1,86 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/ha-card.js"; -import "../../../components/state-history-charts.js"; -import "../../../data/ha-state-history-data"; - -import processConfigEntities from "../common/process-config-entities.js"; - -class HuiHistoryGraphCard extends PolymerElement { - static get template() { - return html` - - - - - - - `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - _names: Object, - _entities: Array, - - _stateHistory: Object, - _stateHistoryLoading: Boolean, - _cacheConfig: Object, - }; - } - - getCardSize() { - return 4; - } - - setConfig(config) { - const entities = processConfigEntities(config.entities); - - this._config = config; - - const _entities = []; - const _names = {}; - for (const entity of entities) { - _entities.push(entity.entity); - if (entity.name) { - _names[entity.entity] = entity.name; - } - } - - this.setProperties({ - _cacheConfig: { - cacheKey: _entities.sort().join(), - hoursToShow: config.hours_to_show || 24, - refresh: config.refresh_interval || 0, - }, - _entities, - _names, - }); - } -} - -customElements.define("hui-history-graph-card", HuiHistoryGraphCard); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/ha-card"; +import "../../../components/state-history-charts"; +import "../../../data/ha-state-history-data"; + +import processConfigEntities from "../common/process-config-entities"; + +class HuiHistoryGraphCard extends PolymerElement { + static get template() { + return html` + + + + + + + `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _names: Object, + _entities: Array, + + _stateHistory: Object, + _stateHistoryLoading: Boolean, + _cacheConfig: Object, + }; + } + + getCardSize() { + return 4; + } + + setConfig(config) { + const entities = processConfigEntities(config.entities); + + this._config = config; + + const _entities = []; + const _names = {}; + for (const entity of entities) { + _entities.push(entity.entity); + if (entity.name) { + _names[entity.entity] = entity.name; + } + } + + this.setProperties({ + _cacheConfig: { + cacheKey: _entities.sort().join(), + hoursToShow: config.hours_to_show || 24, + refresh: config.refresh_interval || 0, + }, + _entities, + _names, + }); + } +} + +customElements.define("hui-history-graph-card", HuiHistoryGraphCard); diff --git a/src/panels/lovelace/cards/hui-horizontal-stack-card.ts b/src/panels/lovelace/cards/hui-horizontal-stack-card.ts index ba9d1dff0f6b..3559e4cdb12a 100644 --- a/src/panels/lovelace/cards/hui-horizontal-stack-card.ts +++ b/src/panels/lovelace/cards/hui-horizontal-stack-card.ts @@ -1,50 +1,50 @@ -import { html } from "@polymer/lit-element"; -import { TemplateResult } from "lit-html"; - -import computeCardSize from "../common/compute-card-size.js"; - -import { HuiStackCard } from "./hui-stack-card"; - -class HuiHorizontalStackCard extends HuiStackCard { - public getCardSize(): number { - let totalSize = 0; - - if (this._cards) { - for (const element of this._cards) { - const elementSize = computeCardSize(element); - totalSize = elementSize > totalSize ? elementSize : totalSize; - } - } - - return totalSize; - } - - protected renderStyle(): TemplateResult { - return html` - - `; - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-horitzontal-stack-card": HuiHorizontalStackCard; - } -} - -customElements.define("hui-horizontal-stack-card", HuiHorizontalStackCard); +import { html } from "@polymer/lit-element"; +import { TemplateResult } from "lit-html"; + +import computeCardSize from "../common/compute-card-size"; + +import { HuiStackCard } from "./hui-stack-card"; + +class HuiHorizontalStackCard extends HuiStackCard { + public getCardSize(): number { + let totalSize = 0; + + if (this._cards) { + for (const element of this._cards) { + const elementSize = computeCardSize(element); + totalSize = elementSize > totalSize ? elementSize : totalSize; + } + } + + return totalSize; + } + + protected renderStyle(): TemplateResult { + return html` + + `; + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-horitzontal-stack-card": HuiHorizontalStackCard; + } +} + +customElements.define("hui-horizontal-stack-card", HuiHorizontalStackCard); diff --git a/src/panels/lovelace/cards/hui-iframe-card.ts b/src/panels/lovelace/cards/hui-iframe-card.ts index 6530a7c13d5a..11c96a22feac 100644 --- a/src/panels/lovelace/cards/hui-iframe-card.ts +++ b/src/panels/lovelace/cards/hui-iframe-card.ts @@ -1,80 +1,80 @@ -import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; - -import "../../../components/ha-card.js"; - -import { LovelaceCard, LovelaceConfig } from "../types.js"; -import { TemplateResult } from "lit-html"; - -interface Config extends LovelaceConfig { - aspect_ratio?: string; - title?: string; - url: string; -} - -export class HuiIframeCard extends LitElement implements LovelaceCard { - protected _config?: Config; - - static get properties(): PropertyDeclarations { - return { - _config: {}, - }; - } - - public getCardSize(): number { - return 1 + this.offsetHeight / 50; - } - - public setConfig(config: Config): void { - if (!config.url) { - throw new Error("URL required"); - } - - this._config = config; - } - - protected render(): TemplateResult { - if (!this._config) { - return html``; - } - - return html` - ${this.renderStyle()} - -
- -
-
- `; - } - - private renderStyle(): TemplateResult { - return html` - - `; - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-iframe-card": HuiIframeCard; - } -} - -customElements.define("hui-iframe-card", HuiIframeCard); +import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; + +import "../../../components/ha-card"; + +import { LovelaceCard, LovelaceConfig } from "../types"; +import { TemplateResult } from "lit-html"; + +interface Config extends LovelaceConfig { + aspect_ratio?: string; + title?: string; + url: string; +} + +export class HuiIframeCard extends LitElement implements LovelaceCard { + protected _config?: Config; + + static get properties(): PropertyDeclarations { + return { + _config: {}, + }; + } + + public getCardSize(): number { + return 1 + this.offsetHeight / 50; + } + + public setConfig(config: Config): void { + if (!config.url) { + throw new Error("URL required"); + } + + this._config = config; + } + + protected render(): TemplateResult { + if (!this._config) { + return html``; + } + + return html` + ${this.renderStyle()} + +
+ +
+
+ `; + } + + private renderStyle(): TemplateResult { + return html` + + `; + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-iframe-card": HuiIframeCard; + } +} + +customElements.define("hui-iframe-card", HuiIframeCard); diff --git a/src/panels/lovelace/cards/hui-legacy-wrapper-card.js b/src/panels/lovelace/cards/hui-legacy-wrapper-card.js index dda181d13f2d..b9903dd6979c 100644 --- a/src/panels/lovelace/cards/hui-legacy-wrapper-card.js +++ b/src/panels/lovelace/cards/hui-legacy-wrapper-card.js @@ -1,57 +1,57 @@ -import createErrorCardConfig from "../common/create-error-card-config.js"; -import computeDomain from "../../../common/entity/compute_domain.js"; - -export default class LegacyWrapperCard extends HTMLElement { - constructor(tag, domain) { - super(); - this._tag = tag.toUpperCase(); - this._domain = domain; - this._element = null; - } - - getCardSize() { - return 3; - } - - setConfig(config) { - if (!config.entity) { - throw new Error("No entity specified"); - } - - if (computeDomain(config.entity) !== this._domain) { - throw new Error( - `Specified entity needs to be of domain ${this._domain}.` - ); - } - - this._config = config; - } - - set hass(hass) { - const entityId = this._config.entity; - - if (entityId in hass.states) { - this._ensureElement(this._tag); - this.lastChild.hass = hass; - this.lastChild.stateObj = hass.states[entityId]; - } else { - this._ensureElement("HUI-ERROR-CARD"); - this.lastChild.setConfig( - createErrorCardConfig( - `No state available for ${entityId}`, - this._config - ) - ); - } - } - - _ensureElement(tag) { - if (this.lastChild && this.lastChild.tagName === tag) return; - - if (this.lastChild) { - this.removeChild(this.lastChild); - } - - this.appendChild(document.createElement(tag)); - } -} +import createErrorCardConfig from "../common/create-error-card-config"; +import computeDomain from "../../../common/entity/compute_domain"; + +export default class LegacyWrapperCard extends HTMLElement { + constructor(tag, domain) { + super(); + this._tag = tag.toUpperCase(); + this._domain = domain; + this._element = null; + } + + getCardSize() { + return 3; + } + + setConfig(config) { + if (!config.entity) { + throw new Error("No entity specified"); + } + + if (computeDomain(config.entity) !== this._domain) { + throw new Error( + `Specified entity needs to be of domain ${this._domain}.` + ); + } + + this._config = config; + } + + set hass(hass) { + const entityId = this._config.entity; + + if (entityId in hass.states) { + this._ensureElement(this._tag); + this.lastChild.hass = hass; + this.lastChild.stateObj = hass.states[entityId]; + } else { + this._ensureElement("HUI-ERROR-CARD"); + this.lastChild.setConfig( + createErrorCardConfig( + `No state available for ${entityId}`, + this._config + ) + ); + } + } + + _ensureElement(tag) { + if (this.lastChild && this.lastChild.tagName === tag) return; + + if (this.lastChild) { + this.removeChild(this.lastChild); + } + + this.appendChild(document.createElement(tag)); + } +} diff --git a/src/panels/lovelace/cards/hui-light-card.ts b/src/panels/lovelace/cards/hui-light-card.ts index cacacc7efcb7..53f8dfdee0a4 100644 --- a/src/panels/lovelace/cards/hui-light-card.ts +++ b/src/panels/lovelace/cards/hui-light-card.ts @@ -1,327 +1,327 @@ -import { - html, - LitElement, - PropertyValues, - PropertyDeclarations, -} from "@polymer/lit-element"; -import { fireEvent } from "../../../common/dom/fire_event.js"; -import { styleMap } from "lit-html/directives/styleMap.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import stateIcon from "../../../common/entity/state_icon.js"; -import { jQuery } from "../../../resources/jquery"; - -import "../../../components/ha-card.js"; -import "../../../components/ha-icon.js"; -import { roundSliderStyle } from "../../../resources/jquery.roundslider"; - -import { HomeAssistant, LightEntity } from "../../../types.js"; -import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; -import { LovelaceCard, LovelaceConfig } from "../types.js"; -import { longPress } from "../common/directives/long-press-directive"; -import { TemplateResult } from "lit-html"; - -const lightConfig = { - radius: 80, - step: 1, - circleShape: "pie", - startAngle: 315, - width: 5, - min: 1, - max: 100, - sliderType: "min-range", - lineCap: "round", - handleSize: "+12", - showTooltip: false, -}; - -interface Config extends LovelaceConfig { - entity: string; - name?: string; -} - -export class HuiLightCard extends hassLocalizeLitMixin(LitElement) - implements LovelaceCard { - public hass?: HomeAssistant; - private _config?: Config; - private _brightnessTimout?: number; - - static get properties(): PropertyDeclarations { - return { - hass: {}, - _config: {}, - }; - } - - public getCardSize(): number { - return 2; - } - - public setConfig(config: Config): void { - if (!config.entity || config.entity.split(".")[0] !== "light") { - throw new Error("Specify an entity from within the light domain."); - } - - this._config = config; - } - - protected render(): TemplateResult { - if (!this.hass || !this._config) { - return html``; - } - - const stateObj = this.hass.states[this._config!.entity] as LightEntity; - - return html` - ${this.renderStyle()} - - ${ - !stateObj - ? html` -
Entity not available: ${ - this._config.entity - }
` - : html` -
-
-
- -
-
${this._config.name || - computeStateName(stateObj)}
-
-
- ` - } - -
- `; - } - - protected shouldUpdate(changedProps: PropertyValues): boolean { - if (changedProps.get("hass")) { - return ( - (changedProps.get("hass") as any).states[this._config!.entity] !== - this.hass!.states[this._config!.entity] - ); - } - return (changedProps as unknown) as boolean; - } - - protected firstUpdated(): void { - const brightness = this.hass!.states[this._config!.entity].attributes - .brightness; - jQuery("#light", this.shadowRoot).roundSlider({ - ...lightConfig, - change: (value) => this._setBrightness(value), - drag: (value) => this._dragEvent(value), - start: () => this._showBrightness(), - stop: () => this._hideBrightness(), - }); - this.shadowRoot!.querySelector(".brightness")!.innerHTML = - (Math.round((brightness / 254) * 100) || 0) + "%"; - } - - protected updated(): void { - const attrs = this.hass!.states[this._config!.entity].attributes; - - jQuery("#light", this.shadowRoot).roundSlider({ - value: Math.round((attrs.brightness / 254) * 100) || 0, - }); - } - - private renderStyle(): TemplateResult { - return html` - ${roundSliderStyle} - - `; - } - - private _dragEvent(e: any): void { - this.shadowRoot!.querySelector(".brightness")!.innerHTML = e.value + "%"; - } - - private _showBrightness(): void { - clearTimeout(this._brightnessTimout); - this.shadowRoot!.querySelector(".brightness")!.classList.add( - "show_brightness" - ); - } - - private _hideBrightness(): void { - this._brightnessTimout = window.setTimeout(() => { - this.shadowRoot!.querySelector(".brightness")!.classList.remove( - "show_brightness" - ); - }, 500); - } - - private _setBrightness(e: any): void { - this.hass!.callService("light", "turn_on", { - entity_id: this._config!.entity, - brightness_pct: e.value, - }); - } - - private _computeBrightness(stateObj: LightEntity): string { - if (!stateObj.attributes.brightness) { - return ""; - } - const brightness = stateObj.attributes.brightness; - return `brightness(${(brightness + 245) / 5}%)`; - } - - private _computeColor(stateObj: LightEntity): string { - if (!stateObj.attributes.hs_color) { - return ""; - } - const [hue, sat] = stateObj.attributes.hs_color; - if (sat <= 10) { - return ""; - } - return `hsl(${hue}, 100%, ${100 - sat / 2}%)`; - } - - private _handleClick(hold: boolean): void { - const entityId = this._config!.entity; - - if (hold) { - fireEvent(this, "hass-more-info", { - entityId, - }); - return; - } - - this.hass!.callService("light", "toggle", { - entity_id: entityId, - }); - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-light-card": HuiLightCard; - } -} - -customElements.define("hui-light-card", HuiLightCard); +import { + html, + LitElement, + PropertyValues, + PropertyDeclarations, +} from "@polymer/lit-element"; +import { fireEvent } from "../../../common/dom/fire_event"; +import { styleMap } from "lit-html/directives/styleMap"; +import computeStateName from "../../../common/entity/compute_state_name"; +import stateIcon from "../../../common/entity/state_icon"; +import { jQuery } from "../../../resources/jquery"; + +import "../../../components/ha-card"; +import "../../../components/ha-icon"; +import { roundSliderStyle } from "../../../resources/jquery.roundslider"; + +import { HomeAssistant, LightEntity } from "../../../types"; +import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; +import { LovelaceCard, LovelaceConfig } from "../types"; +import { longPress } from "../common/directives/long-press-directive"; +import { TemplateResult } from "lit-html"; + +const lightConfig = { + radius: 80, + step: 1, + circleShape: "pie", + startAngle: 315, + width: 5, + min: 1, + max: 100, + sliderType: "min-range", + lineCap: "round", + handleSize: "+12", + showTooltip: false, +}; + +interface Config extends LovelaceConfig { + entity: string; + name?: string; +} + +export class HuiLightCard extends hassLocalizeLitMixin(LitElement) + implements LovelaceCard { + public hass?: HomeAssistant; + private _config?: Config; + private _brightnessTimout?: number; + + static get properties(): PropertyDeclarations { + return { + hass: {}, + _config: {}, + }; + } + + public getCardSize(): number { + return 2; + } + + public setConfig(config: Config): void { + if (!config.entity || config.entity.split(".")[0] !== "light") { + throw new Error("Specify an entity from within the light domain."); + } + + this._config = config; + } + + protected render(): TemplateResult { + if (!this.hass || !this._config) { + return html``; + } + + const stateObj = this.hass.states[this._config!.entity] as LightEntity; + + return html` + ${this.renderStyle()} + + ${ + !stateObj + ? html` +
Entity not available: ${ + this._config.entity + }
` + : html` +
+
+
+ +
+
${this._config.name || + computeStateName(stateObj)}
+
+
+ ` + } + +
+ `; + } + + protected shouldUpdate(changedProps: PropertyValues): boolean { + if (changedProps.get("hass")) { + return ( + (changedProps.get("hass") as any).states[this._config!.entity] !== + this.hass!.states[this._config!.entity] + ); + } + return (changedProps as unknown) as boolean; + } + + protected firstUpdated(): void { + const brightness = this.hass!.states[this._config!.entity].attributes + .brightness; + jQuery("#light", this.shadowRoot).roundSlider({ + ...lightConfig, + change: (value) => this._setBrightness(value), + drag: (value) => this._dragEvent(value), + start: () => this._showBrightness(), + stop: () => this._hideBrightness(), + }); + this.shadowRoot!.querySelector(".brightness")!.innerHTML = + (Math.round((brightness / 254) * 100) || 0) + "%"; + } + + protected updated(): void { + const attrs = this.hass!.states[this._config!.entity].attributes; + + jQuery("#light", this.shadowRoot).roundSlider({ + value: Math.round((attrs.brightness / 254) * 100) || 0, + }); + } + + private renderStyle(): TemplateResult { + return html` + ${roundSliderStyle} + + `; + } + + private _dragEvent(e: any): void { + this.shadowRoot!.querySelector(".brightness")!.innerHTML = e.value + "%"; + } + + private _showBrightness(): void { + clearTimeout(this._brightnessTimout); + this.shadowRoot!.querySelector(".brightness")!.classList.add( + "show_brightness" + ); + } + + private _hideBrightness(): void { + this._brightnessTimout = window.setTimeout(() => { + this.shadowRoot!.querySelector(".brightness")!.classList.remove( + "show_brightness" + ); + }, 500); + } + + private _setBrightness(e: any): void { + this.hass!.callService("light", "turn_on", { + entity_id: this._config!.entity, + brightness_pct: e.value, + }); + } + + private _computeBrightness(stateObj: LightEntity): string { + if (!stateObj.attributes.brightness) { + return ""; + } + const brightness = stateObj.attributes.brightness; + return `brightness(${(brightness + 245) / 5}%)`; + } + + private _computeColor(stateObj: LightEntity): string { + if (!stateObj.attributes.hs_color) { + return ""; + } + const [hue, sat] = stateObj.attributes.hs_color; + if (sat <= 10) { + return ""; + } + return `hsl(${hue}, 100%, ${100 - sat / 2}%)`; + } + + private _handleClick(hold: boolean): void { + const entityId = this._config!.entity; + + if (hold) { + fireEvent(this, "hass-more-info", { + entityId, + }); + return; + } + + this.hass!.callService("light", "toggle", { + entity_id: entityId, + }); + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-light-card": HuiLightCard; + } +} + +customElements.define("hui-light-card", HuiLightCard); diff --git a/src/panels/lovelace/cards/hui-map-card.js b/src/panels/lovelace/cards/hui-map-card.js index 4bc17097f75b..4f213b88a529 100644 --- a/src/panels/lovelace/cards/hui-map-card.js +++ b/src/panels/lovelace/cards/hui-map-card.js @@ -1,305 +1,305 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import Leaflet from "leaflet"; - -import "../../map/ha-entity-marker.js"; - -import setupLeafletMap from "../../../common/dom/setup-leaflet-map.js"; -import processConfigEntities from "../common/process-config-entities.js"; -import computeStateDomain from "../../../common/entity/compute_state_domain.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import debounce from "../../../common/util/debounce.js"; - -Leaflet.Icon.Default.imagePath = "/static/images/leaflet"; - -class HuiMapCard extends PolymerElement { - static get template() { - return html` - - - -
-
- -
-
- - `; - } - - static get properties() { - return { - hass: { - type: Object, - observer: "_drawEntities", - }, - _config: Object, - isPanel: { - type: Boolean, - reflectToAttribute: true, - }, - }; - } - - constructor() { - super(); - this._debouncedResizeListener = debounce(this._resetMap.bind(this), 100); - } - - ready() { - super.ready(); - - if (!this._config || this.isPanel) { - return; - } - - this.$.root.style.paddingTop = this._config.aspect_ratio || "100%"; - } - - setConfig(config) { - if (!config) { - throw new Error("Error in card configuration."); - } - - this._configEntities = processConfigEntities(config.entities); - this._config = config; - } - - getCardSize() { - let ar = this._config.aspect_ratio || "100%"; - ar = ar.substr(0, ar.length - 1); - return 1 + Math.floor(ar / 25) || 3; - } - - connectedCallback() { - super.connectedCallback(); - - // Observe changes to map size and invalidate to prevent broken rendering - // Uses ResizeObserver in Chrome, otherwise window resize event - if (typeof ResizeObserver === "function") { - this._resizeObserver = new ResizeObserver(() => - this._debouncedResizeListener() - ); - this._resizeObserver.observe(this.$.map); - } else { - window.addEventListener("resize", this._debouncedResizeListener); - } - - this._map = setupLeafletMap(this.$.map); - this._drawEntities(this.hass); - - setTimeout(() => { - this._resetMap(); - this._fitMap(); - }, 1); - } - - disconnectedCallback() { - super.disconnectedCallback(); - - if (this._map) { - this._map.remove(); - } - - if (this._resizeObserver) { - this._resizeObserver.unobserve(this.$.map); - } else { - window.removeEventListener("resize", this._debouncedResizeListener); - } - } - - _resetMap() { - if (!this._map) { - return; - } - this._map.invalidateSize(); - } - - _fitMap() { - const zoom = this._config.default_zoom; - if (this._mapItems.length === 0) { - this._map.setView( - new Leaflet.LatLng( - this.hass.config.latitude, - this.hass.config.longitude - ), - zoom || 14 - ); - return; - } - - const bounds = new Leaflet.latLngBounds( - this._mapItems.map((item) => item.getLatLng()) - ); - this._map.fitBounds(bounds.pad(0.5)); - - if (zoom && this._map.getZoom() > zoom) { - this._map.setZoom(zoom); - } - } - - _drawEntities(hass) { - const map = this._map; - if (!map) { - return; - } - - if (this._mapItems) { - this._mapItems.forEach((marker) => marker.remove()); - } - const mapItems = (this._mapItems = []); - - this._configEntities.forEach((entity) => { - const entityId = entity.entity; - if (!(entityId in hass.states)) { - return; - } - const stateObj = hass.states[entityId]; - const title = computeStateName(stateObj); - const { - latitude, - longitude, - passive, - icon, - radius, - entity_picture: entityPicture, - gps_accuracy: gpsAccuracy, - } = stateObj.attributes; - - if (!(latitude && longitude)) { - return; - } - - let markerIcon; - let iconHTML; - let el; - - if (computeStateDomain(stateObj) === "zone") { - // DRAW ZONE - if (passive) return; - - // create icon - if (icon) { - el = document.createElement("ha-icon"); - el.setAttribute("icon", icon); - iconHTML = el.outerHTML; - } else { - iconHTML = title; - } - - markerIcon = Leaflet.divIcon({ - html: iconHTML, - iconSize: [24, 24], - className: "", - }); - - // create market with the icon - mapItems.push( - Leaflet.marker([latitude, longitude], { - icon: markerIcon, - interactive: false, - title: title, - }).addTo(map) - ); - - // create circle around it - mapItems.push( - Leaflet.circle([latitude, longitude], { - interactive: false, - color: "#FF9800", - radius: radius, - }).addTo(map) - ); - - return; - } - - // DRAW ENTITY - // create icon - const entityName = title - .split(" ") - .map((part) => part[0]) - .join("") - .substr(0, 3); - - el = document.createElement("ha-entity-marker"); - el.setAttribute("entity-id", entityId); - el.setAttribute("entity-name", entityName); - el.setAttribute("entity-picture", entityPicture || ""); - - /* Leaflet clones this element before adding it to the map. This messes up - our Polymer object and we can't pass data through. Thus we hack like this. */ - markerIcon = Leaflet.divIcon({ - html: el.outerHTML, - iconSize: [48, 48], - className: "", - }); - - // create market with the icon - mapItems.push( - Leaflet.marker([latitude, longitude], { - icon: markerIcon, - title: computeStateName(stateObj), - }).addTo(map) - ); - - // create circle around if entity has accuracy - if (gpsAccuracy) { - mapItems.push( - Leaflet.circle([latitude, longitude], { - interactive: false, - color: "#0288D1", - radius: gpsAccuracy, - }).addTo(map) - ); - } - }); - } -} - -customElements.define("hui-map-card", HuiMapCard); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/paper-icon-button/paper-icon-button"; +import Leaflet from "leaflet"; + +import "../../map/ha-entity-marker"; + +import setupLeafletMap from "../../../common/dom/setup-leaflet-map"; +import processConfigEntities from "../common/process-config-entities"; +import computeStateDomain from "../../../common/entity/compute_state_domain"; +import computeStateName from "../../../common/entity/compute_state_name"; +import debounce from "../../../common/util/debounce"; + +Leaflet.Icon.Default.imagePath = "/static/images/leaflet"; + +class HuiMapCard extends PolymerElement { + static get template() { + return html` + + + +
+
+ +
+
+ + `; + } + + static get properties() { + return { + hass: { + type: Object, + observer: "_drawEntities", + }, + _config: Object, + isPanel: { + type: Boolean, + reflectToAttribute: true, + }, + }; + } + + constructor() { + super(); + this._debouncedResizeListener = debounce(this._resetMap.bind(this), 100); + } + + ready() { + super.ready(); + + if (!this._config || this.isPanel) { + return; + } + + this.$.root.style.paddingTop = this._config.aspect_ratio || "100%"; + } + + setConfig(config) { + if (!config) { + throw new Error("Error in card configuration."); + } + + this._configEntities = processConfigEntities(config.entities); + this._config = config; + } + + getCardSize() { + let ar = this._config.aspect_ratio || "100%"; + ar = ar.substr(0, ar.length - 1); + return 1 + Math.floor(ar / 25) || 3; + } + + connectedCallback() { + super.connectedCallback(); + + // Observe changes to map size and invalidate to prevent broken rendering + // Uses ResizeObserver in Chrome, otherwise window resize event + if (typeof ResizeObserver === "function") { + this._resizeObserver = new ResizeObserver(() => + this._debouncedResizeListener() + ); + this._resizeObserver.observe(this.$.map); + } else { + window.addEventListener("resize", this._debouncedResizeListener); + } + + this._map = setupLeafletMap(this.$.map); + this._drawEntities(this.hass); + + setTimeout(() => { + this._resetMap(); + this._fitMap(); + }, 1); + } + + disconnectedCallback() { + super.disconnectedCallback(); + + if (this._map) { + this._map.remove(); + } + + if (this._resizeObserver) { + this._resizeObserver.unobserve(this.$.map); + } else { + window.removeEventListener("resize", this._debouncedResizeListener); + } + } + + _resetMap() { + if (!this._map) { + return; + } + this._map.invalidateSize(); + } + + _fitMap() { + const zoom = this._config.default_zoom; + if (this._mapItems.length === 0) { + this._map.setView( + new Leaflet.LatLng( + this.hass.config.latitude, + this.hass.config.longitude + ), + zoom || 14 + ); + return; + } + + const bounds = new Leaflet.latLngBounds( + this._mapItems.map((item) => item.getLatLng()) + ); + this._map.fitBounds(bounds.pad(0.5)); + + if (zoom && this._map.getZoom() > zoom) { + this._map.setZoom(zoom); + } + } + + _drawEntities(hass) { + const map = this._map; + if (!map) { + return; + } + + if (this._mapItems) { + this._mapItems.forEach((marker) => marker.remove()); + } + const mapItems = (this._mapItems = []); + + this._configEntities.forEach((entity) => { + const entityId = entity.entity; + if (!(entityId in hass.states)) { + return; + } + const stateObj = hass.states[entityId]; + const title = computeStateName(stateObj); + const { + latitude, + longitude, + passive, + icon, + radius, + entity_picture: entityPicture, + gps_accuracy: gpsAccuracy, + } = stateObj.attributes; + + if (!(latitude && longitude)) { + return; + } + + let markerIcon; + let iconHTML; + let el; + + if (computeStateDomain(stateObj) === "zone") { + // DRAW ZONE + if (passive) return; + + // create icon + if (icon) { + el = document.createElement("ha-icon"); + el.setAttribute("icon", icon); + iconHTML = el.outerHTML; + } else { + iconHTML = title; + } + + markerIcon = Leaflet.divIcon({ + html: iconHTML, + iconSize: [24, 24], + className: "", + }); + + // create market with the icon + mapItems.push( + Leaflet.marker([latitude, longitude], { + icon: markerIcon, + interactive: false, + title: title, + }).addTo(map) + ); + + // create circle around it + mapItems.push( + Leaflet.circle([latitude, longitude], { + interactive: false, + color: "#FF9800", + radius: radius, + }).addTo(map) + ); + + return; + } + + // DRAW ENTITY + // create icon + const entityName = title + .split(" ") + .map((part) => part[0]) + .join("") + .substr(0, 3); + + el = document.createElement("ha-entity-marker"); + el.setAttribute("entity-id", entityId); + el.setAttribute("entity-name", entityName); + el.setAttribute("entity-picture", entityPicture || ""); + + /* Leaflet clones this element before adding it to the map. This messes up + our Polymer object and we can't pass data through. Thus we hack like this. */ + markerIcon = Leaflet.divIcon({ + html: el.outerHTML, + iconSize: [48, 48], + className: "", + }); + + // create market with the icon + mapItems.push( + Leaflet.marker([latitude, longitude], { + icon: markerIcon, + title: computeStateName(stateObj), + }).addTo(map) + ); + + // create circle around if entity has accuracy + if (gpsAccuracy) { + mapItems.push( + Leaflet.circle([latitude, longitude], { + interactive: false, + color: "#0288D1", + radius: gpsAccuracy, + }).addTo(map) + ); + } + }); + } +} + +customElements.define("hui-map-card", HuiMapCard); diff --git a/src/panels/lovelace/cards/hui-markdown-card.ts b/src/panels/lovelace/cards/hui-markdown-card.ts index 4f24f48daa12..6c71fd904a7b 100644 --- a/src/panels/lovelace/cards/hui-markdown-card.ts +++ b/src/panels/lovelace/cards/hui-markdown-card.ts @@ -1,93 +1,93 @@ -import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; -import { classMap } from "lit-html/directives/classMap.js"; - -import "../../../components/ha-card.js"; -import "../../../components/ha-markdown.js"; - -import { LovelaceCard, LovelaceConfig } from "../types.js"; -import { TemplateResult } from "lit-html"; - -interface Config extends LovelaceConfig { - content: string; - title?: string; -} - -export class HuiMarkdownCard extends LitElement implements LovelaceCard { - private _config?: Config; - - static get properties(): PropertyDeclarations { - return { - _config: {}, - }; - } - - public getCardSize(): number { - return this._config!.content.split("\n").length; - } - - public setConfig(config: Config): void { - if (!config.content) { - throw new Error("Invalid Configuration: Content Required"); - } - - this._config = config; - } - - protected render(): TemplateResult { - if (!this._config) { - return html``; - } - - return html` - ${this.renderStyle()} - - - - `; - } - - private renderStyle(): TemplateResult { - return html` - - `; - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-markdown-card": HuiMarkdownCard; - } -} - -customElements.define("hui-markdown-card", HuiMarkdownCard); +import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; +import { classMap } from "lit-html/directives/classMap"; + +import "../../../components/ha-card"; +import "../../../components/ha-markdown"; + +import { LovelaceCard, LovelaceConfig } from "../types"; +import { TemplateResult } from "lit-html"; + +interface Config extends LovelaceConfig { + content: string; + title?: string; +} + +export class HuiMarkdownCard extends LitElement implements LovelaceCard { + private _config?: Config; + + static get properties(): PropertyDeclarations { + return { + _config: {}, + }; + } + + public getCardSize(): number { + return this._config!.content.split("\n").length; + } + + public setConfig(config: Config): void { + if (!config.content) { + throw new Error("Invalid Configuration: Content Required"); + } + + this._config = config; + } + + protected render(): TemplateResult { + if (!this._config) { + return html``; + } + + return html` + ${this.renderStyle()} + + + + `; + } + + private renderStyle(): TemplateResult { + return html` + + `; + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-markdown-card": HuiMarkdownCard; + } +} + +customElements.define("hui-markdown-card", HuiMarkdownCard); diff --git a/src/panels/lovelace/cards/hui-media-control-card.js b/src/panels/lovelace/cards/hui-media-control-card.js index 6c8dc12e0941..96ad0e75c68e 100644 --- a/src/panels/lovelace/cards/hui-media-control-card.js +++ b/src/panels/lovelace/cards/hui-media-control-card.js @@ -1,11 +1,11 @@ -import "../../../cards/ha-media_player-card.js"; - -import LegacyWrapperCard from "./hui-legacy-wrapper-card.js"; - -class HuiMediaControlCard extends LegacyWrapperCard { - constructor() { - super("ha-media_player-card", "media_player"); - } -} - -customElements.define("hui-media-control-card", HuiMediaControlCard); +import "../../../cards/ha-media_player-card"; + +import LegacyWrapperCard from "./hui-legacy-wrapper-card"; + +class HuiMediaControlCard extends LegacyWrapperCard { + constructor() { + super("ha-media_player-card", "media_player"); + } +} + +customElements.define("hui-media-control-card", HuiMediaControlCard); diff --git a/src/panels/lovelace/cards/hui-picture-card.js b/src/panels/lovelace/cards/hui-picture-card.js index 6318eb3a5bf7..881f3a46dfce 100644 --- a/src/panels/lovelace/cards/hui-picture-card.js +++ b/src/panels/lovelace/cards/hui-picture-card.js @@ -1,67 +1,67 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/ha-card.js"; - -import NavigateMixin from "../../../mixins/navigate-mixin.js"; - -/* - * @appliesMixin NavigateMixin - */ -class HuiPictureCard extends NavigateMixin(PolymerElement) { - static get template() { - return html` - - - - - - `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - }; - } - - getCardSize() { - return 3; - } - - setConfig(config) { - if (!config || !config.image) { - throw new Error("Error in card configuration."); - } - - this._config = config; - } - - _computeClickable(config) { - return config.navigation_path || config.service; - } - - _cardClicked() { - if (this._config.navigation_path) { - this.navigate(this._config.navigation_path); - } - if (this._config.service) { - const [domain, service] = this._config.service.split(".", 2); - this.hass.callService(domain, service, this._config.service_data); - } - } -} - -customElements.define("hui-picture-card", HuiPictureCard); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/ha-card"; + +import NavigateMixin from "../../../mixins/navigate-mixin"; + +/* + * @appliesMixin NavigateMixin + */ +class HuiPictureCard extends NavigateMixin(PolymerElement) { + static get template() { + return html` + + + + + + `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + }; + } + + getCardSize() { + return 3; + } + + setConfig(config) { + if (!config || !config.image) { + throw new Error("Error in card configuration."); + } + + this._config = config; + } + + _computeClickable(config) { + return config.navigation_path || config.service; + } + + _cardClicked() { + if (this._config.navigation_path) { + this.navigate(this._config.navigation_path); + } + if (this._config.service) { + const [domain, service] = this._config.service.split(".", 2); + this.hass.callService(domain, service, this._config.service_data); + } + } +} + +customElements.define("hui-picture-card", HuiPictureCard); diff --git a/src/panels/lovelace/cards/hui-picture-elements-card.ts b/src/panels/lovelace/cards/hui-picture-elements-card.ts index 0a3c7b9e1245..2251f0bb27a7 100644 --- a/src/panels/lovelace/cards/hui-picture-elements-card.ts +++ b/src/panels/lovelace/cards/hui-picture-elements-card.ts @@ -1,111 +1,111 @@ -import { html, LitElement } from "@polymer/lit-element"; -import { TemplateResult } from "lit-html"; - -import createHuiElement from "../common/create-hui-element.js"; - -import { LovelaceCard, LovelaceConfig } from "../types"; -import { HomeAssistant } from "../../../types.js"; -import { LovelaceElementConfig, LovelaceElement } from "../elements/types.js"; - -interface Config extends LovelaceConfig { - title?: string; - image: string; - elements: LovelaceElementConfig[]; -} - -class HuiPictureElementsCard extends LitElement implements LovelaceCard { - private _config?: Config; - private _hass?: HomeAssistant; - - static get properties() { - return { - _config: {}, - }; - } - - set hass(hass: HomeAssistant) { - this._hass = hass; - for (const el of this.shadowRoot!.querySelectorAll("#root > *")) { - const element = el as LovelaceElement; - element.hass = this._hass; - } - } - - public getCardSize(): number { - return 4; - } - - public setConfig(config: Config): void { - if (!config) { - throw new Error("Invalid Configuration"); - } else if (!config.image) { - throw new Error("Invalid Configuration: image required"); - } else if (!Array.isArray(config.elements)) { - throw new Error("Invalid Configuration: elements required"); - } - - this._config = config; - } - - protected render(): TemplateResult { - if (!this._config) { - return html``; - } - - return html` - ${this.renderStyle()} - -
- - ${this._config.elements.map((elementConfig: LovelaceElementConfig) => - this._createHuiElement(elementConfig) - )} -
-
- `; - } - - private renderStyle(): TemplateResult { - return html` - - `; - } - - private _createHuiElement( - elementConfig: LovelaceElementConfig - ): LovelaceElement { - const element = createHuiElement(elementConfig) as LovelaceElement; - element.hass = this._hass; - element.classList.add("element"); - - Object.keys(elementConfig.style).forEach((prop) => { - element.style.setProperty(prop, elementConfig.style[prop]); - }); - - return element; - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-picture-elements-card": HuiPictureElementsCard; - } -} - -customElements.define("hui-picture-elements-card", HuiPictureElementsCard); +import { html, LitElement } from "@polymer/lit-element"; +import { TemplateResult } from "lit-html"; + +import createHuiElement from "../common/create-hui-element"; + +import { LovelaceCard, LovelaceConfig } from "../types"; +import { HomeAssistant } from "../../../types"; +import { LovelaceElementConfig, LovelaceElement } from "../elements/types"; + +interface Config extends LovelaceConfig { + title?: string; + image: string; + elements: LovelaceElementConfig[]; +} + +class HuiPictureElementsCard extends LitElement implements LovelaceCard { + private _config?: Config; + private _hass?: HomeAssistant; + + static get properties() { + return { + _config: {}, + }; + } + + set hass(hass: HomeAssistant) { + this._hass = hass; + for (const el of this.shadowRoot!.querySelectorAll("#root > *")) { + const element = el as LovelaceElement; + element.hass = this._hass; + } + } + + public getCardSize(): number { + return 4; + } + + public setConfig(config: Config): void { + if (!config) { + throw new Error("Invalid Configuration"); + } else if (!config.image) { + throw new Error("Invalid Configuration: image required"); + } else if (!Array.isArray(config.elements)) { + throw new Error("Invalid Configuration: elements required"); + } + + this._config = config; + } + + protected render(): TemplateResult { + if (!this._config) { + return html``; + } + + return html` + ${this.renderStyle()} + +
+ + ${this._config.elements.map((elementConfig: LovelaceElementConfig) => + this._createHuiElement(elementConfig) + )} +
+
+ `; + } + + private renderStyle(): TemplateResult { + return html` + + `; + } + + private _createHuiElement( + elementConfig: LovelaceElementConfig + ): LovelaceElement { + const element = createHuiElement(elementConfig) as LovelaceElement; + element.hass = this._hass; + element.classList.add("element"); + + Object.keys(elementConfig.style).forEach((prop) => { + element.style.setProperty(prop, elementConfig.style[prop]); + }); + + return element; + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-picture-elements-card": HuiPictureElementsCard; + } +} + +customElements.define("hui-picture-elements-card", HuiPictureElementsCard); diff --git a/src/panels/lovelace/cards/hui-picture-entity-card.js b/src/panels/lovelace/cards/hui-picture-entity-card.js index cc1a432b965f..77898ab8cb1d 100644 --- a/src/panels/lovelace/cards/hui-picture-entity-card.js +++ b/src/panels/lovelace/cards/hui-picture-entity-card.js @@ -1,201 +1,201 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/ha-card.js"; -import "../components/hui-image.js"; - -import computeDomain from "../../../common/entity/compute_domain.js"; -import computeStateDisplay from "../../../common/entity/compute_state_display.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import toggleEntity from "../common/entity/toggle-entity.js"; - -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; -import { longPressBind } from "../common/directives/long-press-directive"; - -const UNAVAILABLE = "Unavailable"; - -/* - * @appliesMixin LocalizeMixin - * @appliesMixin EventsMixin - */ -class HuiPictureEntityCard extends EventsMixin(LocalizeMixin(PolymerElement)) { - static get template() { - return html` - - - - - - - - - `; - } - - static get properties() { - return { - hass: { - type: Object, - observer: "_hassChanged", - }, - _config: Object, - _name: String, - _state: String, - }; - } - - getCardSize() { - return 3; - } - - setConfig(config) { - if (!config || !config.entity) { - throw new Error("Error in card configuration."); - } - - this._entityDomain = computeDomain(config.entity); - if ( - this._entityDomain !== "camera" && - (!config.image && !config.state_image && !config.camera_image) - ) { - throw new Error("No image source configured."); - } - - this._config = config; - } - - ready() { - super.ready(); - const card = this.shadowRoot.querySelector("#card"); - longPressBind(card); - card.addEventListener("ha-click", () => this._cardClicked(false)); - card.addEventListener("ha-hold", () => this._cardClicked(true)); - } - - _hassChanged(hass) { - const config = this._config; - const entityId = config.entity; - const stateObj = hass.states[entityId]; - - // Nothing changed - if ( - (!stateObj && this._oldState === UNAVAILABLE) || - (stateObj && stateObj.state === this._oldState) - ) { - return; - } - - let name; - let state; - let stateLabel; - let available; - - if (stateObj) { - name = config.name || computeStateName(stateObj); - state = stateObj.state; - stateLabel = computeStateDisplay(this.localize, stateObj); - available = true; - } else { - name = config.name || entityId; - state = UNAVAILABLE; - stateLabel = this.localize("state.default.unavailable"); - available = false; - } - - this.setProperties({ - _name: name, - _state: stateLabel, - _oldState: state, - }); - - this.$.card.classList.toggle("canInteract", available); - } - - _showNameAndState(config) { - return config.show_name !== false && config.show_state !== false; - } - - _showName(config) { - return config.show_name !== false && config.show_state === false; - } - - _showState(config) { - return config.show_name === false && config.show_state !== false; - } - - _cardClicked(hold) { - const config = this._config; - const entityId = config.entity; - - if (!(entityId in this.hass.states)) return; - - const action = hold ? config.hold_action : config.tap_action || "more-info"; - - switch (action) { - case "toggle": - toggleEntity(this.hass, entityId); - break; - case "more-info": - this.fire("hass-more-info", { entityId }); - break; - default: - } - } - - _getCameraImage(config) { - return this._entityDomain === "camera" - ? config.entity - : config.camera_image; - } -} - -customElements.define("hui-picture-entity-card", HuiPictureEntityCard); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/ha-card"; +import "../components/hui-image"; + +import computeDomain from "../../../common/entity/compute_domain"; +import computeStateDisplay from "../../../common/entity/compute_state_display"; +import computeStateName from "../../../common/entity/compute_state_name"; +import toggleEntity from "../common/entity/toggle-entity"; + +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; +import { longPressBind } from "../common/directives/long-press-directive"; + +const UNAVAILABLE = "Unavailable"; + +/* + * @appliesMixin LocalizeMixin + * @appliesMixin EventsMixin + */ +class HuiPictureEntityCard extends EventsMixin(LocalizeMixin(PolymerElement)) { + static get template() { + return html` + + + + + + + + + `; + } + + static get properties() { + return { + hass: { + type: Object, + observer: "_hassChanged", + }, + _config: Object, + _name: String, + _state: String, + }; + } + + getCardSize() { + return 3; + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error("Error in card configuration."); + } + + this._entityDomain = computeDomain(config.entity); + if ( + this._entityDomain !== "camera" && + (!config.image && !config.state_image && !config.camera_image) + ) { + throw new Error("No image source configured."); + } + + this._config = config; + } + + ready() { + super.ready(); + const card = this.shadowRoot.querySelector("#card"); + longPressBind(card); + card.addEventListener("ha-click", () => this._cardClicked(false)); + card.addEventListener("ha-hold", () => this._cardClicked(true)); + } + + _hassChanged(hass) { + const config = this._config; + const entityId = config.entity; + const stateObj = hass.states[entityId]; + + // Nothing changed + if ( + (!stateObj && this._oldState === UNAVAILABLE) || + (stateObj && stateObj.state === this._oldState) + ) { + return; + } + + let name; + let state; + let stateLabel; + let available; + + if (stateObj) { + name = config.name || computeStateName(stateObj); + state = stateObj.state; + stateLabel = computeStateDisplay(this.localize, stateObj); + available = true; + } else { + name = config.name || entityId; + state = UNAVAILABLE; + stateLabel = this.localize("state.default.unavailable"); + available = false; + } + + this.setProperties({ + _name: name, + _state: stateLabel, + _oldState: state, + }); + + this.$.card.classList.toggle("canInteract", available); + } + + _showNameAndState(config) { + return config.show_name !== false && config.show_state !== false; + } + + _showName(config) { + return config.show_name !== false && config.show_state === false; + } + + _showState(config) { + return config.show_name === false && config.show_state !== false; + } + + _cardClicked(hold) { + const config = this._config; + const entityId = config.entity; + + if (!(entityId in this.hass.states)) return; + + const action = hold ? config.hold_action : config.tap_action || "more-info"; + + switch (action) { + case "toggle": + toggleEntity(this.hass, entityId); + break; + case "more-info": + this.fire("hass-more-info", { entityId }); + break; + default: + } + } + + _getCameraImage(config) { + return this._entityDomain === "camera" + ? config.entity + : config.camera_image; + } +} + +customElements.define("hui-picture-entity-card", HuiPictureEntityCard); diff --git a/src/panels/lovelace/cards/hui-picture-glance-card.js b/src/panels/lovelace/cards/hui-picture-glance-card.js index 727d44b4e31f..0b7783a3c806 100644 --- a/src/panels/lovelace/cards/hui-picture-glance-card.js +++ b/src/panels/lovelace/cards/hui-picture-glance-card.js @@ -1,195 +1,195 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/ha-card.js"; -import "../../../components/ha-icon.js"; -import "../components/hui-image.js"; - -import computeStateDisplay from "../../../common/entity/compute_state_display.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import { DOMAINS_TOGGLE } from "../../../common/const.js"; -import stateIcon from "../../../common/entity/state_icon.js"; -import toggleEntity from "../common/entity/toggle-entity.js"; -import processConfigEntities from "../common/process-config-entities"; - -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; -import NavigateMixin from "../../../mixins/navigate-mixin.js"; -import computeDomain from "../../../common/entity/compute_domain"; - -const STATES_OFF = new Set(["closed", "locked", "not_home", "off"]); - -/* - * @appliesMixin EventsMixin - * @appliesMixin LocalizeMixin - * @appliesMixin NavigateMixin - */ -class HuiPictureGlanceCard extends NavigateMixin( - LocalizeMixin(EventsMixin(PolymerElement)) -) { - static get template() { - return html` - - - - -
- -
- -
-
- -
-
-
- `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - _entitiesDialog: Array, - _entitiesToggle: Array, - }; - } - - getCardSize() { - return 3; - } - - setConfig(config) { - if ( - !config || - !config.entities || - !Array.isArray(config.entities) || - !(config.image || config.camera_image || config.state_image) || - (config.state_image && !config.entity) - ) { - throw new Error("Invalid card configuration"); - } - const entities = processConfigEntities(config.entities); - const dialog = []; - const toggle = []; - - entities.forEach((item) => { - if ( - config.force_dialog || - !DOMAINS_TOGGLE.has(computeDomain(item.entity)) - ) { - dialog.push(item); - } else { - toggle.push(item); - } - }); - this.setProperties({ - _config: config, - _entitiesDialog: dialog, - _entitiesToggle: toggle, - }); - } - - _computeVisible(collection, states) { - return collection.filter((el) => el.entity in states); - } - - _computeIcon(item, states) { - return item.icon || stateIcon(states[item.entity]); - } - - _computeButtonClass(entityId, states) { - return STATES_OFF.has(states[entityId].state) ? "" : "state-on"; - } - - _computeTooltip(entityId, states) { - return `${computeStateName(states[entityId])}: ${computeStateDisplay( - this.localize, - states[entityId] - )}`; - } - - _computeImageClass(config) { - return config.navigation_path || config.camera_image ? "clickable" : ""; - } - - _openDialog(ev) { - this.fire("hass-more-info", { entityId: ev.model.item.entity }); - } - - _callService(ev) { - toggleEntity(this.hass, ev.model.item.entity); - } - - _handleImageClick() { - if (this._config.navigation_path) { - this.navigate(this._config.navigation_path); - return; - } - - if (this._config.camera_image) { - this.fire("hass-more-info", { entityId: this._config.camera_image }); - } - } -} -customElements.define("hui-picture-glance-card", HuiPictureGlanceCard); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/ha-card"; +import "../../../components/ha-icon"; +import "../components/hui-image"; + +import computeStateDisplay from "../../../common/entity/compute_state_display"; +import computeStateName from "../../../common/entity/compute_state_name"; +import { DOMAINS_TOGGLE } from "../../../common/const"; +import stateIcon from "../../../common/entity/state_icon"; +import toggleEntity from "../common/entity/toggle-entity"; +import processConfigEntities from "../common/process-config-entities"; + +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; +import NavigateMixin from "../../../mixins/navigate-mixin"; +import computeDomain from "../../../common/entity/compute_domain"; + +const STATES_OFF = new Set(["closed", "locked", "not_home", "off"]); + +/* + * @appliesMixin EventsMixin + * @appliesMixin LocalizeMixin + * @appliesMixin NavigateMixin + */ +class HuiPictureGlanceCard extends NavigateMixin( + LocalizeMixin(EventsMixin(PolymerElement)) +) { + static get template() { + return html` + + + + +
+ +
+ +
+
+ +
+
+
+ `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _entitiesDialog: Array, + _entitiesToggle: Array, + }; + } + + getCardSize() { + return 3; + } + + setConfig(config) { + if ( + !config || + !config.entities || + !Array.isArray(config.entities) || + !(config.image || config.camera_image || config.state_image) || + (config.state_image && !config.entity) + ) { + throw new Error("Invalid card configuration"); + } + const entities = processConfigEntities(config.entities); + const dialog = []; + const toggle = []; + + entities.forEach((item) => { + if ( + config.force_dialog || + !DOMAINS_TOGGLE.has(computeDomain(item.entity)) + ) { + dialog.push(item); + } else { + toggle.push(item); + } + }); + this.setProperties({ + _config: config, + _entitiesDialog: dialog, + _entitiesToggle: toggle, + }); + } + + _computeVisible(collection, states) { + return collection.filter((el) => el.entity in states); + } + + _computeIcon(item, states) { + return item.icon || stateIcon(states[item.entity]); + } + + _computeButtonClass(entityId, states) { + return STATES_OFF.has(states[entityId].state) ? "" : "state-on"; + } + + _computeTooltip(entityId, states) { + return `${computeStateName(states[entityId])}: ${computeStateDisplay( + this.localize, + states[entityId] + )}`; + } + + _computeImageClass(config) { + return config.navigation_path || config.camera_image ? "clickable" : ""; + } + + _openDialog(ev) { + this.fire("hass-more-info", { entityId: ev.model.item.entity }); + } + + _callService(ev) { + toggleEntity(this.hass, ev.model.item.entity); + } + + _handleImageClick() { + if (this._config.navigation_path) { + this.navigate(this._config.navigation_path); + return; + } + + if (this._config.camera_image) { + this.fire("hass-more-info", { entityId: this._config.camera_image }); + } + } +} +customElements.define("hui-picture-glance-card", HuiPictureGlanceCard); diff --git a/src/panels/lovelace/cards/hui-plant-status-card.js b/src/panels/lovelace/cards/hui-plant-status-card.js index 1b82cf190d06..500bc61df902 100644 --- a/src/panels/lovelace/cards/hui-plant-status-card.js +++ b/src/panels/lovelace/cards/hui-plant-status-card.js @@ -1,11 +1,11 @@ -import "../../../cards/ha-plant-card.js"; - -import LegacyWrapperCard from "./hui-legacy-wrapper-card.js"; - -class HuiPlantStatusCard extends LegacyWrapperCard { - constructor() { - super("ha-plant-card", "plant"); - } -} - -customElements.define("hui-plant-status-card", HuiPlantStatusCard); +import "../../../cards/ha-plant-card"; + +import LegacyWrapperCard from "./hui-legacy-wrapper-card"; + +class HuiPlantStatusCard extends LegacyWrapperCard { + constructor() { + super("ha-plant-card", "plant"); + } +} + +customElements.define("hui-plant-status-card", HuiPlantStatusCard); diff --git a/src/panels/lovelace/cards/hui-sensor-card.js b/src/panels/lovelace/cards/hui-sensor-card.js index ec11bb7ac09e..ea25043f30b0 100644 --- a/src/panels/lovelace/cards/hui-sensor-card.js +++ b/src/panels/lovelace/cards/hui-sensor-card.js @@ -1,292 +1,292 @@ -import { LitElement, html, svg } from "@polymer/lit-element"; - -import "../../../components/ha-card.js"; -import "../../../components/ha-icon.js"; - -import computeStateName from "../../../common/entity/compute_state_name.js"; -import stateIcon from "../../../common/entity/state_icon.js"; - -import EventsMixin from "../../../mixins/events-mixin.js"; - -class HuiSensorCard extends EventsMixin(LitElement) { - set hass(hass) { - this._hass = hass; - const entity = hass.states[this._config.entity]; - if (entity && this._entity !== entity) { - this._entity = entity; - if ( - this._config.graph !== "none" && - entity.attributes.unit_of_measurement - ) { - this._getHistory(); - } - } - } - - static get properties() { - return { - _hass: {}, - _config: {}, - _entity: {}, - _line: String, - }; - } - - setConfig(config) { - if (!config.entity || config.entity.split(".")[0] !== "sensor") { - throw new Error("Specify an entity from within the sensor domain."); - } - - const cardConfig = { - icon: false, - hours_to_show: 24, - accuracy: 10, - height: 100, - line_width: 5, - line_color: "var(--accent-color)", - ...config, - }; - cardConfig.hours_to_show = Number(cardConfig.hours_to_show); - cardConfig.accuracy = Number(cardConfig.accuracy); - cardConfig.height = Number(cardConfig.height); - cardConfig.line_width = Number(cardConfig.line_width); - - this._config = cardConfig; - } - - shouldUpdate(changedProps) { - const change = changedProps.has("_entity") || changedProps.has("_line"); - return change; - } - - render({ _config, _entity, _line } = this) { - return html` - ${this._style()} - -
-
- -
-
- ${this._computeName(_entity)} -
-
-
- ${_entity.state} - ${this._computeUom(_entity)} -
-
-
- ${ - _line - ? svg` - - - ` - : "" - } -
-
-
`; - } - - _handleClick() { - this.fire("hass-more-info", { entityId: this._config.entity }); - } - - _computeIcon(item) { - return this._config.icon || stateIcon(item); - } - - _computeName(item) { - return this._config.name || computeStateName(item); - } - - _computeUom(item) { - return this._config.unit || item.attributes.unit_of_measurement; - } - - _getGraph(items, width, height) { - const values = this._getValueArr(items); - const coords = this._calcCoordinates(values, width, height); - return this._getPath(coords); - } - - _getValueArr(items) { - return items.map((item) => Number(item.state) || 0); - } - - _calcCoordinates(values, width, height) { - const margin = this._config.line_width; - width -= margin * 2; - height -= margin * 2; - const min = Math.floor(Math.min.apply(null, values) * 0.95); - const max = Math.ceil(Math.max.apply(null, values) * 1.05); - - if (values.length === 1) values.push(values[0]); - - const yRatio = (max - min) / height; - const xRatio = width / (values.length - 1); - - return values.map((value, i) => { - const y = height - (value - min) / yRatio || 0; - const x = xRatio * i + margin; - return [x, y]; - }); - } - - _getPath(points) { - const SPACE = " "; - let next; - let Z; - const X = 0; - const Y = 1; - let path = ""; - let point = points[0]; - - path += "M" + point[X] + "," + point[Y]; - const first = point; - - for (let i = 0; i < points.length; i++) { - next = points[i]; - Z = this._midPoint(point[X], point[Y], next[X], next[Y]); - path += SPACE + Z[X] + "," + Z[Y]; - path += "Q" + Math.floor(next[X]) + "," + next[Y]; - point = next; - } - - const second = points[1]; - Z = this._midPoint(first[X], first[Y], second[X], second[Y]); - path += SPACE + Math.floor(next[X]) + "." + points[points.length - 1]; - return path; - } - - _midPoint(Ax, Ay, Bx, By) { - const Zx = (Ax - Bx) / 2 + Bx; - const Zy = (Ay - By) / 2 + By; - return [Zx, Zy]; - } - - async _getHistory() { - const endTime = new Date(); - const startTime = new Date(); - startTime.setHours(endTime.getHours() - this._config.hours_to_show); - const stateHistory = await this._fetchRecent( - this._config.entity, - startTime, - endTime - ); - const history = stateHistory[0]; - const valArray = [history[history.length - 1]]; - - let pos = history.length - 1; - const accuracy = this._config.accuracy <= pos ? this._config.accuracy : pos; - let increment = Math.ceil(history.length / accuracy); - increment = increment <= 0 ? 1 : increment; - for (let i = accuracy; i >= 2; i--) { - pos -= increment; - valArray.unshift(pos >= 0 ? history[pos] : history[0]); - } - this._line = this._getGraph(valArray, 500, this._config.height); - } - - async _fetchRecent(entityId, startTime, endTime) { - let url = "history/period"; - if (startTime) url += "/" + startTime.toISOString(); - url += "?filter_entity_id=" + entityId; - if (endTime) url += "&end_time=" + endTime.toISOString(); - - return await this._hass.callApi("GET", url); - } - - getCardSize() { - return 3; - } - - _style() { - return html` - `; - } -} - -customElements.define("hui-sensor-card", HuiSensorCard); +import { LitElement, html, svg } from "@polymer/lit-element"; + +import "../../../components/ha-card"; +import "../../../components/ha-icon"; + +import computeStateName from "../../../common/entity/compute_state_name"; +import stateIcon from "../../../common/entity/state_icon"; + +import EventsMixin from "../../../mixins/events-mixin"; + +class HuiSensorCard extends EventsMixin(LitElement) { + set hass(hass) { + this._hass = hass; + const entity = hass.states[this._config.entity]; + if (entity && this._entity !== entity) { + this._entity = entity; + if ( + this._config.graph !== "none" && + entity.attributes.unit_of_measurement + ) { + this._getHistory(); + } + } + } + + static get properties() { + return { + _hass: {}, + _config: {}, + _entity: {}, + _line: String, + }; + } + + setConfig(config) { + if (!config.entity || config.entity.split(".")[0] !== "sensor") { + throw new Error("Specify an entity from within the sensor domain."); + } + + const cardConfig = { + icon: false, + hours_to_show: 24, + accuracy: 10, + height: 100, + line_width: 5, + line_color: "var(--accent-color)", + ...config, + }; + cardConfig.hours_to_show = Number(cardConfig.hours_to_show); + cardConfig.accuracy = Number(cardConfig.accuracy); + cardConfig.height = Number(cardConfig.height); + cardConfig.line_width = Number(cardConfig.line_width); + + this._config = cardConfig; + } + + shouldUpdate(changedProps) { + const change = changedProps.has("_entity") || changedProps.has("_line"); + return change; + } + + render({ _config, _entity, _line } = this) { + return html` + ${this._style()} + +
+
+ +
+
+ ${this._computeName(_entity)} +
+
+
+ ${_entity.state} + ${this._computeUom(_entity)} +
+
+
+ ${ + _line + ? svg` + + + ` + : "" + } +
+
+
`; + } + + _handleClick() { + this.fire("hass-more-info", { entityId: this._config.entity }); + } + + _computeIcon(item) { + return this._config.icon || stateIcon(item); + } + + _computeName(item) { + return this._config.name || computeStateName(item); + } + + _computeUom(item) { + return this._config.unit || item.attributes.unit_of_measurement; + } + + _getGraph(items, width, height) { + const values = this._getValueArr(items); + const coords = this._calcCoordinates(values, width, height); + return this._getPath(coords); + } + + _getValueArr(items) { + return items.map((item) => Number(item.state) || 0); + } + + _calcCoordinates(values, width, height) { + const margin = this._config.line_width; + width -= margin * 2; + height -= margin * 2; + const min = Math.floor(Math.min.apply(null, values) * 0.95); + const max = Math.ceil(Math.max.apply(null, values) * 1.05); + + if (values.length === 1) values.push(values[0]); + + const yRatio = (max - min) / height; + const xRatio = width / (values.length - 1); + + return values.map((value, i) => { + const y = height - (value - min) / yRatio || 0; + const x = xRatio * i + margin; + return [x, y]; + }); + } + + _getPath(points) { + const SPACE = " "; + let next; + let Z; + const X = 0; + const Y = 1; + let path = ""; + let point = points[0]; + + path += "M" + point[X] + "," + point[Y]; + const first = point; + + for (let i = 0; i < points.length; i++) { + next = points[i]; + Z = this._midPoint(point[X], point[Y], next[X], next[Y]); + path += SPACE + Z[X] + "," + Z[Y]; + path += "Q" + Math.floor(next[X]) + "," + next[Y]; + point = next; + } + + const second = points[1]; + Z = this._midPoint(first[X], first[Y], second[X], second[Y]); + path += SPACE + Math.floor(next[X]) + "." + points[points.length - 1]; + return path; + } + + _midPoint(Ax, Ay, Bx, By) { + const Zx = (Ax - Bx) / 2 + Bx; + const Zy = (Ay - By) / 2 + By; + return [Zx, Zy]; + } + + async _getHistory() { + const endTime = new Date(); + const startTime = new Date(); + startTime.setHours(endTime.getHours() - this._config.hours_to_show); + const stateHistory = await this._fetchRecent( + this._config.entity, + startTime, + endTime + ); + const history = stateHistory[0]; + const valArray = [history[history.length - 1]]; + + let pos = history.length - 1; + const accuracy = this._config.accuracy <= pos ? this._config.accuracy : pos; + let increment = Math.ceil(history.length / accuracy); + increment = increment <= 0 ? 1 : increment; + for (let i = accuracy; i >= 2; i--) { + pos -= increment; + valArray.unshift(pos >= 0 ? history[pos] : history[0]); + } + this._line = this._getGraph(valArray, 500, this._config.height); + } + + async _fetchRecent(entityId, startTime, endTime) { + let url = "history/period"; + if (startTime) url += "/" + startTime.toISOString(); + url += "?filter_entity_id=" + entityId; + if (endTime) url += "&end_time=" + endTime.toISOString(); + + return await this._hass.callApi("GET", url); + } + + getCardSize() { + return 3; + } + + _style() { + return html` + `; + } +} + +customElements.define("hui-sensor-card", HuiSensorCard); diff --git a/src/panels/lovelace/cards/hui-stack-card.ts b/src/panels/lovelace/cards/hui-stack-card.ts index 7c2e69651abe..709bf441d272 100644 --- a/src/panels/lovelace/cards/hui-stack-card.ts +++ b/src/panels/lovelace/cards/hui-stack-card.ts @@ -1,66 +1,66 @@ -import { html, LitElement } from "@polymer/lit-element"; -import { TemplateResult } from "lit-html"; - -import createCardElement from "../common/create-card-element.js"; - -import { LovelaceCard, LovelaceConfig } from "../types"; -import { HomeAssistant } from "../../../types"; - -interface Config extends LovelaceConfig { - cards: LovelaceConfig[]; -} - -export abstract class HuiStackCard extends LitElement implements LovelaceCard { - protected _cards?: LovelaceCard[]; - private _config?: Config; - private _hass?: HomeAssistant; - - static get properties() { - return { - _config: {}, - }; - } - - set hass(hass: HomeAssistant) { - this._hass = hass; - - if (!this._cards) { - return; - } - - for (const element of this._cards) { - element.hass = this._hass; - } - } - - public abstract getCardSize(): number; - - public setConfig(config: Config): void { - if (!config || !config.cards || !Array.isArray(config.cards)) { - throw new Error("Card config incorrect"); - } - this._config = config; - this._cards = config.cards.map((card) => { - const element = createCardElement(card) as LovelaceCard; - if (this._hass) { - element.hass = this._hass; - } - return element; - }); - } - - protected render(): TemplateResult { - if (!this._config) { - return html``; - } - - return html` - ${this.renderStyle()} -
- ${this._cards} -
- `; - } - - protected abstract renderStyle(): TemplateResult; -} +import { html, LitElement } from "@polymer/lit-element"; +import { TemplateResult } from "lit-html"; + +import createCardElement from "../common/create-card-element"; + +import { LovelaceCard, LovelaceConfig } from "../types"; +import { HomeAssistant } from "../../../types"; + +interface Config extends LovelaceConfig { + cards: LovelaceConfig[]; +} + +export abstract class HuiStackCard extends LitElement implements LovelaceCard { + protected _cards?: LovelaceCard[]; + private _config?: Config; + private _hass?: HomeAssistant; + + static get properties() { + return { + _config: {}, + }; + } + + set hass(hass: HomeAssistant) { + this._hass = hass; + + if (!this._cards) { + return; + } + + for (const element of this._cards) { + element.hass = this._hass; + } + } + + public abstract getCardSize(): number; + + public setConfig(config: Config): void { + if (!config || !config.cards || !Array.isArray(config.cards)) { + throw new Error("Card config incorrect"); + } + this._config = config; + this._cards = config.cards.map((card) => { + const element = createCardElement(card) as LovelaceCard; + if (this._hass) { + element.hass = this._hass; + } + return element; + }); + } + + protected render(): TemplateResult { + if (!this._config) { + return html``; + } + + return html` + ${this.renderStyle()} +
+ ${this._cards} +
+ `; + } + + protected abstract renderStyle(): TemplateResult; +} diff --git a/src/panels/lovelace/cards/hui-thermostat-card.ts b/src/panels/lovelace/cards/hui-thermostat-card.ts index adae97a61889..708a7bcb0aad 100644 --- a/src/panels/lovelace/cards/hui-thermostat-card.ts +++ b/src/panels/lovelace/cards/hui-thermostat-card.ts @@ -1,390 +1,390 @@ -import { - html, - LitElement, - PropertyDeclarations, - PropertyValues, -} from "@polymer/lit-element"; -import { classMap } from "lit-html/directives/classMap.js"; -import { jQuery } from "../../../resources/jquery"; - -import "../../../components/ha-card.js"; -import "../../../components/ha-icon.js"; -import { roundSliderStyle } from "../../../resources/jquery.roundslider"; - -import { HomeAssistant, ClimateEntity } from "../../../types.js"; -import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; -import { LovelaceCard, LovelaceConfig } from "../types.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import { TemplateResult } from "lit-html"; - -const thermostatConfig = { - radius: 150, - step: 1, - circleShape: "pie", - startAngle: 315, - width: 5, - lineCap: "round", - handleSize: "+10", - showTooltip: false, -}; - -const modeIcons = { - auto: "hass:autorenew", - heat: "hass:fire", - cool: "hass:snowflake", - off: "hass:power", -}; - -interface Config extends LovelaceConfig { - entity: string; -} - -function formatTemp(temps: string[]): string { - return temps.filter(Boolean).join("-"); -} - -export class HuiThermostatCard extends hassLocalizeLitMixin(LitElement) - implements LovelaceCard { - public hass?: HomeAssistant; - private _config?: Config; - - static get properties(): PropertyDeclarations { - return { - hass: {}, - _config: {}, - }; - } - - public getCardSize(): number { - return 4; - } - - public setConfig(config: Config): void { - if (!config.entity || config.entity.split(".")[0] !== "climate") { - throw new Error("Specify an entity from within the climate domain."); - } - - this._config = config; - } - - protected render(): TemplateResult { - if (!this.hass || !this._config) { - return html``; - } - const stateObj = this.hass.states[this._config.entity] as ClimateEntity; - const broadCard = this.clientWidth > 390; - const mode = modeIcons[stateObj.attributes.operation_mode || ""] - ? stateObj.attributes.operation_mode! - : "unknown-mode"; - return html` - ${this.renderStyle()} - -
-
-
-
${computeStateName(stateObj)}
-
- ${ - stateObj.attributes.current_temperature - } - ${ - this.hass.config.unit_system.temperature - } - -
-
-
-
${this.localize( - `state.climate.${stateObj.state}` - )}
-
- ${(stateObj.attributes.operation_list || []).map((modeItem) => - this._renderIcon(modeItem, mode) - )} -
-
-
- - `; - } - - protected shouldUpdate(changedProps: PropertyValues): boolean { - if (changedProps.get("hass")) { - return ( - (changedProps.get("hass") as any).states[this._config!.entity] !== - this.hass!.states[this._config!.entity] - ); - } - if (changedProps.has("_config")) { - return true; - } - return true; - } - - protected firstUpdated(): void { - const stateObj = this.hass!.states[this._config!.entity] as ClimateEntity; - - const _sliderType = - stateObj.attributes.target_temp_low && - stateObj.attributes.target_temp_high - ? "range" - : "min-range"; - - jQuery("#thermostat", this.shadowRoot).roundSlider({ - ...thermostatConfig, - radius: this.clientWidth / 3, - min: stateObj.attributes.min_temp, - max: stateObj.attributes.max_temp, - sliderType: _sliderType, - change: (value) => this._setTemperature(value), - drag: (value) => this._dragEvent(value), - }); - } - - protected updated(): void { - const stateObj = this.hass!.states[this._config!.entity] as ClimateEntity; - - let sliderValue; - let uiValue; - - if ( - stateObj.attributes.target_temp_low && - stateObj.attributes.target_temp_high - ) { - sliderValue = `${stateObj.attributes.target_temp_low}, ${ - stateObj.attributes.target_temp_high - }`; - uiValue = formatTemp([ - String(stateObj.attributes.target_temp_low), - String(stateObj.attributes.target_temp_high), - ]); - } else { - sliderValue = uiValue = stateObj.attributes.temperature; - } - - jQuery("#thermostat", this.shadowRoot).roundSlider({ - value: sliderValue, - }); - this.shadowRoot!.querySelector("#set-temperature")!.innerHTML = uiValue; - } - - private renderStyle(): TemplateResult { - return html` - ${roundSliderStyle} - - `; - } - - private _dragEvent(e): void { - this.shadowRoot!.querySelector("#set-temperature")!.innerHTML = formatTemp( - String(e.value).split(",") - ); - } - - private _setTemperature(e): void { - const stateObj = this.hass!.states[this._config!.entity] as ClimateEntity; - if ( - stateObj.attributes.target_temp_low && - stateObj.attributes.target_temp_high - ) { - if (e.handle.index === 1) { - this.hass!.callService("climate", "set_temperature", { - entity_id: this._config!.entity, - target_temp_low: e.handle.value, - target_temp_high: stateObj.attributes.target_temp_high, - }); - } else { - this.hass!.callService("climate", "set_temperature", { - entity_id: this._config!.entity, - target_temp_low: stateObj.attributes.target_temp_low, - target_temp_high: e.handle.value, - }); - } - } else { - this.hass!.callService("climate", "set_temperature", { - entity_id: this._config!.entity, - temperature: e.value, - }); - } - } - - private _renderIcon(mode: string, currentMode: string): TemplateResult { - if (!modeIcons[mode]) { - return html``; - } - return html``; - } - - private _handleModeClick(e: MouseEvent): void { - this.hass!.callService("climate", "set_operation_mode", { - entity_id: this._config!.entity, - operation_mode: (e.currentTarget as any).mode, - }); - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-thermostat-card": HuiThermostatCard; - } -} - -customElements.define("hui-thermostat-card", HuiThermostatCard); +import { + html, + LitElement, + PropertyDeclarations, + PropertyValues, +} from "@polymer/lit-element"; +import { classMap } from "lit-html/directives/classMap"; +import { jQuery } from "../../../resources/jquery"; + +import "../../../components/ha-card"; +import "../../../components/ha-icon"; +import { roundSliderStyle } from "../../../resources/jquery.roundslider"; + +import { HomeAssistant, ClimateEntity } from "../../../types"; +import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; +import { LovelaceCard, LovelaceConfig } from "../types"; +import computeStateName from "../../../common/entity/compute_state_name"; +import { TemplateResult } from "lit-html"; + +const thermostatConfig = { + radius: 150, + step: 1, + circleShape: "pie", + startAngle: 315, + width: 5, + lineCap: "round", + handleSize: "+10", + showTooltip: false, +}; + +const modeIcons = { + auto: "hass:autorenew", + heat: "hass:fire", + cool: "hass:snowflake", + off: "hass:power", +}; + +interface Config extends LovelaceConfig { + entity: string; +} + +function formatTemp(temps: string[]): string { + return temps.filter(Boolean).join("-"); +} + +export class HuiThermostatCard extends hassLocalizeLitMixin(LitElement) + implements LovelaceCard { + public hass?: HomeAssistant; + private _config?: Config; + + static get properties(): PropertyDeclarations { + return { + hass: {}, + _config: {}, + }; + } + + public getCardSize(): number { + return 4; + } + + public setConfig(config: Config): void { + if (!config.entity || config.entity.split(".")[0] !== "climate") { + throw new Error("Specify an entity from within the climate domain."); + } + + this._config = config; + } + + protected render(): TemplateResult { + if (!this.hass || !this._config) { + return html``; + } + const stateObj = this.hass.states[this._config.entity] as ClimateEntity; + const broadCard = this.clientWidth > 390; + const mode = modeIcons[stateObj.attributes.operation_mode || ""] + ? stateObj.attributes.operation_mode! + : "unknown-mode"; + return html` + ${this.renderStyle()} + +
+
+
+
${computeStateName(stateObj)}
+
+ ${ + stateObj.attributes.current_temperature + } + ${ + this.hass.config.unit_system.temperature + } + +
+
+
+
${this.localize( + `state.climate.${stateObj.state}` + )}
+
+ ${(stateObj.attributes.operation_list || []).map((modeItem) => + this._renderIcon(modeItem, mode) + )} +
+
+
+ + `; + } + + protected shouldUpdate(changedProps: PropertyValues): boolean { + if (changedProps.get("hass")) { + return ( + (changedProps.get("hass") as any).states[this._config!.entity] !== + this.hass!.states[this._config!.entity] + ); + } + if (changedProps.has("_config")) { + return true; + } + return true; + } + + protected firstUpdated(): void { + const stateObj = this.hass!.states[this._config!.entity] as ClimateEntity; + + const _sliderType = + stateObj.attributes.target_temp_low && + stateObj.attributes.target_temp_high + ? "range" + : "min-range"; + + jQuery("#thermostat", this.shadowRoot).roundSlider({ + ...thermostatConfig, + radius: this.clientWidth / 3, + min: stateObj.attributes.min_temp, + max: stateObj.attributes.max_temp, + sliderType: _sliderType, + change: (value) => this._setTemperature(value), + drag: (value) => this._dragEvent(value), + }); + } + + protected updated(): void { + const stateObj = this.hass!.states[this._config!.entity] as ClimateEntity; + + let sliderValue; + let uiValue; + + if ( + stateObj.attributes.target_temp_low && + stateObj.attributes.target_temp_high + ) { + sliderValue = `${stateObj.attributes.target_temp_low}, ${ + stateObj.attributes.target_temp_high + }`; + uiValue = formatTemp([ + String(stateObj.attributes.target_temp_low), + String(stateObj.attributes.target_temp_high), + ]); + } else { + sliderValue = uiValue = stateObj.attributes.temperature; + } + + jQuery("#thermostat", this.shadowRoot).roundSlider({ + value: sliderValue, + }); + this.shadowRoot!.querySelector("#set-temperature")!.innerHTML = uiValue; + } + + private renderStyle(): TemplateResult { + return html` + ${roundSliderStyle} + + `; + } + + private _dragEvent(e): void { + this.shadowRoot!.querySelector("#set-temperature")!.innerHTML = formatTemp( + String(e.value).split(",") + ); + } + + private _setTemperature(e): void { + const stateObj = this.hass!.states[this._config!.entity] as ClimateEntity; + if ( + stateObj.attributes.target_temp_low && + stateObj.attributes.target_temp_high + ) { + if (e.handle.index === 1) { + this.hass!.callService("climate", "set_temperature", { + entity_id: this._config!.entity, + target_temp_low: e.handle.value, + target_temp_high: stateObj.attributes.target_temp_high, + }); + } else { + this.hass!.callService("climate", "set_temperature", { + entity_id: this._config!.entity, + target_temp_low: stateObj.attributes.target_temp_low, + target_temp_high: e.handle.value, + }); + } + } else { + this.hass!.callService("climate", "set_temperature", { + entity_id: this._config!.entity, + temperature: e.value, + }); + } + } + + private _renderIcon(mode: string, currentMode: string): TemplateResult { + if (!modeIcons[mode]) { + return html``; + } + return html``; + } + + private _handleModeClick(e: MouseEvent): void { + this.hass!.callService("climate", "set_operation_mode", { + entity_id: this._config!.entity, + operation_mode: (e.currentTarget as any).mode, + }); + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-thermostat-card": HuiThermostatCard; + } +} + +customElements.define("hui-thermostat-card", HuiThermostatCard); diff --git a/src/panels/lovelace/cards/hui-vertical-stack-card.ts b/src/panels/lovelace/cards/hui-vertical-stack-card.ts index 863641cf1dab..3d13d2827ccd 100644 --- a/src/panels/lovelace/cards/hui-vertical-stack-card.ts +++ b/src/panels/lovelace/cards/hui-vertical-stack-card.ts @@ -1,50 +1,50 @@ -import { html } from "@polymer/lit-element"; - -import computeCardSize from "../common/compute-card-size.js"; - -import { HuiStackCard } from "./hui-stack-card"; -import { TemplateResult } from "lit-html"; - -class HuiVerticalStackCard extends HuiStackCard { - public getCardSize() { - let totalSize = 0; - - if (!this._cards) { - return totalSize; - } - - for (const element of this._cards) { - totalSize += computeCardSize(element); - } - - return totalSize; - } - - protected renderStyle(): TemplateResult { - return html` - - `; - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-vertical-stack-card": HuiVerticalStackCard; - } -} - -customElements.define("hui-vertical-stack-card", HuiVerticalStackCard); +import { html } from "@polymer/lit-element"; + +import computeCardSize from "../common/compute-card-size"; + +import { HuiStackCard } from "./hui-stack-card"; +import { TemplateResult } from "lit-html"; + +class HuiVerticalStackCard extends HuiStackCard { + public getCardSize() { + let totalSize = 0; + + if (!this._cards) { + return totalSize; + } + + for (const element of this._cards) { + totalSize += computeCardSize(element); + } + + return totalSize; + } + + protected renderStyle(): TemplateResult { + return html` + + `; + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-vertical-stack-card": HuiVerticalStackCard; + } +} + +customElements.define("hui-vertical-stack-card", HuiVerticalStackCard); diff --git a/src/panels/lovelace/cards/hui-weather-forecast-card.js b/src/panels/lovelace/cards/hui-weather-forecast-card.js index 082c5fc7d408..9ad437423133 100644 --- a/src/panels/lovelace/cards/hui-weather-forecast-card.js +++ b/src/panels/lovelace/cards/hui-weather-forecast-card.js @@ -1,15 +1,15 @@ -import "../../../cards/ha-camera-card.js"; - -import LegacyWrapperCard from "./hui-legacy-wrapper-card.js"; - -class HuiWeatherForecastCard extends LegacyWrapperCard { - constructor() { - super("ha-weather-card", "weather"); - } - - getCardSize() { - return 4; - } -} - -customElements.define("hui-weather-forecast-card", HuiWeatherForecastCard); +import "../../../cards/ha-camera-card"; + +import LegacyWrapperCard from "./hui-legacy-wrapper-card"; + +class HuiWeatherForecastCard extends LegacyWrapperCard { + constructor() { + super("ha-weather-card", "weather"); + } + + getCardSize() { + return 4; + } +} + +customElements.define("hui-weather-forecast-card", HuiWeatherForecastCard); diff --git a/src/panels/lovelace/common/compute-notifications.js b/src/panels/lovelace/common/compute-notifications.js index 94c894e860c0..0e9f57316f19 100644 --- a/src/panels/lovelace/common/compute-notifications.js +++ b/src/panels/lovelace/common/compute-notifications.js @@ -1,7 +1,7 @@ -import computeDomain from "../../../common/entity/compute_domain.js"; - -export default function computeNotifications(states) { - return Object.keys(states) - .filter((entityId) => computeDomain(entityId) === "configurator") - .map((entityId) => states[entityId]); -} +import computeDomain from "../../../common/entity/compute_domain"; + +export default function computeNotifications(states) { + return Object.keys(states) + .filter((entityId) => computeDomain(entityId) === "configurator") + .map((entityId) => states[entityId]); +} diff --git a/src/panels/lovelace/common/create-card-element.js b/src/panels/lovelace/common/create-card-element.js index 92db6f4a6fe0..9417fa8989e8 100644 --- a/src/panels/lovelace/common/create-card-element.js +++ b/src/panels/lovelace/common/create-card-element.js @@ -1,112 +1,112 @@ -import { fireEvent } from "../../../common/dom/fire_event.js"; - -import "../cards/hui-alarm-panel-card.js"; -import "../cards/hui-conditional-card.ts"; -import "../cards/hui-entities-card.ts"; -import "../cards/hui-entity-button-card.ts"; -import "../cards/hui-entity-filter-card.js"; -import "../cards/hui-error-card.ts"; -import "../cards/hui-glance-card.ts"; -import "../cards/hui-history-graph-card.js"; -import "../cards/hui-horizontal-stack-card.ts"; -import "../cards/hui-iframe-card.ts"; -import "../cards/hui-light-card"; -import "../cards/hui-map-card.js"; -import "../cards/hui-markdown-card.ts"; -import "../cards/hui-media-control-card.js"; -import "../cards/hui-picture-card.js"; -import "../cards/hui-picture-elements-card"; -import "../cards/hui-picture-entity-card"; -import "../cards/hui-picture-glance-card"; -import "../cards/hui-plant-status-card.js"; -import "../cards/hui-sensor-card.js"; -import "../cards/hui-vertical-stack-card.ts"; -import "../cards/hui-thermostat-card.ts"; -import "../cards/hui-weather-forecast-card"; -import "../cards/hui-gauge-card"; - -import createErrorCardConfig from "./create-error-card-config.js"; - -const CARD_TYPES = new Set([ - "alarm-panel", - "conditional", - "entities", - "entity-button", - "entity-filter", - "error", - "gauge", - "glance", - "history-graph", - "horizontal-stack", - "iframe", - "light", - "map", - "markdown", - "media-control", - "picture", - "picture-elements", - "picture-entity", - "picture-glance", - "plant-status", - "sensor", - "thermostat", - "vertical-stack", - "weather-forecast", -]); -const CUSTOM_TYPE_PREFIX = "custom:"; -const TIMEOUT = 2000; - -function _createElement(tag, config) { - const element = document.createElement(tag); - try { - element.setConfig(config); - } catch (err) { - // eslint-disable-next-line - console.error(tag, err); - // eslint-disable-next-line - return _createErrorElement(err.message, config); - } - return element; -} - -function _createErrorElement(error, config) { - return _createElement("hui-error-card", createErrorCardConfig(error, config)); -} - -export default function createCardElement(config) { - if (!config || typeof config !== "object" || !config.type) { - return _createErrorElement("No card type configured.", config); - } - - if (config.type.startsWith(CUSTOM_TYPE_PREFIX)) { - const tag = config.type.substr(CUSTOM_TYPE_PREFIX.length); - - if (customElements.get(tag)) { - return _createElement(tag, config); - } - const element = _createErrorElement( - `Custom element doesn't exist: ${tag}.`, - config - ); - element.style.display = "None"; - const timer = window.setTimeout(() => { - element.style.display = ""; - }, TIMEOUT); - - customElements.whenDefined(tag).then(() => { - clearTimeout(timer); - fireEvent(element, "rebuild-view"); - }); - - return element; - } - - if (!CARD_TYPES.has(config.type)) { - return _createErrorElement( - `Unknown card type encountered: ${config.type}.`, - config - ); - } - - return _createElement(`hui-${config.type}-card`, config); -} +import { fireEvent } from "../../../common/dom/fire_event"; + +import "../cards/hui-alarm-panel-card"; +import "../cards/hui-conditional-card.ts"; +import "../cards/hui-entities-card.ts"; +import "../cards/hui-entity-button-card.ts"; +import "../cards/hui-entity-filter-card"; +import "../cards/hui-error-card.ts"; +import "../cards/hui-glance-card.ts"; +import "../cards/hui-history-graph-card"; +import "../cards/hui-horizontal-stack-card.ts"; +import "../cards/hui-iframe-card.ts"; +import "../cards/hui-light-card"; +import "../cards/hui-map-card"; +import "../cards/hui-markdown-card.ts"; +import "../cards/hui-media-control-card"; +import "../cards/hui-picture-card"; +import "../cards/hui-picture-elements-card"; +import "../cards/hui-picture-entity-card"; +import "../cards/hui-picture-glance-card"; +import "../cards/hui-plant-status-card"; +import "../cards/hui-sensor-card"; +import "../cards/hui-vertical-stack-card.ts"; +import "../cards/hui-thermostat-card.ts"; +import "../cards/hui-weather-forecast-card"; +import "../cards/hui-gauge-card"; + +import createErrorCardConfig from "./create-error-card-config"; + +const CARD_TYPES = new Set([ + "alarm-panel", + "conditional", + "entities", + "entity-button", + "entity-filter", + "error", + "gauge", + "glance", + "history-graph", + "horizontal-stack", + "iframe", + "light", + "map", + "markdown", + "media-control", + "picture", + "picture-elements", + "picture-entity", + "picture-glance", + "plant-status", + "sensor", + "thermostat", + "vertical-stack", + "weather-forecast", +]); +const CUSTOM_TYPE_PREFIX = "custom:"; +const TIMEOUT = 2000; + +function _createElement(tag, config) { + const element = document.createElement(tag); + try { + element.setConfig(config); + } catch (err) { + // eslint-disable-next-line + console.error(tag, err); + // eslint-disable-next-line + return _createErrorElement(err.message, config); + } + return element; +} + +function _createErrorElement(error, config) { + return _createElement("hui-error-card", createErrorCardConfig(error, config)); +} + +export default function createCardElement(config) { + if (!config || typeof config !== "object" || !config.type) { + return _createErrorElement("No card type configured.", config); + } + + if (config.type.startsWith(CUSTOM_TYPE_PREFIX)) { + const tag = config.type.substr(CUSTOM_TYPE_PREFIX.length); + + if (customElements.get(tag)) { + return _createElement(tag, config); + } + const element = _createErrorElement( + `Custom element doesn't exist: ${tag}.`, + config + ); + element.style.display = "None"; + const timer = window.setTimeout(() => { + element.style.display = ""; + }, TIMEOUT); + + customElements.whenDefined(tag).then(() => { + clearTimeout(timer); + fireEvent(element, "rebuild-view"); + }); + + return element; + } + + if (!CARD_TYPES.has(config.type)) { + return _createErrorElement( + `Unknown card type encountered: ${config.type}.`, + config + ); + } + + return _createElement(`hui-${config.type}-card`, config); +} diff --git a/src/panels/lovelace/common/create-hui-element.js b/src/panels/lovelace/common/create-hui-element.js index 39d99926c949..b02b86dbcfd2 100644 --- a/src/panels/lovelace/common/create-hui-element.js +++ b/src/panels/lovelace/common/create-hui-element.js @@ -1,79 +1,79 @@ -import "../elements/hui-icon-element"; -import "../elements/hui-image-element"; -import "../elements/hui-service-button-element"; -import "../elements/hui-state-badge-element"; -import "../elements/hui-state-icon-element"; -import "../elements/hui-state-label-element"; - -import { fireEvent } from "../../../common/dom/fire_event.js"; -import createErrorCardConfig from "./create-error-card-config.js"; - -const CUSTOM_TYPE_PREFIX = "custom:"; -const ELEMENT_TYPES = new Set([ - "icon", - "image", - "service-button", - "state-badge", - "state-icon", - "state-label", -]); -const TIMEOUT = 2000; - -function _createElement(tag, config) { - const element = document.createElement(tag); - try { - element.setConfig(config); - } catch (err) { - // eslint-disable-next-line - console.error(tag, err); - // eslint-disable-next-line - return _createErrorElement(err.message, config); - } - return element; -} - -function _createErrorElement(error, config) { - return _createElement("hui-error-card", createErrorCardConfig(error, config)); -} - -function _hideErrorElement(element) { - element.style.display = "None"; - return window.setTimeout(() => { - element.style.display = ""; - }, TIMEOUT); -} - -export default function createHuiElement(config) { - if (!config || typeof config !== "object" || !config.type) { - return _createErrorElement("No element type configured.", config); - } - - if (config.type.startsWith(CUSTOM_TYPE_PREFIX)) { - const tag = config.type.substr(CUSTOM_TYPE_PREFIX.length); - - if (customElements.get(tag)) { - return _createElement(tag, config); - } - const element = _createErrorElement( - `Custom element doesn't exist: ${tag}.`, - config - ); - const timer = _hideErrorElement(element); - - customElements.whenDefined(tag).then(() => { - clearTimeout(timer); - fireEvent(element, "rebuild-view"); - }); - - return element; - } - - if (!ELEMENT_TYPES.has(config.type)) { - return _createErrorElement( - `Unknown element type encountered: ${config.type}.`, - config - ); - } - - return _createElement(`hui-${config.type}-element`, config); -} +import "../elements/hui-icon-element"; +import "../elements/hui-image-element"; +import "../elements/hui-service-button-element"; +import "../elements/hui-state-badge-element"; +import "../elements/hui-state-icon-element"; +import "../elements/hui-state-label-element"; + +import { fireEvent } from "../../../common/dom/fire_event"; +import createErrorCardConfig from "./create-error-card-config"; + +const CUSTOM_TYPE_PREFIX = "custom:"; +const ELEMENT_TYPES = new Set([ + "icon", + "image", + "service-button", + "state-badge", + "state-icon", + "state-label", +]); +const TIMEOUT = 2000; + +function _createElement(tag, config) { + const element = document.createElement(tag); + try { + element.setConfig(config); + } catch (err) { + // eslint-disable-next-line + console.error(tag, err); + // eslint-disable-next-line + return _createErrorElement(err.message, config); + } + return element; +} + +function _createErrorElement(error, config) { + return _createElement("hui-error-card", createErrorCardConfig(error, config)); +} + +function _hideErrorElement(element) { + element.style.display = "None"; + return window.setTimeout(() => { + element.style.display = ""; + }, TIMEOUT); +} + +export default function createHuiElement(config) { + if (!config || typeof config !== "object" || !config.type) { + return _createErrorElement("No element type configured.", config); + } + + if (config.type.startsWith(CUSTOM_TYPE_PREFIX)) { + const tag = config.type.substr(CUSTOM_TYPE_PREFIX.length); + + if (customElements.get(tag)) { + return _createElement(tag, config); + } + const element = _createErrorElement( + `Custom element doesn't exist: ${tag}.`, + config + ); + const timer = _hideErrorElement(element); + + customElements.whenDefined(tag).then(() => { + clearTimeout(timer); + fireEvent(element, "rebuild-view"); + }); + + return element; + } + + if (!ELEMENT_TYPES.has(config.type)) { + return _createErrorElement( + `Unknown element type encountered: ${config.type}.`, + config + ); + } + + return _createElement(`hui-${config.type}-element`, config); +} diff --git a/src/panels/lovelace/common/create-row-element.js b/src/panels/lovelace/common/create-row-element.js index 74222bc2584d..f973db948d26 100644 --- a/src/panels/lovelace/common/create-row-element.js +++ b/src/panels/lovelace/common/create-row-element.js @@ -1,117 +1,117 @@ -import { fireEvent } from "../../../common/dom/fire_event.js"; - -import "../entity-rows/hui-climate-entity-row"; -import "../entity-rows/hui-cover-entity-row.js"; -import "../entity-rows/hui-group-entity-row.js"; -import "../entity-rows/hui-input-number-entity-row.js"; -import "../entity-rows/hui-input-select-entity-row.js"; -import "../entity-rows/hui-input-text-entity-row.js"; -import "../entity-rows/hui-lock-entity-row.js"; -import "../entity-rows/hui-media-player-entity-row.js"; -import "../entity-rows/hui-scene-entity-row.js"; -import "../entity-rows/hui-script-entity-row.js"; -import "../entity-rows/hui-text-entity-row.js"; -import "../entity-rows/hui-timer-entity-row.js"; -import "../entity-rows/hui-toggle-entity-row.js"; - -import "../special-rows/hui-call-service-row"; -import "../special-rows/hui-divider-row"; -import "../special-rows/hui-section-row"; -import "../special-rows/hui-weblink-row"; - -import createErrorCardConfig from "./create-error-card-config.js"; - -const CUSTOM_TYPE_PREFIX = "custom:"; -const SPECIAL_TYPES = new Set([ - "call-service", - "divider", - "section", - "weblink", -]); -const DOMAIN_TO_ELEMENT_TYPE = { - automation: "toggle", - climate: "climate", - cover: "cover", - fan: "toggle", - group: "group", - input_boolean: "toggle", - input_number: "input-number", - input_select: "input-select", - input_text: "input-text", - light: "toggle", - media_player: "media-player", - lock: "lock", - scene: "scene", - script: "script", - timer: "timer", - switch: "toggle", - vacuum: "toggle", -}; -const TIMEOUT = 2000; - -function _createElement(tag, config) { - const element = document.createElement(tag); - try { - if ("setConfig" in element) element.setConfig(config); - } catch (err) { - // eslint-disable-next-line - console.error(tag, err); - // eslint-disable-next-line - return _createErrorElement(err.message, config); - } - - return element; -} - -function _createErrorElement(error, config) { - return _createElement("hui-error-card", createErrorCardConfig(error, config)); -} - -function _hideErrorElement(element) { - element.style.display = "None"; - return window.setTimeout(() => { - element.style.display = ""; - }, TIMEOUT); -} - -export default function createRowElement(config) { - let tag; - - if ( - !config || - typeof config !== "object" || - (!config.entity && !config.type) - ) { - return _createErrorElement("Invalid config given.", config); - } - - const type = config.type || "default"; - if (SPECIAL_TYPES.has(type)) { - return _createElement(`hui-${type}-row`, config); - } - - if (type.startsWith(CUSTOM_TYPE_PREFIX)) { - tag = type.substr(CUSTOM_TYPE_PREFIX.length); - - if (customElements.get(tag)) { - return _createElement(tag, config); - } - const element = _createErrorElement( - `Custom element doesn't exist: ${tag}.`, - config - ); - const timer = _hideErrorElement(element); - - customElements.whenDefined(tag).then(() => { - clearTimeout(timer); - fireEvent(element, "rebuild-view"); - }); - - return element; - } - - const domain = config.entity.split(".", 1)[0]; - tag = `hui-${DOMAIN_TO_ELEMENT_TYPE[domain] || "text"}-entity-row`; - - return _createElement(tag, config); -} +import { fireEvent } from "../../../common/dom/fire_event"; + +import "../entity-rows/hui-climate-entity-row"; +import "../entity-rows/hui-cover-entity-row"; +import "../entity-rows/hui-group-entity-row"; +import "../entity-rows/hui-input-number-entity-row"; +import "../entity-rows/hui-input-select-entity-row"; +import "../entity-rows/hui-input-text-entity-row"; +import "../entity-rows/hui-lock-entity-row"; +import "../entity-rows/hui-media-player-entity-row"; +import "../entity-rows/hui-scene-entity-row"; +import "../entity-rows/hui-script-entity-row"; +import "../entity-rows/hui-text-entity-row"; +import "../entity-rows/hui-timer-entity-row"; +import "../entity-rows/hui-toggle-entity-row"; + +import "../special-rows/hui-call-service-row"; +import "../special-rows/hui-divider-row"; +import "../special-rows/hui-section-row"; +import "../special-rows/hui-weblink-row"; + +import createErrorCardConfig from "./create-error-card-config"; + +const CUSTOM_TYPE_PREFIX = "custom:"; +const SPECIAL_TYPES = new Set([ + "call-service", + "divider", + "section", + "weblink", +]); +const DOMAIN_TO_ELEMENT_TYPE = { + automation: "toggle", + climate: "climate", + cover: "cover", + fan: "toggle", + group: "group", + input_boolean: "toggle", + input_number: "input-number", + input_select: "input-select", + input_text: "input-text", + light: "toggle", + media_player: "media-player", + lock: "lock", + scene: "scene", + script: "script", + timer: "timer", + switch: "toggle", + vacuum: "toggle", +}; +const TIMEOUT = 2000; + +function _createElement(tag, config) { + const element = document.createElement(tag); + try { + if ("setConfig" in element) element.setConfig(config); + } catch (err) { + // eslint-disable-next-line + console.error(tag, err); + // eslint-disable-next-line + return _createErrorElement(err.message, config); + } + + return element; +} + +function _createErrorElement(error, config) { + return _createElement("hui-error-card", createErrorCardConfig(error, config)); +} + +function _hideErrorElement(element) { + element.style.display = "None"; + return window.setTimeout(() => { + element.style.display = ""; + }, TIMEOUT); +} + +export default function createRowElement(config) { + let tag; + + if ( + !config || + typeof config !== "object" || + (!config.entity && !config.type) + ) { + return _createErrorElement("Invalid config given.", config); + } + + const type = config.type || "default"; + if (SPECIAL_TYPES.has(type)) { + return _createElement(`hui-${type}-row`, config); + } + + if (type.startsWith(CUSTOM_TYPE_PREFIX)) { + tag = type.substr(CUSTOM_TYPE_PREFIX.length); + + if (customElements.get(tag)) { + return _createElement(tag, config); + } + const element = _createErrorElement( + `Custom element doesn't exist: ${tag}.`, + config + ); + const timer = _hideErrorElement(element); + + customElements.whenDefined(tag).then(() => { + clearTimeout(timer); + fireEvent(element, "rebuild-view"); + }); + + return element; + } + + const domain = config.entity.split(".", 1)[0]; + tag = `hui-${DOMAIN_TO_ELEMENT_TYPE[domain] || "text"}-entity-row`; + + return _createElement(tag, config); +} diff --git a/src/panels/lovelace/common/entity/toggle-entity.js b/src/panels/lovelace/common/entity/toggle-entity.js index aa57a309d837..21820da7f7bf 100644 --- a/src/panels/lovelace/common/entity/toggle-entity.js +++ b/src/panels/lovelace/common/entity/toggle-entity.js @@ -1,7 +1,7 @@ -import { STATES_OFF } from "../../../../common/const.js"; -import turnOnOffEntity from "./turn-on-off-entity.js"; - -export default function toggleEntity(hass, entityId) { - const turnOn = STATES_OFF.includes(hass.states[entityId].state); - turnOnOffEntity(hass, entityId, turnOn); -} +import { STATES_OFF } from "../../../../common/const"; +import turnOnOffEntity from "./turn-on-off-entity"; + +export default function toggleEntity(hass, entityId) { + const turnOn = STATES_OFF.includes(hass.states[entityId].state); + turnOnOffEntity(hass, entityId, turnOn); +} diff --git a/src/panels/lovelace/common/entity/turn-on-off-entities.js b/src/panels/lovelace/common/entity/turn-on-off-entities.js index caacc03e7911..b3a990e74b6c 100644 --- a/src/panels/lovelace/common/entity/turn-on-off-entities.js +++ b/src/panels/lovelace/common/entity/turn-on-off-entities.js @@ -1,34 +1,34 @@ -import { STATES_OFF } from "../../../../common/const.js"; -import computeDomain from "../../../../common/entity/compute_domain.js"; - -export default function turnOnOffEntities(hass, entityIds, turnOn = true) { - const domainsToCall = {}; - entityIds.forEach((entityId) => { - if (STATES_OFF.includes(hass.states[entityId].state) === turnOn) { - const stateDomain = computeDomain(entityId); - const serviceDomain = ["cover", "lock"].includes(stateDomain) - ? stateDomain - : "homeassistant"; - - if (!(serviceDomain in domainsToCall)) domainsToCall[serviceDomain] = []; - domainsToCall[serviceDomain].push(entityId); - } - }); - - Object.keys(domainsToCall).forEach((domain) => { - let service; - switch (domain) { - case "lock": - service = turnOn ? "unlock" : "lock"; - break; - case "cover": - service = turnOn ? "open_cover" : "close_cover"; - break; - default: - service = turnOn ? "turn_on" : "turn_off"; - } - - const entities = domainsToCall[domain]; - hass.callService(domain, service, { entity_id: entities }); - }); -} +import { STATES_OFF } from "../../../../common/const"; +import computeDomain from "../../../../common/entity/compute_domain"; + +export default function turnOnOffEntities(hass, entityIds, turnOn = true) { + const domainsToCall = {}; + entityIds.forEach((entityId) => { + if (STATES_OFF.includes(hass.states[entityId].state) === turnOn) { + const stateDomain = computeDomain(entityId); + const serviceDomain = ["cover", "lock"].includes(stateDomain) + ? stateDomain + : "homeassistant"; + + if (!(serviceDomain in domainsToCall)) domainsToCall[serviceDomain] = []; + domainsToCall[serviceDomain].push(entityId); + } + }); + + Object.keys(domainsToCall).forEach((domain) => { + let service; + switch (domain) { + case "lock": + service = turnOn ? "unlock" : "lock"; + break; + case "cover": + service = turnOn ? "open_cover" : "close_cover"; + break; + default: + service = turnOn ? "turn_on" : "turn_off"; + } + + const entities = domainsToCall[domain]; + hass.callService(domain, service, { entity_id: entities }); + }); +} diff --git a/src/panels/lovelace/common/entity/turn-on-off-entity.js b/src/panels/lovelace/common/entity/turn-on-off-entity.js index f34d04c0642f..dc7e5d1a4d7c 100644 --- a/src/panels/lovelace/common/entity/turn-on-off-entity.js +++ b/src/panels/lovelace/common/entity/turn-on-off-entity.js @@ -1,20 +1,20 @@ -import computeDomain from "../../../../common/entity/compute_domain.js"; - -export default function turnOnOffEntity(hass, entityId, turnOn = true) { - const stateDomain = computeDomain(entityId); - const serviceDomain = stateDomain === "group" ? "homeassistant" : stateDomain; - - let service; - switch (stateDomain) { - case "lock": - service = turnOn ? "unlock" : "lock"; - break; - case "cover": - service = turnOn ? "open_cover" : "close_cover"; - break; - default: - service = turnOn ? "turn_on" : "turn_off"; - } - - hass.callService(serviceDomain, service, { entity_id: entityId }); -} +import computeDomain from "../../../../common/entity/compute_domain"; + +export default function turnOnOffEntity(hass, entityId, turnOn = true) { + const stateDomain = computeDomain(entityId); + const serviceDomain = stateDomain === "group" ? "homeassistant" : stateDomain; + + let service; + switch (stateDomain) { + case "lock": + service = turnOn ? "unlock" : "lock"; + break; + case "cover": + service = turnOn ? "open_cover" : "close_cover"; + break; + default: + service = turnOn ? "turn_on" : "turn_off"; + } + + hass.callService(serviceDomain, service, { entity_id: entityId }); +} diff --git a/src/panels/lovelace/common/handle-click.ts b/src/panels/lovelace/common/handle-click.ts index 4d98cf7ad74c..c996bf4bac89 100644 --- a/src/panels/lovelace/common/handle-click.ts +++ b/src/panels/lovelace/common/handle-click.ts @@ -1,6 +1,6 @@ import { HomeAssistant } from "../../../types"; import { LovelaceElementConfig } from "../elements/types"; -import { fireEvent } from "../../../common/dom/fire_event.js"; +import { fireEvent } from "../../../common/dom/fire_event"; import { navigate } from "../../../common/navigate"; import toggleEntity from "../../../../src/panels/lovelace/common/entity/toggle-entity"; diff --git a/src/panels/lovelace/common/process-config-entities.js b/src/panels/lovelace/common/process-config-entities.js index 2008ab0502cd..f8082886b345 100644 --- a/src/panels/lovelace/common/process-config-entities.js +++ b/src/panels/lovelace/common/process-config-entities.js @@ -1,38 +1,38 @@ -// Parse array of entity objects from config -import isValidEntityId from "../../../common/entity/valid_entity_id.js"; - -export default function processConfigEntities(entities) { - if (!entities || !Array.isArray(entities)) { - throw new Error("Entities need to be an array"); - } - - return entities.map((entityConf, index) => { - if ( - typeof entityConf === "object" && - !Array.isArray(entityConf) && - entityConf.type - ) { - return entityConf; - } - - if (typeof entityConf === "string") { - entityConf = { entity: entityConf }; - } else if (typeof entityConf === "object" && !Array.isArray(entityConf)) { - if (!entityConf.entity) { - throw new Error( - `Entity object at position ${index} is missing entity field.` - ); - } - } else { - throw new Error(`Invalid entity specified at position ${index}.`); - } - - if (!isValidEntityId(entityConf.entity)) { - throw new Error( - `Invalid entity ID at position ${index}: ${entityConf.entity}` - ); - } - - return entityConf; - }); -} +// Parse array of entity objects from config +import isValidEntityId from "../../../common/entity/valid_entity_id"; + +export default function processConfigEntities(entities) { + if (!entities || !Array.isArray(entities)) { + throw new Error("Entities need to be an array"); + } + + return entities.map((entityConf, index) => { + if ( + typeof entityConf === "object" && + !Array.isArray(entityConf) && + entityConf.type + ) { + return entityConf; + } + + if (typeof entityConf === "string") { + entityConf = { entity: entityConf }; + } else if (typeof entityConf === "object" && !Array.isArray(entityConf)) { + if (!entityConf.entity) { + throw new Error( + `Entity object at position ${index} is missing entity field.` + ); + } + } else { + throw new Error(`Invalid entity specified at position ${index}.`); + } + + if (!isValidEntityId(entityConf.entity)) { + throw new Error( + `Invalid entity ID at position ${index}: ${entityConf.entity}` + ); + } + + return entityConf; + }); +} diff --git a/src/panels/lovelace/components/hui-card-options.ts b/src/panels/lovelace/components/hui-card-options.ts index 7b18f8119ef8..1e7b343c1238 100644 --- a/src/panels/lovelace/components/hui-card-options.ts +++ b/src/panels/lovelace/components/hui-card-options.ts @@ -1,68 +1,68 @@ -import "@polymer/paper-button/paper-button.js"; -import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; -import { fireEvent } from "../../../common/dom/fire_event.js"; -import { HomeAssistant } from "../../../types.js"; - -let registeredDialog = false; - -export class HuiCardOptions extends LitElement { - public cardId?: string; - protected hass?: HomeAssistant; - - static get properties(): PropertyDeclarations { - return { - hass: {}, - }; - } - - public connectedCallback() { - super.connectedCallback(); - if (!registeredDialog) { - registeredDialog = true; - fireEvent(this, "register-dialog", { - dialogShowEvent: "show-edit-card", - dialogTag: "hui-dialog-edit-card", - dialogImport: () => import("../editor/hui-dialog-edit-card"), - }); - } - } - - protected render() { - return html` - - -
- EDIT -
- `; - } - private _editCard() { - fireEvent(this, "show-edit-card", { - hass: this.hass, - cardId: this.cardId, - reloadLovelace: () => fireEvent(this, "config-refresh"), - }); - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-card-options": HuiCardOptions; - } -} - -customElements.define("hui-card-options", HuiCardOptions); +import "@polymer/paper-button/paper-button"; +import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; +import { fireEvent } from "../../../common/dom/fire_event"; +import { HomeAssistant } from "../../../types"; + +let registeredDialog = false; + +export class HuiCardOptions extends LitElement { + public cardId?: string; + protected hass?: HomeAssistant; + + static get properties(): PropertyDeclarations { + return { + hass: {}, + }; + } + + public connectedCallback() { + super.connectedCallback(); + if (!registeredDialog) { + registeredDialog = true; + fireEvent(this, "register-dialog", { + dialogShowEvent: "show-edit-card", + dialogTag: "hui-dialog-edit-card", + dialogImport: () => import("../editor/hui-dialog-edit-card"), + }); + } + } + + protected render() { + return html` + + +
+ EDIT +
+ `; + } + private _editCard() { + fireEvent(this, "show-edit-card", { + hass: this.hass, + cardId: this.cardId, + reloadLovelace: () => fireEvent(this, "config-refresh"), + }); + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-card-options": HuiCardOptions; + } +} + +customElements.define("hui-card-options", HuiCardOptions); diff --git a/src/panels/lovelace/components/hui-entities-toggle.js b/src/panels/lovelace/components/hui-entities-toggle.js index 6df9e1fb7e92..7055c2a962ff 100644 --- a/src/panels/lovelace/components/hui-entities-toggle.js +++ b/src/panels/lovelace/components/hui-entities-toggle.js @@ -1,57 +1,57 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/paper-toggle-button/paper-toggle-button.js"; - -import { DOMAINS_TOGGLE } from "../../../common/const.js"; -import turnOnOffEntities from "../common/entity/turn-on-off-entities.js"; - -class HuiEntitiesToggle extends PolymerElement { - static get template() { - return html` - - -`; - } - - static get properties() { - return { - hass: Object, - entities: Array, - _toggleEntities: { - type: Array, - computed: "_computeToggleEntities(hass, entities)", - }, - }; - } - - _computeToggleEntities(hass, entityIds) { - return entityIds.filter( - (entityId) => - entityId in hass.states && DOMAINS_TOGGLE.has(entityId.split(".", 1)[0]) - ); - } - - _computeIsChecked(hass, entityIds) { - return entityIds.some((entityId) => hass.states[entityId].state === "on"); - } - - _callService(ev) { - const turnOn = ev.target.checked; - turnOnOffEntities(this.hass, this._toggleEntities, turnOn); - } -} - -customElements.define("hui-entities-toggle", HuiEntitiesToggle); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/paper-toggle-button/paper-toggle-button"; + +import { DOMAINS_TOGGLE } from "../../../common/const"; +import turnOnOffEntities from "../common/entity/turn-on-off-entities"; + +class HuiEntitiesToggle extends PolymerElement { + static get template() { + return html` + + +`; + } + + static get properties() { + return { + hass: Object, + entities: Array, + _toggleEntities: { + type: Array, + computed: "_computeToggleEntities(hass, entities)", + }, + }; + } + + _computeToggleEntities(hass, entityIds) { + return entityIds.filter( + (entityId) => + entityId in hass.states && DOMAINS_TOGGLE.has(entityId.split(".", 1)[0]) + ); + } + + _computeIsChecked(hass, entityIds) { + return entityIds.some((entityId) => hass.states[entityId].state === "on"); + } + + _callService(ev) { + const turnOn = ev.target.checked; + turnOnOffEntities(this.hass, this._toggleEntities, turnOn); + } +} + +customElements.define("hui-entities-toggle", HuiEntitiesToggle); diff --git a/src/panels/lovelace/components/hui-generic-entity-row.js b/src/panels/lovelace/components/hui-generic-entity-row.js index 6a14507b7000..092a065c224c 100644 --- a/src/panels/lovelace/components/hui-generic-entity-row.js +++ b/src/panels/lovelace/components/hui-generic-entity-row.js @@ -1,137 +1,137 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/entity/state-badge.js"; -import "../../../components/ha-relative-time.js"; -import "../../../components/ha-icon.js"; - -import computeStateName from "../../../common/entity/compute_state_name.js"; - -class HuiGenericEntityRow extends PolymerElement { - static get template() { - return html` - ${this.styleTemplate} - - - `; - } - - static get styleTemplate() { - return html` - - `; - } - - static get stateBadgeTemplate() { - return html` - - `; - } - - static get infoTemplate() { - return html` -
- [[_computeName(config.name, _stateObj)]] -
- - -
-
- `; - } - - static get properties() { - return { - hass: Object, - config: Object, - _stateObj: { - type: Object, - computed: "_computeStateObj(hass.states, config.entity)", - }, - showSecondary: { - type: Boolean, - value: true, - }, - }; - } - - _equals(a, b) { - return a === b; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - _computeName(name, stateObj) { - return name || computeStateName(stateObj); - } -} -customElements.define("hui-generic-entity-row", HuiGenericEntityRow); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/entity/state-badge"; +import "../../../components/ha-relative-time"; +import "../../../components/ha-icon"; + +import computeStateName from "../../../common/entity/compute_state_name"; + +class HuiGenericEntityRow extends PolymerElement { + static get template() { + return html` + ${this.styleTemplate} + + + `; + } + + static get styleTemplate() { + return html` + + `; + } + + static get stateBadgeTemplate() { + return html` + + `; + } + + static get infoTemplate() { + return html` +
+ [[_computeName(config.name, _stateObj)]] +
+ + +
+
+ `; + } + + static get properties() { + return { + hass: Object, + config: Object, + _stateObj: { + type: Object, + computed: "_computeStateObj(hass.states, config.entity)", + }, + showSecondary: { + type: Boolean, + value: true, + }, + }; + } + + _equals(a, b) { + return a === b; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + _computeName(name, stateObj) { + return name || computeStateName(stateObj); + } +} +customElements.define("hui-generic-entity-row", HuiGenericEntityRow); diff --git a/src/panels/lovelace/components/hui-image.js b/src/panels/lovelace/components/hui-image.js index bbaba4ce91ba..7164da4c4fb2 100644 --- a/src/panels/lovelace/components/hui-image.js +++ b/src/panels/lovelace/components/hui-image.js @@ -1,198 +1,198 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/paper-toggle-button/paper-toggle-button.js"; - -import { STATES_OFF } from "../../../common/const.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; - -import parseAspectRatio from "../../../common/util/parse-aspect-ratio.js"; - -const UPDATE_INTERVAL = 10000; -const DEFAULT_FILTER = "grayscale(100%)"; - -/* - * @appliesMixin LocalizeMixin - */ -class HuiImage extends LocalizeMixin(PolymerElement) { - static get template() { - return html` - ${this.styleTemplate} -
- -
-
- `; - } - - static get styleTemplate() { - return html` - - `; - } - - static get properties() { - return { - hass: { - type: Object, - observer: "_hassChanged", - }, - entity: String, - image: String, - stateImage: Object, - cameraImage: String, - aspectRatio: String, - filter: String, - stateFilter: Object, - _imageSrc: String, - }; - } - - static get observers() { - return ["_configChanged(image, stateImage, cameraImage, aspectRatio)"]; - } - - connectedCallback() { - super.connectedCallback(); - if (this.cameraImage) { - this.timer = setInterval( - () => this._updateCameraImageSrc(), - UPDATE_INTERVAL - ); - } - } - - disconnectedCallback() { - super.disconnectedCallback(); - clearInterval(this.timer); - } - - _configChanged(image, stateImage, cameraImage, aspectRatio) { - const ratio = parseAspectRatio(aspectRatio); - - if (ratio && ratio.w > 0 && ratio.h > 0) { - this.$.wrapper.style.paddingBottom = `${( - (100 * ratio.h) / - ratio.w - ).toFixed(2)}%`; - this.$.wrapper.classList.add("ratio"); - } - - if (cameraImage) { - this._updateCameraImageSrc(); - } else if (image && !stateImage) { - this._imageSrc = image; - } - } - - _onImageError() { - this._imageSrc = null; - this.$.image.classList.add("hidden"); - if (!this.$.wrapper.classList.contains("ratio")) { - this.$.brokenImage.style.setProperty( - "height", - `${this._lastImageHeight || "100"}px` - ); - } - this.$.brokenImage.classList.remove("hidden"); - } - - _onImageLoad() { - this.$.image.classList.remove("hidden"); - this.$.brokenImage.classList.add("hidden"); - if (!this.$.wrapper.classList.contains("ratio")) { - this._lastImageHeight = this.$.image.offsetHeight; - } - } - - _hassChanged(hass) { - if (this.cameraImage || !this.entity) { - return; - } - - const stateObj = hass.states[this.entity]; - const newState = !stateObj ? "unavailable" : stateObj.state; - - if (newState === this._currentState) return; - this._currentState = newState; - - this._updateStateImage(); - this._updateStateFilter(stateObj); - } - - _updateStateImage() { - if (!this.stateImage) { - this._imageFallback = true; - return; - } - const stateImg = this.stateImage[this._currentState]; - this._imageSrc = stateImg || this.image; - this._imageFallback = !stateImg; - } - - _updateStateFilter(stateObj) { - let filter; - if (!this.stateFilter) { - filter = this.filter; - } else { - filter = this.stateFilter[this._currentState] || this.filter; - } - - const isOff = !stateObj || STATES_OFF.includes(stateObj.state); - this.$.image.style.filter = - filter || (isOff && this._imageFallback && DEFAULT_FILTER) || ""; - } - - async _updateCameraImageSrc() { - try { - const { content_type: contentType, content } = await this.hass.callWS({ - type: "camera_thumbnail", - entity_id: this.cameraImage, - }); - this._imageSrc = `data:${contentType};base64, ${content}`; - this._onImageLoad(); - } catch (err) { - this._onImageError(); - } - } -} - -customElements.define("hui-image", HuiImage); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/paper-toggle-button/paper-toggle-button"; + +import { STATES_OFF } from "../../../common/const"; +import LocalizeMixin from "../../../mixins/localize-mixin"; + +import parseAspectRatio from "../../../common/util/parse-aspect-ratio"; + +const UPDATE_INTERVAL = 10000; +const DEFAULT_FILTER = "grayscale(100%)"; + +/* + * @appliesMixin LocalizeMixin + */ +class HuiImage extends LocalizeMixin(PolymerElement) { + static get template() { + return html` + ${this.styleTemplate} +
+ +
+
+ `; + } + + static get styleTemplate() { + return html` + + `; + } + + static get properties() { + return { + hass: { + type: Object, + observer: "_hassChanged", + }, + entity: String, + image: String, + stateImage: Object, + cameraImage: String, + aspectRatio: String, + filter: String, + stateFilter: Object, + _imageSrc: String, + }; + } + + static get observers() { + return ["_configChanged(image, stateImage, cameraImage, aspectRatio)"]; + } + + connectedCallback() { + super.connectedCallback(); + if (this.cameraImage) { + this.timer = setInterval( + () => this._updateCameraImageSrc(), + UPDATE_INTERVAL + ); + } + } + + disconnectedCallback() { + super.disconnectedCallback(); + clearInterval(this.timer); + } + + _configChanged(image, stateImage, cameraImage, aspectRatio) { + const ratio = parseAspectRatio(aspectRatio); + + if (ratio && ratio.w > 0 && ratio.h > 0) { + this.$.wrapper.style.paddingBottom = `${( + (100 * ratio.h) / + ratio.w + ).toFixed(2)}%`; + this.$.wrapper.classList.add("ratio"); + } + + if (cameraImage) { + this._updateCameraImageSrc(); + } else if (image && !stateImage) { + this._imageSrc = image; + } + } + + _onImageError() { + this._imageSrc = null; + this.$.image.classList.add("hidden"); + if (!this.$.wrapper.classList.contains("ratio")) { + this.$.brokenImage.style.setProperty( + "height", + `${this._lastImageHeight || "100"}px` + ); + } + this.$.brokenImage.classList.remove("hidden"); + } + + _onImageLoad() { + this.$.image.classList.remove("hidden"); + this.$.brokenImage.classList.add("hidden"); + if (!this.$.wrapper.classList.contains("ratio")) { + this._lastImageHeight = this.$.image.offsetHeight; + } + } + + _hassChanged(hass) { + if (this.cameraImage || !this.entity) { + return; + } + + const stateObj = hass.states[this.entity]; + const newState = !stateObj ? "unavailable" : stateObj.state; + + if (newState === this._currentState) return; + this._currentState = newState; + + this._updateStateImage(); + this._updateStateFilter(stateObj); + } + + _updateStateImage() { + if (!this.stateImage) { + this._imageFallback = true; + return; + } + const stateImg = this.stateImage[this._currentState]; + this._imageSrc = stateImg || this.image; + this._imageFallback = !stateImg; + } + + _updateStateFilter(stateObj) { + let filter; + if (!this.stateFilter) { + filter = this.filter; + } else { + filter = this.stateFilter[this._currentState] || this.filter; + } + + const isOff = !stateObj || STATES_OFF.includes(stateObj.state); + this.$.image.style.filter = + filter || (isOff && this._imageFallback && DEFAULT_FILTER) || ""; + } + + async _updateCameraImageSrc() { + try { + const { content_type: contentType, content } = await this.hass.callWS({ + type: "camera_thumbnail", + entity_id: this.cameraImage, + }); + this._imageSrc = `data:${contentType};base64, ${content}`; + this._onImageLoad(); + } catch (err) { + this._onImageError(); + } + } +} + +customElements.define("hui-image", HuiImage); diff --git a/src/panels/lovelace/components/notifications/hui-configurator-notification-item.js b/src/panels/lovelace/components/notifications/hui-configurator-notification-item.js index 3d6c670f0a92..9924c40eb800 100644 --- a/src/panels/lovelace/components/notifications/hui-configurator-notification-item.js +++ b/src/panels/lovelace/components/notifications/hui-configurator-notification-item.js @@ -1,62 +1,62 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; - -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "./hui-notification-item-template.js"; - -import EventsMixin from "../../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../../mixins/localize-mixin.js"; - -/* - * @appliesMixin EventsMixin - * @appliesMixin LocalizeMixin - */ -export class HuiConfiguratorNotificationItem extends EventsMixin( - LocalizeMixin(PolymerElement) -) { - static get template() { - return html` - - [[localize('domain.configurator')]] - -
[[_getMessage(notification)]]
- - [[_localizeState(notification.state)]] -
- `; - } - - static get properties() { - return { - hass: Object, - notification: Object, - }; - } - - _handleClick() { - this.fire("hass-more-info", { entityId: this.notification.entity_id }); - } - - _localizeState(state) { - return this.localize(`state.configurator.${state}`); - } - - _getMessage(notification) { - const friendlyName = notification.attributes.friendly_name; - return this.localize( - "ui.notification_drawer.click_to_configure", - "entity", - friendlyName - ); - } -} -customElements.define( - "hui-configurator-notification-item", - HuiConfiguratorNotificationItem -); +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-icon-button/paper-icon-button"; + +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "./hui-notification-item-template"; + +import EventsMixin from "../../../../mixins/events-mixin"; +import LocalizeMixin from "../../../../mixins/localize-mixin"; + +/* + * @appliesMixin EventsMixin + * @appliesMixin LocalizeMixin + */ +export class HuiConfiguratorNotificationItem extends EventsMixin( + LocalizeMixin(PolymerElement) +) { + static get template() { + return html` + + [[localize('domain.configurator')]] + +
[[_getMessage(notification)]]
+ + [[_localizeState(notification.state)]] +
+ `; + } + + static get properties() { + return { + hass: Object, + notification: Object, + }; + } + + _handleClick() { + this.fire("hass-more-info", { entityId: this.notification.entity_id }); + } + + _localizeState(state) { + return this.localize(`state.configurator.${state}`); + } + + _getMessage(notification) { + const friendlyName = notification.attributes.friendly_name; + return this.localize( + "ui.notification_drawer.click_to_configure", + "entity", + friendlyName + ); + } +} +customElements.define( + "hui-configurator-notification-item", + HuiConfiguratorNotificationItem +); diff --git a/src/panels/lovelace/components/notifications/hui-notification-drawer.js b/src/panels/lovelace/components/notifications/hui-notification-drawer.js index c07d3ecbc115..62ce12b5af88 100644 --- a/src/panels/lovelace/components/notifications/hui-notification-drawer.js +++ b/src/panels/lovelace/components/notifications/hui-notification-drawer.js @@ -1,175 +1,175 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; - -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "./hui-notification-item.js"; - -import EventsMixin from "../../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../../mixins/localize-mixin.js"; - -/* - * @appliesMixin EventsMixin - * @appliesMixin LocalizeMixin - */ -export class HuiNotificationDrawer extends EventsMixin( - LocalizeMixin(PolymerElement) -) { - static get template() { - return html` - -
-
- -
[[localize('ui.notification_drawer.title')]]
- -
-
- - -
-
- `; - } - - static get properties() { - return { - hass: Object, - narrow: { - type: Boolean, - reflectToAttribute: true, - }, - open: { - type: Boolean, - notify: true, - observer: "_openChanged", - }, - hidden: { - type: Boolean, - value: true, - reflectToAttribute: true, - }, - notifications: { - type: Array, - value: [], - }, - }; - } - - _closeDrawer(ev) { - ev.stopPropagation(); - this.open = false; - } - - _empty(notifications) { - return notifications.length === 0; - } - - _openChanged(open) { - clearTimeout(this._openTimer); - if (open) { - // Render closed then animate open - this.hidden = false; - this._openTimer = setTimeout(() => { - this.classList.add("open"); - }, 50); - } else { - // Animate closed then hide - this.classList.remove("open"); - this._openTimer = setTimeout(() => { - this.hidden = true; - }, 250); - } - } -} -customElements.define("hui-notification-drawer", HuiNotificationDrawer); +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; + +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "./hui-notification-item"; + +import EventsMixin from "../../../../mixins/events-mixin"; +import LocalizeMixin from "../../../../mixins/localize-mixin"; + +/* + * @appliesMixin EventsMixin + * @appliesMixin LocalizeMixin + */ +export class HuiNotificationDrawer extends EventsMixin( + LocalizeMixin(PolymerElement) +) { + static get template() { + return html` + +
+
+ +
[[localize('ui.notification_drawer.title')]]
+ +
+
+ + +
+
+ `; + } + + static get properties() { + return { + hass: Object, + narrow: { + type: Boolean, + reflectToAttribute: true, + }, + open: { + type: Boolean, + notify: true, + observer: "_openChanged", + }, + hidden: { + type: Boolean, + value: true, + reflectToAttribute: true, + }, + notifications: { + type: Array, + value: [], + }, + }; + } + + _closeDrawer(ev) { + ev.stopPropagation(); + this.open = false; + } + + _empty(notifications) { + return notifications.length === 0; + } + + _openChanged(open) { + clearTimeout(this._openTimer); + if (open) { + // Render closed then animate open + this.hidden = false; + this._openTimer = setTimeout(() => { + this.classList.add("open"); + }, 50); + } else { + // Animate closed then hide + this.classList.remove("open"); + this._openTimer = setTimeout(() => { + this.hidden = true; + }, 250); + } + } +} +customElements.define("hui-notification-drawer", HuiNotificationDrawer); diff --git a/src/panels/lovelace/components/notifications/hui-notification-item-template.js b/src/panels/lovelace/components/notifications/hui-notification-item-template.js index 995b0e486993..de9d8c80856c 100644 --- a/src/panels/lovelace/components/notifications/hui-notification-item-template.js +++ b/src/panels/lovelace/components/notifications/hui-notification-item-template.js @@ -1,49 +1,49 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; - -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../../components/ha-card.js"; - -export class HuiNotificationItemTemplate extends PolymerElement { - static get template() { - return html` - - -
- -
-
- -
-
- -
-
- `; - } -} -customElements.define( - "hui-notification-item-template", - HuiNotificationItemTemplate -); +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-icon-button/paper-icon-button"; + +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../../components/ha-card"; + +export class HuiNotificationItemTemplate extends PolymerElement { + static get template() { + return html` + + +
+ +
+
+ +
+
+ +
+
+ `; + } +} +customElements.define( + "hui-notification-item-template", + HuiNotificationItemTemplate +); diff --git a/src/panels/lovelace/components/notifications/hui-notification-item.js b/src/panels/lovelace/components/notifications/hui-notification-item.js index c9ddb15c92a7..c54664c6babb 100644 --- a/src/panels/lovelace/components/notifications/hui-notification-item.js +++ b/src/panels/lovelace/components/notifications/hui-notification-item.js @@ -1,35 +1,35 @@ -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import computeDomain from "../../../../common/entity/compute_domain.js"; - -import "./hui-configurator-notification-item.js"; -import "./hui-persistent-notification-item.js"; - -export class HuiNotificationItem extends PolymerElement { - static get properties() { - return { - hass: Object, - notification: { - type: Object, - observer: "_stateChanged", - }, - }; - } - - _stateChanged(notification) { - if (this.lastChild) { - this.removeChild(this.lastChild); - } - - if (!notification) return; - - const domain = notification.entity_id - ? computeDomain(notification.entity_id) - : "persistent_notification"; - const tag = `hui-${domain}-notification-item`; - const el = document.createElement(tag); - el.hass = this.hass; - el.notification = notification; - this.appendChild(el); - } -} -customElements.define("hui-notification-item", HuiNotificationItem); +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import computeDomain from "../../../../common/entity/compute_domain"; + +import "./hui-configurator-notification-item"; +import "./hui-persistent-notification-item"; + +export class HuiNotificationItem extends PolymerElement { + static get properties() { + return { + hass: Object, + notification: { + type: Object, + observer: "_stateChanged", + }, + }; + } + + _stateChanged(notification) { + if (this.lastChild) { + this.removeChild(this.lastChild); + } + + if (!notification) return; + + const domain = notification.entity_id + ? computeDomain(notification.entity_id) + : "persistent_notification"; + const tag = `hui-${domain}-notification-item`; + const el = document.createElement(tag); + el.hass = this.hass; + el.notification = notification; + this.appendChild(el); + } +} +customElements.define("hui-notification-item", HuiNotificationItem); diff --git a/src/panels/lovelace/components/notifications/hui-notifications-button.js b/src/panels/lovelace/components/notifications/hui-notifications-button.js index ba73b4c88db5..5c26714296c3 100644 --- a/src/panels/lovelace/components/notifications/hui-notifications-button.js +++ b/src/panels/lovelace/components/notifications/hui-notifications-button.js @@ -1,62 +1,62 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; - -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import EventsMixin from "../../../../mixins/events-mixin.js"; - -/* - * @appliesMixin EventsMixin - */ -export class HuiNotificationsButton extends EventsMixin(PolymerElement) { - static get template() { - return html` - - - - `; - } - - static get properties() { - return { - notificationsOpen: { - type: Boolean, - notify: true, - }, - notifications: { - type: Array, - value: [], - }, - }; - } - - _clicked() { - this.notificationsOpen = true; - } - - _hasNotifications(notifications) { - return notifications.length > 0; - } -} -customElements.define("hui-notifications-button", HuiNotificationsButton); +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; + +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import EventsMixin from "../../../../mixins/events-mixin"; + +/* + * @appliesMixin EventsMixin + */ +export class HuiNotificationsButton extends EventsMixin(PolymerElement) { + static get template() { + return html` + + + + `; + } + + static get properties() { + return { + notificationsOpen: { + type: Boolean, + notify: true, + }, + notifications: { + type: Array, + value: [], + }, + }; + } + + _clicked() { + this.notificationsOpen = true; + } + + _hasNotifications(notifications) { + return notifications.length > 0; + } +} +customElements.define("hui-notifications-button", HuiNotificationsButton); diff --git a/src/panels/lovelace/components/notifications/hui-persistent-notification-item.js b/src/panels/lovelace/components/notifications/hui-persistent-notification-item.js index d9dc8a52dd14..86bf11d006db 100644 --- a/src/panels/lovelace/components/notifications/hui-persistent-notification-item.js +++ b/src/panels/lovelace/components/notifications/hui-persistent-notification-item.js @@ -1,89 +1,89 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-tooltip/paper-tooltip.js"; - -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../../components/ha-relative-time.js"; -import "../../../../components/ha-markdown.js"; -import "./hui-notification-item-template.js"; - -import LocalizeMixin from "../../../../mixins/localize-mixin.js"; - -/* - * @appliesMixin LocalizeMixin - */ -export class HuiPersistentNotificationItem extends LocalizeMixin( - PolymerElement -) { - static get template() { - return html` - - - [[_computeTitle(notification)]] - - - -
- - - [[_computeTooltip(hass, notification)]] - -
- - [[localize('ui.card.persistent_notification.dismiss')]] -
- `; - } - - static get properties() { - return { - hass: Object, - notification: Object, - }; - } - - _handleDismiss() { - this.hass.callService("persistent_notification", "dismiss", { - notification_id: this.notification.notification_id, - }); - } - - _computeTitle(notification) { - return notification.title || notification.notification_id; - } - - _computeTooltip(hass, notification) { - if (!hass || !notification) return null; - - const d = new Date(notification.created_at); - return d.toLocaleDateString(hass.language, { - year: "numeric", - month: "short", - day: "numeric", - minute: "numeric", - hour: "numeric", - }); - } -} -customElements.define( - "hui-persistent_notification-notification-item", - HuiPersistentNotificationItem -); +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-tooltip/paper-tooltip"; + +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../../components/ha-relative-time"; +import "../../../../components/ha-markdown"; +import "./hui-notification-item-template"; + +import LocalizeMixin from "../../../../mixins/localize-mixin"; + +/* + * @appliesMixin LocalizeMixin + */ +export class HuiPersistentNotificationItem extends LocalizeMixin( + PolymerElement +) { + static get template() { + return html` + + + [[_computeTitle(notification)]] + + + +
+ + + [[_computeTooltip(hass, notification)]] + +
+ + [[localize('ui.card.persistent_notification.dismiss')]] +
+ `; + } + + static get properties() { + return { + hass: Object, + notification: Object, + }; + } + + _handleDismiss() { + this.hass.callService("persistent_notification", "dismiss", { + notification_id: this.notification.notification_id, + }); + } + + _computeTitle(notification) { + return notification.title || notification.notification_id; + } + + _computeTooltip(hass, notification) { + if (!hass || !notification) return null; + + const d = new Date(notification.created_at); + return d.toLocaleDateString(hass.language, { + year: "numeric", + month: "short", + day: "numeric", + minute: "numeric", + hour: "numeric", + }); + } +} +customElements.define( + "hui-persistent_notification-notification-item", + HuiPersistentNotificationItem +); diff --git a/src/panels/lovelace/editor/hui-dialog-edit-card.ts b/src/panels/lovelace/editor/hui-dialog-edit-card.ts index adae0b17e8b2..c674b156c9bd 100644 --- a/src/panels/lovelace/editor/hui-dialog-edit-card.ts +++ b/src/panels/lovelace/editor/hui-dialog-edit-card.ts @@ -1,122 +1,122 @@ -import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; -import { fireEvent } from "../../../common/dom/fire_event.js"; - -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-input/paper-textarea.js"; -import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable.js"; -import "@polymer/paper-dialog/paper-dialog.js"; -// This is not a duplicate import, one is for types, one is for element. -// tslint:disable-next-line -import { PaperDialogElement } from "@polymer/paper-dialog/paper-dialog.js"; -import { HomeAssistant } from "../../../types"; -import { getCardConfig, updateCardConfig } from "../common/data"; - -import "./hui-yaml-editor"; -import "./hui-yaml-card-preview"; -// This is not a duplicate import, one is for types, one is for element. -// tslint:disable-next-line -import { HuiYAMLCardPreview } from "./hui-yaml-card-preview"; - -export class HuiDialogEditCard extends LitElement { - protected hass?: HomeAssistant; - private _cardId?: string; - private _cardConfig?: string; - private _reloadLovelace?: () => void; - - static get properties(): PropertyDeclarations { - return { - hass: {}, - cardId: { - type: Number, - }, - _cardConfig: {}, - _dialogClosedCallback: {}, - }; - } - - public async showDialog({ hass, cardId, reloadLovelace }) { - this.hass = hass; - this._cardId = cardId; - this._reloadLovelace = reloadLovelace; - this._cardConfig = ""; - this._loadConfig(); - // Wait till dialog is rendered. - await this.updateComplete; - this._dialog.open(); - } - - private get _dialog(): PaperDialogElement { - return this.shadowRoot!.querySelector("paper-dialog")!; - } - - private get _previewEl(): HuiYAMLCardPreview { - return this.shadowRoot!.querySelector("hui-yaml-card-preview")!; - } - - protected render() { - return html` - - -

Card Configuration

- - - - -
- Cancel - Save -
-
- `; - } - - private _handleYamlChanged(ev) { - this._previewEl.yaml = ev.detail.yaml; - } - - private _closeDialog() { - this._dialog.close(); - } - - private async _loadConfig() { - this._cardConfig = await getCardConfig(this.hass!, this._cardId!); - await this.updateComplete; - // This will center the dialog with the updated config - fireEvent(this._dialog, "iron-resize"); - } - - private async _updateConfig() { - const newCardConfig = this.shadowRoot!.querySelector("hui-yaml-editor")! - .yaml; - - if (this._cardConfig === newCardConfig) { - this._dialog.close(); - return; - } - try { - await updateCardConfig(this.hass!, this._cardId!, newCardConfig); - this._dialog.close(); - this._reloadLovelace!(); - } catch (err) { - alert(`Saving failed: ${err.reason}`); - } - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-dialog-edit-card": HuiDialogEditCard; - } -} - -customElements.define("hui-dialog-edit-card", HuiDialogEditCard); +import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; +import { fireEvent } from "../../../common/dom/fire_event"; + +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-input/paper-textarea"; +import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable"; +import "@polymer/paper-dialog/paper-dialog"; +// This is not a duplicate import, one is for types, one is for element. +// tslint:disable-next-line +import { PaperDialogElement } from "@polymer/paper-dialog/paper-dialog"; +import { HomeAssistant } from "../../../types"; +import { getCardConfig, updateCardConfig } from "../common/data"; + +import "./hui-yaml-editor"; +import "./hui-yaml-card-preview"; +// This is not a duplicate import, one is for types, one is for element. +// tslint:disable-next-line +import { HuiYAMLCardPreview } from "./hui-yaml-card-preview"; + +export class HuiDialogEditCard extends LitElement { + protected hass?: HomeAssistant; + private _cardId?: string; + private _cardConfig?: string; + private _reloadLovelace?: () => void; + + static get properties(): PropertyDeclarations { + return { + hass: {}, + cardId: { + type: Number, + }, + _cardConfig: {}, + _dialogClosedCallback: {}, + }; + } + + public async showDialog({ hass, cardId, reloadLovelace }) { + this.hass = hass; + this._cardId = cardId; + this._reloadLovelace = reloadLovelace; + this._cardConfig = ""; + this._loadConfig(); + // Wait till dialog is rendered. + await this.updateComplete; + this._dialog.open(); + } + + private get _dialog(): PaperDialogElement { + return this.shadowRoot!.querySelector("paper-dialog")!; + } + + private get _previewEl(): HuiYAMLCardPreview { + return this.shadowRoot!.querySelector("hui-yaml-card-preview")!; + } + + protected render() { + return html` + + +

Card Configuration

+ + + + +
+ Cancel + Save +
+
+ `; + } + + private _handleYamlChanged(ev) { + this._previewEl.yaml = ev.detail.yaml; + } + + private _closeDialog() { + this._dialog.close(); + } + + private async _loadConfig() { + this._cardConfig = await getCardConfig(this.hass!, this._cardId!); + await this.updateComplete; + // This will center the dialog with the updated config + fireEvent(this._dialog, "iron-resize"); + } + + private async _updateConfig() { + const newCardConfig = this.shadowRoot!.querySelector("hui-yaml-editor")! + .yaml; + + if (this._cardConfig === newCardConfig) { + this._dialog.close(); + return; + } + try { + await updateCardConfig(this.hass!, this._cardId!, newCardConfig); + this._dialog.close(); + this._reloadLovelace!(); + } catch (err) { + alert(`Saving failed: ${err.reason}`); + } + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-dialog-edit-card": HuiDialogEditCard; + } +} + +customElements.define("hui-dialog-edit-card", HuiDialogEditCard); diff --git a/src/panels/lovelace/editor/hui-yaml-card-preview.ts b/src/panels/lovelace/editor/hui-yaml-card-preview.ts index 67ce7f1d6b23..9eae71466a47 100644 --- a/src/panels/lovelace/editor/hui-yaml-card-preview.ts +++ b/src/panels/lovelace/editor/hui-yaml-card-preview.ts @@ -1,52 +1,52 @@ -import yaml from "js-yaml"; - -import "@polymer/paper-input/paper-textarea.js"; - -import createCardElement from "../common/create-card-element"; -import createErrorCardConfig from "../common/create-error-card-config"; -import { HomeAssistant } from "../../../types"; -import { LovelaceCard } from "../types"; - -export class HuiYAMLCardPreview extends HTMLElement { - private _hass?: HomeAssistant; - - set hass(value: HomeAssistant) { - this._hass = value; - if (this.lastChild) { - (this.lastChild as LovelaceCard).hass = value; - } - } - - set yaml(value: string) { - if (this.lastChild) { - this.removeChild(this.lastChild); - } - - if (value === "") { - return; - } - - let conf; - try { - conf = yaml.safeLoad(value); - } catch (err) { - conf = createErrorCardConfig(`Invalid YAML: ${err.message}`, undefined); - } - - const element = createCardElement(conf); - - if (this._hass) { - element.hass = this._hass; - } - - this.appendChild(element); - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-yaml-card-preview": HuiYAMLCardPreview; - } -} - -customElements.define("hui-yaml-card-preview", HuiYAMLCardPreview); +import yaml from "js-yaml"; + +import "@polymer/paper-input/paper-textarea"; + +import createCardElement from "../common/create-card-element"; +import createErrorCardConfig from "../common/create-error-card-config"; +import { HomeAssistant } from "../../../types"; +import { LovelaceCard } from "../types"; + +export class HuiYAMLCardPreview extends HTMLElement { + private _hass?: HomeAssistant; + + set hass(value: HomeAssistant) { + this._hass = value; + if (this.lastChild) { + (this.lastChild as LovelaceCard).hass = value; + } + } + + set yaml(value: string) { + if (this.lastChild) { + this.removeChild(this.lastChild); + } + + if (value === "") { + return; + } + + let conf; + try { + conf = yaml.safeLoad(value); + } catch (err) { + conf = createErrorCardConfig(`Invalid YAML: ${err.message}`, undefined); + } + + const element = createCardElement(conf); + + if (this._hass) { + element.hass = this._hass; + } + + this.appendChild(element); + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-yaml-card-preview": HuiYAMLCardPreview; + } +} + +customElements.define("hui-yaml-card-preview", HuiYAMLCardPreview); diff --git a/src/panels/lovelace/editor/hui-yaml-editor.ts b/src/panels/lovelace/editor/hui-yaml-editor.ts index 170a08b3cb22..f1bdaa58e07a 100644 --- a/src/panels/lovelace/editor/hui-yaml-editor.ts +++ b/src/panels/lovelace/editor/hui-yaml-editor.ts @@ -1,41 +1,41 @@ -import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; -import { fireEvent } from "../../../common/dom/fire_event.js"; - -import "@polymer/paper-input/paper-textarea.js"; - -export class HuiYAMLEditor extends LitElement { - public yaml?: string; - - static get properties(): PropertyDeclarations { - return { - yaml: {}, - }; - } - - protected render() { - return html` - - - `; - } - - private _valueChanged(ev) { - this.yaml = ev.target.value; - fireEvent(this, "yaml-changed", { yaml: ev.target.value }); - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-yaml-editor": HuiYAMLEditor; - } -} - -customElements.define("hui-yaml-editor", HuiYAMLEditor); +import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; +import { fireEvent } from "../../../common/dom/fire_event"; + +import "@polymer/paper-input/paper-textarea"; + +export class HuiYAMLEditor extends LitElement { + public yaml?: string; + + static get properties(): PropertyDeclarations { + return { + yaml: {}, + }; + } + + protected render() { + return html` + + + `; + } + + private _valueChanged(ev) { + this.yaml = ev.target.value; + fireEvent(this, "yaml-changed", { yaml: ev.target.value }); + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-yaml-editor": HuiYAMLEditor; + } +} + +customElements.define("hui-yaml-editor", HuiYAMLEditor); diff --git a/src/panels/lovelace/elements/hui-icon-element.ts b/src/panels/lovelace/elements/hui-icon-element.ts index 58c408b8dd9f..3a3fce32a8d7 100644 --- a/src/panels/lovelace/elements/hui-icon-element.ts +++ b/src/panels/lovelace/elements/hui-icon-element.ts @@ -1,68 +1,68 @@ -import { html, LitElement } from "@polymer/lit-element"; - -import "../../../components/ha-icon.js"; - -import { computeTooltip } from "../common/compute-tooltip"; -import { handleClick } from "../common/handle-click"; -import { longPress } from "../common/directives/long-press-directive"; -import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; -import { LovelaceElement, LovelaceElementConfig } from "./types.js"; -import { HomeAssistant } from "../../../types.js"; -import { TemplateResult } from "lit-html"; - -interface Config extends LovelaceElementConfig { - icon: string; -} - -export class HuiIconElement extends hassLocalizeLitMixin(LitElement) - implements LovelaceElement { - public hass?: HomeAssistant; - private _config?: Config; - - static get properties() { - return { hass: {}, _config: {} }; - } - - public setConfig(config: Config): void { - if (!config.icon) { - throw Error("Invalid Configuration: 'icon' required"); - } - - this._config = config; - } - - protected render(): TemplateResult { - if (!this._config) { - return html``; - } - - return html` - ${this.renderStyle()} - - `; - } - - private renderStyle(): TemplateResult { - return html` - - `; - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-icon-element": HuiIconElement; - } -} - -customElements.define("hui-icon-element", HuiIconElement); +import { html, LitElement } from "@polymer/lit-element"; + +import "../../../components/ha-icon"; + +import { computeTooltip } from "../common/compute-tooltip"; +import { handleClick } from "../common/handle-click"; +import { longPress } from "../common/directives/long-press-directive"; +import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; +import { LovelaceElement, LovelaceElementConfig } from "./types"; +import { HomeAssistant } from "../../../types"; +import { TemplateResult } from "lit-html"; + +interface Config extends LovelaceElementConfig { + icon: string; +} + +export class HuiIconElement extends hassLocalizeLitMixin(LitElement) + implements LovelaceElement { + public hass?: HomeAssistant; + private _config?: Config; + + static get properties() { + return { hass: {}, _config: {} }; + } + + public setConfig(config: Config): void { + if (!config.icon) { + throw Error("Invalid Configuration: 'icon' required"); + } + + this._config = config; + } + + protected render(): TemplateResult { + if (!this._config) { + return html``; + } + + return html` + ${this.renderStyle()} + + `; + } + + private renderStyle(): TemplateResult { + return html` + + `; + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-icon-element": HuiIconElement; + } +} + +customElements.define("hui-icon-element", HuiIconElement); diff --git a/src/panels/lovelace/elements/hui-image-element.ts b/src/panels/lovelace/elements/hui-image-element.ts index 97631063b32e..5f5992a9cf5c 100644 --- a/src/panels/lovelace/elements/hui-image-element.ts +++ b/src/panels/lovelace/elements/hui-image-element.ts @@ -1,13 +1,13 @@ import { html, LitElement } from "@polymer/lit-element"; -import "../components/hui-image.js"; +import "../components/hui-image"; import { computeTooltip } from "../common/compute-tooltip"; import { handleClick } from "../common/handle-click"; import { longPress } from "../common/directives/long-press-directive"; import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; -import { LovelaceElement, LovelaceElementConfig } from "./types.js"; -import { HomeAssistant } from "../../../types.js"; +import { LovelaceElement, LovelaceElementConfig } from "./types"; +import { HomeAssistant } from "../../../types"; import { TemplateResult } from "lit-html"; interface Config extends LovelaceElementConfig { diff --git a/src/panels/lovelace/elements/hui-service-button-element.ts b/src/panels/lovelace/elements/hui-service-button-element.ts index c87e3099def9..7a39f19d35f8 100644 --- a/src/panels/lovelace/elements/hui-service-button-element.ts +++ b/src/panels/lovelace/elements/hui-service-button-element.ts @@ -1,10 +1,10 @@ import { html, LitElement } from "@polymer/lit-element"; import { TemplateResult } from "lit-html"; -import "../../../components/buttons/ha-call-service-button.js"; +import "../../../components/buttons/ha-call-service-button"; -import { LovelaceElement, LovelaceElementConfig } from "./types.js"; -import { HomeAssistant } from "../../../types.js"; +import { LovelaceElement, LovelaceElementConfig } from "./types"; +import { HomeAssistant } from "../../../types"; export class HuiServiceButtonElement extends LitElement implements LovelaceElement { diff --git a/src/panels/lovelace/elements/hui-state-badge-element.ts b/src/panels/lovelace/elements/hui-state-badge-element.ts index 9a5a461e892f..0c27e33f6dfa 100644 --- a/src/panels/lovelace/elements/hui-state-badge-element.ts +++ b/src/panels/lovelace/elements/hui-state-badge-element.ts @@ -1,10 +1,10 @@ import { html, LitElement } from "@polymer/lit-element"; -import "../../../components/entity/ha-state-label-badge.js"; +import "../../../components/entity/ha-state-label-badge"; import computeStateName from "../../../common/entity/compute_state_name"; -import { LovelaceElement, LovelaceElementConfig } from "./types.js"; -import { HomeAssistant } from "../../../types.js"; +import { LovelaceElement, LovelaceElementConfig } from "./types"; +import { HomeAssistant } from "../../../types"; import { TemplateResult } from "lit-html"; export class HuiStateBadgeElement extends LitElement diff --git a/src/panels/lovelace/elements/hui-state-icon-element.ts b/src/panels/lovelace/elements/hui-state-icon-element.ts index 574d2f620b3a..5615af861479 100644 --- a/src/panels/lovelace/elements/hui-state-icon-element.ts +++ b/src/panels/lovelace/elements/hui-state-icon-element.ts @@ -1,14 +1,14 @@ import { html, LitElement } from "@polymer/lit-element"; import { TemplateResult } from "lit-html"; -import "../../../components/entity/state-badge.js"; +import "../../../components/entity/state-badge"; import { computeTooltip } from "../common/compute-tooltip"; import { handleClick } from "../common/handle-click"; import { longPress } from "../common/directives/long-press-directive"; import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; -import { LovelaceElement, LovelaceElementConfig } from "./types.js"; -import { HomeAssistant } from "../../../types.js"; +import { LovelaceElement, LovelaceElementConfig } from "./types"; +import { HomeAssistant } from "../../../types"; export class HuiStateIconElement extends hassLocalizeLitMixin(LitElement) implements LovelaceElement { diff --git a/src/panels/lovelace/elements/hui-state-label-element.ts b/src/panels/lovelace/elements/hui-state-label-element.ts index b066d81daea0..6ad1a6b93df9 100644 --- a/src/panels/lovelace/elements/hui-state-label-element.ts +++ b/src/panels/lovelace/elements/hui-state-label-element.ts @@ -1,78 +1,78 @@ -import { html, LitElement } from "@polymer/lit-element"; - -import "../../../components/entity/ha-state-label-badge.js"; - -import computeStateDisplay from "../../../common/entity/compute_state_display.js"; -import { computeTooltip } from "../common/compute-tooltip"; -import { handleClick } from "../common/handle-click"; -import { longPress } from "../common/directives/long-press-directive"; -import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; -import { LovelaceElement, LovelaceElementConfig } from "./types.js"; -import { HomeAssistant } from "../../../types.js"; -import { TemplateResult } from "lit-html"; - -interface Config extends LovelaceElementConfig { - prefix?: string; - suffix?: string; -} - -class HuiStateLabelElement extends hassLocalizeLitMixin(LitElement) - implements LovelaceElement { - public hass?: HomeAssistant; - private _config?: Config; - - static get properties() { - return { hass: {}, _config: {} }; - } - - public setConfig(config: Config): void { - if (!config.entity) { - throw Error("Invalid Configuration: 'entity' required"); - } - - this._config = config; - } - - protected render(): TemplateResult { - if (!this._config) { - return html``; - } - - const state = this.hass!.states[this._config.entity!]; - return html` - ${this.renderStyle()} -
- ${this._config.prefix}${ - state ? computeStateDisplay(this.localize, state) : "-" - }${this._config.suffix} -
- `; - } - - private renderStyle(): TemplateResult { - return html` - - `; - } -} - -declare global { - interface HTMLElementTagNameMap { - "hui-state-label-element": HuiStateLabelElement; - } -} - -customElements.define("hui-state-label-element", HuiStateLabelElement); +import { html, LitElement } from "@polymer/lit-element"; + +import "../../../components/entity/ha-state-label-badge"; + +import computeStateDisplay from "../../../common/entity/compute_state_display"; +import { computeTooltip } from "../common/compute-tooltip"; +import { handleClick } from "../common/handle-click"; +import { longPress } from "../common/directives/long-press-directive"; +import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; +import { LovelaceElement, LovelaceElementConfig } from "./types"; +import { HomeAssistant } from "../../../types"; +import { TemplateResult } from "lit-html"; + +interface Config extends LovelaceElementConfig { + prefix?: string; + suffix?: string; +} + +class HuiStateLabelElement extends hassLocalizeLitMixin(LitElement) + implements LovelaceElement { + public hass?: HomeAssistant; + private _config?: Config; + + static get properties() { + return { hass: {}, _config: {} }; + } + + public setConfig(config: Config): void { + if (!config.entity) { + throw Error("Invalid Configuration: 'entity' required"); + } + + this._config = config; + } + + protected render(): TemplateResult { + if (!this._config) { + return html``; + } + + const state = this.hass!.states[this._config.entity!]; + return html` + ${this.renderStyle()} +
+ ${this._config.prefix}${ + state ? computeStateDisplay(this.localize, state) : "-" + }${this._config.suffix} +
+ `; + } + + private renderStyle(): TemplateResult { + return html` + + `; + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-state-label-element": HuiStateLabelElement; + } +} + +customElements.define("hui-state-label-element", HuiStateLabelElement); diff --git a/src/panels/lovelace/entity-rows/hui-climate-entity-row.ts b/src/panels/lovelace/entity-rows/hui-climate-entity-row.ts index 074ef40c3313..2bc9a156d186 100644 --- a/src/panels/lovelace/entity-rows/hui-climate-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-climate-entity-row.ts @@ -1,11 +1,11 @@ import { html, LitElement } from "@polymer/lit-element"; import { TemplateResult } from "lit-html"; -import "../../../components/ha-climate-state.js"; -import "../components/hui-generic-entity-row.js"; +import "../../../components/ha-climate-state"; +import "../components/hui-generic-entity-row"; -import { HomeAssistant } from "../../../types.js"; -import { EntityRow, EntityConfig } from "./types.js"; +import { HomeAssistant } from "../../../types"; +import { EntityRow, EntityConfig } from "./types"; class HuiClimateEntityRow extends LitElement implements EntityRow { public hass?: HomeAssistant; diff --git a/src/panels/lovelace/entity-rows/hui-cover-entity-row.js b/src/panels/lovelace/entity-rows/hui-cover-entity-row.js index f0334c9c306f..b4c3de695386 100644 --- a/src/panels/lovelace/entity-rows/hui-cover-entity-row.js +++ b/src/panels/lovelace/entity-rows/hui-cover-entity-row.js @@ -1,74 +1,74 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../components/hui-generic-entity-row.js"; -import "../../../components/ha-cover-controls.js"; -import "../../../components/ha-cover-tilt-controls.js"; -import CoverEntity from "../../../util/cover-model.js"; - -class HuiCoverEntityRow extends PolymerElement { - static get template() { - return html` - ${this.styleTemplate} - - ${this.coverControlTemplate} - - `; - } - - static get styleTemplate() { - return html` - - `; - } - - static get coverControlTemplate() { - return html` - - - `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - _stateObj: { - type: Object, - computed: "_computeStateObj(hass.states, _config.entity)", - }, - _entityObj: { - type: Object, - computed: "_computeEntityObj(hass, _stateObj)", - }, - }; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - _computeEntityObj(hass, stateObj) { - return stateObj ? new CoverEntity(hass, stateObj) : null; - } - - setConfig(config) { - if (!config || !config.entity) { - throw new Error("Entity not configured."); - } - this._config = config; - } -} -customElements.define("hui-cover-entity-row", HuiCoverEntityRow); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../components/hui-generic-entity-row"; +import "../../../components/ha-cover-controls"; +import "../../../components/ha-cover-tilt-controls"; +import CoverEntity from "../../../util/cover-model"; + +class HuiCoverEntityRow extends PolymerElement { + static get template() { + return html` + ${this.styleTemplate} + + ${this.coverControlTemplate} + + `; + } + + static get styleTemplate() { + return html` + + `; + } + + static get coverControlTemplate() { + return html` + + + `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _stateObj: { + type: Object, + computed: "_computeStateObj(hass.states, _config.entity)", + }, + _entityObj: { + type: Object, + computed: "_computeEntityObj(hass, _stateObj)", + }, + }; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + _computeEntityObj(hass, stateObj) { + return stateObj ? new CoverEntity(hass, stateObj) : null; + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error("Entity not configured."); + } + this._config = config; + } +} +customElements.define("hui-cover-entity-row", HuiCoverEntityRow); diff --git a/src/panels/lovelace/entity-rows/hui-group-entity-row.js b/src/panels/lovelace/entity-rows/hui-group-entity-row.js index 8da9c1072249..77720fd0bf2c 100644 --- a/src/panels/lovelace/entity-rows/hui-group-entity-row.js +++ b/src/panels/lovelace/entity-rows/hui-group-entity-row.js @@ -1,78 +1,78 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../components/hui-generic-entity-row.js"; -import "../../../components/entity/ha-entity-toggle.js"; - -import computeStateDisplay from "../../../common/entity/compute_state_display.js"; -import { DOMAINS_TOGGLE } from "../../../common/const.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; - -/* - * @appliesMixin LocalizeMixin - */ -class HuiGroupEntityRow extends LocalizeMixin(PolymerElement) { - static get template() { - return html` - - ${this.groupControlTemplate} - - `; - } - - static get groupControlTemplate() { - return html` - - - `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - _stateObj: { - type: Object, - computed: "_computeStateObj(hass.states, _config.entity)", - }, - _canToggle: { - type: Boolean, - computed: "_computeCanToggle(_stateObj.attributes.entity_id)", - }, - }; - } - - setConfig(config) { - if (!config || !config.entity) { - throw new Error("Entity not configured."); - } - this._config = config; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - _computeCanToggle(entityIds) { - return entityIds.some((entityId) => - DOMAINS_TOGGLE.has(entityId.split(".", 1)[0]) - ); - } - - _computeState(stateObj) { - return computeStateDisplay(this.localize, stateObj); - } -} -customElements.define("hui-group-entity-row", HuiGroupEntityRow); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../components/hui-generic-entity-row"; +import "../../../components/entity/ha-entity-toggle"; + +import computeStateDisplay from "../../../common/entity/compute_state_display"; +import { DOMAINS_TOGGLE } from "../../../common/const"; +import LocalizeMixin from "../../../mixins/localize-mixin"; + +/* + * @appliesMixin LocalizeMixin + */ +class HuiGroupEntityRow extends LocalizeMixin(PolymerElement) { + static get template() { + return html` + + ${this.groupControlTemplate} + + `; + } + + static get groupControlTemplate() { + return html` + + + `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _stateObj: { + type: Object, + computed: "_computeStateObj(hass.states, _config.entity)", + }, + _canToggle: { + type: Boolean, + computed: "_computeCanToggle(_stateObj.attributes.entity_id)", + }, + }; + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error("Entity not configured."); + } + this._config = config; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + _computeCanToggle(entityIds) { + return entityIds.some((entityId) => + DOMAINS_TOGGLE.has(entityId.split(".", 1)[0]) + ); + } + + _computeState(stateObj) { + return computeStateDisplay(this.localize, stateObj); + } +} +customElements.define("hui-group-entity-row", HuiGroupEntityRow); diff --git a/src/panels/lovelace/entity-rows/hui-input-number-entity-row.js b/src/panels/lovelace/entity-rows/hui-input-number-entity-row.js index 6c6e81bc0649..33b827221694 100644 --- a/src/panels/lovelace/entity-rows/hui-input-number-entity-row.js +++ b/src/panels/lovelace/entity-rows/hui-input-number-entity-row.js @@ -1,170 +1,170 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/paper-input/paper-input.js"; -import { IronResizableBehavior } from "@polymer/iron-resizable-behavior/iron-resizable-behavior.js"; -import { mixinBehaviors } from "@polymer/polymer/lib/legacy/class.js"; - -import "../components/hui-generic-entity-row.js"; -import "../../../components/ha-slider"; - -class HuiInputNumberEntityRow extends mixinBehaviors( - [IronResizableBehavior], - PolymerElement -) { - static get template() { - return html` - ${this.styleTemplate} - - ${this.inputNumberControlTemplate} - - `; - } - - static get styleTemplate() { - return html` - - `; - } - - static get inputNumberControlTemplate() { - return html` -
- - -
- `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - _stateObj: { - type: Object, - computed: "_computeStateObj(hass.states, _config.entity)", - observer: "_stateObjChanged", - }, - _min: { - type: Number, - value: 0, - }, - _max: { - type: Number, - value: 100, - }, - _step: Number, - _value: Number, - }; - } - - ready() { - super.ready(); - if (typeof ResizeObserver === "function") { - const ro = new ResizeObserver((entries) => { - entries.forEach(() => { - this._hiddenState(); - }); - }); - ro.observe(this.$.input_number_card); - } else { - this.addEventListener("iron-resize", this._hiddenState); - } - } - - _equals(a, b) { - return a === b; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - setConfig(config) { - if (!config || !config.entity) { - throw new Error("Entity not configured."); - } - this._config = config; - } - - _hiddenState() { - if ( - !this.$ || - !this._stateObj || - this._stateObj.attributes.mode !== "slider" - ) - return; - const width = this.$.input_number_card.offsetWidth; - const stateEl = this.shadowRoot.querySelector(".state"); - if (!stateEl) return; - stateEl.hidden = width <= 350; - } - - _stateObjChanged(stateObj, oldStateObj) { - if (!stateObj) return; - - this.setProperties({ - _min: Number(stateObj.attributes.min), - _max: Number(stateObj.attributes.max), - _step: Number(stateObj.attributes.step), - _value: Number(stateObj.state), - }); - if ( - oldStateObj && - stateObj.attributes.mode === "slider" && - oldStateObj.attributes.mode !== "slider" - ) { - this._hiddenState(); - } - } - - _selectedValueChanged() { - if (this._value === Number(this._stateObj.state)) return; - - this.hass.callService("input_number", "set_value", { - value: this._value, - entity_id: this._stateObj.entity_id, - }); - } -} -customElements.define("hui-input-number-entity-row", HuiInputNumberEntityRow); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/paper-input/paper-input"; +import { IronResizableBehavior } from "@polymer/iron-resizable-behavior/iron-resizable-behavior"; +import { mixinBehaviors } from "@polymer/polymer/lib/legacy/class"; + +import "../components/hui-generic-entity-row"; +import "../../../components/ha-slider"; + +class HuiInputNumberEntityRow extends mixinBehaviors( + [IronResizableBehavior], + PolymerElement +) { + static get template() { + return html` + ${this.styleTemplate} + + ${this.inputNumberControlTemplate} + + `; + } + + static get styleTemplate() { + return html` + + `; + } + + static get inputNumberControlTemplate() { + return html` +
+ + +
+ `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _stateObj: { + type: Object, + computed: "_computeStateObj(hass.states, _config.entity)", + observer: "_stateObjChanged", + }, + _min: { + type: Number, + value: 0, + }, + _max: { + type: Number, + value: 100, + }, + _step: Number, + _value: Number, + }; + } + + ready() { + super.ready(); + if (typeof ResizeObserver === "function") { + const ro = new ResizeObserver((entries) => { + entries.forEach(() => { + this._hiddenState(); + }); + }); + ro.observe(this.$.input_number_card); + } else { + this.addEventListener("iron-resize", this._hiddenState); + } + } + + _equals(a, b) { + return a === b; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error("Entity not configured."); + } + this._config = config; + } + + _hiddenState() { + if ( + !this.$ || + !this._stateObj || + this._stateObj.attributes.mode !== "slider" + ) + return; + const width = this.$.input_number_card.offsetWidth; + const stateEl = this.shadowRoot.querySelector(".state"); + if (!stateEl) return; + stateEl.hidden = width <= 350; + } + + _stateObjChanged(stateObj, oldStateObj) { + if (!stateObj) return; + + this.setProperties({ + _min: Number(stateObj.attributes.min), + _max: Number(stateObj.attributes.max), + _step: Number(stateObj.attributes.step), + _value: Number(stateObj.state), + }); + if ( + oldStateObj && + stateObj.attributes.mode === "slider" && + oldStateObj.attributes.mode !== "slider" + ) { + this._hiddenState(); + } + } + + _selectedValueChanged() { + if (this._value === Number(this._stateObj.state)) return; + + this.hass.callService("input_number", "set_value", { + value: this._value, + entity_id: this._stateObj.entity_id, + }); + } +} +customElements.define("hui-input-number-entity-row", HuiInputNumberEntityRow); diff --git a/src/panels/lovelace/entity-rows/hui-input-select-entity-row.js b/src/panels/lovelace/entity-rows/hui-input-select-entity-row.js index 2f5850386bc3..61ce4317c48f 100644 --- a/src/panels/lovelace/entity-rows/hui-input-select-entity-row.js +++ b/src/panels/lovelace/entity-rows/hui-input-select-entity-row.js @@ -1,107 +1,107 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; - -import "../../../components/entity/state-badge.js"; - -import computeStateName from "../../../common/entity/compute_state_name.js"; - -import EventsMixin from "../../../mixins/events-mixin.js"; - -/* - * @appliesMixin EventsMixin - */ -class HuiInputSelectEntityRow extends EventsMixin(PolymerElement) { - static get template() { - return html` - ${this.styleTemplate} - - - `; - } - - static get styleTemplate() { - return html` - - `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - _stateObj: { - type: Object, - computed: "_computeStateObj(hass.states, _config.entity)", - }, - _selected: { - type: String, - observer: "_selectedChanged", - }, - }; - } - - setConfig(config) { - if (!config || !config.entity) { - throw new Error("Entity not configured."); - } - this._config = config; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - _computeName(name, stateObj) { - return name || computeStateName(stateObj); - } - - _computeSelected(stateObj) { - return stateObj.attributes.options.indexOf(stateObj.state); - } - - _selectedChanged(option) { - // Selected Option will transition to '' before transitioning to new value - if (option === "" || option === this._stateObj.state) { - return; - } - this.hass.callService("input_select", "select_option", { - option: option, - entity_id: this._stateObj.entity_id, - }); - } - - _stopPropagation(ev) { - ev.stopPropagation(); - } -} -customElements.define("hui-input-select-entity-row", HuiInputSelectEntityRow); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; + +import "../../../components/entity/state-badge"; + +import computeStateName from "../../../common/entity/compute_state_name"; + +import EventsMixin from "../../../mixins/events-mixin"; + +/* + * @appliesMixin EventsMixin + */ +class HuiInputSelectEntityRow extends EventsMixin(PolymerElement) { + static get template() { + return html` + ${this.styleTemplate} + + + `; + } + + static get styleTemplate() { + return html` + + `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _stateObj: { + type: Object, + computed: "_computeStateObj(hass.states, _config.entity)", + }, + _selected: { + type: String, + observer: "_selectedChanged", + }, + }; + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error("Entity not configured."); + } + this._config = config; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + _computeName(name, stateObj) { + return name || computeStateName(stateObj); + } + + _computeSelected(stateObj) { + return stateObj.attributes.options.indexOf(stateObj.state); + } + + _selectedChanged(option) { + // Selected Option will transition to '' before transitioning to new value + if (option === "" || option === this._stateObj.state) { + return; + } + this.hass.callService("input_select", "select_option", { + option: option, + entity_id: this._stateObj.entity_id, + }); + } + + _stopPropagation(ev) { + ev.stopPropagation(); + } +} +customElements.define("hui-input-select-entity-row", HuiInputSelectEntityRow); diff --git a/src/panels/lovelace/entity-rows/hui-input-text-entity-row.js b/src/panels/lovelace/entity-rows/hui-input-text-entity-row.js index 98efd8e187de..dc27bb8315ed 100644 --- a/src/panels/lovelace/entity-rows/hui-input-text-entity-row.js +++ b/src/panels/lovelace/entity-rows/hui-input-text-entity-row.js @@ -1,73 +1,73 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/paper-input/paper-input.js"; - -import "../components/hui-generic-entity-row.js"; - -class HuiInputTextEntityRow extends PolymerElement { - static get template() { - return html` - - ${this.inputTextControlTemplate} - - `; - } - - static get inputTextControlTemplate() { - return html` - - `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - _stateObj: { - type: Object, - computed: "_computeStateObj(hass.states, _config.entity)", - observer: "_stateObjChanged", - }, - _value: String, - }; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - setConfig(config) { - if (!config || !config.entity) { - throw new Error("Entity not configured."); - } - this._config = config; - } - - _stateObjChanged(stateObj) { - this._value = stateObj && stateObj.state; - } - - _selectedValueChanged() { - if (this._value === this._stateObj.state) { - return; - } - this.hass.callService("input_text", "set_value", { - value: this._value, - entity_id: this._stateObj.entity_id, - }); - } -} -customElements.define("hui-input-text-entity-row", HuiInputTextEntityRow); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/paper-input/paper-input"; + +import "../components/hui-generic-entity-row"; + +class HuiInputTextEntityRow extends PolymerElement { + static get template() { + return html` + + ${this.inputTextControlTemplate} + + `; + } + + static get inputTextControlTemplate() { + return html` + + `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _stateObj: { + type: Object, + computed: "_computeStateObj(hass.states, _config.entity)", + observer: "_stateObjChanged", + }, + _value: String, + }; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error("Entity not configured."); + } + this._config = config; + } + + _stateObjChanged(stateObj) { + this._value = stateObj && stateObj.state; + } + + _selectedValueChanged() { + if (this._value === this._stateObj.state) { + return; + } + this.hass.callService("input_text", "set_value", { + value: this._value, + entity_id: this._stateObj.entity_id, + }); + } +} +customElements.define("hui-input-text-entity-row", HuiInputTextEntityRow); diff --git a/src/panels/lovelace/entity-rows/hui-lock-entity-row.js b/src/panels/lovelace/entity-rows/hui-lock-entity-row.js index 616316d6a242..f75559d30acb 100644 --- a/src/panels/lovelace/entity-rows/hui-lock-entity-row.js +++ b/src/panels/lovelace/entity-rows/hui-lock-entity-row.js @@ -1,83 +1,83 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/paper-button/paper-button.js"; - -import "../components/hui-generic-entity-row.js"; - -import LocalizeMixin from "../../../mixins/localize-mixin.js"; - -/* - * @appliesMixin LocalizeMixin - */ -class HuiLockEntityRow extends LocalizeMixin(PolymerElement) { - static get template() { - return html` - ${this.styleTemplate} - - ${this.lockControlTemplate} - - `; - } - - static get styleTemplate() { - return html` - - `; - } - - static get lockControlTemplate() { - return html` - - [[_computeButtonTitle(_stateObj.state)]] - - `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - _stateObj: { - type: Object, - computed: "_computeStateObj(hass.states, _config.entity)", - }, - }; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - setConfig(config) { - if (!config || !config.entity) { - throw new Error("Entity not configured."); - } - this._config = config; - } - - _computeButtonTitle(state) { - return state === "locked" - ? this.localize("ui.card.lock.unlock") - : this.localize("ui.card.lock.lock"); - } - - _callService(ev) { - ev.stopPropagation(); - const stateObj = this._stateObj; - this.hass.callService( - "lock", - stateObj.state === "locked" ? "unlock" : "lock", - { entity_id: stateObj.entity_id } - ); - } -} -customElements.define("hui-lock-entity-row", HuiLockEntityRow); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/paper-button/paper-button"; + +import "../components/hui-generic-entity-row"; + +import LocalizeMixin from "../../../mixins/localize-mixin"; + +/* + * @appliesMixin LocalizeMixin + */ +class HuiLockEntityRow extends LocalizeMixin(PolymerElement) { + static get template() { + return html` + ${this.styleTemplate} + + ${this.lockControlTemplate} + + `; + } + + static get styleTemplate() { + return html` + + `; + } + + static get lockControlTemplate() { + return html` + + [[_computeButtonTitle(_stateObj.state)]] + + `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _stateObj: { + type: Object, + computed: "_computeStateObj(hass.states, _config.entity)", + }, + }; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error("Entity not configured."); + } + this._config = config; + } + + _computeButtonTitle(state) { + return state === "locked" + ? this.localize("ui.card.lock.unlock") + : this.localize("ui.card.lock.lock"); + } + + _callService(ev) { + ev.stopPropagation(); + const stateObj = this._stateObj; + this.hass.callService( + "lock", + stateObj.state === "locked" ? "unlock" : "lock", + { entity_id: stateObj.entity_id } + ); + } +} +customElements.define("hui-lock-entity-row", HuiLockEntityRow); diff --git a/src/panels/lovelace/entity-rows/hui-media-player-entity-row.js b/src/panels/lovelace/entity-rows/hui-media-player-entity-row.js index 77cbde1b94ed..b6d90e944f59 100644 --- a/src/panels/lovelace/entity-rows/hui-media-player-entity-row.js +++ b/src/panels/lovelace/entity-rows/hui-media-player-entity-row.js @@ -1,162 +1,162 @@ -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../components/hui-generic-entity-row.js"; - -import LocalizeMixin from "../../../mixins/localize-mixin.js"; - -const SUPPORT_PAUSE = 1; -const SUPPORT_NEXT_TRACK = 32; -const SUPPORTS_PLAY = 16384; -const OFF_STATES = ["off", "idle"]; - -/* - * @appliesMixin LocalizeMixin - */ -class HuiMediaPlayerEntityRow extends LocalizeMixin(PolymerElement) { - static get template() { - return html` - ${this.styleTemplate} - - ${this.mediaPlayerControlTemplate} - - `; - } - - static get styleTemplate() { - return html` - - `; - } - - static get mediaPlayerControlTemplate() { - return html` - - - -
- [[_computeMediaTitle(_stateObj)]] -
- `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - _stateObj: { - type: Object, - computed: "_computeStateObj(hass.states, _config.entity)", - }, - }; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - setConfig(config) { - if (!config || !config.entity) { - throw new Error("Entity not configured."); - } - this._config = config; - } - - _computeControlIcon(stateObj) { - if (!stateObj) return null; - - if (stateObj.state !== "playing") { - return stateObj.attributes.supported_features & SUPPORTS_PLAY - ? "hass:play" - : ""; - } - - return stateObj.attributes.supported_features & SUPPORT_PAUSE - ? "hass:pause" - : "hass:stop"; - } - - _computeMediaTitle(stateObj) { - if (!stateObj || this._isOff(stateObj.state)) return null; - - switch (stateObj.attributes.media_content_type) { - case "music": - return `${stateObj.attributes.media_artist}: ${ - stateObj.attributes.media_title - }`; - case "tvshow": - return `${stateObj.attributes.media_series_title}: ${ - stateObj.attributes.media_title - }`; - default: - return ( - stateObj.attributes.media_title || - stateObj.attributes.app_name || - stateObj.state - ); - } - } - - _computeState(state) { - return ( - this.localize(`state.media_player.${state}`) || - this.localize(`state.default.${state}`) || - state - ); - } - - _callService(service) { - this.hass.callService("media_player", service, { - entity_id: this._config.entity, - }); - } - - _playPause(event) { - event.stopPropagation(); - this._callService("media_play_pause"); - } - - _nextTrack(event) { - event.stopPropagation(); - if (this._stateObj.attributes.supported_features & SUPPORT_NEXT_TRACK) { - this._callService("media_next_track"); - } - } - - _isOff(state) { - return OFF_STATES.includes(state); - } - - _supportsNext(stateObj) { - return ( - stateObj && stateObj.attributes.supported_features & SUPPORT_NEXT_TRACK - ); - } -} -customElements.define("hui-media-player-entity-row", HuiMediaPlayerEntityRow); +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../components/hui-generic-entity-row"; + +import LocalizeMixin from "../../../mixins/localize-mixin"; + +const SUPPORT_PAUSE = 1; +const SUPPORT_NEXT_TRACK = 32; +const SUPPORTS_PLAY = 16384; +const OFF_STATES = ["off", "idle"]; + +/* + * @appliesMixin LocalizeMixin + */ +class HuiMediaPlayerEntityRow extends LocalizeMixin(PolymerElement) { + static get template() { + return html` + ${this.styleTemplate} + + ${this.mediaPlayerControlTemplate} + + `; + } + + static get styleTemplate() { + return html` + + `; + } + + static get mediaPlayerControlTemplate() { + return html` + + + +
+ [[_computeMediaTitle(_stateObj)]] +
+ `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _stateObj: { + type: Object, + computed: "_computeStateObj(hass.states, _config.entity)", + }, + }; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error("Entity not configured."); + } + this._config = config; + } + + _computeControlIcon(stateObj) { + if (!stateObj) return null; + + if (stateObj.state !== "playing") { + return stateObj.attributes.supported_features & SUPPORTS_PLAY + ? "hass:play" + : ""; + } + + return stateObj.attributes.supported_features & SUPPORT_PAUSE + ? "hass:pause" + : "hass:stop"; + } + + _computeMediaTitle(stateObj) { + if (!stateObj || this._isOff(stateObj.state)) return null; + + switch (stateObj.attributes.media_content_type) { + case "music": + return `${stateObj.attributes.media_artist}: ${ + stateObj.attributes.media_title + }`; + case "tvshow": + return `${stateObj.attributes.media_series_title}: ${ + stateObj.attributes.media_title + }`; + default: + return ( + stateObj.attributes.media_title || + stateObj.attributes.app_name || + stateObj.state + ); + } + } + + _computeState(state) { + return ( + this.localize(`state.media_player.${state}`) || + this.localize(`state.default.${state}`) || + state + ); + } + + _callService(service) { + this.hass.callService("media_player", service, { + entity_id: this._config.entity, + }); + } + + _playPause(event) { + event.stopPropagation(); + this._callService("media_play_pause"); + } + + _nextTrack(event) { + event.stopPropagation(); + if (this._stateObj.attributes.supported_features & SUPPORT_NEXT_TRACK) { + this._callService("media_next_track"); + } + } + + _isOff(state) { + return OFF_STATES.includes(state); + } + + _supportsNext(stateObj) { + return ( + stateObj && stateObj.attributes.supported_features & SUPPORT_NEXT_TRACK + ); + } +} +customElements.define("hui-media-player-entity-row", HuiMediaPlayerEntityRow); diff --git a/src/panels/lovelace/entity-rows/hui-scene-entity-row.js b/src/panels/lovelace/entity-rows/hui-scene-entity-row.js index 5d55e3bb7508..f0d15443359d 100644 --- a/src/panels/lovelace/entity-rows/hui-scene-entity-row.js +++ b/src/panels/lovelace/entity-rows/hui-scene-entity-row.js @@ -1,70 +1,70 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/paper-button/paper-button.js"; - -import "../components/hui-generic-entity-row.js"; - -import LocalizeMixin from "../../../mixins/localize-mixin.js"; - -/* - * @appliesMixin LocalizeMixin - */ -class HuiSceneEntityRow extends LocalizeMixin(PolymerElement) { - static get template() { - return html` - ${this.styleTemplate} - - ${this.sceneControlTemplate} - - `; - } - - static get styleTemplate() { - return html` - - `; - } - - static get sceneControlTemplate() { - return html` - - [[localize('ui.card.scene.activate')]] - - `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - }; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - setConfig(config) { - if (!config || !config.entity) { - throw new Error("Entity not configured."); - } - this._config = config; - } - - _callService(ev) { - ev.stopPropagation(); - this.hass.callService("scene", "turn_on", { - entity_id: this._config.entity, - }); - } -} -customElements.define("hui-scene-entity-row", HuiSceneEntityRow); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/paper-button/paper-button"; + +import "../components/hui-generic-entity-row"; + +import LocalizeMixin from "../../../mixins/localize-mixin"; + +/* + * @appliesMixin LocalizeMixin + */ +class HuiSceneEntityRow extends LocalizeMixin(PolymerElement) { + static get template() { + return html` + ${this.styleTemplate} + + ${this.sceneControlTemplate} + + `; + } + + static get styleTemplate() { + return html` + + `; + } + + static get sceneControlTemplate() { + return html` + + [[localize('ui.card.scene.activate')]] + + `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + }; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error("Entity not configured."); + } + this._config = config; + } + + _callService(ev) { + ev.stopPropagation(); + this.hass.callService("scene", "turn_on", { + entity_id: this._config.entity, + }); + } +} +customElements.define("hui-scene-entity-row", HuiSceneEntityRow); diff --git a/src/panels/lovelace/entity-rows/hui-script-entity-row.js b/src/panels/lovelace/entity-rows/hui-script-entity-row.js index f00fa0b74429..db5b948160f6 100644 --- a/src/panels/lovelace/entity-rows/hui-script-entity-row.js +++ b/src/panels/lovelace/entity-rows/hui-script-entity-row.js @@ -1,78 +1,78 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/paper-button/paper-button.js"; - -import "../components/hui-generic-entity-row.js"; -import "../../../components/entity/ha-entity-toggle.js"; - -import LocalizeMixin from "../../../mixins/localize-mixin.js"; - -/* - * @appliesMixin LocalizeMixin - */ -class HuiScriptEntityRow extends LocalizeMixin(PolymerElement) { - static get template() { - return html` - ${this.styleTemplate} - - ${this.scriptControlTemplate} - - `; - } - - static get styleTemplate() { - return html` - - `; - } - - static get scriptControlTemplate() { - return html` - - - `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - _stateObj: { - type: Object, - computed: "_computeStateObj(hass.states, _config.entity)", - }, - }; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - setConfig(config) { - if (!config || !config.entity) { - throw new Error("Entity not configured."); - } - this._config = config; - } - - _callService(ev) { - ev.stopPropagation(); - this.hass.callService("script", "turn_on", { - entity_id: this._config.entity, - }); - } -} -customElements.define("hui-script-entity-row", HuiScriptEntityRow); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/paper-button/paper-button"; + +import "../components/hui-generic-entity-row"; +import "../../../components/entity/ha-entity-toggle"; + +import LocalizeMixin from "../../../mixins/localize-mixin"; + +/* + * @appliesMixin LocalizeMixin + */ +class HuiScriptEntityRow extends LocalizeMixin(PolymerElement) { + static get template() { + return html` + ${this.styleTemplate} + + ${this.scriptControlTemplate} + + `; + } + + static get styleTemplate() { + return html` + + `; + } + + static get scriptControlTemplate() { + return html` + + + `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _stateObj: { + type: Object, + computed: "_computeStateObj(hass.states, _config.entity)", + }, + }; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error("Entity not configured."); + } + this._config = config; + } + + _callService(ev) { + ev.stopPropagation(); + this.hass.callService("script", "turn_on", { + entity_id: this._config.entity, + }); + } +} +customElements.define("hui-script-entity-row", HuiScriptEntityRow); diff --git a/src/panels/lovelace/entity-rows/hui-text-entity-row.js b/src/panels/lovelace/entity-rows/hui-text-entity-row.js index 833ed16edb76..9c78c3a4e962 100644 --- a/src/panels/lovelace/entity-rows/hui-text-entity-row.js +++ b/src/panels/lovelace/entity-rows/hui-text-entity-row.js @@ -1,70 +1,70 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../components/hui-generic-entity-row.js"; - -import computeStateDisplay from "../../../common/entity/compute_state_display.js"; - -import LocalizeMixin from "../../../mixins/localize-mixin.js"; - -/* - * @appliesMixin LocalizeMixin - */ -class HuiTextEntityRow extends LocalizeMixin(PolymerElement) { - static get template() { - return html` - ${this.styleTemplate} - - ${this.textControlTemplate} - - `; - } - - static get styleTemplate() { - return html` - - `; - } - - static get textControlTemplate() { - return html` -
- [[_computeState(_stateObj)]] -
- `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - _stateObj: { - type: Object, - computed: "_computeStateObj(hass.states, _config.entity)", - }, - }; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - setConfig(config) { - if (!config || !config.entity) { - throw new Error("Entity not configured."); - } - this._config = config; - } - - _computeState(stateObj) { - return stateObj && computeStateDisplay(this.localize, stateObj); - } -} -customElements.define("hui-text-entity-row", HuiTextEntityRow); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../components/hui-generic-entity-row"; + +import computeStateDisplay from "../../../common/entity/compute_state_display"; + +import LocalizeMixin from "../../../mixins/localize-mixin"; + +/* + * @appliesMixin LocalizeMixin + */ +class HuiTextEntityRow extends LocalizeMixin(PolymerElement) { + static get template() { + return html` + ${this.styleTemplate} + + ${this.textControlTemplate} + + `; + } + + static get styleTemplate() { + return html` + + `; + } + + static get textControlTemplate() { + return html` +
+ [[_computeState(_stateObj)]] +
+ `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _stateObj: { + type: Object, + computed: "_computeStateObj(hass.states, _config.entity)", + }, + }; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error("Entity not configured."); + } + this._config = config; + } + + _computeState(stateObj) { + return stateObj && computeStateDisplay(this.localize, stateObj); + } +} +customElements.define("hui-text-entity-row", HuiTextEntityRow); diff --git a/src/panels/lovelace/entity-rows/hui-timer-entity-row.js b/src/panels/lovelace/entity-rows/hui-timer-entity-row.js index 7bb836200707..ad9d9791846a 100644 --- a/src/panels/lovelace/entity-rows/hui-timer-entity-row.js +++ b/src/panels/lovelace/entity-rows/hui-timer-entity-row.js @@ -1,103 +1,103 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../components/hui-generic-entity-row.js"; - -import timerTimeRemaining from "../../../common/entity/timer_time_remaining.js"; -import secondsToDuration from "../../../common/datetime/seconds_to_duration.js"; - -class HuiTimerEntityRow extends PolymerElement { - static get template() { - return html` - - ${this.timerControlTemplate} - - `; - } - - static get timerControlTemplate() { - return html` -
- [[_computeDisplay(_stateObj, _timeRemaining)]] -
- `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - _stateObj: { - type: Object, - computed: "_computeStateObj(hass.states, _config.entity)", - observer: "_stateObjChanged", - }, - _timeRemaining: Number, - }; - } - - disconnectedCallback() { - super.disconnectedCallback(); - this._clearInterval(); - } - - _stateObjChanged(stateObj) { - if (stateObj) { - this._startInterval(stateObj); - } else { - this._clearInterval(); - } - } - - _clearInterval() { - if (this._updateRemaining) { - clearInterval(this._updateRemaining); - this._updateRemaining = null; - } - } - - _startInterval(stateObj) { - this._clearInterval(); - this._calculateRemaining(stateObj); - - if (stateObj.state === "active") { - this._updateRemaining = setInterval( - () => this._calculateRemaining(this._stateObj), - 1000 - ); - } - } - - _calculateRemaining(stateObj) { - this._timeRemaining = timerTimeRemaining(stateObj); - } - - _computeDisplay(stateObj, time) { - if (!stateObj) return null; - - if (stateObj.state === "idle" || time === 0) return stateObj.state; - - let display = secondsToDuration(time); - - if (stateObj.state === "paused") { - display += " (paused)"; - } - - return display; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - setConfig(config) { - if (!config || !config.entity) { - throw new Error("Entity not configured."); - } - this._config = config; - } -} -customElements.define("hui-timer-entity-row", HuiTimerEntityRow); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../components/hui-generic-entity-row"; + +import timerTimeRemaining from "../../../common/entity/timer_time_remaining"; +import secondsToDuration from "../../../common/datetime/seconds_to_duration"; + +class HuiTimerEntityRow extends PolymerElement { + static get template() { + return html` + + ${this.timerControlTemplate} + + `; + } + + static get timerControlTemplate() { + return html` +
+ [[_computeDisplay(_stateObj, _timeRemaining)]] +
+ `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _stateObj: { + type: Object, + computed: "_computeStateObj(hass.states, _config.entity)", + observer: "_stateObjChanged", + }, + _timeRemaining: Number, + }; + } + + disconnectedCallback() { + super.disconnectedCallback(); + this._clearInterval(); + } + + _stateObjChanged(stateObj) { + if (stateObj) { + this._startInterval(stateObj); + } else { + this._clearInterval(); + } + } + + _clearInterval() { + if (this._updateRemaining) { + clearInterval(this._updateRemaining); + this._updateRemaining = null; + } + } + + _startInterval(stateObj) { + this._clearInterval(); + this._calculateRemaining(stateObj); + + if (stateObj.state === "active") { + this._updateRemaining = setInterval( + () => this._calculateRemaining(this._stateObj), + 1000 + ); + } + } + + _calculateRemaining(stateObj) { + this._timeRemaining = timerTimeRemaining(stateObj); + } + + _computeDisplay(stateObj, time) { + if (!stateObj) return null; + + if (stateObj.state === "idle" || time === 0) return stateObj.state; + + let display = secondsToDuration(time); + + if (stateObj.state === "paused") { + display += " (paused)"; + } + + return display; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error("Entity not configured."); + } + this._config = config; + } +} +customElements.define("hui-timer-entity-row", HuiTimerEntityRow); diff --git a/src/panels/lovelace/entity-rows/hui-toggle-entity-row.js b/src/panels/lovelace/entity-rows/hui-toggle-entity-row.js index 5f9a6f5a4781..c75055635f8d 100644 --- a/src/panels/lovelace/entity-rows/hui-toggle-entity-row.js +++ b/src/panels/lovelace/entity-rows/hui-toggle-entity-row.js @@ -1,76 +1,76 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../components/hui-generic-entity-row.js"; -import "../../../components/entity/ha-entity-toggle.js"; - -import computeStateDisplay from "../../../common/entity/compute_state_display.js"; - -import LocalizeMixin from "../../../mixins/localize-mixin.js"; - -/* - * @appliesMixin LocalizeMixin - */ -class HuiToggleEntityRow extends LocalizeMixin(PolymerElement) { - static get template() { - return html` - - ${this.toggleControlTemplate} - - `; - } - - static get toggleControlTemplate() { - return html` - - - `; - } - - static get properties() { - return { - hass: Object, - _config: Object, - _stateObj: { - type: Object, - computed: "_computeStateObj(hass.states, _config.entity)", - }, - _canToggle: { - type: Boolean, - computed: "_computeCanToggle(_stateObj.state)", - }, - }; - } - - _computeStateObj(states, entityId) { - return states && entityId in states ? states[entityId] : null; - } - - _computeCanToggle(state) { - return state === "on" || state === "off"; - } - - _computeState(stateObj) { - return stateObj && computeStateDisplay(this.localize, stateObj); - } - - setConfig(config) { - if (!config || !config.entity) { - throw new Error("Entity not configured."); - } - this._config = config; - } -} -customElements.define("hui-toggle-entity-row", HuiToggleEntityRow); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../components/hui-generic-entity-row"; +import "../../../components/entity/ha-entity-toggle"; + +import computeStateDisplay from "../../../common/entity/compute_state_display"; + +import LocalizeMixin from "../../../mixins/localize-mixin"; + +/* + * @appliesMixin LocalizeMixin + */ +class HuiToggleEntityRow extends LocalizeMixin(PolymerElement) { + static get template() { + return html` + + ${this.toggleControlTemplate} + + `; + } + + static get toggleControlTemplate() { + return html` + + + `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _stateObj: { + type: Object, + computed: "_computeStateObj(hass.states, _config.entity)", + }, + _canToggle: { + type: Boolean, + computed: "_computeCanToggle(_stateObj.state)", + }, + }; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + _computeCanToggle(state) { + return state === "on" || state === "off"; + } + + _computeState(stateObj) { + return stateObj && computeStateDisplay(this.localize, stateObj); + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error("Entity not configured."); + } + this._config = config; + } +} +customElements.define("hui-toggle-entity-row", HuiToggleEntityRow); diff --git a/src/panels/lovelace/ha-panel-lovelace.js b/src/panels/lovelace/ha-panel-lovelace.js index 0f4603818031..1d11e2d0f395 100644 --- a/src/panels/lovelace/ha-panel-lovelace.js +++ b/src/panels/lovelace/ha-panel-lovelace.js @@ -1,125 +1,125 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/paper-button/paper-button.js"; - -import "../../layouts/hass-loading-screen.js"; -import "../../layouts/hass-error-screen.js"; -import "./hui-root.js"; - -class Lovelace extends PolymerElement { - static get template() { - return html` - - - - - `; - } - - static get properties() { - return { - hass: Object, - - narrow: { - type: Boolean, - value: false, - }, - - showMenu: { - type: Boolean, - value: false, - }, - - route: Object, - - _columns: { - type: Number, - value: 1, - }, - - _state: { - type: String, - value: "loading", - }, - - _errorMsg: String, - - _config: { - type: Object, - value: null, - }, - }; - } - - static get observers() { - return ["_updateColumns(narrow, showMenu)"]; - } - - ready() { - this._fetchConfig(); - this._updateColumns = this._updateColumns.bind(this); - this.mqls = [300, 600, 900, 1200].map((width) => { - const mql = matchMedia(`(min-width: ${width}px)`); - mql.addListener(this._updateColumns); - return mql; - }); - this._updateColumns(); - super.ready(); - } - - _updateColumns() { - const matchColumns = this.mqls.reduce((cols, mql) => cols + mql.matches, 0); - // Do -1 column if the menu is docked and open - this._columns = Math.max(1, matchColumns - (!this.narrow && this.showMenu)); - } - - async _fetchConfig() { - try { - const conf = await this.hass.callWS({ type: "lovelace/config" }); - this.setProperties({ - _config: conf, - _state: "loaded", - }); - } catch (err) { - this.setProperties({ - _state: "error", - _errorMsg: err.message, - }); - } - } - - _equal(a, b) { - return a === b; - } -} - -customElements.define("ha-panel-lovelace", Lovelace); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/paper-button/paper-button"; + +import "../../layouts/hass-loading-screen"; +import "../../layouts/hass-error-screen"; +import "./hui-root"; + +class Lovelace extends PolymerElement { + static get template() { + return html` + + + + + `; + } + + static get properties() { + return { + hass: Object, + + narrow: { + type: Boolean, + value: false, + }, + + showMenu: { + type: Boolean, + value: false, + }, + + route: Object, + + _columns: { + type: Number, + value: 1, + }, + + _state: { + type: String, + value: "loading", + }, + + _errorMsg: String, + + _config: { + type: Object, + value: null, + }, + }; + } + + static get observers() { + return ["_updateColumns(narrow, showMenu)"]; + } + + ready() { + this._fetchConfig(); + this._updateColumns = this._updateColumns.bind(this); + this.mqls = [300, 600, 900, 1200].map((width) => { + const mql = matchMedia(`(min-width: ${width}px)`); + mql.addListener(this._updateColumns); + return mql; + }); + this._updateColumns(); + super.ready(); + } + + _updateColumns() { + const matchColumns = this.mqls.reduce((cols, mql) => cols + mql.matches, 0); + // Do -1 column if the menu is docked and open + this._columns = Math.max(1, matchColumns - (!this.narrow && this.showMenu)); + } + + async _fetchConfig() { + try { + const conf = await this.hass.callWS({ type: "lovelace/config" }); + this.setProperties({ + _config: conf, + _state: "loaded", + }); + } catch (err) { + this.setProperties({ + _state: "error", + _errorMsg: err.message, + }); + } + } + + _equal(a, b) { + return a === b; + } +} + +customElements.define("ha-panel-lovelace", Lovelace); diff --git a/src/panels/lovelace/hui-root.js b/src/panels/lovelace/hui-root.js index 716e1bbb177a..3e937ca7640d 100644 --- a/src/panels/lovelace/hui-root.js +++ b/src/panels/lovelace/hui-root.js @@ -1,380 +1,380 @@ -import "@polymer/app-layout/app-header-layout/app-header-layout.js"; -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-scroll-effects/effects/waterfall.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/app-route/app-route.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import "@polymer/paper-menu-button/paper-menu-button.js"; -import "@polymer/paper-tabs/paper-tab.js"; -import "@polymer/paper-tabs/paper-tabs.js"; - -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import scrollToTarget from "../../common/dom/scroll-to-target.js"; - -import EventsMixin from "../../mixins/events-mixin.js"; -import NavigateMixin from "../../mixins/navigate-mixin.js"; - -import "../../layouts/ha-app-layout.js"; -import "../../components/ha-start-voice-button.js"; -import "../../components/ha-icon.js"; -import { loadModule, loadCSS, loadJS } from "../../common/dom/load_resource.js"; -import { subscribeNotifications } from "../../data/ws-notifications"; -import "./components/notifications/hui-notification-drawer.js"; -import "./components/notifications/hui-notifications-button.js"; -import "./hui-unused-entities.js"; -import "./hui-view.js"; -import debounce from "../../common/util/debounce.js"; - -import createCardElement from "./common/create-card-element.js"; -import computeNotifications from "./common/compute-notifications"; - -// CSS and JS should only be imported once. Modules and HTML are safe. -const CSS_CACHE = {}; -const JS_CACHE = {}; - -class HUIRoot extends NavigateMixin(EventsMixin(PolymerElement)) { - static get template() { - return html` - - - - - - - - -
- - - -
-
- -
- - `; - } - - static get properties() { - return { - narrow: Boolean, - showMenu: Boolean, - hass: { - type: Object, - observer: "_hassChanged", - }, - config: { - type: Object, - observer: "_configChanged", - }, - columns: { - type: Number, - observer: "_columnsChanged", - }, - - _curView: { - type: Number, - value: 0, - }, - - route: { - type: Object, - observer: "_routeChanged", - }, - - notificationsOpen: { - type: Boolean, - value: false, - }, - - _persistentNotifications: { - type: Array, - value: [], - }, - - _notifications: { - type: Array, - computed: "_updateNotifications(hass.states, _persistentNotifications)", - }, - - _editMode: { - type: Boolean, - value: false, - observer: "_editModeChanged", - }, - - routeData: Object, - }; - } - - constructor() { - super(); - this._debouncedConfigChanged = debounce( - () => this._selectView(this._curView), - 100 - ); - } - - connectedCallback() { - super.connectedCallback(); - this._unsubNotifications = subscribeNotifications( - this.hass.connection, - (notifications) => { - this._persistentNotifications = notifications; - } - ); - } - - disconnectedCallback() { - super.disconnectedCallback(); - if (typeof this._unsubNotifications === "function") { - this._unsubNotifications(); - } - } - - _updateNotifications(states, persistent) { - if (!states) return persistent; - - const configurator = computeNotifications(states); - return persistent.concat(configurator); - } - - _routeChanged(route) { - const views = this.config && this.config.views; - if (route.path === "" && route.prefix === "/lovelace" && views) { - this.navigate(`/lovelace/${views[0].id || 0}`, true); - } else if (this.routeData.view) { - const view = this.routeData.view; - let index = 0; - for (let i = 0; i < views.length; i++) { - if (views[i].id === view || i === parseInt(view)) { - index = i; - break; - } - } - if (index !== this._curView) this._selectView(index); - } - } - - _computeViewId(id, index) { - return id || index; - } - - _computeTitle(config) { - return config.title || "Home Assistant"; - } - - _computeTabsHidden(views) { - return views.length < 2; - } - - _computeTabTitle(title) { - return title || "Unnamed view"; - } - - _handleRefresh() { - this.fire("config-refresh"); - } - - _handleUnusedEntities() { - this._selectView("unused"); - } - - _deselect(ev) { - ev.target.selected = null; - } - - _handleHelp() { - window.open("https://www.home-assistant.io/lovelace/", "_blank"); - } - - _editModeEnable() { - this._editMode = true; - } - - _editModeDisable() { - this._editMode = false; - } - - _editModeChanged() { - this._selectView(this._curView); - } - - _handleViewSelected(ev) { - const index = ev.detail.selected; - if (index !== this._curView) { - const id = this.config.views[index].id || index; - this.navigate(`/lovelace/${id}`); - } - scrollToTarget(this, this.$.layout.header.scrollTarget); - } - - _selectView(viewIndex) { - this._curView = viewIndex; - - // Recreate a new element to clear the applied themes. - const root = this.$.view; - if (root.lastChild) { - root.removeChild(root.lastChild); - } - - let view; - let background = this.config.background || ""; - - if (viewIndex === "unused") { - view = document.createElement("hui-unused-entities"); - view.config = this.config; - } else { - const viewConfig = this.config.views[this._curView]; - if (viewConfig.panel) { - view = createCardElement(viewConfig.cards[0]); - view.isPanel = true; - view.editMode = this._editMode; - } else { - view = document.createElement("hui-view"); - view.config = viewConfig; - view.columns = this.columns; - view.editMode = this._editMode; - } - if (viewConfig.background) background = viewConfig.background; - } - - this.$.view.style.background = background; - - view.hass = this.hass; - root.appendChild(view); - } - - _hassChanged(hass) { - if (!this.$.view.lastChild) return; - this.$.view.lastChild.hass = hass; - } - - _configChanged(config) { - this._loadResources(config.resources || []); - // On config change, recreate the view from scratch. - this._selectView(this._curView); - this.$.view.classList.toggle("tabs-hidden", config.views.length < 2); - } - - _columnsChanged(columns) { - if (!this.$.view.lastChild) return; - this.$.view.lastChild.columns = columns; - } - - _loadResources(resources) { - resources.forEach((resource) => { - switch (resource.type) { - case "css": - if (resource.url in CSS_CACHE) break; - CSS_CACHE[resource.url] = loadCSS(resource.url); - break; - - case "js": - if (resource.url in JS_CACHE) break; - JS_CACHE[resource.url] = loadJS(resource.url); - break; - - case "module": - loadModule(resource.url); - break; - - case "html": - import(/* webpackChunkName: "import-href-polyfill" */ "../../resources/html-import/import-href.js").then( - ({ importHref }) => importHref(resource.url) - ); - break; - - default: - // eslint-disable-next-line - console.warn("Unknown resource type specified: ${resource.type}"); - } - }); - } -} -customElements.define("hui-root", HUIRoot); +import "@polymer/app-layout/app-header-layout/app-header-layout"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-scroll-effects/effects/waterfall"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/app-route/app-route"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import "@polymer/paper-menu-button/paper-menu-button"; +import "@polymer/paper-tabs/paper-tab"; +import "@polymer/paper-tabs/paper-tabs"; + +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import scrollToTarget from "../../common/dom/scroll-to-target"; + +import EventsMixin from "../../mixins/events-mixin"; +import NavigateMixin from "../../mixins/navigate-mixin"; + +import "../../layouts/ha-app-layout"; +import "../../components/ha-start-voice-button"; +import "../../components/ha-icon"; +import { loadModule, loadCSS, loadJS } from "../../common/dom/load_resource"; +import { subscribeNotifications } from "../../data/ws-notifications"; +import "./components/notifications/hui-notification-drawer"; +import "./components/notifications/hui-notifications-button"; +import "./hui-unused-entities"; +import "./hui-view"; +import debounce from "../../common/util/debounce"; + +import createCardElement from "./common/create-card-element"; +import computeNotifications from "./common/compute-notifications"; + +// CSS and JS should only be imported once. Modules and HTML are safe. +const CSS_CACHE = {}; +const JS_CACHE = {}; + +class HUIRoot extends NavigateMixin(EventsMixin(PolymerElement)) { + static get template() { + return html` + + + + + + + + +
+ + + +
+
+ +
+ + `; + } + + static get properties() { + return { + narrow: Boolean, + showMenu: Boolean, + hass: { + type: Object, + observer: "_hassChanged", + }, + config: { + type: Object, + observer: "_configChanged", + }, + columns: { + type: Number, + observer: "_columnsChanged", + }, + + _curView: { + type: Number, + value: 0, + }, + + route: { + type: Object, + observer: "_routeChanged", + }, + + notificationsOpen: { + type: Boolean, + value: false, + }, + + _persistentNotifications: { + type: Array, + value: [], + }, + + _notifications: { + type: Array, + computed: "_updateNotifications(hass.states, _persistentNotifications)", + }, + + _editMode: { + type: Boolean, + value: false, + observer: "_editModeChanged", + }, + + routeData: Object, + }; + } + + constructor() { + super(); + this._debouncedConfigChanged = debounce( + () => this._selectView(this._curView), + 100 + ); + } + + connectedCallback() { + super.connectedCallback(); + this._unsubNotifications = subscribeNotifications( + this.hass.connection, + (notifications) => { + this._persistentNotifications = notifications; + } + ); + } + + disconnectedCallback() { + super.disconnectedCallback(); + if (typeof this._unsubNotifications === "function") { + this._unsubNotifications(); + } + } + + _updateNotifications(states, persistent) { + if (!states) return persistent; + + const configurator = computeNotifications(states); + return persistent.concat(configurator); + } + + _routeChanged(route) { + const views = this.config && this.config.views; + if (route.path === "" && route.prefix === "/lovelace" && views) { + this.navigate(`/lovelace/${views[0].id || 0}`, true); + } else if (this.routeData.view) { + const view = this.routeData.view; + let index = 0; + for (let i = 0; i < views.length; i++) { + if (views[i].id === view || i === parseInt(view)) { + index = i; + break; + } + } + if (index !== this._curView) this._selectView(index); + } + } + + _computeViewId(id, index) { + return id || index; + } + + _computeTitle(config) { + return config.title || "Home Assistant"; + } + + _computeTabsHidden(views) { + return views.length < 2; + } + + _computeTabTitle(title) { + return title || "Unnamed view"; + } + + _handleRefresh() { + this.fire("config-refresh"); + } + + _handleUnusedEntities() { + this._selectView("unused"); + } + + _deselect(ev) { + ev.target.selected = null; + } + + _handleHelp() { + window.open("https://www.home-assistant.io/lovelace/", "_blank"); + } + + _editModeEnable() { + this._editMode = true; + } + + _editModeDisable() { + this._editMode = false; + } + + _editModeChanged() { + this._selectView(this._curView); + } + + _handleViewSelected(ev) { + const index = ev.detail.selected; + if (index !== this._curView) { + const id = this.config.views[index].id || index; + this.navigate(`/lovelace/${id}`); + } + scrollToTarget(this, this.$.layout.header.scrollTarget); + } + + _selectView(viewIndex) { + this._curView = viewIndex; + + // Recreate a new element to clear the applied themes. + const root = this.$.view; + if (root.lastChild) { + root.removeChild(root.lastChild); + } + + let view; + let background = this.config.background || ""; + + if (viewIndex === "unused") { + view = document.createElement("hui-unused-entities"); + view.config = this.config; + } else { + const viewConfig = this.config.views[this._curView]; + if (viewConfig.panel) { + view = createCardElement(viewConfig.cards[0]); + view.isPanel = true; + view.editMode = this._editMode; + } else { + view = document.createElement("hui-view"); + view.config = viewConfig; + view.columns = this.columns; + view.editMode = this._editMode; + } + if (viewConfig.background) background = viewConfig.background; + } + + this.$.view.style.background = background; + + view.hass = this.hass; + root.appendChild(view); + } + + _hassChanged(hass) { + if (!this.$.view.lastChild) return; + this.$.view.lastChild.hass = hass; + } + + _configChanged(config) { + this._loadResources(config.resources || []); + // On config change, recreate the view from scratch. + this._selectView(this._curView); + this.$.view.classList.toggle("tabs-hidden", config.views.length < 2); + } + + _columnsChanged(columns) { + if (!this.$.view.lastChild) return; + this.$.view.lastChild.columns = columns; + } + + _loadResources(resources) { + resources.forEach((resource) => { + switch (resource.type) { + case "css": + if (resource.url in CSS_CACHE) break; + CSS_CACHE[resource.url] = loadCSS(resource.url); + break; + + case "js": + if (resource.url in JS_CACHE) break; + JS_CACHE[resource.url] = loadJS(resource.url); + break; + + case "module": + loadModule(resource.url); + break; + + case "html": + import(/* webpackChunkName: "import-href-polyfill" */ "../../resources/html-import/import-href").then( + ({ importHref }) => importHref(resource.url) + ); + break; + + default: + // eslint-disable-next-line + console.warn("Unknown resource type specified: ${resource.type}"); + } + }); + } +} +customElements.define("hui-root", HUIRoot); diff --git a/src/panels/lovelace/hui-unused-entities.js b/src/panels/lovelace/hui-unused-entities.js index 9b9e318954fb..7b066f9269e3 100644 --- a/src/panels/lovelace/hui-unused-entities.js +++ b/src/panels/lovelace/hui-unused-entities.js @@ -1,61 +1,61 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import computeUnusedEntities from "./common/compute-unused-entities.js"; -import createCardElement from "./common/create-card-element.js"; - -import "./cards/hui-entities-card.ts"; - -class HuiUnusedEntities extends PolymerElement { - static get template() { - return html` - -
- `; - } - - static get properties() { - return { - hass: { - type: Object, - observer: "_hassChanged", - }, - config: { - type: Object, - observer: "_configChanged", - }, - }; - } - - _configChanged(config) { - const root = this.$.root; - if (root.lastChild) root.removeChild(root.lastChild); - - const entities = computeUnusedEntities(this.hass, config).map((entity) => ({ - entity, - secondary_info: "entity-id", - })); - const cardConfig = { - type: "entities", - title: "Unused entities", - entities, - show_header_toggle: false, - }; - const element = createCardElement(cardConfig); - element.hass = this.hass; - root.appendChild(element); - } - - _hassChanged(hass) { - const root = this.$.root; - if (!root.lastChild) return; - root.lastChild.hass = hass; - } -} -customElements.define("hui-unused-entities", HuiUnusedEntities); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import computeUnusedEntities from "./common/compute-unused-entities"; +import createCardElement from "./common/create-card-element"; + +import "./cards/hui-entities-card.ts"; + +class HuiUnusedEntities extends PolymerElement { + static get template() { + return html` + +
+ `; + } + + static get properties() { + return { + hass: { + type: Object, + observer: "_hassChanged", + }, + config: { + type: Object, + observer: "_configChanged", + }, + }; + } + + _configChanged(config) { + const root = this.$.root; + if (root.lastChild) root.removeChild(root.lastChild); + + const entities = computeUnusedEntities(this.hass, config).map((entity) => ({ + entity, + secondary_info: "entity-id", + })); + const cardConfig = { + type: "entities", + title: "Unused entities", + entities, + show_header_toggle: false, + }; + const element = createCardElement(cardConfig); + element.hass = this.hass; + root.appendChild(element); + } + + _hassChanged(hass) { + const root = this.$.root; + if (!root.lastChild) return; + root.lastChild.hass = hass; + } +} +customElements.define("hui-unused-entities", HuiUnusedEntities); diff --git a/src/panels/lovelace/hui-view.js b/src/panels/lovelace/hui-view.js index bc334390183c..91931c71ed0a 100644 --- a/src/panels/lovelace/hui-view.js +++ b/src/panels/lovelace/hui-view.js @@ -1,218 +1,218 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../components/entity/ha-state-label-badge.js"; -import "./components/hui-card-options.ts"; - -import applyThemesOnElement from "../../common/dom/apply_themes_on_element.js"; - -import createCardElement from "./common/create-card-element"; -import computeCardSize from "./common/compute-card-size"; - -class HUIView extends PolymerElement { - static get template() { - return html` - -
-
- `; - } - - static get properties() { - return { - hass: { - type: Object, - observer: "_hassChanged", - }, - config: Object, - columns: Number, - editMode: Boolean, - }; - } - - static get observers() { - return [ - // Put all properties in 1 observer so we only call configChanged once - "_createBadges(config)", - "_createCards(config, columns, editMode)", - ]; - } - - constructor() { - super(); - this._cards = []; - this._badges = []; - } - - _createBadges(config) { - const root = this.$.badges; - while (root.lastChild) { - root.removeChild(root.lastChild); - } - - if (!config || !config.badges || !Array.isArray(config.badges)) { - root.style.display = "none"; - this._badges = []; - return; - } - - const elements = []; - for (const entityId of config.badges) { - if (!(entityId in this.hass.states)) continue; - - const element = document.createElement("ha-state-label-badge"); - element.setProperties({ - hass: this.hass, - state: this.hass.states[entityId], - }); - elements.push({ element, entityId }); - root.appendChild(element); - } - this._badges = elements; - root.style.display = elements.length > 0 ? "block" : "none"; - } - - _createCards(config) { - const root = this.$.columns; - - while (root.lastChild) { - root.removeChild(root.lastChild); - } - - if (!config || !config.cards || !Array.isArray(config.cards)) { - this._cards = []; - return; - } - - const elements = []; - const elementsToAppend = []; - for (const cardConfig of config.cards) { - const element = createCardElement(cardConfig); - element.hass = this.hass; - elements.push(element); - - if (!this.editMode) { - elementsToAppend.push(element); - continue; - } - - const wrapper = document.createElement("hui-card-options"); - wrapper.hass = this.hass; - wrapper.cardId = cardConfig.id; - wrapper.editMode = this.editMode; - wrapper.appendChild(element); - elementsToAppend.push(wrapper); - } - - let columns = []; - const columnEntityCount = []; - for (let i = 0; i < this.columns; i++) { - columns.push([]); - columnEntityCount.push(0); - } - - // Find column with < 5 entities, else column with lowest count - function getColumnIndex(size) { - let minIndex = 0; - for (let i = 0; i < columnEntityCount.length; i++) { - if (columnEntityCount[i] < 5) { - minIndex = i; - break; - } - if (columnEntityCount[i] < columnEntityCount[minIndex]) { - minIndex = i; - } - } - - columnEntityCount[minIndex] += size; - - return minIndex; - } - - elements.forEach((el, index) => { - const cardSize = computeCardSize(el); - // Element to append might be the wrapped card when we're editing. - columns[getColumnIndex(cardSize)].push(elementsToAppend[index]); - }); - - // Remove empty columns - columns = columns.filter((val) => val.length > 0); - - columns.forEach((column) => { - const columnEl = document.createElement("div"); - columnEl.classList.add("column"); - column.forEach((el) => columnEl.appendChild(el)); - root.appendChild(columnEl); - }); - - this._cards = elements; - - if ("theme" in config) { - applyThemesOnElement(root, this.hass.themes, config.theme); - } - } - - _hassChanged(hass) { - this._badges.forEach((badge) => { - const { element, entityId } = badge; - element.setProperties({ - hass, - state: hass.states[entityId], - }); - }); - this._cards.forEach((element) => { - element.hass = hass; - }); - } -} - -customElements.define("hui-view", HUIView); +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../components/entity/ha-state-label-badge"; +import "./components/hui-card-options.ts"; + +import applyThemesOnElement from "../../common/dom/apply_themes_on_element"; + +import createCardElement from "./common/create-card-element"; +import computeCardSize from "./common/compute-card-size"; + +class HUIView extends PolymerElement { + static get template() { + return html` + +
+
+ `; + } + + static get properties() { + return { + hass: { + type: Object, + observer: "_hassChanged", + }, + config: Object, + columns: Number, + editMode: Boolean, + }; + } + + static get observers() { + return [ + // Put all properties in 1 observer so we only call configChanged once + "_createBadges(config)", + "_createCards(config, columns, editMode)", + ]; + } + + constructor() { + super(); + this._cards = []; + this._badges = []; + } + + _createBadges(config) { + const root = this.$.badges; + while (root.lastChild) { + root.removeChild(root.lastChild); + } + + if (!config || !config.badges || !Array.isArray(config.badges)) { + root.style.display = "none"; + this._badges = []; + return; + } + + const elements = []; + for (const entityId of config.badges) { + if (!(entityId in this.hass.states)) continue; + + const element = document.createElement("ha-state-label-badge"); + element.setProperties({ + hass: this.hass, + state: this.hass.states[entityId], + }); + elements.push({ element, entityId }); + root.appendChild(element); + } + this._badges = elements; + root.style.display = elements.length > 0 ? "block" : "none"; + } + + _createCards(config) { + const root = this.$.columns; + + while (root.lastChild) { + root.removeChild(root.lastChild); + } + + if (!config || !config.cards || !Array.isArray(config.cards)) { + this._cards = []; + return; + } + + const elements = []; + const elementsToAppend = []; + for (const cardConfig of config.cards) { + const element = createCardElement(cardConfig); + element.hass = this.hass; + elements.push(element); + + if (!this.editMode) { + elementsToAppend.push(element); + continue; + } + + const wrapper = document.createElement("hui-card-options"); + wrapper.hass = this.hass; + wrapper.cardId = cardConfig.id; + wrapper.editMode = this.editMode; + wrapper.appendChild(element); + elementsToAppend.push(wrapper); + } + + let columns = []; + const columnEntityCount = []; + for (let i = 0; i < this.columns; i++) { + columns.push([]); + columnEntityCount.push(0); + } + + // Find column with < 5 entities, else column with lowest count + function getColumnIndex(size) { + let minIndex = 0; + for (let i = 0; i < columnEntityCount.length; i++) { + if (columnEntityCount[i] < 5) { + minIndex = i; + break; + } + if (columnEntityCount[i] < columnEntityCount[minIndex]) { + minIndex = i; + } + } + + columnEntityCount[minIndex] += size; + + return minIndex; + } + + elements.forEach((el, index) => { + const cardSize = computeCardSize(el); + // Element to append might be the wrapped card when we're editing. + columns[getColumnIndex(cardSize)].push(elementsToAppend[index]); + }); + + // Remove empty columns + columns = columns.filter((val) => val.length > 0); + + columns.forEach((column) => { + const columnEl = document.createElement("div"); + columnEl.classList.add("column"); + column.forEach((el) => columnEl.appendChild(el)); + root.appendChild(columnEl); + }); + + this._cards = elements; + + if ("theme" in config) { + applyThemesOnElement(root, this.hass.themes, config.theme); + } + } + + _hassChanged(hass) { + this._badges.forEach((badge) => { + const { element, entityId } = badge; + element.setProperties({ + hass, + state: hass.states[entityId], + }); + }); + this._cards.forEach((element) => { + element.hass = hass; + }); + } +} + +customElements.define("hui-view", HUIView); diff --git a/src/panels/lovelace/special-rows/hui-call-service-row.ts b/src/panels/lovelace/special-rows/hui-call-service-row.ts index 1a06ad90ab1e..44c7f2354cfb 100644 --- a/src/panels/lovelace/special-rows/hui-call-service-row.ts +++ b/src/panels/lovelace/special-rows/hui-call-service-row.ts @@ -1,11 +1,11 @@ import { html, LitElement } from "@polymer/lit-element"; -import "@polymer/paper-button/paper-button.js"; +import "@polymer/paper-button/paper-button"; -import "../../../components/ha-icon.js"; +import "../../../components/ha-icon"; -import callService from "../common/call-service.js"; -import { EntityRow, CallServiceConfig } from "../entity-rows/types.js"; -import { HomeAssistant } from "../../../types.js"; +import callService from "../common/call-service"; +import { EntityRow, CallServiceConfig } from "../entity-rows/types"; +import { HomeAssistant } from "../../../types"; import { TemplateResult } from "lit-html"; class HuiCallServiceRow extends LitElement implements EntityRow { diff --git a/src/panels/lovelace/special-rows/hui-section-row.ts b/src/panels/lovelace/special-rows/hui-section-row.ts index f590c4d96d4e..9033755203a6 100644 --- a/src/panels/lovelace/special-rows/hui-section-row.ts +++ b/src/panels/lovelace/special-rows/hui-section-row.ts @@ -2,7 +2,7 @@ import { html, LitElement } from "@polymer/lit-element"; import { EntityRow, SectionConfig } from "../entity-rows/types"; import { HomeAssistant } from "../../../types"; -import "../../../components/ha-icon.js"; +import "../../../components/ha-icon"; import { TemplateResult } from "lit-html"; class HuiSectionRow extends LitElement implements EntityRow { diff --git a/src/panels/lovelace/special-rows/hui-weblink-row.ts b/src/panels/lovelace/special-rows/hui-weblink-row.ts index e49690ece5db..a9ff56c4007a 100644 --- a/src/panels/lovelace/special-rows/hui-weblink-row.ts +++ b/src/panels/lovelace/special-rows/hui-weblink-row.ts @@ -2,7 +2,7 @@ import { html, LitElement } from "@polymer/lit-element"; import { EntityRow, WeblinkConfig } from "../entity-rows/types"; import { HomeAssistant } from "../../../types"; -import "../../../components/ha-icon.js"; +import "../../../components/ha-icon"; import { TemplateResult } from "lit-html"; From 17274f9d5867a0b649f42472563e0e9aff6e7a79 Mon Sep 17 00:00:00 2001 From: Ian Richardson Date: Thu, 1 Nov 2018 23:45:26 -0500 Subject: [PATCH 2/5] Go big or go home --- gallery/src/components/demo-card.js | 14 ++-- gallery/src/components/demo-cards.js | 10 +-- gallery/src/components/demo-more-info.js | 10 +-- gallery/src/components/demo-more-infos.js | 10 +-- gallery/src/data/provide_hass.js | 6 +- .../src/demos/demo-hui-alarm-panel-card.js | 10 +-- .../src/demos/demo-hui-conditional-card.js | 10 +-- gallery/src/demos/demo-hui-entities-card.js | 10 +-- .../src/demos/demo-hui-entity-button-card.js | 10 +-- .../src/demos/demo-hui-entity-filter-card.js | 10 +-- gallery/src/demos/demo-hui-gauge-card.js | 6 +- gallery/src/demos/demo-hui-glance-card.js | 10 +-- gallery/src/demos/demo-hui-iframe-card.js | 6 +- gallery/src/demos/demo-hui-light-card.js | 10 +-- gallery/src/demos/demo-hui-map-card.js | 10 +-- gallery/src/demos/demo-hui-markdown-card.js | 6 +- .../src/demos/demo-hui-media-player-rows.js | 12 ++-- .../demos/demo-hui-picture-elements-card.js | 10 +-- .../src/demos/demo-hui-picture-entity-card.js | 6 +- .../src/demos/demo-hui-picture-glance-card.js | 6 +- gallery/src/demos/demo-hui-stack-card.js | 10 +-- gallery/src/demos/demo-hui-thermostat-card.js | 10 +-- gallery/src/demos/demo-more-info-light.js | 14 ++-- gallery/src/entrypoint.js | 16 ++--- gallery/src/ha-gallery.js | 24 +++---- gallery/webpack.config.js | 2 +- .../addon-store/hassio-addon-repository.js | 12 ++-- hassio/src/addon-store/hassio-addon-store.js | 8 +-- .../addon-store/hassio-repositories-editor.js | 16 ++--- hassio/src/addon-view/hassio-addon-audio.js | 20 +++--- hassio/src/addon-view/hassio-addon-config.js | 12 ++-- hassio/src/addon-view/hassio-addon-info.js | 22 +++---- hassio/src/addon-view/hassio-addon-logs.js | 10 +-- hassio/src/addon-view/hassio-addon-network.js | 14 ++-- hassio/src/addon-view/hassio-addon-view.js | 32 ++++----- hassio/src/components/hassio-card-content.js | 8 +-- hassio/src/dashboard/hassio-addons.js | 12 ++-- hassio/src/dashboard/hassio-dashboard.js | 10 +-- hassio/src/dashboard/hassio-hass-update.js | 14 ++-- hassio/src/hassio-app.js | 8 +-- hassio/src/hassio-data.js | 2 +- hassio/src/hassio-main.js | 20 +++--- hassio/src/hassio-markdown-dialog.js | 16 ++--- hassio/src/hassio-pages-with-tabs.js | 36 +++++----- hassio/src/resources/hassio-icons.js | 2 +- hassio/src/snapshots/hassio-snapshot.js | 20 +++--- hassio/src/snapshots/hassio-snapshots.js | 22 +++---- hassio/src/system/hassio-host-info.js | 12 ++-- hassio/src/system/hassio-supervisor-info.js | 12 ++-- hassio/src/system/hassio-supervisor-log.js | 8 +-- hassio/src/system/hassio-system.js | 12 ++-- hassio/webpack.config.js | 2 +- src/auth/ha-auth-flow.js | 10 +-- src/auth/ha-authorize.js | 14 ++-- src/auth/ha-pick-auth-provider.js | 12 ++-- src/cards/ha-badges-card.js | 6 +- src/cards/ha-camera-card.js | 12 ++-- src/cards/ha-card-chooser.js | 18 ++--- src/cards/ha-entities-card.js | 28 ++++---- src/cards/ha-history_graph-card.js | 12 ++-- src/cards/ha-media_player-card.js | 24 +++---- src/cards/ha-persistent_notification-card.js | 14 ++-- src/cards/ha-plant-card.js | 12 ++-- src/cards/ha-weather-card.js | 12 ++-- src/common/entity/can_toggle_state.js | 4 +- src/common/entity/compute_state_display.js | 8 +-- src/common/entity/compute_state_domain.js | 2 +- src/common/entity/cover_icon.js | 2 +- src/common/entity/domain_icon.js | 2 +- src/common/entity/extract_views.js | 2 +- src/common/entity/get_view_entities.js | 4 +- src/common/entity/input_dateteime_icon.js | 2 +- src/common/entity/sensor_icon.js | 4 +- src/common/entity/split_by_groups.js | 2 +- src/common/entity/state_card_type.js | 6 +- src/common/entity/state_icon.js | 14 ++-- src/common/entity/state_more_info_type.js | 4 +- src/common/entity/states_sort_by_name.js | 2 +- src/common/entity/timer_time_remaining.js | 2 +- src/common/navigate.ts | 2 +- src/components/buttons/ha-call-api-button.js | 4 +- .../buttons/ha-call-service-button.js | 8 +-- src/components/buttons/ha-progress-button.js | 8 +-- src/components/entity/ha-chart-base.js | 18 ++--- src/components/entity/ha-entity-picker.js | 26 ++++---- src/components/entity/ha-entity-toggle.js | 12 ++-- src/components/entity/ha-state-icon.js | 8 +-- src/components/entity/ha-state-label-badge.js | 24 +++---- src/components/entity/state-badge.js | 10 +-- src/components/entity/state-info.js | 10 +-- src/components/ha-attributes.js | 8 +-- src/components/ha-card.js | 6 +- src/components/ha-cards.js | 26 ++++---- src/components/ha-climate-control.js | 10 +-- src/components/ha-climate-state.js | 6 +- src/components/ha-color-picker.js | 6 +- src/components/ha-combo-box.js | 14 ++-- src/components/ha-cover-controls.js | 8 +-- src/components/ha-cover-tilt-controls.js | 10 +-- src/components/ha-demo-badge.js | 6 +- src/components/ha-form.js | 22 +++---- src/components/ha-icon.js | 2 +- src/components/ha-iconset-svg.js | 2 +- src/components/ha-label-badge.js | 6 +- src/components/ha-labeled-slider.js | 8 +-- src/components/ha-markdown.js | 4 +- src/components/ha-menu-button.js | 8 +-- src/components/ha-paper-slider.js | 2 +- .../ha-push-notifications-toggle.js | 8 +-- src/components/ha-relative-time.js | 8 +-- src/components/ha-service-description.js | 4 +- src/components/ha-service-picker.js | 8 +-- src/components/ha-sidebar.js | 26 ++++---- src/components/ha-start-voice-button.js | 10 +-- src/components/ha-textarea.js | 6 +- src/components/ha-toast.js | 2 +- src/components/ha-vacuum-state.js | 8 +-- src/components/ha-water_heater-control.js | 10 +-- src/components/ha-water_heater-state.js | 6 +- src/components/paper-time-input.js | 12 ++-- src/components/state-history-chart-line.js | 12 ++-- .../state-history-chart-timeline.js | 10 +-- src/components/state-history-charts.js | 12 ++-- src/data/ha-state-history-data.js | 8 +-- src/data/history.ts | 10 +-- src/dialogs/ha-more-info-dialog.js | 18 ++--- src/dialogs/ha-store-auth-card.js | 12 ++-- src/dialogs/ha-voice-command-dialog.js | 12 ++-- .../controls/more-info-alarm_control_panel.js | 14 ++-- .../controls/more-info-automation.js | 10 +-- .../more-info/controls/more-info-camera.js | 10 +-- .../more-info/controls/more-info-climate.js | 32 ++++----- .../controls/more-info-configurator.js | 18 ++--- .../more-info/controls/more-info-content.js | 46 ++++++------- .../more-info/controls/more-info-cover.js | 16 ++--- .../more-info/controls/more-info-default.js | 6 +- .../more-info/controls/more-info-fan.js | 22 +++---- .../more-info/controls/more-info-group.js | 10 +-- .../controls/more-info-history_graph.js | 8 +-- .../controls/more-info-input_datetime.js | 18 ++--- .../more-info/controls/more-info-light.js | 22 +++---- .../more-info/controls/more-info-lock.js | 12 ++-- .../controls/more-info-media_player.js | 28 ++++---- .../more-info/controls/more-info-script.js | 6 +- .../more-info/controls/more-info-sun.js | 12 ++-- .../more-info/controls/more-info-updater.js | 4 +- .../more-info/controls/more-info-vacuum.js | 20 +++--- .../controls/more-info-water_heater.js | 28 ++++---- .../more-info/controls/more-info-weather.js | 8 +-- src/dialogs/more-info/more-info-controls.js | 28 ++++---- src/dialogs/more-info/more-info-settings.js | 26 ++++---- src/entrypoints/app.js | 18 ++--- src/entrypoints/authorize.js | 12 ++-- src/entrypoints/core.js | 8 +-- src/entrypoints/custom-panel.js | 8 +-- src/entrypoints/hass-icons.js | 2 +- src/entrypoints/onboarding.js | 6 +- src/layouts/app/auth-mixin.js | 8 +-- src/layouts/app/connection-mixin.js | 16 ++--- src/layouts/app/disconnect-toast-mixin.js | 2 +- src/layouts/app/home-assistant.js | 40 +++++------ src/layouts/app/more-info-mixin.js | 2 +- src/layouts/app/sidebar-mixin.js | 2 +- src/layouts/app/themes-mixin.js | 6 +- src/layouts/app/translations-mixin.js | 4 +- src/layouts/ha-app-layout.js | 6 +- src/layouts/ha-init-page.js | 14 ++-- src/layouts/hass-error-screen.js | 10 +-- src/layouts/hass-loading-screen.js | 12 ++-- src/layouts/hass-subpage.js | 12 ++-- src/layouts/home-assistant-main.js | 28 ++++---- src/layouts/partial-cards.js | 50 +++++++------- src/layouts/partial-panel-resolver.js | 16 ++--- src/managers/notification-manager.js | 6 +- src/mixins/dialog-mixin.js | 6 +- src/mixins/events-mixin.js | 4 +- src/mixins/localize-base-mixin.ts | 2 +- src/mixins/localize-lite-mixin.js | 7 +- src/mixins/localize-mixin.js | 2 +- src/mixins/navigate-mixin.js | 2 +- src/onboarding/ha-onboarding.js | 14 ++-- src/panels/calendar/ha-big-calendar.js | 8 +-- src/panels/calendar/ha-panel-calendar.js | 26 ++++---- .../config/automation/ha-automation-editor.js | 24 +++---- .../config/automation/ha-automation-picker.js | 36 +++++----- .../config/automation/ha-config-automation.js | 12 ++-- .../config/cloud/ha-config-cloud-account.js | 32 ++++----- .../cloud/ha-config-cloud-forgot-password.js | 16 ++--- .../config/cloud/ha-config-cloud-login.js | 30 ++++----- .../config/cloud/ha-config-cloud-register.js | 20 +++--- src/panels/config/cloud/ha-config-cloud.js | 24 +++---- .../config-entries/ha-ce-entities-card.js | 20 +++--- .../ha-config-entries-dashboard.js | 36 +++++----- .../config-entries/ha-config-entries.js | 20 +++--- .../config-entries/ha-config-entry-page.js | 22 +++---- .../config/config-entries/ha-config-flow.js | 28 ++++---- .../config/config-entries/ha-device-card.js | 22 +++---- src/panels/config/core/ha-config-core.js | 18 ++--- .../config/core/ha-config-section-core.js | 20 +++--- .../config/customize/ha-config-customize.js | 28 ++++---- .../customize/ha-customize-attribute.js | 20 +++--- .../customize/ha-form-customize-attributes.js | 8 +-- .../config/customize/ha-form-customize.js | 14 ++-- .../customize/types/ha-customize-array.js | 12 ++-- .../customize/types/ha-customize-boolean.js | 6 +- .../customize/types/ha-customize-icon.js | 8 +-- .../customize/types/ha-customize-key-value.js | 6 +- .../customize/types/ha-customize-string.js | 6 +- .../config/dashboard/ha-config-dashboard.js | 30 ++++----- .../config/dashboard/ha-config-navigation.js | 18 ++--- src/panels/config/ha-config-section.js | 6 +- src/panels/config/ha-entity-config.js | 20 +++--- src/panels/config/ha-panel-config.js | 16 ++--- src/panels/config/js/automation.js | 14 ++-- .../config/js/condition/condition_edit.js | 18 ++--- .../config/js/condition/condition_row.js | 12 ++-- src/panels/config/js/condition/index.js | 6 +- .../config/js/condition/numeric_state.js | 8 +-- src/panels/config/js/condition/state.js | 6 +- src/panels/config/js/condition/sun.js | 8 +-- src/panels/config/js/condition/template.js | 4 +- src/panels/config/js/condition/time.js | 4 +- src/panels/config/js/condition/zone.js | 8 +-- src/panels/config/js/json_textarea.js | 2 +- src/panels/config/js/script.js | 8 +-- src/panels/config/js/script/action_edit.js | 16 ++--- src/panels/config/js/script/action_row.js | 12 ++-- src/panels/config/js/script/call_service.js | 4 +- src/panels/config/js/script/condition.js | 4 +- src/panels/config/js/script/delay.js | 4 +- src/panels/config/js/script/event.js | 6 +- src/panels/config/js/script/index.js | 6 +- src/panels/config/js/script/wait.js | 6 +- src/panels/config/js/trigger/event.js | 6 +- src/panels/config/js/trigger/homeassistant.js | 4 +- src/panels/config/js/trigger/index.js | 8 +-- src/panels/config/js/trigger/mqtt.js | 4 +- src/panels/config/js/trigger/numeric_state.js | 8 +-- src/panels/config/js/trigger/state.js | 6 +- src/panels/config/js/trigger/sun.js | 8 +-- src/panels/config/js/trigger/template.js | 4 +- src/panels/config/js/trigger/time.js | 4 +- src/panels/config/js/trigger/trigger_edit.js | 24 +++---- src/panels/config/js/trigger/trigger_row.js | 12 ++-- src/panels/config/js/trigger/zone.js | 12 ++-- src/panels/config/script/ha-config-script.js | 14 ++-- src/panels/config/script/ha-script-editor.js | 26 ++++---- src/panels/config/script/ha-script-picker.js | 34 +++++----- src/panels/config/users/ha-config-users.js | 18 ++--- src/panels/config/users/ha-dialog-add-user.js | 14 ++-- src/panels/config/users/ha-user-editor.js | 16 ++--- src/panels/config/users/ha-user-picker.js | 20 +++--- src/panels/config/zwave/ha-config-zwave.js | 66 +++++++++---------- src/panels/config/zwave/zwave-groups.js | 16 ++--- src/panels/config/zwave/zwave-log-dialog.js | 12 ++-- src/panels/config/zwave/zwave-log.js | 26 ++++---- src/panels/config/zwave/zwave-network.js | 18 ++--- src/panels/config/zwave/zwave-node-config.js | 18 ++--- .../config/zwave/zwave-node-protection.js | 18 ++--- src/panels/config/zwave/zwave-usercodes.js | 18 ++--- src/panels/config/zwave/zwave-values.js | 16 ++--- src/panels/custom/ha-panel-custom.js | 12 ++-- src/panels/dev-event/events-list.js | 6 +- src/panels/dev-event/ha-panel-dev-event.js | 28 ++++---- src/panels/dev-info/ha-loaded-components.js | 12 ++-- src/panels/dev-info/ha-panel-dev-info.js | 42 ++++++------ src/panels/dev-mqtt/ha-panel-dev-mqtt.js | 24 +++---- .../dev-service/ha-panel-dev-service.js | 26 ++++---- src/panels/dev-state/ha-panel-dev-state.js | 30 ++++----- .../dev-template/ha-panel-dev-template.js | 24 +++---- src/panels/history/ha-panel-history.js | 36 +++++----- src/panels/iframe/ha-panel-iframe.js | 10 +-- src/panels/kiosk/ha-panel-kiosk.js | 6 +- src/panels/logbook/ha-logbook-data.js | 2 +- src/panels/logbook/ha-logbook.js | 18 ++--- src/panels/logbook/ha-panel-logbook.js | 40 +++++------ .../mailbox/ha-dialog-show-audio-message.js | 14 ++-- src/panels/mailbox/ha-panel-mailbox.js | 34 +++++----- src/panels/map/ha-entity-marker.js | 8 +-- src/panels/map/ha-panel-map.js | 20 +++--- src/panels/profile/ha-change-password-card.js | 16 ++--- .../ha-long-lived-access-tokens-card.js | 16 ++--- .../profile/ha-mfa-module-setup-flow.js | 26 ++++---- src/panels/profile/ha-mfa-modules-card.js | 18 ++--- src/panels/profile/ha-panel-profile.js | 48 +++++++------- src/panels/profile/ha-pick-language-row.js | 18 ++--- src/panels/profile/ha-pick-theme-row.js | 16 ++--- .../profile/ha-push-notifications-row.js | 18 ++--- src/panels/profile/ha-refresh-tokens-card.js | 16 ++--- src/panels/profile/ha-settings-row.js | 4 +- .../shopping-list/ha-panel-shopping-list.js | 36 +++++----- src/resources/ha-style.js | 4 +- src/resources/html-import/import-href.js | 2 +- src/state-summary/state-card-climate.js | 10 +-- src/state-summary/state-card-configurator.js | 12 ++-- src/state-summary/state-card-content.js | 38 +++++------ src/state-summary/state-card-cover.js | 14 ++-- src/state-summary/state-card-display.js | 14 ++-- src/state-summary/state-card-input_number.js | 14 ++-- src/state-summary/state-card-input_select.js | 14 ++-- src/state-summary/state-card-input_text.js | 10 +-- src/state-summary/state-card-lock.js | 12 ++-- src/state-summary/state-card-media_player.js | 12 ++-- src/state-summary/state-card-scene.js | 12 ++-- src/state-summary/state-card-script.js | 14 ++-- src/state-summary/state-card-timer.js | 12 ++-- src/state-summary/state-card-toggle.js | 10 +-- src/state-summary/state-card-vacuum.js | 10 +-- src/state-summary/state-card-water_heater.js | 10 +-- src/state-summary/state-card-weblink.js | 8 +-- src/util/app-localstorage-document.js | 6 +- src/util/custom-panel/load-custom-panel.js | 2 +- src/util/ha-url-sync.js | 4 +- src/util/hass-call-api.js | 2 +- src/util/legacy-support.js | 6 +- src/util/register-service-worker.js | 2 +- src/util/show-new-frontend-toast.js | 4 +- .../datetime/duration_to_seconds_test.js | 2 +- .../datetime/seconds_to_duration_test.js | 2 +- .../common/entity/compute_state_domain.js | 2 +- .../common/entity/extract_views.spec.js | 2 +- .../common/entity/get_group_entities.spec.js | 2 +- .../common/entity/get_view_entities.spec.js | 2 +- test-mocha/common/entity/has_location.test.js | 2 +- .../common/entity/split_by_groups.spec.js | 2 +- .../common/entity/state_card_type_test.js | 2 +- .../entity/state_more_info_type_test.js | 2 +- .../entity/timer_time_remaining_test.js | 2 +- .../common/util/parse_aspect_ratio_test.js | 2 +- webpack.config.js | 6 +- 330 files changed, 2097 insertions(+), 2102 deletions(-) diff --git a/gallery/src/components/demo-card.js b/gallery/src/components/demo-card.js index ed8238da3684..8b3c816480a3 100644 --- a/gallery/src/components/demo-card.js +++ b/gallery/src/components/demo-card.js @@ -1,13 +1,13 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; import JsYaml from "js-yaml"; -import HomeAssistant from "../data/hass.js"; -import { demoConfig } from "../data/demo_config.js"; +import HomeAssistant from "../data/hass"; +import { demoConfig } from "../data/demo_config"; import { demoServices } from "../data/demo_services"; -import demoResources from "../data/demo_resources.js"; -import demoStates from "../data/demo_states.js"; -import createCardElement from "../../../src/panels/lovelace/common/create-card-element.js"; +import demoResources from "../data/demo_resources"; +import demoStates from "../data/demo_states"; +import createCardElement from "../../../src/panels/lovelace/common/create-card-element"; class DemoCard extends PolymerElement { static get template() { diff --git a/gallery/src/components/demo-cards.js b/gallery/src/components/demo-cards.js index 45920ef5a55e..227b69614650 100644 --- a/gallery/src/components/demo-cards.js +++ b/gallery/src/components/demo-cards.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-toggle-button/paper-toggle-button.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-toggle-button/paper-toggle-button"; -import "./demo-card.js"; +import "./demo-card"; class DemoCards extends PolymerElement { static get template() { diff --git a/gallery/src/components/demo-more-info.js b/gallery/src/components/demo-more-info.js index 8438733d6ef7..13a8dea6b8d2 100644 --- a/gallery/src/components/demo-more-info.js +++ b/gallery/src/components/demo-more-info.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../src/state-summary/state-card-content.js"; -import "../../../src/dialogs/more-info/controls/more-info-content.js"; -import "../../../src/components/ha-card.js"; +import "../../../src/state-summary/state-card-content"; +import "../../../src/dialogs/more-info/controls/more-info-content"; +import "../../../src/components/ha-card"; class DemoMoreInfo extends PolymerElement { static get template() { diff --git a/gallery/src/components/demo-more-infos.js b/gallery/src/components/demo-more-infos.js index c44b114e9522..c296b4488772 100644 --- a/gallery/src/components/demo-more-infos.js +++ b/gallery/src/components/demo-more-infos.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-toggle-button/paper-toggle-button.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-toggle-button/paper-toggle-button"; -import "./demo-more-info.js"; +import "./demo-more-info"; class DemoMoreInfos extends PolymerElement { static get template() { diff --git a/gallery/src/data/provide_hass.js b/gallery/src/data/provide_hass.js index ffac2687078a..79db10cbda9f 100644 --- a/gallery/src/data/provide_hass.js +++ b/gallery/src/data/provide_hass.js @@ -1,8 +1,8 @@ -import { fireEvent } from "../../../src/common/dom/fire_event.js"; +import { fireEvent } from "../../../src/common/dom/fire_event"; -import { demoConfig } from "./demo_config.js"; +import { demoConfig } from "./demo_config"; import { demoServices } from "./demo_services"; -import demoResources from "./demo_resources.js"; +import demoResources from "./demo_resources"; const ensureArray = (val) => (Array.isArray(val) ? val : [val]); diff --git a/gallery/src/demos/demo-hui-alarm-panel-card.js b/gallery/src/demos/demo-hui-alarm-panel-card.js index 23c95804b500..41340e1c1e77 100644 --- a/gallery/src/demos/demo-hui-alarm-panel-card.js +++ b/gallery/src/demos/demo-hui-alarm-panel-card.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import getEntity from "../data/entity.js"; -import provideHass from "../data/provide_hass.js"; -import "../components/demo-cards.js"; +import getEntity from "../data/entity"; +import provideHass from "../data/provide_hass"; +import "../components/demo-cards"; const ENTITIES = [ getEntity("alarm_control_panel", "alarm", "disarmed", { diff --git a/gallery/src/demos/demo-hui-conditional-card.js b/gallery/src/demos/demo-hui-conditional-card.js index 9511be12e08a..2e58cae0bca5 100644 --- a/gallery/src/demos/demo-hui-conditional-card.js +++ b/gallery/src/demos/demo-hui-conditional-card.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import getEntity from "../data/entity.js"; -import provideHass from "../data/provide_hass.js"; -import "../components/demo-cards.js"; +import getEntity from "../data/entity"; +import provideHass from "../data/provide_hass"; +import "../components/demo-cards"; const ENTITIES = [ getEntity("light", "controller_1", "on", { diff --git a/gallery/src/demos/demo-hui-entities-card.js b/gallery/src/demos/demo-hui-entities-card.js index 743ca273be3a..7cdc2b01efa8 100644 --- a/gallery/src/demos/demo-hui-entities-card.js +++ b/gallery/src/demos/demo-hui-entities-card.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import getEntity from "../data/entity.js"; -import provideHass from "../data/provide_hass.js"; -import "../components/demo-cards.js"; +import getEntity from "../data/entity"; +import provideHass from "../data/provide_hass"; +import "../components/demo-cards"; const ENTITIES = [ getEntity("light", "bed_light", "on", { diff --git a/gallery/src/demos/demo-hui-entity-button-card.js b/gallery/src/demos/demo-hui-entity-button-card.js index 439dd76e55b1..d440b02995a5 100644 --- a/gallery/src/demos/demo-hui-entity-button-card.js +++ b/gallery/src/demos/demo-hui-entity-button-card.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import getEntity from "../data/entity.js"; -import provideHass from "../data/provide_hass.js"; -import "../components/demo-cards.js"; +import getEntity from "../data/entity"; +import provideHass from "../data/provide_hass"; +import "../components/demo-cards"; const ENTITIES = [ getEntity("light", "bed_light", "on", { diff --git a/gallery/src/demos/demo-hui-entity-filter-card.js b/gallery/src/demos/demo-hui-entity-filter-card.js index d3759c661427..80c5e4587e4c 100644 --- a/gallery/src/demos/demo-hui-entity-filter-card.js +++ b/gallery/src/demos/demo-hui-entity-filter-card.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import getEntity from "../data/entity.js"; -import provideHass from "../data/provide_hass.js"; -import "../components/demo-cards.js"; +import getEntity from "../data/entity"; +import provideHass from "../data/provide_hass"; +import "../components/demo-cards"; const ENTITIES = [ getEntity("device_tracker", "demo_paulus", "work", { diff --git a/gallery/src/demos/demo-hui-gauge-card.js b/gallery/src/demos/demo-hui-gauge-card.js index f737c4fd0201..6f9b4c4ac42a 100644 --- a/gallery/src/demos/demo-hui-gauge-card.js +++ b/gallery/src/demos/demo-hui-gauge-card.js @@ -1,7 +1,7 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/demo-cards.js"; +import "../components/demo-cards"; const CONFIGS = [ { diff --git a/gallery/src/demos/demo-hui-glance-card.js b/gallery/src/demos/demo-hui-glance-card.js index 83440e66111b..4f209b8a47c6 100644 --- a/gallery/src/demos/demo-hui-glance-card.js +++ b/gallery/src/demos/demo-hui-glance-card.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import getEntity from "../data/entity.js"; -import provideHass from "../data/provide_hass.js"; -import "../components/demo-cards.js"; +import getEntity from "../data/entity"; +import provideHass from "../data/provide_hass"; +import "../components/demo-cards"; const ENTITIES = [ getEntity("device_tracker", "demo_paulus", "home", { diff --git a/gallery/src/demos/demo-hui-iframe-card.js b/gallery/src/demos/demo-hui-iframe-card.js index c705916d5d3b..d7651473b188 100644 --- a/gallery/src/demos/demo-hui-iframe-card.js +++ b/gallery/src/demos/demo-hui-iframe-card.js @@ -1,7 +1,7 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/demo-cards.js"; +import "../components/demo-cards"; const CONFIGS = [ { diff --git a/gallery/src/demos/demo-hui-light-card.js b/gallery/src/demos/demo-hui-light-card.js index 8f5b2cca2867..1288b8a8cb3c 100644 --- a/gallery/src/demos/demo-hui-light-card.js +++ b/gallery/src/demos/demo-hui-light-card.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import getEntity from "../data/entity.js"; -import provideHass from "../data/provide_hass.js"; -import "../components/demo-cards.js"; +import getEntity from "../data/entity"; +import provideHass from "../data/provide_hass"; +import "../components/demo-cards"; const ENTITIES = [ getEntity("light", "bed_light", "on", { diff --git a/gallery/src/demos/demo-hui-map-card.js b/gallery/src/demos/demo-hui-map-card.js index ed5426a2e2fc..ec6890b2aac7 100644 --- a/gallery/src/demos/demo-hui-map-card.js +++ b/gallery/src/demos/demo-hui-map-card.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import getEntity from "../data/entity.js"; -import provideHass from "../data/provide_hass.js"; -import "../components/demo-cards.js"; +import getEntity from "../data/entity"; +import provideHass from "../data/provide_hass"; +import "../components/demo-cards"; const ENTITIES = [ getEntity("device_tracker", "demo_paulus", "not_home", { diff --git a/gallery/src/demos/demo-hui-markdown-card.js b/gallery/src/demos/demo-hui-markdown-card.js index b8bbc725821d..fe0ca6d175ca 100644 --- a/gallery/src/demos/demo-hui-markdown-card.js +++ b/gallery/src/demos/demo-hui-markdown-card.js @@ -1,7 +1,7 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/demo-cards.js"; +import "../components/demo-cards"; const CONFIGS = [ { diff --git a/gallery/src/demos/demo-hui-media-player-rows.js b/gallery/src/demos/demo-hui-media-player-rows.js index fb2f5020dd1c..a205186a2349 100644 --- a/gallery/src/demos/demo-hui-media-player-rows.js +++ b/gallery/src/demos/demo-hui-media-player-rows.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import getEntity from "../data/entity.js"; -import provideHass from "../data/provide_hass.js"; -import "../components/demo-cards.js"; +import getEntity from "../data/entity"; +import provideHass from "../data/provide_hass"; +import "../components/demo-cards"; const ENTITIES = [ getEntity("media_player", "bedroom", "playing", { @@ -65,7 +65,7 @@ const CONFIGS = [ - entity: media_player.living_room name: Pause, No skip, tvshow - entity: media_player.android_cast - name: Screen casting + name: Screen casting - entity: media_player.lounge_room name: Chromcast Idle - entity: media_player.theater diff --git a/gallery/src/demos/demo-hui-picture-elements-card.js b/gallery/src/demos/demo-hui-picture-elements-card.js index 99cfa7c12cc7..93d9bfcc6fbf 100644 --- a/gallery/src/demos/demo-hui-picture-elements-card.js +++ b/gallery/src/demos/demo-hui-picture-elements-card.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import getEntity from "../data/entity.js"; -import provideHass from "../data/provide_hass.js"; -import "../components/demo-cards.js"; +import getEntity from "../data/entity"; +import provideHass from "../data/provide_hass"; +import "../components/demo-cards"; const ENTITIES = [ getEntity("light", "bed_light", "on", { diff --git a/gallery/src/demos/demo-hui-picture-entity-card.js b/gallery/src/demos/demo-hui-picture-entity-card.js index 7a5ef9b0e49a..7940a5ad000f 100644 --- a/gallery/src/demos/demo-hui-picture-entity-card.js +++ b/gallery/src/demos/demo-hui-picture-entity-card.js @@ -1,7 +1,7 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/demo-cards.js"; +import "../components/demo-cards"; const CONFIGS = [ { diff --git a/gallery/src/demos/demo-hui-picture-glance-card.js b/gallery/src/demos/demo-hui-picture-glance-card.js index d78275ed2cbb..18b564326719 100644 --- a/gallery/src/demos/demo-hui-picture-glance-card.js +++ b/gallery/src/demos/demo-hui-picture-glance-card.js @@ -1,7 +1,7 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/demo-cards.js"; +import "../components/demo-cards"; const CONFIGS = [ { diff --git a/gallery/src/demos/demo-hui-stack-card.js b/gallery/src/demos/demo-hui-stack-card.js index c06b3ffa3035..31a30066eb20 100644 --- a/gallery/src/demos/demo-hui-stack-card.js +++ b/gallery/src/demos/demo-hui-stack-card.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import getEntity from "../data/entity.js"; -import provideHass from "../data/provide_hass.js"; -import "../components/demo-cards.js"; +import getEntity from "../data/entity"; +import provideHass from "../data/provide_hass"; +import "../components/demo-cards"; const ENTITIES = [ getEntity("light", "kitchen_lights", "on", { diff --git a/gallery/src/demos/demo-hui-thermostat-card.js b/gallery/src/demos/demo-hui-thermostat-card.js index 3c2d5d6cf189..4fc421df3bc7 100644 --- a/gallery/src/demos/demo-hui-thermostat-card.js +++ b/gallery/src/demos/demo-hui-thermostat-card.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import getEntity from "../data/entity.js"; -import provideHass from "../data/provide_hass.js"; -import "../components/demo-cards.js"; +import getEntity from "../data/entity"; +import provideHass from "../data/provide_hass"; +import "../components/demo-cards"; const ENTITIES = [ getEntity("climate", "ecobee", "auto", { diff --git a/gallery/src/demos/demo-more-info-light.js b/gallery/src/demos/demo-more-info-light.js index 601e73195787..f1faa2017ce2 100644 --- a/gallery/src/demos/demo-more-info-light.js +++ b/gallery/src/demos/demo-more-info-light.js @@ -1,13 +1,13 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../src/dialogs/more-info/controls/more-info-content.js"; -import "../../../src/components/ha-card.js"; +import "../../../src/dialogs/more-info/controls/more-info-content"; +import "../../../src/components/ha-card"; -import getEntity from "../data/entity.js"; -import provideHass from "../data/provide_hass.js"; +import getEntity from "../data/entity"; +import provideHass from "../data/provide_hass"; -import "../components/demo-more-infos.js"; +import "../components/demo-more-infos"; /* eslint-disable no-unused-vars */ diff --git a/gallery/src/entrypoint.js b/gallery/src/entrypoint.js index a690d9d3e074..6e656edc989a 100644 --- a/gallery/src/entrypoint.js +++ b/gallery/src/entrypoint.js @@ -1,12 +1,12 @@ -import "@polymer/paper-styles/typography.js"; -import "@polymer/polymer/lib/elements/dom-if.js"; -import "@polymer/polymer/lib/elements/dom-repeat.js"; +import "@polymer/paper-styles/typography"; +import "@polymer/polymer/lib/elements/dom-if"; +import "@polymer/polymer/lib/elements/dom-repeat"; -import "../../src/resources/hass-icons.js"; -import "../../src/resources/ha-style.js"; -import "../../src/resources/roboto.js"; -import "../../src/components/ha-iconset-svg.js"; +import "../../src/resources/hass-icons"; +import "../../src/resources/ha-style"; +import "../../src/resources/roboto"; +import "../../src/components/ha-iconset-svg"; -import "./ha-gallery.js"; +import "./ha-gallery"; document.body.appendChild(document.createElement("ha-gallery")); diff --git a/gallery/src/ha-gallery.js b/gallery/src/ha-gallery.js index e336f6e56f8e..73c3e666d67e 100644 --- a/gallery/src/ha-gallery.js +++ b/gallery/src/ha-gallery.js @@ -1,15 +1,15 @@ -import "@polymer/app-layout/app-header-layout/app-header-layout.js"; -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/iron-icon/iron-icon.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-item/paper-item-body.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../src/managers/notification-manager.js"; +import "@polymer/app-layout/app-header-layout/app-header-layout"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/iron-icon/iron-icon"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-item/paper-item-body"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../src/managers/notification-manager"; const DEMOS = require.context("./demos", true, /^(.*\.(js$))[^.]*$/im); diff --git a/gallery/webpack.config.js b/gallery/webpack.config.js index 7b711ac3550a..2959cc1a7969 100644 --- a/gallery/webpack.config.js +++ b/gallery/webpack.config.js @@ -4,7 +4,7 @@ const CopyWebpackPlugin = require("copy-webpack-plugin"); const { babelLoaderConfig } = require("../config/babel.js"); const isProd = process.env.NODE_ENV === "production"; -const chunkFilename = isProd ? "chunk.[chunkhash].js" : "[name].chunk.js"; +const chunkFilename = isProd ? "chunk.[chunkhash].js" : "[name].chunk"; const buildPath = path.resolve(__dirname, "dist"); const publicPath = isProd ? "./" : "http://localhost:8080/"; diff --git a/hassio/src/addon-store/hassio-addon-repository.js b/hassio/src/addon-store/hassio-addon-repository.js index 04eef73f61da..0a75dfd9259f 100644 --- a/hassio/src/addon-store/hassio-addon-repository.js +++ b/hassio/src/addon-store/hassio-addon-repository.js @@ -1,10 +1,10 @@ -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/hassio-card-content.js"; -import "../resources/hassio-style.js"; -import NavigateMixin from "../../../src/mixins/navigate-mixin.js"; +import "../components/hassio-card-content"; +import "../resources/hassio-style"; +import NavigateMixin from "../../../src/mixins/navigate-mixin"; class HassioAddonRepository extends NavigateMixin(PolymerElement) { static get template() { diff --git a/hassio/src/addon-store/hassio-addon-store.js b/hassio/src/addon-store/hassio-addon-store.js index 01bc52a0ded8..1cfae301e431 100644 --- a/hassio/src/addon-store/hassio-addon-store.js +++ b/hassio/src/addon-store/hassio-addon-store.js @@ -1,8 +1,8 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./hassio-addon-repository.js"; -import "./hassio-repositories-editor.js"; +import "./hassio-addon-repository"; +import "./hassio-repositories-editor"; class HassioAddonStore extends PolymerElement { static get template() { diff --git a/hassio/src/addon-store/hassio-repositories-editor.js b/hassio/src/addon-store/hassio-repositories-editor.js index 3a07a9269fc9..cec3c40eb6b5 100644 --- a/hassio/src/addon-store/hassio-repositories-editor.js +++ b/hassio/src/addon-store/hassio-repositories-editor.js @@ -1,12 +1,12 @@ -import "@polymer/iron-icon/iron-icon.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-input/paper-input.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-icon/iron-icon"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../src/components/buttons/ha-call-api-button.js"; -import "../components/hassio-card-content.js"; -import "../resources/hassio-style.js"; +import "../../../src/components/buttons/ha-call-api-button"; +import "../components/hassio-card-content"; +import "../resources/hassio-style"; class HassioRepositoriesEditor extends PolymerElement { static get template() { diff --git a/hassio/src/addon-view/hassio-addon-audio.js b/hassio/src/addon-view/hassio-addon-audio.js index 0f03169cda9a..c651923b0a90 100644 --- a/hassio/src/addon-view/hassio-addon-audio.js +++ b/hassio/src/addon-view/hassio-addon-audio.js @@ -1,15 +1,15 @@ -import "web-animations-js/web-animations-next-lite.min.js"; +import "web-animations-js/web-animations-next-lite.min"; -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../src/resources/ha-style.js"; -import EventsMixin from "../../../src/mixins/events-mixin.js"; +import "../../../src/resources/ha-style"; +import EventsMixin from "../../../src/mixins/events-mixin"; class HassioAddonAudio extends EventsMixin(PolymerElement) { static get template() { diff --git a/hassio/src/addon-view/hassio-addon-config.js b/hassio/src/addon-view/hassio-addon-config.js index 3ae1361d65b4..56d73a8830ee 100644 --- a/hassio/src/addon-view/hassio-addon-config.js +++ b/hassio/src/addon-view/hassio-addon-config.js @@ -1,10 +1,10 @@ -import "@polymer/iron-autogrow-textarea/iron-autogrow-textarea.js"; -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-autogrow-textarea/iron-autogrow-textarea"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../src/components/buttons/ha-call-api-button.js"; +import "../../../src/components/buttons/ha-call-api-button"; class HassioAddonConfig extends PolymerElement { static get template() { diff --git a/hassio/src/addon-view/hassio-addon-info.js b/hassio/src/addon-view/hassio-addon-info.js index fb18a5695aea..4871ba9f821a 100644 --- a/hassio/src/addon-view/hassio-addon-info.js +++ b/hassio/src/addon-view/hassio-addon-info.js @@ -1,16 +1,16 @@ -import "@polymer/iron-icon/iron-icon.js"; -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-toggle-button/paper-toggle-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-icon/iron-icon"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-toggle-button/paper-toggle-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../src/components/buttons/ha-call-api-button.js"; -import "../../../src/components/ha-markdown.js"; -import "../../../src/resources/ha-style.js"; -import EventsMixin from "../../../src/mixins/events-mixin.js"; +import "../../../src/components/buttons/ha-call-api-button"; +import "../../../src/components/ha-markdown"; +import "../../../src/resources/ha-style"; +import EventsMixin from "../../../src/mixins/events-mixin"; -import "../components/hassio-card-content.js"; +import "../components/hassio-card-content"; class HassioAddonInfo extends EventsMixin(PolymerElement) { static get template() { diff --git a/hassio/src/addon-view/hassio-addon-logs.js b/hassio/src/addon-view/hassio-addon-logs.js index baa1a4c63f70..d411fb928ff2 100644 --- a/hassio/src/addon-view/hassio-addon-logs.js +++ b/hassio/src/addon-view/hassio-addon-logs.js @@ -1,9 +1,9 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../src/resources/ha-style.js"; +import "../../../src/resources/ha-style"; class HassioAddonLogs extends PolymerElement { static get template() { diff --git a/hassio/src/addon-view/hassio-addon-network.js b/hassio/src/addon-view/hassio-addon-network.js index 770ea2eef7a4..7041f8921080 100644 --- a/hassio/src/addon-view/hassio-addon-network.js +++ b/hassio/src/addon-view/hassio-addon-network.js @@ -1,11 +1,11 @@ -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-input/paper-input.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../src/components/buttons/ha-call-api-button.js"; -import "../../../src/resources/ha-style.js"; -import EventsMixin from "../../../src/mixins/events-mixin.js"; +import "../../../src/components/buttons/ha-call-api-button"; +import "../../../src/resources/ha-style"; +import EventsMixin from "../../../src/mixins/events-mixin"; class HassioAddonNetwork extends EventsMixin(PolymerElement) { static get template() { diff --git a/hassio/src/addon-view/hassio-addon-view.js b/hassio/src/addon-view/hassio-addon-view.js index 7fe9dc40ab6f..f20efe01cc5b 100644 --- a/hassio/src/addon-view/hassio-addon-view.js +++ b/hassio/src/addon-view/hassio-addon-view.js @@ -1,19 +1,19 @@ -import "@polymer/app-layout/app-header-layout/app-header-layout.js"; -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/app-route/app-route.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../src/components/ha-menu-button.js"; -import "../../../src/resources/ha-style.js"; -import "../hassio-markdown-dialog.js"; -import "./hassio-addon-audio.js"; -import "./hassio-addon-config.js"; -import "./hassio-addon-info.js"; -import "./hassio-addon-logs.js"; -import "./hassio-addon-network.js"; +import "@polymer/app-layout/app-header-layout/app-header-layout"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/app-route/app-route"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../src/components/ha-menu-button"; +import "../../../src/resources/ha-style"; +import "../hassio-markdown-dialog"; +import "./hassio-addon-audio"; +import "./hassio-addon-config"; +import "./hassio-addon-info"; +import "./hassio-addon-logs"; +import "./hassio-addon-network"; class HassioAddonView extends PolymerElement { static get template() { diff --git a/hassio/src/components/hassio-card-content.js b/hassio/src/components/hassio-card-content.js index 84d2db96559e..dfd5c0a49ec5 100644 --- a/hassio/src/components/hassio-card-content.js +++ b/hassio/src/components/hassio-card-content.js @@ -1,8 +1,8 @@ -import "@polymer/iron-icon/iron-icon.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-icon/iron-icon"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../src/components/ha-relative-time.js"; +import "../../../src/components/ha-relative-time"; class HassioCardContent extends PolymerElement { static get template() { diff --git a/hassio/src/dashboard/hassio-addons.js b/hassio/src/dashboard/hassio-addons.js index d4f5a56535dc..2418b9dfb4b2 100644 --- a/hassio/src/dashboard/hassio-addons.js +++ b/hassio/src/dashboard/hassio-addons.js @@ -1,10 +1,10 @@ -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/hassio-card-content.js"; -import "../resources/hassio-style.js"; -import NavigateMixin from "../../../src/mixins/navigate-mixin.js"; +import "../components/hassio-card-content"; +import "../resources/hassio-style"; +import NavigateMixin from "../../../src/mixins/navigate-mixin"; class HassioAddons extends NavigateMixin(PolymerElement) { static get template() { diff --git a/hassio/src/dashboard/hassio-dashboard.js b/hassio/src/dashboard/hassio-dashboard.js index 3c9ecde4dd1b..c868c8dbb318 100644 --- a/hassio/src/dashboard/hassio-dashboard.js +++ b/hassio/src/dashboard/hassio-dashboard.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./hassio-addons.js"; -import "./hassio-hass-update.js"; -import EventsMixin from "../../../src/mixins/events-mixin.js"; +import "./hassio-addons"; +import "./hassio-hass-update"; +import EventsMixin from "../../../src/mixins/events-mixin"; class HassioDashboard extends EventsMixin(PolymerElement) { static get template() { diff --git a/hassio/src/dashboard/hassio-hass-update.js b/hassio/src/dashboard/hassio-hass-update.js index dd7df1f429cf..0ad1b8a64b71 100644 --- a/hassio/src/dashboard/hassio-hass-update.js +++ b/hassio/src/dashboard/hassio-hass-update.js @@ -1,11 +1,11 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../src/components/buttons/ha-call-api-button.js"; -import "../components/hassio-card-content.js"; -import "../resources/hassio-style.js"; +import "../../../src/components/buttons/ha-call-api-button"; +import "../components/hassio-card-content"; +import "../resources/hassio-style"; class HassioHassUpdate extends PolymerElement { static get template() { diff --git a/hassio/src/hassio-app.js b/hassio/src/hassio-app.js index c85962b6e2c4..aee5c1ede0db 100644 --- a/hassio/src/hassio-app.js +++ b/hassio/src/hassio-app.js @@ -1,8 +1,8 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./hassio-main.js"; -import "./resources/hassio-icons.js"; +import "./hassio-main"; +import "./resources/hassio-icons"; class HassioApp extends PolymerElement { static get template() { diff --git a/hassio/src/hassio-data.js b/hassio/src/hassio-data.js index 39795402e943..38de4b5809f6 100644 --- a/hassio/src/hassio-data.js +++ b/hassio/src/hassio-data.js @@ -1,4 +1,4 @@ -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class HassioData extends PolymerElement { static get properties() { diff --git a/hassio/src/hassio-main.js b/hassio/src/hassio-main.js index b18745edb274..2cc8de46ae39 100644 --- a/hassio/src/hassio-main.js +++ b/hassio/src/hassio-main.js @@ -1,15 +1,15 @@ -import "@polymer/app-route/app-route.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-route/app-route"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../src/layouts/hass-loading-screen.js"; -import "./addon-view/hassio-addon-view.js"; -import "./hassio-data.js"; -import "./hassio-pages-with-tabs.js"; +import "../../src/layouts/hass-loading-screen"; +import "./addon-view/hassio-addon-view"; +import "./hassio-data"; +import "./hassio-pages-with-tabs"; -import applyThemesOnElement from "../../src/common/dom/apply_themes_on_element.js"; -import EventsMixin from "../../src/mixins/events-mixin.js"; -import NavigateMixin from "../../src/mixins/navigate-mixin.js"; +import applyThemesOnElement from "../../src/common/dom/apply_themes_on_element"; +import EventsMixin from "../../src/mixins/events-mixin"; +import NavigateMixin from "../../src/mixins/navigate-mixin"; class HassioMain extends EventsMixin(NavigateMixin(PolymerElement)) { static get template() { diff --git a/hassio/src/hassio-markdown-dialog.js b/hassio/src/hassio-markdown-dialog.js index c12cf283bdaa..17eed8f4b353 100644 --- a/hassio/src/hassio-markdown-dialog.js +++ b/hassio/src/hassio-markdown-dialog.js @@ -1,12 +1,12 @@ -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable.js"; -import "@polymer/paper-dialog/paper-dialog.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable"; +import "@polymer/paper-dialog/paper-dialog"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../src/components/ha-markdown.js"; -import "../../src/resources/ha-style.js"; +import "../../src/components/ha-markdown"; +import "../../src/resources/ha-style"; class HassioMarkdownDialog extends PolymerElement { static get template() { diff --git a/hassio/src/hassio-pages-with-tabs.js b/hassio/src/hassio-pages-with-tabs.js index d9ad4247a19e..0d7d26a07853 100644 --- a/hassio/src/hassio-pages-with-tabs.js +++ b/hassio/src/hassio-pages-with-tabs.js @@ -1,24 +1,24 @@ -import "@polymer/app-layout/app-header-layout/app-header-layout.js"; -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-tabs/paper-tab.js"; -import "@polymer/paper-tabs/paper-tabs.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-layout/app-header-layout/app-header-layout"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-tabs/paper-tab"; +import "@polymer/paper-tabs/paper-tabs"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../src/components/ha-menu-button.js"; -import "../../src/resources/ha-style.js"; -import "./addon-store/hassio-addon-store.js"; -import "./dashboard/hassio-dashboard.js"; -import "./hassio-markdown-dialog.js"; -import "./snapshots/hassio-snapshot.js"; -import "./snapshots/hassio-snapshots.js"; -import "./system/hassio-system.js"; +import "../../src/components/ha-menu-button"; +import "../../src/resources/ha-style"; +import "./addon-store/hassio-addon-store"; +import "./dashboard/hassio-dashboard"; +import "./hassio-markdown-dialog"; +import "./snapshots/hassio-snapshot"; +import "./snapshots/hassio-snapshots"; +import "./system/hassio-system"; -import scrollToTarget from "../../src/common/dom/scroll-to-target.js"; +import scrollToTarget from "../../src/common/dom/scroll-to-target"; -import NavigateMixin from "../../src/mixins/navigate-mixin.js"; +import NavigateMixin from "../../src/mixins/navigate-mixin"; class HassioPagesWithTabs extends NavigateMixin(PolymerElement) { static get template() { diff --git a/hassio/src/resources/hassio-icons.js b/hassio/src/resources/hassio-icons.js index 5f347236ab01..ca4a7fa58f24 100644 --- a/hassio/src/resources/hassio-icons.js +++ b/hassio/src/resources/hassio-icons.js @@ -1,4 +1,4 @@ -import "../../../src/components/ha-iconset-svg.js"; +import "../../../src/components/ha-iconset-svg"; import iconSetContent from "../../hassio-icons.html"; const documentContainer = document.createElement("template"); diff --git a/hassio/src/snapshots/hassio-snapshot.js b/hassio/src/snapshots/hassio-snapshot.js index 929bc64ddfd7..6033cb2ca3fc 100644 --- a/hassio/src/snapshots/hassio-snapshot.js +++ b/hassio/src/snapshots/hassio-snapshot.js @@ -1,14 +1,14 @@ -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-checkbox/paper-checkbox.js"; -import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable.js"; -import "@polymer/paper-dialog/paper-dialog.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-input/paper-input.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-checkbox/paper-checkbox"; +import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable"; +import "@polymer/paper-dialog/paper-dialog"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../src/resources/ha-style.js"; +import "../../../src/resources/ha-style"; class HassioSnapshot extends PolymerElement { static get template() { diff --git a/hassio/src/snapshots/hassio-snapshots.js b/hassio/src/snapshots/hassio-snapshots.js index c2953b013762..99a8766d70d3 100644 --- a/hassio/src/snapshots/hassio-snapshots.js +++ b/hassio/src/snapshots/hassio-snapshots.js @@ -1,15 +1,15 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-checkbox/paper-checkbox.js"; -import "@polymer/paper-input/paper-input.js"; -import "@polymer/paper-radio-button/paper-radio-button.js"; -import "@polymer/paper-radio-group/paper-radio-group.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-checkbox/paper-checkbox"; +import "@polymer/paper-input/paper-input"; +import "@polymer/paper-radio-button/paper-radio-button"; +import "@polymer/paper-radio-group/paper-radio-group"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/hassio-card-content.js"; -import "../resources/hassio-style.js"; -import EventsMixin from "../../../src/mixins/events-mixin.js"; +import "../components/hassio-card-content"; +import "../resources/hassio-style"; +import EventsMixin from "../../../src/mixins/events-mixin"; class HassioSnapshots extends EventsMixin(PolymerElement) { static get template() { diff --git a/hassio/src/system/hassio-host-info.js b/hassio/src/system/hassio-host-info.js index 245c8580652e..4ade53491f92 100644 --- a/hassio/src/system/hassio-host-info.js +++ b/hassio/src/system/hassio-host-info.js @@ -1,10 +1,10 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../src/components/buttons/ha-call-api-button.js"; -import EventsMixin from "../../../src/mixins/events-mixin.js"; +import "../../../src/components/buttons/ha-call-api-button"; +import EventsMixin from "../../../src/mixins/events-mixin"; class HassioHostInfo extends EventsMixin(PolymerElement) { static get template() { diff --git a/hassio/src/system/hassio-supervisor-info.js b/hassio/src/system/hassio-supervisor-info.js index d29c517e5cba..c594bad418f2 100644 --- a/hassio/src/system/hassio-supervisor-info.js +++ b/hassio/src/system/hassio-supervisor-info.js @@ -1,10 +1,10 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../src/components/buttons/ha-call-api-button.js"; -import EventsMixin from "../../../src/mixins/events-mixin.js"; +import "../../../src/components/buttons/ha-call-api-button"; +import EventsMixin from "../../../src/mixins/events-mixin"; class HassioSupervisorInfo extends EventsMixin(PolymerElement) { static get template() { diff --git a/hassio/src/system/hassio-supervisor-log.js b/hassio/src/system/hassio-supervisor-log.js index 759119f3b149..4b086008513c 100644 --- a/hassio/src/system/hassio-supervisor-log.js +++ b/hassio/src/system/hassio-supervisor-log.js @@ -1,7 +1,7 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class HassioSupervisorLog extends PolymerElement { static get template() { diff --git a/hassio/src/system/hassio-system.js b/hassio/src/system/hassio-system.js index 2abc884c27d1..48d963c35d5d 100644 --- a/hassio/src/system/hassio-system.js +++ b/hassio/src/system/hassio-system.js @@ -1,10 +1,10 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./hassio-host-info.js"; -import "./hassio-supervisor-info.js"; -import "./hassio-supervisor-log.js"; +import "./hassio-host-info"; +import "./hassio-supervisor-info"; +import "./hassio-supervisor-log"; class HassioSystem extends PolymerElement { static get template() { diff --git a/hassio/webpack.config.js b/hassio/webpack.config.js index 8ce545eac957..dc27e32e1567 100644 --- a/hassio/webpack.config.js +++ b/hassio/webpack.config.js @@ -4,7 +4,7 @@ const config = require("./config.js"); const { babelLoaderConfig } = require("../config/babel.js"); const isProdBuild = process.env.NODE_ENV === "production"; -const chunkFilename = isProdBuild ? "chunk.[chunkhash].js" : "[name].chunk.js"; +const chunkFilename = isProdBuild ? "chunk.[chunkhash].js" : "[name].chunk"; module.exports = { mode: isProdBuild ? "production" : "development", diff --git a/src/auth/ha-auth-flow.js b/src/auth/ha-auth-flow.js index be44f10a9372..22f4435c8312 100644 --- a/src/auth/ha-auth-flow.js +++ b/src/auth/ha-auth-flow.js @@ -1,8 +1,8 @@ -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/paper-button/paper-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import "../components/ha-form.js"; -import LocalizeLiteMixin from "../mixins/localize-lite-mixin.js"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/paper-button/paper-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import "../components/ha-form"; +import LocalizeLiteMixin from "../mixins/localize-lite-mixin"; class HaAuthFlow extends LocalizeLiteMixin(PolymerElement) { static get template() { diff --git a/src/auth/ha-authorize.js b/src/auth/ha-authorize.js index 41ed02450548..9bd8bbe37424 100644 --- a/src/auth/ha-authorize.js +++ b/src/auth/ha-authorize.js @@ -1,13 +1,13 @@ -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 "@polymer/polymer/lib/elements/dom-if"; +import "@polymer/polymer/lib/elements/dom-repeat"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/ha-markdown.js"; +import "../components/ha-markdown"; -import LocalizeLiteMixin from "../mixins/localize-lite-mixin.js"; +import LocalizeLiteMixin from "../mixins/localize-lite-mixin"; -import "./ha-auth-flow.js"; +import "./ha-auth-flow"; class HaAuthorize extends LocalizeLiteMixin(PolymerElement) { static get template() { diff --git a/src/auth/ha-pick-auth-provider.js b/src/auth/ha-pick-auth-provider.js index cbf188015c73..378e656ad57f 100644 --- a/src/auth/ha-pick-auth-provider.js +++ b/src/auth/ha-pick-auth-provider.js @@ -1,10 +1,10 @@ -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-item/paper-item-body.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-item/paper-item-body"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import EventsMixin from "../mixins/events-mixin.js"; -import LocalizeLiteMixin from "../mixins/localize-lite-mixin.js"; +import EventsMixin from "../mixins/events-mixin"; +import LocalizeLiteMixin from "../mixins/localize-lite-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/cards/ha-badges-card.js b/src/cards/ha-badges-card.js index 35bd6ea490bc..47e8327eb06a 100644 --- a/src/cards/ha-badges-card.js +++ b/src/cards/ha-badges-card.js @@ -1,7 +1,7 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/entity/ha-state-label-badge.js"; +import "../components/entity/ha-state-label-badge"; class HaBadgesCard extends PolymerElement { static get template() { diff --git a/src/cards/ha-camera-card.js b/src/cards/ha-camera-card.js index 76fb22ce3712..424867052e90 100644 --- a/src/cards/ha-camera-card.js +++ b/src/cards/ha-camera-card.js @@ -1,10 +1,10 @@ -import "@polymer/paper-styles/element-styles/paper-material-styles.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-styles/element-styles/paper-material-styles"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import computeStateName from "../common/entity/compute_state_name.js"; -import EventsMixin from "../mixins/events-mixin.js"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import computeStateName from "../common/entity/compute_state_name"; +import EventsMixin from "../mixins/events-mixin"; +import LocalizeMixin from "../mixins/localize-mixin"; const UPDATE_INTERVAL = 10000; // ms /* diff --git a/src/cards/ha-card-chooser.js b/src/cards/ha-card-chooser.js index 15e9896df171..d1b875964f5c 100644 --- a/src/cards/ha-card-chooser.js +++ b/src/cards/ha-card-chooser.js @@ -1,14 +1,14 @@ -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./ha-camera-card.js"; -import "./ha-entities-card.js"; -import "./ha-history_graph-card.js"; -import "./ha-media_player-card.js"; -import "./ha-persistent_notification-card.js"; -import "./ha-plant-card.js"; -import "./ha-weather-card.js"; +import "./ha-camera-card"; +import "./ha-entities-card"; +import "./ha-history_graph-card"; +import "./ha-media_player-card"; +import "./ha-persistent_notification-card"; +import "./ha-plant-card"; +import "./ha-weather-card"; -import dynamicContentUpdater from "../common/dom/dynamic_content_updater.js"; +import dynamicContentUpdater from "../common/dom/dynamic_content_updater"; class HaCardChooser extends PolymerElement { static get properties() { diff --git a/src/cards/ha-entities-card.js b/src/cards/ha-entities-card.js index 1cd7092bdc2e..b1ce669fd773 100644 --- a/src/cards/ha-entities-card.js +++ b/src/cards/ha-entities-card.js @@ -1,17 +1,17 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../components/entity/ha-entity-toggle.js"; -import "../components/ha-card.js"; -import "../state-summary/state-card-content.js"; - -import computeStateDomain from "../common/entity/compute_state_domain.js"; -import computeStateName from "../common/entity/compute_state_name.js"; -import stateMoreInfoType from "../common/entity/state_more_info_type.js"; -import canToggleState from "../common/entity/can_toggle_state.js"; -import EventsMixin from "../mixins/events-mixin.js"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../components/entity/ha-entity-toggle"; +import "../components/ha-card"; +import "../state-summary/state-card-content"; + +import computeStateDomain from "../common/entity/compute_state_domain"; +import computeStateName from "../common/entity/compute_state_name"; +import stateMoreInfoType from "../common/entity/state_more_info_type"; +import canToggleState from "../common/entity/can_toggle_state"; +import EventsMixin from "../mixins/events-mixin"; +import LocalizeMixin from "../mixins/localize-mixin"; class HaEntitiesCard extends LocalizeMixin(EventsMixin(PolymerElement)) { static get template() { diff --git a/src/cards/ha-history_graph-card.js b/src/cards/ha-history_graph-card.js index ca2e3aad7b74..2b1e79a863a8 100644 --- a/src/cards/ha-history_graph-card.js +++ b/src/cards/ha-history_graph-card.js @@ -1,12 +1,12 @@ -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/state-history-charts.js"; +import "../components/state-history-charts"; import "../data/ha-state-history-data"; -import computeStateName from "../common/entity/compute_state_name.js"; -import EventsMixin from "../mixins/events-mixin.js"; +import computeStateName from "../common/entity/compute_state_name"; +import EventsMixin from "../mixins/events-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/cards/ha-media_player-card.js b/src/cards/ha-media_player-card.js index 08c6141f7f39..804ccb27804a 100644 --- a/src/cards/ha-media_player-card.js +++ b/src/cards/ha-media_player-card.js @@ -1,15 +1,15 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-progress/paper-progress.js"; -import "@polymer/paper-styles/element-styles/paper-material-styles.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import HassMediaPlayerEntity from "../util/hass-media-player-model.js"; - -import computeStateName from "../common/entity/compute_state_name.js"; -import EventsMixin from "../mixins/events-mixin.js"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-progress/paper-progress"; +import "@polymer/paper-styles/element-styles/paper-material-styles"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import HassMediaPlayerEntity from "../util/hass-media-player-model"; + +import computeStateName from "../common/entity/compute_state_name"; +import EventsMixin from "../mixins/events-mixin"; +import LocalizeMixin from "../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/cards/ha-persistent_notification-card.js b/src/cards/ha-persistent_notification-card.js index e6ed980f2942..9592c05699c5 100644 --- a/src/cards/ha-persistent_notification-card.js +++ b/src/cards/ha-persistent_notification-card.js @@ -1,12 +1,12 @@ -import "@polymer/paper-button/paper-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/ha-card.js"; -import "../components/ha-markdown.js"; +import "../components/ha-card"; +import "../components/ha-markdown"; -import computeStateName from "../common/entity/compute_state_name.js"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import computeStateName from "../common/entity/compute_state_name"; +import LocalizeMixin from "../mixins/localize-mixin"; import computeObjectId from "../common/entity/compute_object_id"; /* diff --git a/src/cards/ha-plant-card.js b/src/cards/ha-plant-card.js index 63152f94376a..93862dece09e 100644 --- a/src/cards/ha-plant-card.js +++ b/src/cards/ha-plant-card.js @@ -1,11 +1,11 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/ha-card.js"; -import "../components/ha-icon.js"; +import "../components/ha-card"; +import "../components/ha-icon"; -import computeStateName from "../common/entity/compute_state_name.js"; -import EventsMixin from "../mixins/events-mixin.js"; +import computeStateName from "../common/entity/compute_state_name"; +import EventsMixin from "../mixins/events-mixin"; class HaPlantCard extends EventsMixin(PolymerElement) { static get template() { diff --git a/src/cards/ha-weather-card.js b/src/cards/ha-weather-card.js index 90b49d97a397..f8a1c219da25 100644 --- a/src/cards/ha-weather-card.js +++ b/src/cards/ha-weather-card.js @@ -1,11 +1,11 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/ha-card.js"; -import "../components/ha-icon.js"; +import "../components/ha-card"; +import "../components/ha-icon"; -import EventsMixin from "../mixins/events-mixin.js"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import EventsMixin from "../mixins/events-mixin"; +import LocalizeMixin from "../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/common/entity/can_toggle_state.js b/src/common/entity/can_toggle_state.js index cd056caaa827..8b7a1eaee070 100644 --- a/src/common/entity/can_toggle_state.js +++ b/src/common/entity/can_toggle_state.js @@ -1,5 +1,5 @@ -import canToggleDomain from "./can_toggle_domain.js"; -import computeStateDomain from "./compute_state_domain.js"; +import canToggleDomain from "./can_toggle_domain"; +import computeStateDomain from "./compute_state_domain"; export default function canToggleState(hass, stateObj) { const domain = computeStateDomain(stateObj); diff --git a/src/common/entity/compute_state_display.js b/src/common/entity/compute_state_display.js index d383b3b5e881..56f5d28c48f2 100644 --- a/src/common/entity/compute_state_display.js +++ b/src/common/entity/compute_state_display.js @@ -1,7 +1,7 @@ -import computeStateDomain from "./compute_state_domain.js"; -import formatDateTime from "../datetime/format_date_time.js"; -import formatDate from "../datetime/format_date.js"; -import formatTime from "../datetime/format_time.js"; +import computeStateDomain from "./compute_state_domain"; +import formatDateTime from "../datetime/format_date_time"; +import formatDate from "../datetime/format_date"; +import formatTime from "../datetime/format_time"; export default function computeStateDisplay(localize, stateObj, language) { if (!stateObj._stateDisplay) { diff --git a/src/common/entity/compute_state_domain.js b/src/common/entity/compute_state_domain.js index 64687a9f115c..492b700eaadc 100644 --- a/src/common/entity/compute_state_domain.js +++ b/src/common/entity/compute_state_domain.js @@ -1,4 +1,4 @@ -import computeDomain from "./compute_domain.js"; +import computeDomain from "./compute_domain"; export default function computeStateDomain(stateObj) { return computeDomain(stateObj.entity_id); diff --git a/src/common/entity/cover_icon.js b/src/common/entity/cover_icon.js index 1db6b1a750fd..78876025b462 100644 --- a/src/common/entity/cover_icon.js +++ b/src/common/entity/cover_icon.js @@ -1,5 +1,5 @@ /** Return an icon representing a cover state. */ -import domainIcon from "./domain_icon.js"; +import domainIcon from "./domain_icon"; export default function coverIcon(state) { var open = state.state && state.state !== "closed"; diff --git a/src/common/entity/domain_icon.js b/src/common/entity/domain_icon.js index 22b357d7e5cf..a50fcb943e9d 100644 --- a/src/common/entity/domain_icon.js +++ b/src/common/entity/domain_icon.js @@ -3,7 +3,7 @@ * * Optionally pass in a state to influence the domain icon. */ -import { DEFAULT_DOMAIN_ICON } from "../const.js"; +import { DEFAULT_DOMAIN_ICON } from "../const"; const fixedIcons = { alert: "hass:alert", diff --git a/src/common/entity/extract_views.js b/src/common/entity/extract_views.js index e5705ea6e3c9..c3b794991193 100644 --- a/src/common/entity/extract_views.js +++ b/src/common/entity/extract_views.js @@ -1,4 +1,4 @@ -import { DEFAULT_VIEW_ENTITY_ID } from "../const.js"; +import { DEFAULT_VIEW_ENTITY_ID } from "../const"; // Return an ordered array of available views export default function extractViews(entities) { diff --git a/src/common/entity/get_view_entities.js b/src/common/entity/get_view_entities.js index 67a435ef0701..00b21ee30e20 100644 --- a/src/common/entity/get_view_entities.js +++ b/src/common/entity/get_view_entities.js @@ -1,5 +1,5 @@ -import computeDomain from "./compute_domain.js"; -import getGroupEntities from "./get_group_entities.js"; +import computeDomain from "./compute_domain"; +import getGroupEntities from "./get_group_entities"; // Return an object containing all entities that the view will show // including embedded groups. diff --git a/src/common/entity/input_dateteime_icon.js b/src/common/entity/input_dateteime_icon.js index b14163c3938f..8418226e90b7 100644 --- a/src/common/entity/input_dateteime_icon.js +++ b/src/common/entity/input_dateteime_icon.js @@ -1,5 +1,5 @@ /** Return an icon representing an input datetime state. */ -import domainIcon from "./domain_icon.js"; +import domainIcon from "./domain_icon"; export default function inputDateTimeIcon(state) { if (!state.attributes.has_date) { diff --git a/src/common/entity/sensor_icon.js b/src/common/entity/sensor_icon.js index 9f555a56584c..44e6f3ce0979 100644 --- a/src/common/entity/sensor_icon.js +++ b/src/common/entity/sensor_icon.js @@ -1,6 +1,6 @@ /** Return an icon representing a sensor state. */ -import { UNIT_C, UNIT_F } from "../const.js"; -import domainIcon from "./domain_icon.js"; +import { UNIT_C, UNIT_F } from "../const"; +import domainIcon from "./domain_icon"; const fixedDeviceClassIcons = { humidity: "hass:water-percent", diff --git a/src/common/entity/split_by_groups.js b/src/common/entity/split_by_groups.js index ac4b60bbf6bf..e0631dfddac2 100644 --- a/src/common/entity/split_by_groups.js +++ b/src/common/entity/split_by_groups.js @@ -1,4 +1,4 @@ -import computeDomain from "./compute_domain.js"; +import computeDomain from "./compute_domain"; // Split a collection into a list of groups and a 'rest' list of ungrouped // entities. diff --git a/src/common/entity/state_card_type.js b/src/common/entity/state_card_type.js index 76bb4eda7bcb..170ca9cb8bf2 100644 --- a/src/common/entity/state_card_type.js +++ b/src/common/entity/state_card_type.js @@ -1,6 +1,6 @@ -import canToggleState from "./can_toggle_state.js"; -import computeStateDomain from "./compute_state_domain.js"; -import { DOMAINS_WITH_CARD } from "../const.js"; +import canToggleState from "./can_toggle_state"; +import computeStateDomain from "./compute_state_domain"; +import { DOMAINS_WITH_CARD } from "../const"; export default function stateCardType(hass, stateObj) { if (stateObj.state === "unavailable") { diff --git a/src/common/entity/state_icon.js b/src/common/entity/state_icon.js index 3b5196cc8cf7..928d7bc1868c 100644 --- a/src/common/entity/state_icon.js +++ b/src/common/entity/state_icon.js @@ -1,13 +1,13 @@ /** Return an icon representing a state. */ -import { DEFAULT_DOMAIN_ICON } from "../const.js"; +import { DEFAULT_DOMAIN_ICON } from "../const"; -import computeDomain from "./compute_domain.js"; -import domainIcon from "./domain_icon.js"; +import computeDomain from "./compute_domain"; +import domainIcon from "./domain_icon"; -import binarySensorIcon from "./binary_sensor_icon.js"; -import coverIcon from "./cover_icon.js"; -import sensorIcon from "./sensor_icon.js"; -import inputDateTimeIcon from "./input_dateteime_icon.js"; +import binarySensorIcon from "./binary_sensor_icon"; +import coverIcon from "./cover_icon"; +import sensorIcon from "./sensor_icon"; +import inputDateTimeIcon from "./input_dateteime_icon"; const domainIcons = { binary_sensor: binarySensorIcon, diff --git a/src/common/entity/state_more_info_type.js b/src/common/entity/state_more_info_type.js index 7b31701c14bc..a35ad61f352f 100644 --- a/src/common/entity/state_more_info_type.js +++ b/src/common/entity/state_more_info_type.js @@ -1,5 +1,5 @@ -import computeStateDomain from "./compute_state_domain.js"; -import { DOMAINS_HIDE_MORE_INFO, DOMAINS_WITH_MORE_INFO } from "../const.js"; +import computeStateDomain from "./compute_state_domain"; +import { DOMAINS_HIDE_MORE_INFO, DOMAINS_WITH_MORE_INFO } from "../const"; export default function stateMoreInfoType(stateObj) { const domain = computeStateDomain(stateObj); diff --git a/src/common/entity/states_sort_by_name.js b/src/common/entity/states_sort_by_name.js index 8d28db1dc53b..f4b67fe2b4c3 100644 --- a/src/common/entity/states_sort_by_name.js +++ b/src/common/entity/states_sort_by_name.js @@ -5,7 +5,7 @@ * const states = [state1, state2] * states.sort(statesSortByName); */ -import computeStateName from "./compute_state_name.js"; +import computeStateName from "./compute_state_name"; export default function sortStatesByName(entityA, entityB) { const nameA = computeStateName(entityA); diff --git a/src/common/entity/timer_time_remaining.js b/src/common/entity/timer_time_remaining.js index c61c7f548320..100c55a88c32 100644 --- a/src/common/entity/timer_time_remaining.js +++ b/src/common/entity/timer_time_remaining.js @@ -1,4 +1,4 @@ -import durationToSeconds from "../datetime/duration_to_seconds.js"; +import durationToSeconds from "../datetime/duration_to_seconds"; export default function timerTimeRemaining(stateObj) { let timeRemaining = durationToSeconds(stateObj.attributes.remaining); diff --git a/src/common/navigate.ts b/src/common/navigate.ts index 6c9675a246ff..155cef6b693c 100644 --- a/src/common/navigate.ts +++ b/src/common/navigate.ts @@ -1,4 +1,4 @@ -import { fireEvent } from "./dom/fire_event.js"; +import { fireEvent } from "./dom/fire_event"; export const navigate = ( node: HTMLElement, diff --git a/src/components/buttons/ha-call-api-button.js b/src/components/buttons/ha-call-api-button.js index cc1984bd58d1..01de64a64de9 100644 --- a/src/components/buttons/ha-call-api-button.js +++ b/src/components/buttons/ha-call-api-button.js @@ -1,7 +1,7 @@ import { LitElement, html } from "@polymer/lit-element"; -import "./ha-progress-button.js"; -import { fireEvent } from "../../common/dom/fire_event.js"; +import "./ha-progress-button"; +import { fireEvent } from "../../common/dom/fire_event"; class HaCallApiButton extends LitElement { render() { diff --git a/src/components/buttons/ha-call-service-button.js b/src/components/buttons/ha-call-service-button.js index fd64489c02fb..3f3b02860fe3 100644 --- a/src/components/buttons/ha-call-service-button.js +++ b/src/components/buttons/ha-call-service-button.js @@ -1,8 +1,8 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./ha-progress-button.js"; -import EventsMixin from "../../mixins/events-mixin.js"; +import "./ha-progress-button"; +import EventsMixin from "../../mixins/events-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/components/buttons/ha-progress-button.js b/src/components/buttons/ha-progress-button.js index 30468267f0d6..f45a8a0c8842 100644 --- a/src/components/buttons/ha-progress-button.js +++ b/src/components/buttons/ha-progress-button.js @@ -1,7 +1,7 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-spinner/paper-spinner.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-spinner/paper-spinner"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class HaProgressButton extends PolymerElement { static get template() { diff --git a/src/components/entity/ha-chart-base.js b/src/components/entity/ha-chart-base.js index 6ae433eda7cc..fa8364b480c2 100644 --- a/src/components/entity/ha-chart-base.js +++ b/src/components/entity/ha-chart-base.js @@ -1,12 +1,12 @@ -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import { IronResizableBehavior } from "@polymer/iron-resizable-behavior/iron-resizable-behavior.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { Debouncer } from "@polymer/polymer/lib/utils/debounce.js"; -import { timeOut } from "@polymer/polymer/lib/utils/async.js"; -import { mixinBehaviors } from "@polymer/polymer/lib/legacy/class.js"; - -import formatTime from "../../common/datetime/format_time.js"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import { IronResizableBehavior } from "@polymer/iron-resizable-behavior/iron-resizable-behavior"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { Debouncer } from "@polymer/polymer/lib/utils/debounce"; +import { timeOut } from "@polymer/polymer/lib/utils/async"; +import { mixinBehaviors } from "@polymer/polymer/lib/legacy/class"; + +import formatTime from "../../common/datetime/format_time"; // eslint-disable-next-line no-unused-vars /* global Chart moment Color */ diff --git a/src/components/entity/ha-entity-picker.js b/src/components/entity/ha-entity-picker.js index 3e1a2e4ecb02..d3e71eff98f3 100644 --- a/src/components/entity/ha-entity-picker.js +++ b/src/components/entity/ha-entity-picker.js @@ -1,16 +1,16 @@ -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-input/paper-input.js"; -import "@polymer/paper-item/paper-icon-item.js"; -import "@polymer/paper-item/paper-item-body.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@vaadin/vaadin-combo-box/vaadin-combo-box-light.js"; - -import "./state-badge.js"; - -import computeStateName from "../../common/entity/compute_state_name.js"; -import LocalizeMixin from "../../mixins/localize-mixin.js"; -import EventsMixin from "../../mixins/events-mixin.js"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-input/paper-input"; +import "@polymer/paper-item/paper-icon-item"; +import "@polymer/paper-item/paper-item-body"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@vaadin/vaadin-combo-box/vaadin-combo-box-light"; + +import "./state-badge"; + +import computeStateName from "../../common/entity/compute_state_name"; +import LocalizeMixin from "../../mixins/localize-mixin"; +import EventsMixin from "../../mixins/events-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/components/entity/ha-entity-toggle.js b/src/components/entity/ha-entity-toggle.js index 646570140f95..729def5660d9 100644 --- a/src/components/entity/ha-entity-toggle.js +++ b/src/components/entity/ha-entity-toggle.js @@ -1,10 +1,10 @@ -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-toggle-button/paper-toggle-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-toggle-button/paper-toggle-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import { STATES_OFF } from "../../common/const.js"; -import computeStateDomain from "../../common/entity/compute_state_domain.js"; +import { STATES_OFF } from "../../common/const"; +import computeStateDomain from "../../common/entity/compute_state_domain"; class HaEntityToggle extends PolymerElement { static get template() { diff --git a/src/components/entity/ha-state-icon.js b/src/components/entity/ha-state-icon.js index 9f76108abcb2..a70bd8d29946 100644 --- a/src/components/entity/ha-state-icon.js +++ b/src/components/entity/ha-state-icon.js @@ -1,8 +1,8 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../ha-icon.js"; -import stateIcon from "../../common/entity/state_icon.js"; +import "../ha-icon"; +import stateIcon from "../../common/entity/state_icon"; class HaStateIcon extends PolymerElement { static get template() { diff --git a/src/components/entity/ha-state-label-badge.js b/src/components/entity/ha-state-label-badge.js index f192237b3481..f40f24f0de09 100644 --- a/src/components/entity/ha-state-label-badge.js +++ b/src/components/entity/ha-state-label-badge.js @@ -1,18 +1,18 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../ha-label-badge.js"; +import "../ha-label-badge"; -import computeStateDomain from "../../common/entity/compute_state_domain.js"; -import computeStateName from "../../common/entity/compute_state_name.js"; -import domainIcon from "../../common/entity/domain_icon.js"; -import stateIcon from "../../common/entity/state_icon.js"; -import timerTimeRemaining from "../../common/entity/timer_time_remaining.js"; -import attributeClassNames from "../../common/entity/attribute_class_names.js"; -import secondsToDuration from "../../common/datetime/seconds_to_duration.js"; +import computeStateDomain from "../../common/entity/compute_state_domain"; +import computeStateName from "../../common/entity/compute_state_name"; +import domainIcon from "../../common/entity/domain_icon"; +import stateIcon from "../../common/entity/state_icon"; +import timerTimeRemaining from "../../common/entity/timer_time_remaining"; +import attributeClassNames from "../../common/entity/attribute_class_names"; +import secondsToDuration from "../../common/datetime/seconds_to_duration"; -import EventsMixin from "../../mixins/events-mixin.js"; -import LocalizeMixin from "../../mixins/localize-mixin.js"; +import EventsMixin from "../../mixins/events-mixin"; +import LocalizeMixin from "../../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/components/entity/state-badge.js b/src/components/entity/state-badge.js index 2b4134be8b82..c20fd31465e0 100644 --- a/src/components/entity/state-badge.js +++ b/src/components/entity/state-badge.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../ha-icon.js"; -import computeStateDomain from "../../common/entity/compute_state_domain.js"; -import stateIcon from "../../common/entity/state_icon.js"; +import "../ha-icon"; +import computeStateDomain from "../../common/entity/compute_state_domain"; +import stateIcon from "../../common/entity/state_icon"; class StateBadge extends PolymerElement { static get template() { diff --git a/src/components/entity/state-info.js b/src/components/entity/state-info.js index f307fb5918d1..1b2f79208885 100644 --- a/src/components/entity/state-info.js +++ b/src/components/entity/state-info.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../ha-relative-time.js"; -import "./state-badge.js"; -import computeStateName from "../../common/entity/compute_state_name.js"; +import "../ha-relative-time"; +import "./state-badge"; +import computeStateName from "../../common/entity/compute_state_name"; class StateInfo extends PolymerElement { static get template() { diff --git a/src/components/ha-attributes.js b/src/components/ha-attributes.js index 7e0e8d844d2f..4197fd0ca13e 100644 --- a/src/components/ha-attributes.js +++ b/src/components/ha-attributes.js @@ -1,8 +1,8 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import hassAttributeUtil from "../util/hass-attributes-util.js"; +import hassAttributeUtil from "../util/hass-attributes-util"; class HaAttributes extends PolymerElement { static get template() { diff --git a/src/components/ha-card.js b/src/components/ha-card.js index b7cb4fb2fc68..785b48077b3f 100644 --- a/src/components/ha-card.js +++ b/src/components/ha-card.js @@ -1,6 +1,6 @@ -import "@polymer/paper-styles/element-styles/paper-material-styles.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-styles/element-styles/paper-material-styles"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class HaCard extends PolymerElement { static get template() { diff --git a/src/components/ha-cards.js b/src/components/ha-cards.js index a81b40ff0f69..a3ad11d92d70 100644 --- a/src/components/ha-cards.js +++ b/src/components/ha-cards.js @@ -1,16 +1,16 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import { timeOut } from "@polymer/polymer/lib/utils/async.js"; -import { Debouncer } from "@polymer/polymer/lib/utils/debounce.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../cards/ha-badges-card.js"; -import "../cards/ha-card-chooser.js"; -import "./ha-demo-badge.js"; - -import computeStateDomain from "../common/entity/compute_state_domain.js"; -import splitByGroups from "../common/entity/split_by_groups.js"; -import getGroupEntities from "../common/entity/get_group_entities.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import { timeOut } from "@polymer/polymer/lib/utils/async"; +import { Debouncer } from "@polymer/polymer/lib/utils/debounce"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../cards/ha-badges-card"; +import "../cards/ha-card-chooser"; +import "./ha-demo-badge"; + +import computeStateDomain from "../common/entity/compute_state_domain"; +import splitByGroups from "../common/entity/split_by_groups"; +import getGroupEntities from "../common/entity/get_group_entities"; // mapping domain to size of the card. const DOMAINS_WITH_CARD = { diff --git a/src/components/ha-climate-control.js b/src/components/ha-climate-control.js index eb791852c4fd..e9515affb656 100644 --- a/src/components/ha-climate-control.js +++ b/src/components/ha-climate-control.js @@ -1,9 +1,9 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import EventsMixin from "../mixins/events-mixin.js"; +import EventsMixin from "../mixins/events-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/components/ha-climate-state.js b/src/components/ha-climate-state.js index 79462114d8a3..8cdc2e37d9a0 100644 --- a/src/components/ha-climate-state.js +++ b/src/components/ha-climate-state.js @@ -1,7 +1,7 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import LocalizeMixin from "../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/components/ha-color-picker.js b/src/components/ha-color-picker.js index 1429afce33fa..fb363636e52a 100644 --- a/src/components/ha-color-picker.js +++ b/src/components/ha-color-picker.js @@ -1,7 +1,7 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import EventsMixin from "../mixins/events-mixin.js"; +import EventsMixin from "../mixins/events-mixin"; /** * Color-picker custom element diff --git a/src/components/ha-combo-box.js b/src/components/ha-combo-box.js index 29e3d0b2022b..51c75a0a9903 100644 --- a/src/components/ha-combo-box.js +++ b/src/components/ha-combo-box.js @@ -1,11 +1,11 @@ -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-input/paper-input.js"; -import "@polymer/paper-item/paper-item.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@vaadin/vaadin-combo-box/vaadin-combo-box-light.js"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-input/paper-input"; +import "@polymer/paper-item/paper-item"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@vaadin/vaadin-combo-box/vaadin-combo-box-light"; -import EventsMixin from "../mixins/events-mixin.js"; +import EventsMixin from "../mixins/events-mixin"; class HaComboBox extends EventsMixin(PolymerElement) { static get template() { diff --git a/src/components/ha-cover-controls.js b/src/components/ha-cover-controls.js index 5fdf73d78104..d1f1c088a0f3 100644 --- a/src/components/ha-cover-controls.js +++ b/src/components/ha-cover-controls.js @@ -1,8 +1,8 @@ -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import CoverEntity from "../util/cover-model.js"; +import CoverEntity from "../util/cover-model"; class HaCoverControls extends PolymerElement { static get template() { diff --git a/src/components/ha-cover-tilt-controls.js b/src/components/ha-cover-tilt-controls.js index 610d2b2fbf2a..8791793fa19c 100644 --- a/src/components/ha-cover-tilt-controls.js +++ b/src/components/ha-cover-tilt-controls.js @@ -1,9 +1,9 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import CoverEntity from "../util/cover-model.js"; +import CoverEntity from "../util/cover-model"; class HaCoverTiltControls extends PolymerElement { static get template() { diff --git a/src/components/ha-demo-badge.js b/src/components/ha-demo-badge.js index f75210898d21..76ab85f550eb 100644 --- a/src/components/ha-demo-badge.js +++ b/src/components/ha-demo-badge.js @@ -1,7 +1,7 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./ha-label-badge.js"; +import "./ha-label-badge"; class HaDemoBadge extends PolymerElement { static get template() { diff --git a/src/components/ha-form.js b/src/components/ha-form.js index a581babd444a..71f4c0cdbe4b 100644 --- a/src/components/ha-form.js +++ b/src/components/ha-form.js @@ -1,14 +1,14 @@ -import "@polymer/paper-checkbox/paper-checkbox.js"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-input/paper-input.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "./ha-paper-slider.js"; -import EventsMixin from "../mixins/events-mixin.js"; +import "@polymer/paper-checkbox/paper-checkbox"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-input/paper-input"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "./ha-paper-slider"; +import EventsMixin from "../mixins/events-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/components/ha-icon.js b/src/components/ha-icon.js index bdef41d4fb11..37f0890c329b 100644 --- a/src/components/ha-icon.js +++ b/src/components/ha-icon.js @@ -1,4 +1,4 @@ -import "@polymer/iron-icon/iron-icon.js"; +import "@polymer/iron-icon/iron-icon"; const IronIconClass = customElements.get("iron-icon"); diff --git a/src/components/ha-iconset-svg.js b/src/components/ha-iconset-svg.js index d2cedd78deab..ae2b414a25d5 100644 --- a/src/components/ha-iconset-svg.js +++ b/src/components/ha-iconset-svg.js @@ -1,4 +1,4 @@ -import "@polymer/iron-iconset-svg/iron-iconset-svg.js"; +import "@polymer/iron-iconset-svg/iron-iconset-svg"; const IronIconsetClass = customElements.get("iron-iconset-svg"); diff --git a/src/components/ha-label-badge.js b/src/components/ha-label-badge.js index be672f0163f7..bad3c7dd5b13 100644 --- a/src/components/ha-label-badge.js +++ b/src/components/ha-label-badge.js @@ -1,6 +1,6 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "./ha-icon.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "./ha-icon"; class HaLabelBadge extends PolymerElement { static get template() { diff --git a/src/components/ha-labeled-slider.js b/src/components/ha-labeled-slider.js index d8b2691651a2..f91500a31338 100644 --- a/src/components/ha-labeled-slider.js +++ b/src/components/ha-labeled-slider.js @@ -1,8 +1,8 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./ha-paper-slider.js"; -import "./ha-icon.js"; +import "./ha-paper-slider"; +import "./ha-icon"; class HaLabeledSlider extends PolymerElement { static get template() { diff --git a/src/components/ha-markdown.js b/src/components/ha-markdown.js index a23ad01761af..0387d37e0599 100644 --- a/src/components/ha-markdown.js +++ b/src/components/ha-markdown.js @@ -1,5 +1,5 @@ -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import EventsMixin from "../mixins/events-mixin.js"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import EventsMixin from "../mixins/events-mixin"; let loaded = null; diff --git a/src/components/ha-menu-button.js b/src/components/ha-menu-button.js index 9437eea702c4..2313e75197a2 100644 --- a/src/components/ha-menu-button.js +++ b/src/components/ha-menu-button.js @@ -1,8 +1,8 @@ -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import EventsMixin from "../mixins/events-mixin.js"; +import EventsMixin from "../mixins/events-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/components/ha-paper-slider.js b/src/components/ha-paper-slider.js index fae25e62981b..f7cad5fec220 100644 --- a/src/components/ha-paper-slider.js +++ b/src/components/ha-paper-slider.js @@ -1,4 +1,4 @@ -import "@polymer/paper-slider/paper-slider.js"; +import "@polymer/paper-slider/paper-slider"; /** * @polymer diff --git a/src/components/ha-push-notifications-toggle.js b/src/components/ha-push-notifications-toggle.js index 77cc9696613c..0974b5b82c36 100644 --- a/src/components/ha-push-notifications-toggle.js +++ b/src/components/ha-push-notifications-toggle.js @@ -1,8 +1,8 @@ -import "@polymer/paper-toggle-button/paper-toggle-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-toggle-button/paper-toggle-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import EventsMixin from "../mixins/events-mixin.js"; +import EventsMixin from "../mixins/events-mixin"; export const pushSupported = "serviceWorker" in navigator && diff --git a/src/components/ha-relative-time.js b/src/components/ha-relative-time.js index caca4052b5d4..0d6128552481 100644 --- a/src/components/ha-relative-time.js +++ b/src/components/ha-relative-time.js @@ -1,9 +1,9 @@ -import { dom } from "@polymer/polymer/lib/legacy/polymer.dom.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { dom } from "@polymer/polymer/lib/legacy/polymer.dom"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import relativeTime from "../common/datetime/relative_time.js"; +import relativeTime from "../common/datetime/relative_time"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import LocalizeMixin from "../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/components/ha-service-description.js b/src/components/ha-service-description.js index ee769db5864a..dc0af4a04d37 100644 --- a/src/components/ha-service-description.js +++ b/src/components/ha-service-description.js @@ -1,5 +1,5 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class HaServiceDescription extends PolymerElement { static get template() { diff --git a/src/components/ha-service-picker.js b/src/components/ha-service-picker.js index e87eed968409..bb52246a3cfd 100644 --- a/src/components/ha-service-picker.js +++ b/src/components/ha-service-picker.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./ha-combo-box.js"; +import "./ha-combo-box"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import LocalizeMixin from "../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/components/ha-sidebar.js b/src/components/ha-sidebar.js index 0d63fba06b98..a3d87db4c745 100644 --- a/src/components/ha-sidebar.js +++ b/src/components/ha-sidebar.js @@ -1,16 +1,16 @@ -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-item/paper-icon-item.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "./ha-icon.js"; - -import "../util/hass-translation.js"; -import LocalizeMixin from "../mixins/localize-mixin.js"; -import isComponentLoaded from "../common/config/is_component_loaded.js"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-item/paper-icon-item"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "./ha-icon"; + +import "../util/hass-translation"; +import LocalizeMixin from "../mixins/localize-mixin"; +import isComponentLoaded from "../common/config/is_component_loaded"; /* * @appliesMixin LocalizeMixin diff --git a/src/components/ha-start-voice-button.js b/src/components/ha-start-voice-button.js index 193839f1c56b..31e6427e0054 100644 --- a/src/components/ha-start-voice-button.js +++ b/src/components/ha-start-voice-button.js @@ -1,10 +1,10 @@ -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import EventsMixin from "../mixins/events-mixin.js"; +import EventsMixin from "../mixins/events-mixin"; -import isComponentLoaded from "../common/config/is_component_loaded.js"; +import isComponentLoaded from "../common/config/is_component_loaded"; /* * @appliesMixin EventsMixin diff --git a/src/components/ha-textarea.js b/src/components/ha-textarea.js index 4de27c8abe58..8146aa71e17e 100644 --- a/src/components/ha-textarea.js +++ b/src/components/ha-textarea.js @@ -9,9 +9,9 @@ paper-textarea issue: https://github.com/PolymerElements/paper-input/issues/556 WebKit issue: https://bugs.webkit.org/show_bug.cgi?id=174629 */ -import "@polymer/paper-input/paper-textarea.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-input/paper-textarea"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class HaTextarea extends PolymerElement { static get template() { diff --git a/src/components/ha-toast.js b/src/components/ha-toast.js index 2371afb711ac..ba14c6a3920c 100644 --- a/src/components/ha-toast.js +++ b/src/components/ha-toast.js @@ -1,4 +1,4 @@ -import "@polymer/paper-toast/paper-toast.js"; +import "@polymer/paper-toast/paper-toast"; const PaperToast = customElements.get("paper-toast"); diff --git a/src/components/ha-vacuum-state.js b/src/components/ha-vacuum-state.js index 0fb8faf46b3c..c6ad7e98a642 100644 --- a/src/components/ha-vacuum-state.js +++ b/src/components/ha-vacuum-state.js @@ -1,8 +1,8 @@ -import "@polymer/paper-button/paper-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import LocalizeMixin from "../mixins/localize-mixin"; const STATES_INTERCEPTABLE = { cleaning: { diff --git a/src/components/ha-water_heater-control.js b/src/components/ha-water_heater-control.js index 3517a4aa5fab..c65506ce5d80 100644 --- a/src/components/ha-water_heater-control.js +++ b/src/components/ha-water_heater-control.js @@ -1,9 +1,9 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import EventsMixin from "../mixins/events-mixin.js"; +import EventsMixin from "../mixins/events-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/components/ha-water_heater-state.js b/src/components/ha-water_heater-state.js index 9133b67da47d..c116f5eaea95 100644 --- a/src/components/ha-water_heater-state.js +++ b/src/components/ha-water_heater-state.js @@ -1,7 +1,7 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import LocalizeMixin from "../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/components/paper-time-input.js b/src/components/paper-time-input.js index 30075398df8b..402f8807b6e0 100644 --- a/src/components/paper-time-input.js +++ b/src/components/paper-time-input.js @@ -16,12 +16,12 @@ Custom property | Description | Default `--paper-time-input-cotnainer` | Mixin applied to the inputs | `{}` `--paper-time-dropdown-input-cotnainer` | Mixin applied to the dropdown input | `{}` */ -import "@polymer/paper-input/paper-input.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-input/paper-input"; +import "@polymer/paper-listbox/paper-listbox"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class PaperTimeInput extends PolymerElement { static get template() { diff --git a/src/components/state-history-chart-line.js b/src/components/state-history-chart-line.js index 5981b68c9b70..3e36e9a9a42a 100644 --- a/src/components/state-history-chart-line.js +++ b/src/components/state-history-chart-line.js @@ -1,11 +1,11 @@ -import "@polymer/polymer/lib/utils/debounce.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/polymer/lib/utils/debounce"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./entity/ha-chart-base.js"; +import "./entity/ha-chart-base"; -import LocalizeMixin from "../mixins/localize-mixin.js"; -import formatDateTime from "../common/datetime/format_date_time.js"; +import LocalizeMixin from "../mixins/localize-mixin"; +import formatDateTime from "../common/datetime/format_date_time"; class StateHistoryChartLine extends LocalizeMixin(PolymerElement) { static get template() { diff --git a/src/components/state-history-chart-timeline.js b/src/components/state-history-chart-timeline.js index 7aae50b7f89f..45ff9646ccd3 100644 --- a/src/components/state-history-chart-timeline.js +++ b/src/components/state-history-chart-timeline.js @@ -1,10 +1,10 @@ -import "@polymer/polymer/lib/utils/debounce.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/polymer/lib/utils/debounce"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import LocalizeMixin from "../mixins/localize-mixin"; -import "./entity/ha-chart-base.js"; +import "./entity/ha-chart-base"; import formatDateTime from "../common/datetime/format_date_time"; diff --git a/src/components/state-history-charts.js b/src/components/state-history-charts.js index 2701eee073e7..fcb014de44ab 100644 --- a/src/components/state-history-charts.js +++ b/src/components/state-history-charts.js @@ -1,11 +1,11 @@ -import "@polymer/paper-spinner/paper-spinner.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-spinner/paper-spinner"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./state-history-chart-line.js"; -import "./state-history-chart-timeline.js"; +import "./state-history-chart-line"; +import "./state-history-chart-timeline"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import LocalizeMixin from "../mixins/localize-mixin"; class StateHistoryCharts extends LocalizeMixin(PolymerElement) { static get template() { diff --git a/src/data/ha-state-history-data.js b/src/data/ha-state-history-data.js index f366b1039dfa..bd97a759b273 100644 --- a/src/data/ha-state-history-data.js +++ b/src/data/ha-state-history-data.js @@ -1,8 +1,8 @@ -import { timeOut } from "@polymer/polymer/lib/utils/async.js"; -import { Debouncer } from "@polymer/polymer/lib/utils/debounce.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { timeOut } from "@polymer/polymer/lib/utils/async"; +import { Debouncer } from "@polymer/polymer/lib/utils/debounce"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import LocalizeMixin from "../mixins/localize-mixin"; import { computeHistory, fetchDate } from "./history"; import { getRecent, getRecentWithCache } from "./cached-history"; diff --git a/src/data/history.ts b/src/data/history.ts index de28f78cff88..76990944544b 100644 --- a/src/data/history.ts +++ b/src/data/history.ts @@ -1,9 +1,9 @@ -import computeStateName from "../common/entity/compute_state_name.js"; -import computeStateDomain from "../common/entity/compute_state_domain.js"; -import computeStateDisplay from "../common/entity/compute_state_display.js"; +import computeStateName from "../common/entity/compute_state_name"; +import computeStateDomain from "../common/entity/compute_state_domain"; +import computeStateDisplay from "../common/entity/compute_state_display"; import { HassEntity } from "home-assistant-js-websocket"; -import { LocalizeFunc } from "../mixins/localize-base-mixin.js"; -import { HomeAssistant } from "../types.js"; +import { LocalizeFunc } from "../mixins/localize-base-mixin"; +import { HomeAssistant } from "../types"; const DOMAINS_USE_LAST_UPDATED = ["climate", "water_heater"]; const LINE_ATTRIBUTES_TO_KEEP = [ diff --git a/src/dialogs/ha-more-info-dialog.js b/src/dialogs/ha-more-info-dialog.js index b4000f4960d5..c8d7efdcbf53 100644 --- a/src/dialogs/ha-more-info-dialog.js +++ b/src/dialogs/ha-more-info-dialog.js @@ -1,17 +1,17 @@ -import "@polymer/paper-dialog-behavior/paper-dialog-shared-styles.js"; -import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-dialog-behavior/paper-dialog-shared-styles"; +import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../resources/ha-style.js"; +import "../resources/ha-style"; -import "./more-info/more-info-controls.js"; -import "./more-info/more-info-settings.js"; +import "./more-info/more-info-controls"; +import "./more-info/more-info-settings"; import computeStateDomain from "../common/entity/compute_state_domain"; -import isComponentLoaded from "../common/config/is_component_loaded.js"; +import isComponentLoaded from "../common/config/is_component_loaded"; -import DialogMixin from "../mixins/dialog-mixin.js"; +import DialogMixin from "../mixins/dialog-mixin"; /* * @appliesMixin DialogMixin diff --git a/src/dialogs/ha-store-auth-card.js b/src/dialogs/ha-store-auth-card.js index ebeb73ac8886..c1f6a2bd26fd 100644 --- a/src/dialogs/ha-store-auth-card.js +++ b/src/dialogs/ha-store-auth-card.js @@ -1,11 +1,11 @@ -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import { enableWrite } from "../common/auth/token_storage.js"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import { enableWrite } from "../common/auth/token_storage"; +import LocalizeMixin from "../mixins/localize-mixin"; -import "../resources/ha-style.js"; +import "../resources/ha-style"; class HaStoreAuth extends LocalizeMixin(PolymerElement) { static get template() { diff --git a/src/dialogs/ha-voice-command-dialog.js b/src/dialogs/ha-voice-command-dialog.js index bab4a97a2aac..abc5029cca0b 100644 --- a/src/dialogs/ha-voice-command-dialog.js +++ b/src/dialogs/ha-voice-command-dialog.js @@ -1,10 +1,10 @@ -import "@polymer/iron-icon/iron-icon.js"; -import "@polymer/paper-dialog-behavior/paper-dialog-shared-styles.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-icon/iron-icon"; +import "@polymer/paper-dialog-behavior/paper-dialog-shared-styles"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import DialogMixin from "../mixins/dialog-mixin.js"; +import DialogMixin from "../mixins/dialog-mixin"; /* * @appliesMixin DialogMixin diff --git a/src/dialogs/more-info/controls/more-info-alarm_control_panel.js b/src/dialogs/more-info/controls/more-info-alarm_control_panel.js index dd27860f1186..5d92024fd0e3 100644 --- a/src/dialogs/more-info/controls/more-info-alarm_control_panel.js +++ b/src/dialogs/more-info/controls/more-info-alarm_control_panel.js @@ -1,11 +1,11 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-input/paper-input.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; class MoreInfoAlarmControlPanel extends LocalizeMixin( EventsMixin(PolymerElement) diff --git a/src/dialogs/more-info/controls/more-info-automation.js b/src/dialogs/more-info/controls/more-info-automation.js index f225bf3376b5..311ba9a3179f 100644 --- a/src/dialogs/more-info/controls/more-info-automation.js +++ b/src/dialogs/more-info/controls/more-info-automation.js @@ -1,10 +1,10 @@ -import "@polymer/paper-button/paper-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../components/ha-relative-time.js"; +import "../../../components/ha-relative-time"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import LocalizeMixin from "../../../mixins/localize-mixin"; class MoreInfoAutomation extends LocalizeMixin(PolymerElement) { static get template() { diff --git a/src/dialogs/more-info/controls/more-info-camera.js b/src/dialogs/more-info/controls/more-info-camera.js index 607c7b95c06f..d82ac7034c36 100644 --- a/src/dialogs/more-info/controls/more-info-camera.js +++ b/src/dialogs/more-info/controls/more-info-camera.js @@ -1,9 +1,9 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import emptyImageBase64 from "../../../common/empty_image_base64.js"; -import EventsMixin from "../../../mixins/events-mixin.js"; +import computeStateName from "../../../common/entity/compute_state_name"; +import emptyImageBase64 from "../../../common/empty_image_base64"; +import EventsMixin from "../../../mixins/events-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/dialogs/more-info/controls/more-info-climate.js b/src/dialogs/more-info/controls/more-info-climate.js index eaa391305633..bd769921b569 100644 --- a/src/dialogs/more-info/controls/more-info-climate.js +++ b/src/dialogs/more-info/controls/more-info-climate.js @@ -1,21 +1,21 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import "@polymer/paper-toggle-button/paper-toggle-button.js"; -import { timeOut } from "@polymer/polymer/lib/utils/async.js"; -import { Debouncer } from "@polymer/polymer/lib/utils/debounce.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/ha-climate-control.js"; -import "../../../components/ha-paper-slider.js"; - -import attributeClassNames from "../../../common/entity/attribute_class_names.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import "@polymer/paper-toggle-button/paper-toggle-button"; +import { timeOut } from "@polymer/polymer/lib/utils/async"; +import { Debouncer } from "@polymer/polymer/lib/utils/debounce"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/ha-climate-control"; +import "../../../components/ha-paper-slider"; + +import attributeClassNames from "../../../common/entity/attribute_class_names"; import featureClassNames from "../../../common/entity/feature_class_names"; -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/dialogs/more-info/controls/more-info-configurator.js b/src/dialogs/more-info/controls/more-info-configurator.js index 03a6b465e461..c3dcdad2d1ad 100644 --- a/src/dialogs/more-info/controls/more-info-configurator.js +++ b/src/dialogs/more-info/controls/more-info-configurator.js @@ -1,12 +1,12 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/iron-input/iron-input.js"; -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-input/paper-input.js"; -import "@polymer/paper-spinner/paper-spinner.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/ha-markdown.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/iron-input/iron-input"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-input/paper-input"; +import "@polymer/paper-spinner/paper-spinner"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/ha-markdown"; class MoreInfoConfigurator extends PolymerElement { static get template() { diff --git a/src/dialogs/more-info/controls/more-info-content.js b/src/dialogs/more-info/controls/more-info-content.js index f2f1473fe11c..2d4f20a7c148 100644 --- a/src/dialogs/more-info/controls/more-info-content.js +++ b/src/dialogs/more-info/controls/more-info-content.js @@ -1,28 +1,28 @@ -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./more-info-alarm_control_panel.js"; -import "./more-info-automation.js"; -import "./more-info-camera.js"; -import "./more-info-climate.js"; -import "./more-info-configurator.js"; -import "./more-info-cover.js"; -import "./more-info-default.js"; -import "./more-info-fan.js"; -import "./more-info-group.js"; -import "./more-info-history_graph.js"; -import "./more-info-input_datetime.js"; -import "./more-info-light.js"; -import "./more-info-lock.js"; -import "./more-info-media_player.js"; -import "./more-info-script.js"; -import "./more-info-sun.js"; -import "./more-info-updater.js"; -import "./more-info-vacuum.js"; -import "./more-info-water_heater.js"; -import "./more-info-weather.js"; +import "./more-info-alarm_control_panel"; +import "./more-info-automation"; +import "./more-info-camera"; +import "./more-info-climate"; +import "./more-info-configurator"; +import "./more-info-cover"; +import "./more-info-default"; +import "./more-info-fan"; +import "./more-info-group"; +import "./more-info-history_graph"; +import "./more-info-input_datetime"; +import "./more-info-light"; +import "./more-info-lock"; +import "./more-info-media_player"; +import "./more-info-script"; +import "./more-info-sun"; +import "./more-info-updater"; +import "./more-info-vacuum"; +import "./more-info-water_heater"; +import "./more-info-weather"; -import stateMoreInfoType from "../../../common/entity/state_more_info_type.js"; -import dynamicContentUpdater from "../../../common/dom/dynamic_content_updater.js"; +import stateMoreInfoType from "../../../common/entity/state_more_info_type"; +import dynamicContentUpdater from "../../../common/dom/dynamic_content_updater"; class MoreInfoContent extends PolymerElement { static get properties() { diff --git a/src/dialogs/more-info/controls/more-info-cover.js b/src/dialogs/more-info/controls/more-info-cover.js index 4dcdae677309..fcec33fd45a6 100644 --- a/src/dialogs/more-info/controls/more-info-cover.js +++ b/src/dialogs/more-info/controls/more-info-cover.js @@ -1,16 +1,16 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../components/ha-cover-tilt-controls.js"; -import "../../../components/ha-labeled-slider.js"; -import CoverEntity from "../../../util/cover-model.js"; +import "../../../components/ha-cover-tilt-controls"; +import "../../../components/ha-labeled-slider"; +import CoverEntity from "../../../util/cover-model"; import attributeClassNames from "../../../common/entity/attribute_class_names"; import featureClassNames from "../../../common/entity/feature_class_names"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import LocalizeMixin from "../../../mixins/localize-mixin"; const FEATURE_CLASS_NAMES = { 128: "has-set_tilt_position", diff --git a/src/dialogs/more-info/controls/more-info-default.js b/src/dialogs/more-info/controls/more-info-default.js index a2e97d61d8e6..f9062ecef455 100644 --- a/src/dialogs/more-info/controls/more-info-default.js +++ b/src/dialogs/more-info/controls/more-info-default.js @@ -1,7 +1,7 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../components/ha-attributes.js"; +import "../../../components/ha-attributes"; class MoreInfoDefault extends PolymerElement { static get template() { diff --git a/src/dialogs/more-info/controls/more-info-fan.js b/src/dialogs/more-info/controls/more-info-fan.js index 0d7bbfc31d42..f1a95a61bc5b 100644 --- a/src/dialogs/more-info/controls/more-info-fan.js +++ b/src/dialogs/more-info/controls/more-info-fan.js @@ -1,17 +1,17 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import "@polymer/paper-toggle-button/paper-toggle-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import "@polymer/paper-toggle-button/paper-toggle-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../components/ha-attributes.js"; +import "../../../components/ha-attributes"; import attributeClassNames from "../../../common/entity/attribute_class_names"; -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/dialogs/more-info/controls/more-info-group.js b/src/dialogs/more-info/controls/more-info-group.js index 0c93ab21f7fc..d551efc6b294 100644 --- a/src/dialogs/more-info/controls/more-info-group.js +++ b/src/dialogs/more-info/controls/more-info-group.js @@ -1,11 +1,11 @@ -import { dom } from "@polymer/polymer/lib/legacy/polymer.dom.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { dom } from "@polymer/polymer/lib/legacy/polymer.dom"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../state-summary/state-card-content.js"; +import "../../../state-summary/state-card-content"; import computeStateDomain from "../../../common/entity/compute_state_domain"; -import dynamicContentUpdater from "../../../common/dom/dynamic_content_updater.js"; +import dynamicContentUpdater from "../../../common/dom/dynamic_content_updater"; class MoreInfoGroup extends PolymerElement { static get template() { diff --git a/src/dialogs/more-info/controls/more-info-history_graph.js b/src/dialogs/more-info/controls/more-info-history_graph.js index 168022816222..713b17f57351 100644 --- a/src/dialogs/more-info/controls/more-info-history_graph.js +++ b/src/dialogs/more-info/controls/more-info-history_graph.js @@ -1,8 +1,8 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../cards/ha-history_graph-card.js"; -import "../../../components/ha-attributes.js"; +import "../../../cards/ha-history_graph-card"; +import "../../../components/ha-attributes"; class MoreInfoHistoryGraph extends PolymerElement { static get template() { diff --git a/src/dialogs/more-info/controls/more-info-input_datetime.js b/src/dialogs/more-info/controls/more-info-input_datetime.js index 0cc236a871dd..aa112ef38be2 100644 --- a/src/dialogs/more-info/controls/more-info-input_datetime.js +++ b/src/dialogs/more-info/controls/more-info-input_datetime.js @@ -1,14 +1,14 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-input/paper-input.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import "@polymer/polymer/polymer-legacy.js"; -import "@vaadin/vaadin-date-picker/vaadin-date-picker.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import "@polymer/polymer/polymer-legacy"; +import "@vaadin/vaadin-date-picker/vaadin-date-picker"; -import "../../../components/ha-relative-time.js"; -import "../../../components/paper-time-input.js"; +import "../../../components/ha-relative-time"; +import "../../../components/paper-time-input"; -import attributeClassNames from "../../../common/entity/attribute_class_names.js"; +import attributeClassNames from "../../../common/entity/attribute_class_names"; class DatetimeInput extends PolymerElement { static get template() { diff --git a/src/dialogs/more-info/controls/more-info-light.js b/src/dialogs/more-info/controls/more-info-light.js index 7aff5eb1e7ba..403db8efe436 100644 --- a/src/dialogs/more-info/controls/more-info-light.js +++ b/src/dialogs/more-info/controls/more-info-light.js @@ -1,17 +1,17 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../components/ha-attributes.js"; -import "../../../components/ha-color-picker.js"; -import "../../../components/ha-labeled-slider.js"; +import "../../../components/ha-attributes"; +import "../../../components/ha-color-picker"; +import "../../../components/ha-labeled-slider"; import featureClassNames from "../../../common/entity/feature_class_names"; -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; const FEATURE_CLASS_NAMES = { 1: "has-brightness", diff --git a/src/dialogs/more-info/controls/more-info-lock.js b/src/dialogs/more-info/controls/more-info-lock.js index 5c5a232790e5..c4f8adda6816 100644 --- a/src/dialogs/more-info/controls/more-info-lock.js +++ b/src/dialogs/more-info/controls/more-info-lock.js @@ -1,11 +1,11 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-input/paper-input.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../components/ha-attributes.js"; +import "../../../components/ha-attributes"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import LocalizeMixin from "../../../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/dialogs/more-info/controls/more-info-media_player.js b/src/dialogs/more-info/controls/more-info-media_player.js index 7c23250852dd..a7164ee92fa0 100644 --- a/src/dialogs/more-info/controls/more-info-media_player.js +++ b/src/dialogs/more-info/controls/more-info-media_player.js @@ -1,19 +1,19 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/iron-icon/iron-icon.js"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/ha-paper-slider.js"; -import HassMediaPlayerEntity from "../../../util/hass-media-player-model.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/iron-icon/iron-icon"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/ha-paper-slider"; +import HassMediaPlayerEntity from "../../../util/hass-media-player-model"; import attributeClassNames from "../../../common/entity/attribute_class_names"; -import isComponentLoaded from "../../../common/config/is_component_loaded.js"; -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import isComponentLoaded from "../../../common/config/is_component_loaded"; +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/dialogs/more-info/controls/more-info-script.js b/src/dialogs/more-info/controls/more-info-script.js index af6f3f1115dd..93a7e7552d33 100644 --- a/src/dialogs/more-info/controls/more-info-script.js +++ b/src/dialogs/more-info/controls/more-info-script.js @@ -1,6 +1,6 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class MoreInfoScript extends PolymerElement { static get template() { diff --git a/src/dialogs/more-info/controls/more-info-sun.js b/src/dialogs/more-info/controls/more-info-sun.js index 46a8d6cab5f9..3104fdf18897 100644 --- a/src/dialogs/more-info/controls/more-info-sun.js +++ b/src/dialogs/more-info/controls/more-info-sun.js @@ -1,11 +1,11 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../components/ha-relative-time.js"; +import "../../../components/ha-relative-time"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; -import formatTime from "../../../common/datetime/format_time.js"; +import LocalizeMixin from "../../../mixins/localize-mixin"; +import formatTime from "../../../common/datetime/format_time"; class MoreInfoSun extends LocalizeMixin(PolymerElement) { static get template() { diff --git a/src/dialogs/more-info/controls/more-info-updater.js b/src/dialogs/more-info/controls/more-info-updater.js index c6ab55002583..7b687fa82314 100644 --- a/src/dialogs/more-info/controls/more-info-updater.js +++ b/src/dialogs/more-info/controls/more-info-updater.js @@ -1,5 +1,5 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class MoreInfoUpdater extends PolymerElement { static get template() { diff --git a/src/dialogs/more-info/controls/more-info-vacuum.js b/src/dialogs/more-info/controls/more-info-vacuum.js index bdf1704abb76..293180b84d0f 100644 --- a/src/dialogs/more-info/controls/more-info-vacuum.js +++ b/src/dialogs/more-info/controls/more-info-vacuum.js @@ -1,13 +1,13 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/iron-icon/iron-icon.js"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/iron-icon/iron-icon"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../components/ha-attributes.js"; +import "../../../components/ha-attributes"; class MoreInfoVacuum extends PolymerElement { static get template() { @@ -54,7 +54,7 @@ class MoreInfoVacuum extends PolymerElement {
- +
diff --git a/src/dialogs/more-info/controls/more-info-water_heater.js b/src/dialogs/more-info/controls/more-info-water_heater.js index 757f8791b2f8..49a15e24fdd7 100644 --- a/src/dialogs/more-info/controls/more-info-water_heater.js +++ b/src/dialogs/more-info/controls/more-info-water_heater.js @@ -1,20 +1,20 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import "@polymer/paper-toggle-button/paper-toggle-button.js"; -import { timeOut } from "@polymer/polymer/lib/utils/async.js"; -import { Debouncer } from "@polymer/polymer/lib/utils/debounce.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/ha-water_heater-control.js"; -import "../../../components/ha-paper-slider.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import "@polymer/paper-toggle-button/paper-toggle-button"; +import { timeOut } from "@polymer/polymer/lib/utils/async"; +import { Debouncer } from "@polymer/polymer/lib/utils/debounce"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/ha-water_heater-control"; +import "../../../components/ha-paper-slider"; import featureClassNames from "../../../common/entity/feature_class_names"; -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/dialogs/more-info/controls/more-info-weather.js b/src/dialogs/more-info/controls/more-info-weather.js index eb787675c2d9..118c2ca234ca 100644 --- a/src/dialogs/more-info/controls/more-info-weather.js +++ b/src/dialogs/more-info/controls/more-info-weather.js @@ -1,8 +1,8 @@ -import "@polymer/iron-icon/iron-icon.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-icon/iron-icon"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import LocalizeMixin from "../../../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/dialogs/more-info/more-info-controls.js b/src/dialogs/more-info/more-info-controls.js index a23cf38be834..dcfb91414eba 100644 --- a/src/dialogs/more-info/more-info-controls.js +++ b/src/dialogs/more-info/more-info-controls.js @@ -1,21 +1,21 @@ -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../components/state-history-charts.js"; +import "../../components/state-history-charts"; import "../../data/ha-state-history-data"; -import "../../resources/ha-style.js"; -import "../../state-summary/state-card-content.js"; +import "../../resources/ha-style"; +import "../../state-summary/state-card-content"; -import "./controls/more-info-content.js"; +import "./controls/more-info-content"; -import computeStateName from "../../common/entity/compute_state_name.js"; -import computeStateDomain from "../../common/entity/compute_state_domain.js"; -import isComponentLoaded from "../../common/config/is_component_loaded.js"; -import { DOMAINS_MORE_INFO_NO_HISTORY } from "../../common/const.js"; -import EventsMixin from "../../mixins/events-mixin.js"; +import computeStateName from "../../common/entity/compute_state_name"; +import computeStateDomain from "../../common/entity/compute_state_domain"; +import isComponentLoaded from "../../common/config/is_component_loaded"; +import { DOMAINS_MORE_INFO_NO_HISTORY } from "../../common/const"; +import EventsMixin from "../../mixins/events-mixin"; const DOMAINS_NO_INFO = ["camera", "configurator", "history_graph"]; /* diff --git a/src/dialogs/more-info/more-info-settings.js b/src/dialogs/more-info/more-info-settings.js index 11a36f03f883..484b76eb7c58 100644 --- a/src/dialogs/more-info/more-info-settings.js +++ b/src/dialogs/more-info/more-info-settings.js @@ -1,16 +1,16 @@ -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-input/paper-input.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import EventsMixin from "../../mixins/events-mixin.js"; -import LocalizeMixin from "../../mixins/localize-mixin.js"; - -import computeStateName from "../../common/entity/compute_state_name.js"; -import computeDomain from "../../common/entity/compute_domain.js"; -import isComponentLoaded from "../../common/config/is_component_loaded.js"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import EventsMixin from "../../mixins/events-mixin"; +import LocalizeMixin from "../../mixins/localize-mixin"; + +import computeStateName from "../../common/entity/compute_state_name"; +import computeDomain from "../../common/entity/compute_domain"; +import isComponentLoaded from "../../common/config/is_component_loaded"; /* * @appliesMixin EventsMixin diff --git a/src/entrypoints/app.js b/src/entrypoints/app.js index 5f5226349c60..9ba251699480 100644 --- a/src/entrypoints/app.js +++ b/src/entrypoints/app.js @@ -1,20 +1,20 @@ // Load polyfill first so HTML imports start resolving /* eslint-disable import/first */ -import "../resources/html-import/polyfill.js"; -import "@polymer/app-route/app-location.js"; -import "@polymer/app-route/app-route.js"; -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-styles/typography.js"; -import { setPassiveTouchGestures } from "@polymer/polymer/lib/utils/settings.js"; +import "../resources/html-import/polyfill"; +import "@polymer/app-route/app-location"; +import "@polymer/app-route/app-route"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-styles/typography"; +import { setPassiveTouchGestures } from "@polymer/polymer/lib/utils/settings"; import "../util/legacy-support"; -import "../resources/roboto.js"; +import "../resources/roboto"; // For MDI icons. Needs to be part of main bundle or else it won't hook // properly into iron-meta, which is used to transfer iconsets to iron-icon. -import "../components/ha-iconset-svg.js"; +import "../components/ha-iconset-svg"; -import "../layouts/app/home-assistant.js"; +import "../layouts/app/home-assistant"; /* polyfill for paper-dropdown */ setTimeout( diff --git a/src/entrypoints/authorize.js b/src/entrypoints/authorize.js index a4b7fb67d365..f5052c148a8a 100644 --- a/src/entrypoints/authorize.js +++ b/src/entrypoints/authorize.js @@ -1,11 +1,11 @@ -import "@polymer/polymer/lib/elements/dom-if.js"; -import "@polymer/polymer/lib/elements/dom-repeat.js"; +import "@polymer/polymer/lib/elements/dom-if"; +import "@polymer/polymer/lib/elements/dom-repeat"; -import "../components/ha-iconset-svg.js"; -import "../resources/ha-style.js"; -import "../resources/roboto.js"; +import "../components/ha-iconset-svg"; +import "../resources/ha-style"; +import "../resources/roboto"; -import "../auth/ha-authorize.js"; +import "../auth/ha-authorize"; /* polyfill for paper-dropdown */ setTimeout( diff --git a/src/entrypoints/core.js b/src/entrypoints/core.js index 2890c0ef5f57..ed0930e9eab8 100644 --- a/src/entrypoints/core.js +++ b/src/entrypoints/core.js @@ -7,10 +7,10 @@ import { ERR_INVALID_AUTH, } from "home-assistant-js-websocket"; -import { loadTokens, saveTokens } from "../common/auth/token_storage.js"; -import { subscribePanels } from "../data/ws-panels.js"; -import { subscribeThemes } from "../data/ws-themes.js"; -import { subscribeUser } from "../data/ws-user.js"; +import { loadTokens, saveTokens } from "../common/auth/token_storage"; +import { subscribePanels } from "../data/ws-panels"; +import { subscribeThemes } from "../data/ws-themes"; +import { subscribeUser } from "../data/ws-user"; const hassUrl = `${location.protocol}//${location.host}`; const isExternal = location.search.includes("external_auth=1"); diff --git a/src/entrypoints/custom-panel.js b/src/entrypoints/custom-panel.js index 2a6fe2ccbbd5..c219b67fc473 100644 --- a/src/entrypoints/custom-panel.js +++ b/src/entrypoints/custom-panel.js @@ -1,7 +1,7 @@ -import { loadJS } from "../common/dom/load_resource.js"; -import loadCustomPanel from "../util/custom-panel/load-custom-panel.js"; -import createCustomPanelElement from "../util/custom-panel/create-custom-panel-element.js"; -import setCustomPanelProperties from "../util/custom-panel/set-custom-panel-properties.js"; +import { loadJS } from "../common/dom/load_resource"; +import loadCustomPanel from "../util/custom-panel/load-custom-panel"; +import createCustomPanelElement from "../util/custom-panel/create-custom-panel-element"; +import setCustomPanelProperties from "../util/custom-panel/set-custom-panel-properties"; const webComponentsSupported = "customElements" in window && diff --git a/src/entrypoints/hass-icons.js b/src/entrypoints/hass-icons.js index ee033f31524d..dcb7c48fc8be 100644 --- a/src/entrypoints/hass-icons.js +++ b/src/entrypoints/hass-icons.js @@ -1 +1 @@ -import "../resources/hass-icons.js"; +import "../resources/hass-icons"; diff --git a/src/entrypoints/onboarding.js b/src/entrypoints/onboarding.js index 256b61a7c84b..ab286de092f8 100644 --- a/src/entrypoints/onboarding.js +++ b/src/entrypoints/onboarding.js @@ -1,3 +1,3 @@ -import "../components/ha-iconset-svg.js"; -import "../resources/roboto.js"; -import "../onboarding/ha-onboarding.js"; +import "../components/ha-iconset-svg"; +import "../resources/roboto"; +import "../onboarding/ha-onboarding"; diff --git a/src/layouts/app/auth-mixin.js b/src/layouts/app/auth-mixin.js index 41452068f65d..daa86d9910e0 100644 --- a/src/layouts/app/auth-mixin.js +++ b/src/layouts/app/auth-mixin.js @@ -1,8 +1,8 @@ -import { afterNextRender } from "@polymer/polymer/lib/utils/render-status.js"; +import { afterNextRender } from "@polymer/polymer/lib/utils/render-status"; import { getUser } from "home-assistant-js-websocket"; -import { clearState } from "../../util/ha-pref-storage.js"; -import { askWrite } from "../../common/auth/token_storage.js"; -import { subscribeUser } from "../../data/ws-user.js"; +import { clearState } from "../../util/ha-pref-storage"; +import { askWrite } from "../../common/auth/token_storage"; +import { subscribeUser } from "../../data/ws-user"; export default (superClass) => class extends superClass { diff --git a/src/layouts/app/connection-mixin.js b/src/layouts/app/connection-mixin.js index e12b19bc33f1..222d1b4ea234 100644 --- a/src/layouts/app/connection-mixin.js +++ b/src/layouts/app/connection-mixin.js @@ -8,14 +8,14 @@ import { import translationMetadata from "../../../build-translations/translationMetadata.json"; -import LocalizeMixin from "../../mixins/localize-mixin.js"; -import EventsMixin from "../../mixins/events-mixin.js"; - -import { getState } from "../../util/ha-pref-storage.js"; -import { getActiveTranslation } from "../../util/hass-translation.js"; -import { fetchWithAuth } from "../../util/fetch-with-auth.js"; -import hassCallApi from "../../util/hass-call-api.js"; -import computeStateName from "../../common/entity/compute_state_name.js"; +import LocalizeMixin from "../../mixins/localize-mixin"; +import EventsMixin from "../../mixins/events-mixin"; + +import { getState } from "../../util/ha-pref-storage"; +import { getActiveTranslation } from "../../util/hass-translation"; +import { fetchWithAuth } from "../../util/fetch-with-auth"; +import hassCallApi from "../../util/hass-call-api"; +import computeStateName from "../../common/entity/compute_state_name"; import { subscribePanels } from "../../data/ws-panels"; export default (superClass) => diff --git a/src/layouts/app/disconnect-toast-mixin.js b/src/layouts/app/disconnect-toast-mixin.js index 0e0b5aaf00ef..b3f941881283 100644 --- a/src/layouts/app/disconnect-toast-mixin.js +++ b/src/layouts/app/disconnect-toast-mixin.js @@ -1,4 +1,4 @@ -import LocalizeMixin from "../../mixins/localize-mixin.js"; +import LocalizeMixin from "../../mixins/localize-mixin"; export default (superClass) => class extends LocalizeMixin(superClass) { diff --git a/src/layouts/app/home-assistant.js b/src/layouts/app/home-assistant.js index e3818099e33d..bf1a3e26777f 100644 --- a/src/layouts/app/home-assistant.js +++ b/src/layouts/app/home-assistant.js @@ -1,25 +1,25 @@ -import "@polymer/app-route/app-location.js"; -import "@polymer/app-route/app-route.js"; -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import { afterNextRender } from "@polymer/polymer/lib/utils/render-status.js"; +import "@polymer/app-route/app-location"; +import "@polymer/app-route/app-route"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import { afterNextRender } from "@polymer/polymer/lib/utils/render-status"; -import "../home-assistant-main.js"; -import "../ha-init-page.js"; -import "../../resources/ha-style.js"; -import registerServiceWorker from "../../util/register-service-worker.js"; +import "../home-assistant-main"; +import "../ha-init-page"; +import "../../resources/ha-style"; +import registerServiceWorker from "../../util/register-service-worker"; -import HassBaseMixin from "./hass-base-mixin.js"; -import AuthMixin from "./auth-mixin.js"; -import TranslationsMixin from "./translations-mixin.js"; -import ThemesMixin from "./themes-mixin.js"; -import MoreInfoMixin from "./more-info-mixin.js"; -import SidebarMixin from "./sidebar-mixin.js"; -import DialogManagerMixin from "./dialog-manager-mixin.js"; -import ConnectionMixin from "./connection-mixin.js"; -import NotificationMixin from "./notification-mixin.js"; -import DisconnectToastMixin from "./disconnect-toast-mixin.js"; +import HassBaseMixin from "./hass-base-mixin"; +import AuthMixin from "./auth-mixin"; +import TranslationsMixin from "./translations-mixin"; +import ThemesMixin from "./themes-mixin"; +import MoreInfoMixin from "./more-info-mixin"; +import SidebarMixin from "./sidebar-mixin"; +import DialogManagerMixin from "./dialog-manager-mixin"; +import ConnectionMixin from "./connection-mixin"; +import NotificationMixin from "./notification-mixin"; +import DisconnectToastMixin from "./disconnect-toast-mixin"; const ext = (baseClass, mixins) => mixins.reduceRight((base, mixin) => mixin(base), baseClass); diff --git a/src/layouts/app/more-info-mixin.js b/src/layouts/app/more-info-mixin.js index 1a373027e08f..02ea75d352ba 100644 --- a/src/layouts/app/more-info-mixin.js +++ b/src/layouts/app/more-info-mixin.js @@ -1,4 +1,4 @@ -import { afterNextRender } from "@polymer/polymer/lib/utils/render-status.js"; +import { afterNextRender } from "@polymer/polymer/lib/utils/render-status"; export default (superClass) => class extends superClass { diff --git a/src/layouts/app/sidebar-mixin.js b/src/layouts/app/sidebar-mixin.js index 304a4433c431..c0ff17804fcc 100644 --- a/src/layouts/app/sidebar-mixin.js +++ b/src/layouts/app/sidebar-mixin.js @@ -1,4 +1,4 @@ -import { storeState } from "../../util/ha-pref-storage.js"; +import { storeState } from "../../util/ha-pref-storage"; export default (superClass) => class extends superClass { diff --git a/src/layouts/app/themes-mixin.js b/src/layouts/app/themes-mixin.js index ff8f33b385c2..7698dc074638 100644 --- a/src/layouts/app/themes-mixin.js +++ b/src/layouts/app/themes-mixin.js @@ -1,6 +1,6 @@ -import applyThemesOnElement from "../../common/dom/apply_themes_on_element.js"; -import { storeState } from "../../util/ha-pref-storage.js"; -import { subscribeThemes } from "../../data/ws-themes.js"; +import applyThemesOnElement from "../../common/dom/apply_themes_on_element"; +import { storeState } from "../../util/ha-pref-storage"; +import { subscribeThemes } from "../../data/ws-themes"; export default (superClass) => class extends superClass { diff --git a/src/layouts/app/translations-mixin.js b/src/layouts/app/translations-mixin.js index a623aab06954..4414f2a03d13 100644 --- a/src/layouts/app/translations-mixin.js +++ b/src/layouts/app/translations-mixin.js @@ -1,7 +1,7 @@ import translationMetadata from "../../../build-translations/translationMetadata.json"; -import { getTranslation } from "../../util/hass-translation.js"; +import { getTranslation } from "../../util/hass-translation"; -import { storeState } from "../../util/ha-pref-storage.js"; +import { storeState } from "../../util/ha-pref-storage"; /* * superClass needs to contain `this.hass` and `this._updateHass`. diff --git a/src/layouts/ha-app-layout.js b/src/layouts/ha-app-layout.js index 712a08be56e7..3b2e0a12aa7e 100644 --- a/src/layouts/ha-app-layout.js +++ b/src/layouts/ha-app-layout.js @@ -17,9 +17,9 @@ transform: translate(0) is added. from HTML and may be out of place here. Review them and then delete this comment! */ -import "@polymer/app-layout/app-header-layout/app-header-layout.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import "@polymer/polymer/polymer-element.js"; +import "@polymer/app-layout/app-header-layout/app-header-layout"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import "@polymer/polymer/polymer-element"; class HaAppLayout extends customElements.get("app-header-layout") { static get template() { diff --git a/src/layouts/ha-init-page.js b/src/layouts/ha-init-page.js index c4d605bee277..893af7b40cf5 100644 --- a/src/layouts/ha-init-page.js +++ b/src/layouts/ha-init-page.js @@ -1,11 +1,11 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-spinner/paper-spinner.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-spinner/paper-spinner"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import LocalizeMixin from "../mixins/localize-mixin.js"; -import EventsMixin from "../mixins/events-mixin.js"; +import LocalizeMixin from "../mixins/localize-mixin"; +import EventsMixin from "../mixins/events-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/layouts/hass-error-screen.js b/src/layouts/hass-error-screen.js index e6177a962235..52e5ff97d394 100644 --- a/src/layouts/hass-error-screen.js +++ b/src/layouts/hass-error-screen.js @@ -1,8 +1,8 @@ -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-button/paper-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-button/paper-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class HassErrorScreen extends PolymerElement { static get template() { diff --git a/src/layouts/hass-loading-screen.js b/src/layouts/hass-loading-screen.js index d49f8e6153e0..fabd6b74dbfd 100644 --- a/src/layouts/hass-loading-screen.js +++ b/src/layouts/hass-loading-screen.js @@ -1,10 +1,10 @@ -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-spinner/paper-spinner.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-spinner/paper-spinner"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../components/ha-menu-button.js"; +import "../components/ha-menu-button"; class HassLoadingScreen extends PolymerElement { static get template() { diff --git a/src/layouts/hass-subpage.js b/src/layouts/hass-subpage.js index fca7ad8254f5..f36b57271c14 100644 --- a/src/layouts/hass-subpage.js +++ b/src/layouts/hass-subpage.js @@ -1,9 +1,9 @@ -import "@polymer/app-layout/app-header-layout/app-header-layout.js"; -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-layout/app-header-layout/app-header-layout"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class HassSubpage extends PolymerElement { static get template() { diff --git a/src/layouts/home-assistant-main.js b/src/layouts/home-assistant-main.js index c15c58ec6eb5..8eebd269b104 100644 --- a/src/layouts/home-assistant-main.js +++ b/src/layouts/home-assistant-main.js @@ -1,17 +1,17 @@ -import "@polymer/app-layout/app-drawer-layout/app-drawer-layout.js"; -import "@polymer/app-layout/app-drawer/app-drawer.js"; -import "@polymer/app-route/app-route.js"; -import "@polymer/iron-media-query/iron-media-query.js"; -import "@polymer/iron-pages/iron-pages.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../util/ha-url-sync.js"; - -import "./partial-cards.js"; -import "./partial-panel-resolver.js"; -import EventsMixin from "../mixins/events-mixin.js"; -import NavigateMixin from "../mixins/navigate-mixin.js"; +import "@polymer/app-layout/app-drawer-layout/app-drawer-layout"; +import "@polymer/app-layout/app-drawer/app-drawer"; +import "@polymer/app-route/app-route"; +import "@polymer/iron-media-query/iron-media-query"; +import "@polymer/iron-pages/iron-pages"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../util/ha-url-sync"; + +import "./partial-cards"; +import "./partial-panel-resolver"; +import EventsMixin from "../mixins/events-mixin"; +import NavigateMixin from "../mixins/navigate-mixin"; import(/* webpackChunkName: "ha-sidebar" */ "../components/ha-sidebar.js"); import(/* webpackChunkName: "voice-command-dialog" */ "../dialogs/ha-voice-command-dialog.js"); diff --git a/src/layouts/partial-cards.js b/src/layouts/partial-cards.js index c9c68a1c4063..bf0c6b807121 100644 --- a/src/layouts/partial-cards.js +++ b/src/layouts/partial-cards.js @@ -1,28 +1,28 @@ -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-scroll-effects/effects/waterfall.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/app-route/app-route.js"; -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/iron-pages/iron-pages.js"; -import "@polymer/paper-tabs/paper-tab.js"; -import "@polymer/paper-tabs/paper-tabs.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../components/ha-cards.js"; -import "../components/ha-icon.js"; -import "../components/ha-menu-button.js"; -import "../components/ha-start-voice-button.js"; - -import "./ha-app-layout.js"; - -import extractViews from "../common/entity/extract_views.js"; -import getViewEntities from "../common/entity/get_view_entities.js"; -import computeStateName from "../common/entity/compute_state_name.js"; -import computeStateDomain from "../common/entity/compute_state_domain.js"; -import computeLocationName from "../common/config/location_name.js"; -import NavigateMixin from "../mixins/navigate-mixin.js"; -import EventsMixin from "../mixins/events-mixin.js"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-scroll-effects/effects/waterfall"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/app-route/app-route"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/iron-pages/iron-pages"; +import "@polymer/paper-tabs/paper-tab"; +import "@polymer/paper-tabs/paper-tabs"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../components/ha-cards"; +import "../components/ha-icon"; +import "../components/ha-menu-button"; +import "../components/ha-start-voice-button"; + +import "./ha-app-layout"; + +import extractViews from "../common/entity/extract_views"; +import getViewEntities from "../common/entity/get_view_entities"; +import computeStateName from "../common/entity/compute_state_name"; +import computeStateDomain from "../common/entity/compute_state_domain"; +import computeLocationName from "../common/config/location_name"; +import NavigateMixin from "../mixins/navigate-mixin"; +import EventsMixin from "../mixins/events-mixin"; const DEFAULT_VIEW_ENTITY_ID = "group.default_view"; const ALWAYS_SHOW_DOMAIN = ["persistent_notification", "configurator"]; diff --git a/src/layouts/partial-panel-resolver.js b/src/layouts/partial-panel-resolver.js index 4a32702374f8..67014d3c3ad3 100644 --- a/src/layouts/partial-panel-resolver.js +++ b/src/layouts/partial-panel-resolver.js @@ -1,14 +1,14 @@ -import "@polymer/app-route/app-route.js"; -import { dom } from "@polymer/polymer/lib/legacy/polymer.dom.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-route/app-route"; +import { dom } from "@polymer/polymer/lib/legacy/polymer.dom"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./hass-loading-screen.js"; -import "./hass-error-screen.js"; +import "./hass-loading-screen"; +import "./hass-error-screen"; import { importHref } from "../resources/html-import/import-href"; -import dynamicContentUpdater from "../common/dom/dynamic_content_updater.js"; -import NavigateMixin from "../mixins/navigate-mixin.js"; +import dynamicContentUpdater from "../common/dom/dynamic_content_updater"; +import NavigateMixin from "../mixins/navigate-mixin"; const loaded = {}; diff --git a/src/managers/notification-manager.js b/src/managers/notification-manager.js index 727c29b99dc7..131d12082b3d 100644 --- a/src/managers/notification-manager.js +++ b/src/managers/notification-manager.js @@ -1,7 +1,7 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import LocalizeMixin from "../mixins/localize-mixin.js"; +import LocalizeMixin from "../mixins/localize-mixin"; class NotificationManager extends LocalizeMixin(PolymerElement) { static get template() { diff --git a/src/mixins/dialog-mixin.js b/src/mixins/dialog-mixin.js index 4acecbcc759b..61e6da06de43 100644 --- a/src/mixins/dialog-mixin.js +++ b/src/mixins/dialog-mixin.js @@ -1,6 +1,6 @@ -import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin.js"; -import { PaperDialogBehavior } from "@polymer/paper-dialog-behavior/paper-dialog-behavior.js"; -import { mixinBehaviors } from "@polymer/polymer/lib/legacy/class.js"; +import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin"; +import { PaperDialogBehavior } from "@polymer/paper-dialog-behavior/paper-dialog-behavior"; +import { mixinBehaviors } from "@polymer/polymer/lib/legacy/class"; import EventsMixin from "./events-mixin"; /** * @polymerMixin diff --git a/src/mixins/events-mixin.js b/src/mixins/events-mixin.js index 81cea3bfe40b..80b5d33e7d2c 100644 --- a/src/mixins/events-mixin.js +++ b/src/mixins/events-mixin.js @@ -1,6 +1,6 @@ -import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin.js"; +import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin"; -import { fireEvent } from "../common/dom/fire_event.js"; +import { fireEvent } from "../common/dom/fire_event"; // Polymer legacy event helpers used courtesy of the Polymer project. // diff --git a/src/mixins/localize-base-mixin.ts b/src/mixins/localize-base-mixin.ts index 9214c0d6f2ff..f7084902e8fd 100644 --- a/src/mixins/localize-base-mixin.ts +++ b/src/mixins/localize-base-mixin.ts @@ -1,4 +1,4 @@ -import IntlMessageFormat from "intl-messageformat/src/main.js"; +import IntlMessageFormat from "intl-messageformat/src/main"; /** * Adapted from Polymer app-localize-behavior. diff --git a/src/mixins/localize-lite-mixin.js b/src/mixins/localize-lite-mixin.js index 6f2aec4b962d..8df031b522ef 100644 --- a/src/mixins/localize-lite-mixin.js +++ b/src/mixins/localize-lite-mixin.js @@ -1,12 +1,9 @@ /** * Lite mixin to add localization without depending on the Hass object. */ -import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin.js"; +import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin"; import { localizeBaseMixin } from "./localize-base-mixin"; -import { - getActiveTranslation, - getTranslation, -} from "../util/hass-translation.js"; +import { getActiveTranslation, getTranslation } from "../util/hass-translation"; /** * @polymerMixin diff --git a/src/mixins/localize-mixin.js b/src/mixins/localize-mixin.js index 5928fb36db74..06884ddbcf70 100644 --- a/src/mixins/localize-mixin.js +++ b/src/mixins/localize-mixin.js @@ -1,4 +1,4 @@ -import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin.js"; +import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin"; import { localizeBaseMixin } from "./localize-base-mixin"; /** * Polymer Mixin to enable a localize function powered by language/resources from hass object. diff --git a/src/mixins/navigate-mixin.js b/src/mixins/navigate-mixin.js index c00a502b00a3..7b8764c65bfe 100644 --- a/src/mixins/navigate-mixin.js +++ b/src/mixins/navigate-mixin.js @@ -1,4 +1,4 @@ -import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin.js"; +import { dedupingMixin } from "@polymer/polymer/lib/utils/mixin"; import { navigate } from "../common/navigate"; /* diff --git a/src/onboarding/ha-onboarding.js b/src/onboarding/ha-onboarding.js index 8c5350ef7ab0..3a30c3c8c570 100644 --- a/src/onboarding/ha-onboarding.js +++ b/src/onboarding/ha-onboarding.js @@ -1,10 +1,10 @@ -import "@polymer/polymer/lib/elements/dom-if.js"; -import "@polymer/polymer/lib/elements/dom-repeat.js"; -import "@polymer/paper-input/paper-input.js"; -import "@polymer/paper-button/paper-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import localizeLiteMixin from "../mixins/localize-lite-mixin.js"; +import "@polymer/polymer/lib/elements/dom-if"; +import "@polymer/polymer/lib/elements/dom-repeat"; +import "@polymer/paper-input/paper-input"; +import "@polymer/paper-button/paper-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import localizeLiteMixin from "../mixins/localize-lite-mixin"; class HaOnboarding extends localizeLiteMixin(PolymerElement) { static get template() { diff --git a/src/panels/calendar/ha-big-calendar.js b/src/panels/calendar/ha-big-calendar.js index 50572a2ec2aa..80bf29598f4f 100644 --- a/src/panels/calendar/ha-big-calendar.js +++ b/src/panels/calendar/ha-big-calendar.js @@ -1,5 +1,5 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; /* eslint-disable */ import { render } from "react-dom"; @@ -7,9 +7,9 @@ import React from "react"; /* eslint-enable */ import BigCalendar from "react-big-calendar"; import moment from "moment"; -import EventsMixin from "../../mixins/events-mixin.js"; +import EventsMixin from "../../mixins/events-mixin"; -import "../../resources/ha-style.js"; +import "../../resources/ha-style"; BigCalendar.setLocalizer(BigCalendar.momentLocalizer(moment)); diff --git a/src/panels/calendar/ha-panel-calendar.js b/src/panels/calendar/ha-panel-calendar.js index 2c69f198f409..a806315c5486 100644 --- a/src/panels/calendar/ha-panel-calendar.js +++ b/src/panels/calendar/ha-panel-calendar.js @@ -1,20 +1,20 @@ -import "@polymer/app-layout/app-header-layout/app-header-layout.js"; -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-checkbox/paper-checkbox.js"; -import "@polymer/paper-item/paper-item.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-layout/app-header-layout/app-header-layout"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-listbox/paper-listbox"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-checkbox/paper-checkbox"; +import "@polymer/paper-item/paper-item"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; import moment from "moment"; import dates from "react-big-calendar/lib/utils/dates"; -import "../../components/ha-menu-button.js"; -import "../../resources/ha-style.js"; -import "./ha-big-calendar.js"; +import "../../components/ha-menu-button"; +import "../../resources/ha-style"; +import "./ha-big-calendar"; -import LocalizeMixin from "../../mixins/localize-mixin.js"; +import LocalizeMixin from "../../mixins/localize-mixin"; const DEFAULT_VIEW = "month"; diff --git a/src/panels/config/automation/ha-automation-editor.js b/src/panels/config/automation/ha-automation-editor.js index 047da257c9d0..35d3ee342541 100644 --- a/src/panels/config/automation/ha-automation-editor.js +++ b/src/panels/config/automation/ha-automation-editor.js @@ -1,19 +1,19 @@ -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-fab/paper-fab.js"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-fab/paper-fab"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; import { h, render } from "preact"; -import "../../../layouts/ha-app-layout.js"; +import "../../../layouts/ha-app-layout"; -import Automation from "../js/automation.js"; -import unmountPreact from "../../../common/preact/unmount.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import NavigateMixin from "../../../mixins/navigate-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import Automation from "../js/automation"; +import unmountPreact from "../../../common/preact/unmount"; +import computeStateName from "../../../common/entity/compute_state_name"; +import NavigateMixin from "../../../mixins/navigate-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; function AutomationEditor(mountEl, props, mergeEl) { return render(h(Automation, props), mountEl, mergeEl); diff --git a/src/panels/config/automation/ha-automation-picker.js b/src/panels/config/automation/ha-automation-picker.js index 6e8e234d26a2..c393ecff097d 100644 --- a/src/panels/config/automation/ha-automation-picker.js +++ b/src/panels/config/automation/ha-automation-picker.js @@ -1,21 +1,21 @@ -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-fab/paper-fab.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-item/paper-item-body.js"; -import "@polymer/paper-item/paper-item.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/ha-markdown.js"; -import "../../../layouts/ha-app-layout.js"; - -import "../ha-config-section.js"; - -import NavigateMixin from "../../../mixins/navigate-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-fab/paper-fab"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-item/paper-item-body"; +import "@polymer/paper-item/paper-item"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/ha-markdown"; +import "../../../layouts/ha-app-layout"; + +import "../ha-config-section"; + +import NavigateMixin from "../../../mixins/navigate-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; +import computeStateName from "../../../common/entity/compute_state_name"; /* * @appliesMixin LocalizeMixin * @appliesMixin NavigateMixin diff --git a/src/panels/config/automation/ha-config-automation.js b/src/panels/config/automation/ha-config-automation.js index 02dd8e59a4a6..f9bf17bc9ffa 100644 --- a/src/panels/config/automation/ha-config-automation.js +++ b/src/panels/config/automation/ha-config-automation.js @@ -1,11 +1,11 @@ -import "@polymer/app-route/app-route.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-route/app-route"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./ha-automation-editor.js"; -import "./ha-automation-picker.js"; +import "./ha-automation-editor"; +import "./ha-automation-picker"; -import computeStateDomain from "../../../common/entity/compute_state_domain.js"; +import computeStateDomain from "../../../common/entity/compute_state_domain"; class HaConfigAutomation extends PolymerElement { static get template() { diff --git a/src/panels/config/cloud/ha-config-cloud-account.js b/src/panels/config/cloud/ha-config-cloud-account.js index 8c5a0b634a61..3aabd609de62 100644 --- a/src/panels/config/cloud/ha-config-cloud-account.js +++ b/src/panels/config/cloud/ha-config-cloud-account.js @@ -1,19 +1,19 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-item/paper-item-body.js"; -import "@polymer/paper-toggle-button/paper-toggle-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/buttons/ha-call-api-button.js"; -import "../../../layouts/hass-subpage.js"; -import "../../../resources/ha-style.js"; - -import "../ha-config-section.js"; - -import formatDateTime from "../../../common/datetime/format_date_time.js"; -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-item/paper-item-body"; +import "@polymer/paper-toggle-button/paper-toggle-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/buttons/ha-call-api-button"; +import "../../../layouts/hass-subpage"; +import "../../../resources/ha-style"; + +import "../ha-config-section"; + +import formatDateTime from "../../../common/datetime/format_date_time"; +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/panels/config/cloud/ha-config-cloud-forgot-password.js b/src/panels/config/cloud/ha-config-cloud-forgot-password.js index bf7aa9c52e58..4d425785cdb6 100644 --- a/src/panels/config/cloud/ha-config-cloud-forgot-password.js +++ b/src/panels/config/cloud/ha-config-cloud-forgot-password.js @@ -1,12 +1,12 @@ -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-input/paper-input.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../components/buttons/ha-progress-button.js"; -import "../../../layouts/hass-subpage.js"; -import "../../../resources/ha-style.js"; -import EventsMixin from "../../../mixins/events-mixin.js"; +import "../../../components/buttons/ha-progress-button"; +import "../../../layouts/hass-subpage"; +import "../../../resources/ha-style"; +import EventsMixin from "../../../mixins/events-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/panels/config/cloud/ha-config-cloud-login.js b/src/panels/config/cloud/ha-config-cloud-login.js index 5f25789207b6..ed4230ef4fd2 100644 --- a/src/panels/config/cloud/ha-config-cloud-login.js +++ b/src/panels/config/cloud/ha-config-cloud-login.js @@ -1,20 +1,20 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-input/paper-input.js"; -import "@polymer/paper-item/paper-item-body.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-ripple/paper-ripple.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-input/paper-input"; +import "@polymer/paper-item/paper-item-body"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-ripple/paper-ripple"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../components/buttons/ha-progress-button.js"; -import "../../../layouts/hass-subpage.js"; -import "../../../resources/ha-style.js"; +import "../../../components/buttons/ha-progress-button"; +import "../../../layouts/hass-subpage"; +import "../../../resources/ha-style"; -import "../ha-config-section.js"; -import EventsMixin from "../../../mixins/events-mixin.js"; -import NavigateMixin from "../../../mixins/navigate-mixin.js"; +import "../ha-config-section"; +import EventsMixin from "../../../mixins/events-mixin"; +import NavigateMixin from "../../../mixins/navigate-mixin"; /* * @appliesMixin NavigateMixin diff --git a/src/panels/config/cloud/ha-config-cloud-register.js b/src/panels/config/cloud/ha-config-cloud-register.js index c0f6d4fea4ef..05c4f8982927 100644 --- a/src/panels/config/cloud/ha-config-cloud-register.js +++ b/src/panels/config/cloud/ha-config-cloud-register.js @@ -1,13 +1,13 @@ -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-input/paper-input.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/buttons/ha-progress-button.js"; -import "../../../layouts/hass-subpage.js"; -import "../../../resources/ha-style.js"; -import "../ha-config-section.js"; -import EventsMixin from "../../../mixins/events-mixin.js"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/buttons/ha-progress-button"; +import "../../../layouts/hass-subpage"; +import "../../../resources/ha-style"; +import "../ha-config-section"; +import EventsMixin from "../../../mixins/events-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/panels/config/cloud/ha-config-cloud.js b/src/panels/config/cloud/ha-config-cloud.js index ab0d85e9ee0a..62947dd828bd 100644 --- a/src/panels/config/cloud/ha-config-cloud.js +++ b/src/panels/config/cloud/ha-config-cloud.js @@ -1,15 +1,15 @@ -import "@polymer/app-route/app-route.js"; -import { timeOut } from "@polymer/polymer/lib/utils/async.js"; -import { Debouncer } from "@polymer/polymer/lib/utils/debounce.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../ha-config-section.js"; -import "./ha-config-cloud-account.js"; -import "./ha-config-cloud-forgot-password.js"; -import "./ha-config-cloud-login.js"; -import "./ha-config-cloud-register.js"; -import NavigateMixin from "../../../mixins/navigate-mixin.js"; +import "@polymer/app-route/app-route"; +import { timeOut } from "@polymer/polymer/lib/utils/async"; +import { Debouncer } from "@polymer/polymer/lib/utils/debounce"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../ha-config-section"; +import "./ha-config-cloud-account"; +import "./ha-config-cloud-forgot-password"; +import "./ha-config-cloud-login"; +import "./ha-config-cloud-register"; +import NavigateMixin from "../../../mixins/navigate-mixin"; const LOGGED_IN_URLS = ["/cloud/account"]; const NOT_LOGGED_IN_URLS = [ diff --git a/src/panels/config/config-entries/ha-ce-entities-card.js b/src/panels/config/config-entries/ha-ce-entities-card.js index 78719c584add..9f4faafa169a 100644 --- a/src/panels/config/config-entries/ha-ce-entities-card.js +++ b/src/panels/config/config-entries/ha-ce-entities-card.js @@ -1,15 +1,15 @@ -import "@polymer/paper-item/paper-icon-item.js"; -import "@polymer/paper-item/paper-item-body.js"; -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-item/paper-icon-item"; +import "@polymer/paper-item/paper-item-body"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../layouts/hass-subpage.js"; +import "../../../layouts/hass-subpage"; -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixIn from "../../../mixins/localize-mixin.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import "../../../components/entity/state-badge.js"; +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixIn from "../../../mixins/localize-mixin"; +import computeStateName from "../../../common/entity/compute_state_name"; +import "../../../components/entity/state-badge"; function computeEntityName(hass, entity) { if (entity.name) return entity.name; diff --git a/src/panels/config/config-entries/ha-config-entries-dashboard.js b/src/panels/config/config-entries/ha-config-entries-dashboard.js index 1149e6ddbfbd..172e82e626e3 100644 --- a/src/panels/config/config-entries/ha-config-entries-dashboard.js +++ b/src/panels/config/config-entries/ha-config-entries-dashboard.js @@ -1,21 +1,21 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes.js"; -import "@polymer/paper-tooltip/paper-tooltip.js"; -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/iron-icon/iron-icon.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-item/paper-item-body.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/entity/ha-state-icon.js"; -import "../../../layouts/hass-subpage.js"; -import "../../../resources/ha-style.js"; - -import "../ha-config-section.js"; -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; +import "@polymer/iron-flex-layout/iron-flex-layout-classes"; +import "@polymer/paper-tooltip/paper-tooltip"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import "@polymer/iron-icon/iron-icon"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-item/paper-item-body"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/entity/ha-state-icon"; +import "../../../layouts/hass-subpage"; +import "../../../resources/ha-style"; + +import "../ha-config-section"; +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; +import computeStateName from "../../../common/entity/compute_state_name"; let registeredDialog = false; diff --git a/src/panels/config/config-entries/ha-config-entries.js b/src/panels/config/config-entries/ha-config-entries.js index 85804246f340..0826e0fed2ab 100644 --- a/src/panels/config/config-entries/ha-config-entries.js +++ b/src/panels/config/config-entries/ha-config-entries.js @@ -1,13 +1,13 @@ -import "@polymer/app-route/app-route.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; -import { Debouncer } from "@polymer/polymer/lib/utils/debounce.js"; -import { timeOut } from "@polymer/polymer/lib/utils/async.js"; - -import "./ha-config-entries-dashboard.js"; -import "./ha-config-entry-page.js"; -import NavigateMixin from "../../../mixins/navigate-mixin.js"; -import compare from "../../../common/string/compare.js"; +import "@polymer/app-route/app-route"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; +import { Debouncer } from "@polymer/polymer/lib/utils/debounce"; +import { timeOut } from "@polymer/polymer/lib/utils/async"; + +import "./ha-config-entries-dashboard"; +import "./ha-config-entry-page"; +import NavigateMixin from "../../../mixins/navigate-mixin"; +import compare from "../../../common/string/compare"; class HaConfigEntries extends NavigateMixin(PolymerElement) { static get template() { diff --git a/src/panels/config/config-entries/ha-config-entry-page.js b/src/panels/config/config-entries/ha-config-entry-page.js index 676568365c95..7ba95bcf4586 100644 --- a/src/panels/config/config-entries/ha-config-entry-page.js +++ b/src/panels/config/config-entries/ha-config-entry-page.js @@ -1,17 +1,17 @@ -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../layouts/hass-subpage.js"; +import "../../../layouts/hass-subpage"; -import "../../../components/entity/state-badge.js"; -import compare from "../../../common/string/compare.js"; +import "../../../components/entity/state-badge"; +import compare from "../../../common/string/compare"; -import "./ha-device-card.js"; -import "./ha-ce-entities-card.js"; -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; -import NavigateMixin from "../../../mixins/navigate-mixin.js"; +import "./ha-device-card"; +import "./ha-ce-entities-card"; +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; +import NavigateMixin from "../../../mixins/navigate-mixin"; class HaConfigEntryPage extends NavigateMixin( EventsMixin(LocalizeMixin(PolymerElement)) diff --git a/src/panels/config/config-entries/ha-config-flow.js b/src/panels/config/config-entries/ha-config-flow.js index e60ac2338c45..94a1a3bac4c7 100644 --- a/src/panels/config/config-entries/ha-config-flow.js +++ b/src/panels/config/config-entries/ha-config-flow.js @@ -1,17 +1,17 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable.js"; -import "@polymer/paper-dialog/paper-dialog.js"; -import "@polymer/paper-tooltip/paper-tooltip.js"; -import "@polymer/paper-spinner/paper-spinner.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/ha-form.js"; -import "../../../components/ha-markdown.js"; -import "../../../resources/ha-style.js"; - -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable"; +import "@polymer/paper-dialog/paper-dialog"; +import "@polymer/paper-tooltip/paper-tooltip"; +import "@polymer/paper-spinner/paper-spinner"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/ha-form"; +import "../../../components/ha-markdown"; +import "../../../resources/ha-style"; + +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; let instance = 0; diff --git a/src/panels/config/config-entries/ha-device-card.js b/src/panels/config/config-entries/ha-device-card.js index 40c45246f9e3..4b4ffd541396 100644 --- a/src/panels/config/config-entries/ha-device-card.js +++ b/src/panels/config/config-entries/ha-device-card.js @@ -1,16 +1,16 @@ -import "@polymer/paper-item/paper-icon-item.js"; -import "@polymer/paper-item/paper-item-body.js"; -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-item/paper-icon-item"; +import "@polymer/paper-item/paper-item-body"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../layouts/hass-subpage.js"; +import "../../../layouts/hass-subpage"; -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import "../../../components/entity/state-badge.js"; -import compare from "../../../common/string/compare.js"; +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; +import computeStateName from "../../../common/entity/compute_state_name"; +import "../../../components/entity/state-badge"; +import compare from "../../../common/string/compare"; function computeEntityName(hass, entity) { if (entity.name) return entity.name; diff --git a/src/panels/config/core/ha-config-core.js b/src/panels/config/core/ha-config-core.js index 1d3bae2b2501..1a960b6abfcc 100644 --- a/src/panels/config/core/ha-config-core.js +++ b/src/panels/config/core/ha-config-core.js @@ -1,15 +1,15 @@ -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../layouts/hass-subpage.js"; -import "../../../resources/ha-style.js"; +import "../../../layouts/hass-subpage"; +import "../../../resources/ha-style"; -import "./ha-config-section-core.js"; +import "./ha-config-section-core"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import LocalizeMixin from "../../../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/panels/config/core/ha-config-section-core.js b/src/panels/config/core/ha-config-section-core.js index 946b5699b5d5..c70d767e08ea 100644 --- a/src/panels/config/core/ha-config-section-core.js +++ b/src/panels/config/core/ha-config-section-core.js @@ -1,16 +1,16 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-input/paper-input.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../components/buttons/ha-call-service-button.js"; -import "../../../resources/ha-style.js"; +import "../../../components/buttons/ha-call-service-button"; +import "../../../resources/ha-style"; -import "../ha-config-section.js"; +import "../ha-config-section"; -import isComponentLoaded from "../../../common/config/is_component_loaded.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import isComponentLoaded from "../../../common/config/is_component_loaded"; +import LocalizeMixin from "../../../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/panels/config/customize/ha-config-customize.js b/src/panels/config/customize/ha-config-customize.js index 965891df1d73..d37674ed6478 100644 --- a/src/panels/config/customize/ha-config-customize.js +++ b/src/panels/config/customize/ha-config-customize.js @@ -1,20 +1,20 @@ -import "@polymer/app-layout/app-header-layout/app-header-layout.js"; -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-layout/app-header-layout/app-header-layout"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../resources/ha-style.js"; +import "../../../resources/ha-style"; -import "../ha-config-section.js"; -import "../ha-entity-config.js"; -import "./ha-form-customize.js"; +import "../ha-config-section"; +import "../ha-entity-config"; +import "./ha-form-customize"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import computeStateDomain from "../../../common/entity/compute_state_domain.js"; -import sortByName from "../../../common/entity/states_sort_by_name.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import computeStateName from "../../../common/entity/compute_state_name"; +import computeStateDomain from "../../../common/entity/compute_state_domain"; +import sortByName from "../../../common/entity/states_sort_by_name"; +import LocalizeMixin from "../../../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/panels/config/customize/ha-customize-attribute.js b/src/panels/config/customize/ha-customize-attribute.js index dda62ab8131d..072e649a9a9a 100644 --- a/src/panels/config/customize/ha-customize-attribute.js +++ b/src/panels/config/customize/ha-customize-attribute.js @@ -1,14 +1,14 @@ -import "@polymer/paper-icon-button/paper-icon-button.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-icon-button/paper-icon-button"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import hassAttributeUtil from "../../../util/hass-attributes-util.js"; -import "../ha-form-style.js"; -import "./types/ha-customize-array.js"; -import "./types/ha-customize-boolean.js"; -import "./types/ha-customize-icon.js"; -import "./types/ha-customize-key-value.js"; -import "./types/ha-customize-string.js"; +import hassAttributeUtil from "../../../util/hass-attributes-util"; +import "../ha-form-style"; +import "./types/ha-customize-array"; +import "./types/ha-customize-boolean"; +import "./types/ha-customize-icon"; +import "./types/ha-customize-key-value"; +import "./types/ha-customize-string"; class HaCustomizeAttribute extends PolymerElement { static get template() { diff --git a/src/panels/config/customize/ha-form-customize-attributes.js b/src/panels/config/customize/ha-form-customize-attributes.js index a6d19e1db7ea..d572a67faa7c 100644 --- a/src/panels/config/customize/ha-form-customize-attributes.js +++ b/src/panels/config/customize/ha-form-customize-attributes.js @@ -1,8 +1,8 @@ -import { MutableData } from "@polymer/polymer/lib/mixins/mutable-data.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { MutableData } from "@polymer/polymer/lib/mixins/mutable-data"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./ha-customize-attribute.js"; +import "./ha-customize-attribute"; class HaFormCustomizeAttributes extends MutableData(PolymerElement) { static get template() { diff --git a/src/panels/config/customize/ha-form-customize.js b/src/panels/config/customize/ha-form-customize.js index cf79fc85f262..d3f51377b9bb 100644 --- a/src/panels/config/customize/ha-form-customize.js +++ b/src/panels/config/customize/ha-form-customize.js @@ -1,11 +1,11 @@ -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import hassAttributeUtil from "../../../util/hass-attributes-util.js"; -import "./ha-form-customize-attributes.js"; +import hassAttributeUtil from "../../../util/hass-attributes-util"; +import "./ha-form-customize-attributes"; import computeStateDomain from "../../../common/entity/compute_state_domain"; diff --git a/src/panels/config/customize/types/ha-customize-array.js b/src/panels/config/customize/types/ha-customize-array.js index 2401fa677262..dc1eb05128ff 100644 --- a/src/panels/config/customize/types/ha-customize-array.js +++ b/src/panels/config/customize/types/ha-customize-array.js @@ -1,10 +1,10 @@ -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import EventsMixin from "../../../../mixins/events-mixin.js"; +import EventsMixin from "../../../../mixins/events-mixin"; /* * @appliesMixin EventsMixin diff --git a/src/panels/config/customize/types/ha-customize-boolean.js b/src/panels/config/customize/types/ha-customize-boolean.js index a9f0049d6ffb..d85892892e01 100644 --- a/src/panels/config/customize/types/ha-customize-boolean.js +++ b/src/panels/config/customize/types/ha-customize-boolean.js @@ -1,6 +1,6 @@ -import "@polymer/paper-checkbox/paper-checkbox.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-checkbox/paper-checkbox"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class HaCustomizeBoolean extends PolymerElement { static get template() { diff --git a/src/panels/config/customize/types/ha-customize-icon.js b/src/panels/config/customize/types/ha-customize-icon.js index 81bf8a23ecd2..da9547db2c73 100644 --- a/src/panels/config/customize/types/ha-customize-icon.js +++ b/src/panels/config/customize/types/ha-customize-icon.js @@ -1,7 +1,7 @@ -import "@polymer/iron-icon/iron-icon.js"; -import "@polymer/paper-input/paper-input.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-icon/iron-icon"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class HaCustomizeIcon extends PolymerElement { static get template() { diff --git a/src/panels/config/customize/types/ha-customize-key-value.js b/src/panels/config/customize/types/ha-customize-key-value.js index a540a6fcb64a..d572cd8a1867 100644 --- a/src/panels/config/customize/types/ha-customize-key-value.js +++ b/src/panels/config/customize/types/ha-customize-key-value.js @@ -1,6 +1,6 @@ -import "@polymer/paper-input/paper-input.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class HaCustomizeKeyValue extends PolymerElement { static get template() { diff --git a/src/panels/config/customize/types/ha-customize-string.js b/src/panels/config/customize/types/ha-customize-string.js index 8fab122a8a84..845f9e10d206 100644 --- a/src/panels/config/customize/types/ha-customize-string.js +++ b/src/panels/config/customize/types/ha-customize-string.js @@ -1,6 +1,6 @@ -import "@polymer/paper-input/paper-input.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-input/paper-input"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; class HaCustomizeString extends PolymerElement { static get template() { diff --git a/src/panels/config/dashboard/ha-config-dashboard.js b/src/panels/config/dashboard/ha-config-dashboard.js index 56da4e2fb842..f6338ba5f9f2 100644 --- a/src/panels/config/dashboard/ha-config-dashboard.js +++ b/src/panels/config/dashboard/ha-config-dashboard.js @@ -1,21 +1,21 @@ -import "@polymer/app-layout/app-header-layout/app-header-layout.js"; -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/iron-icon/iron-icon.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-item/paper-item-body.js"; -import "@polymer/paper-item/paper-item.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-layout/app-header-layout/app-header-layout"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/iron-icon/iron-icon"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-item/paper-item-body"; +import "@polymer/paper-item/paper-item"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../components/ha-menu-button.js"; +import "../../../components/ha-menu-button"; -import "../ha-config-section.js"; -import "./ha-config-navigation.js"; +import "../ha-config-section"; +import "./ha-config-navigation"; -import isComponentLoaded from "../../../common/config/is_component_loaded.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; -import NavigateMixin from "../../../mixins/navigate-mixin.js"; +import isComponentLoaded from "../../../common/config/is_component_loaded"; +import LocalizeMixin from "../../../mixins/localize-mixin"; +import NavigateMixin from "../../../mixins/navigate-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/panels/config/dashboard/ha-config-navigation.js b/src/panels/config/dashboard/ha-config-navigation.js index fb559abd6d3d..c419b1171530 100644 --- a/src/panels/config/dashboard/ha-config-navigation.js +++ b/src/panels/config/dashboard/ha-config-navigation.js @@ -1,14 +1,14 @@ -import "@polymer/iron-icon/iron-icon.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-item/paper-item-body.js"; -import "@polymer/paper-item/paper-item.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/iron-icon/iron-icon"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-item/paper-item-body"; +import "@polymer/paper-item/paper-item"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import NavigateMixin from "../../../mixins/navigate-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import NavigateMixin from "../../../mixins/navigate-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; -import isComponentLoaded from "../../../common/config/is_component_loaded.js"; +import isComponentLoaded from "../../../common/config/is_component_loaded"; const CORE_PAGES = ["core", "customize"]; /* diff --git a/src/panels/config/ha-config-section.js b/src/panels/config/ha-config-section.js index 12f00b4a56bb..7ceeaebc2305 100644 --- a/src/panels/config/ha-config-section.js +++ b/src/panels/config/ha-config-section.js @@ -1,7 +1,7 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../resources/ha-style.js"; +import "../../resources/ha-style"; class HaConfigSection extends PolymerElement { static get template() { diff --git a/src/panels/config/ha-entity-config.js b/src/panels/config/ha-entity-config.js index 5696241c7e13..235ddb8c0ef2 100644 --- a/src/panels/config/ha-entity-config.js +++ b/src/panels/config/ha-entity-config.js @@ -1,13 +1,13 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import "@polymer/paper-spinner/paper-spinner.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import computeStateName from "../../common/entity/compute_state_name.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import "@polymer/paper-spinner/paper-spinner"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import computeStateName from "../../common/entity/compute_state_name"; class HaEntityConfig extends PolymerElement { static get template() { diff --git a/src/panels/config/ha-panel-config.js b/src/panels/config/ha-panel-config.js index eb840836892e..c7e1ebba34cd 100644 --- a/src/panels/config/ha-panel-config.js +++ b/src/panels/config/ha-panel-config.js @@ -1,13 +1,13 @@ -import "@polymer/app-route/app-route.js"; -import "@polymer/iron-media-query/iron-media-query.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-route/app-route"; +import "@polymer/iron-media-query/iron-media-query"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../layouts/hass-error-screen.js"; +import "../../layouts/hass-error-screen"; -import isComponentLoaded from "../../common/config/is_component_loaded.js"; -import EventsMixin from "../../mixins/events-mixin.js"; -import NavigateMixin from "../../mixins/navigate-mixin.js"; +import isComponentLoaded from "../../common/config/is_component_loaded"; +import EventsMixin from "../../mixins/events-mixin"; +import NavigateMixin from "../../mixins/navigate-mixin"; import(/* webpackChunkName: "panel-config-automation" */ "./automation/ha-config-automation.js"); import(/* webpackChunkName: "panel-config-cloud" */ "./cloud/ha-config-cloud.js"); diff --git a/src/panels/config/js/automation.js b/src/panels/config/js/automation.js index 515bc6804bdc..4c16a8cf52cb 100644 --- a/src/panels/config/js/automation.js +++ b/src/panels/config/js/automation.js @@ -1,13 +1,13 @@ import { h, Component } from "preact"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-input/paper-input.js"; -import "../ha-config-section.js"; -import "../../../components/ha-markdown.js"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-input/paper-input"; +import "../ha-config-section"; +import "../../../components/ha-markdown"; -import Trigger from "./trigger/index.js"; -import Condition from "./condition/index.js"; -import Script from "./script/index.js"; +import Trigger from "./trigger/index"; +import Condition from "./condition/index"; +import Script from "./script/index"; export default class Automation extends Component { constructor() { diff --git a/src/panels/config/js/condition/condition_edit.js b/src/panels/config/js/condition/condition_edit.js index 362455ea53ed..3012aca88590 100644 --- a/src/panels/config/js/condition/condition_edit.js +++ b/src/panels/config/js/condition/condition_edit.js @@ -1,14 +1,14 @@ import { h, Component } from "preact"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import "@polymer/paper-item/paper-item.js"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light"; +import "@polymer/paper-listbox/paper-listbox"; +import "@polymer/paper-item/paper-item"; -import NumericStateCondition from "./numeric_state.js"; -import StateCondition from "./state.js"; -import SunCondition from "./sun.js"; -import TemplateCondition from "./template.js"; -import TimeCondition from "./time.js"; -import ZoneCondition from "./zone.js"; +import NumericStateCondition from "./numeric_state"; +import StateCondition from "./state"; +import SunCondition from "./sun"; +import TemplateCondition from "./template"; +import TimeCondition from "./time"; +import ZoneCondition from "./zone"; const TYPES = { state: StateCondition, diff --git a/src/panels/config/js/condition/condition_row.js b/src/panels/config/js/condition/condition_row.js index 7767a4be020f..b518af93bc1f 100644 --- a/src/panels/config/js/condition/condition_row.js +++ b/src/panels/config/js/condition/condition_row.js @@ -1,11 +1,11 @@ import { h, Component } from "preact"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-menu-button/paper-menu-button.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import "@polymer/paper-item/paper-item.js"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-menu-button/paper-menu-button"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-listbox/paper-listbox"; +import "@polymer/paper-item/paper-item"; -import ConditionEdit from "./condition_edit.js"; +import ConditionEdit from "./condition_edit"; export default class ConditionRow extends Component { constructor() { diff --git a/src/panels/config/js/condition/index.js b/src/panels/config/js/condition/index.js index 1dff74c1d99b..b568c9e63ec7 100644 --- a/src/panels/config/js/condition/index.js +++ b/src/panels/config/js/condition/index.js @@ -1,8 +1,8 @@ import { h, Component } from "preact"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-button/paper-button.js"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-button/paper-button"; -import ConditionRow from "./condition_row.js"; +import ConditionRow from "./condition_row"; export default class Condition extends Component { constructor() { diff --git a/src/panels/config/js/condition/numeric_state.js b/src/panels/config/js/condition/numeric_state.js index 0e3dd10ccaa4..abb01edc4d09 100644 --- a/src/panels/config/js/condition/numeric_state.js +++ b/src/panels/config/js/condition/numeric_state.js @@ -1,9 +1,9 @@ import { h, Component } from "preact"; -import "@polymer/paper-input/paper-input.js"; -import "../../../../components/ha-textarea.js"; -import "../../../../components/entity/ha-entity-picker.js"; +import "@polymer/paper-input/paper-input"; +import "../../../../components/ha-textarea"; +import "../../../../components/entity/ha-entity-picker"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class NumericStateCondition extends Component { constructor() { diff --git a/src/panels/config/js/condition/state.js b/src/panels/config/js/condition/state.js index 1968283bfe13..4249ef60cd23 100644 --- a/src/panels/config/js/condition/state.js +++ b/src/panels/config/js/condition/state.js @@ -1,8 +1,8 @@ import { h, Component } from "preact"; -import "@polymer/paper-input/paper-input.js"; -import "../../../../components/entity/ha-entity-picker.js"; +import "@polymer/paper-input/paper-input"; +import "../../../../components/entity/ha-entity-picker"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class StateCondition extends Component { constructor() { diff --git a/src/panels/config/js/condition/sun.js b/src/panels/config/js/condition/sun.js index 5ec8bce6b1a1..793a91af5287 100644 --- a/src/panels/config/js/condition/sun.js +++ b/src/panels/config/js/condition/sun.js @@ -1,9 +1,9 @@ import { h, Component } from "preact"; -import "@polymer/paper-input/paper-input.js"; -import "@polymer/paper-radio-button/paper-radio-button.js"; -import "@polymer/paper-radio-group/paper-radio-group.js"; +import "@polymer/paper-input/paper-input"; +import "@polymer/paper-radio-button/paper-radio-button"; +import "@polymer/paper-radio-group/paper-radio-group"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class SunCondition extends Component { constructor() { diff --git a/src/panels/config/js/condition/template.js b/src/panels/config/js/condition/template.js index 1d2f4e64bb77..ba4fc00ba3e5 100644 --- a/src/panels/config/js/condition/template.js +++ b/src/panels/config/js/condition/template.js @@ -1,7 +1,7 @@ import { h, Component } from "preact"; -import "../../../../components/ha-textarea.js"; +import "../../../../components/ha-textarea"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class TemplateCondition extends Component { constructor() { diff --git a/src/panels/config/js/condition/time.js b/src/panels/config/js/condition/time.js index d3f19f1b4b5d..269b3dad8b82 100644 --- a/src/panels/config/js/condition/time.js +++ b/src/panels/config/js/condition/time.js @@ -1,7 +1,7 @@ import { h, Component } from "preact"; -import "@polymer/paper-input/paper-input.js"; +import "@polymer/paper-input/paper-input"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class TimeCondition extends Component { constructor() { diff --git a/src/panels/config/js/condition/zone.js b/src/panels/config/js/condition/zone.js index f2ffa0fe850b..a09ae77e2ad3 100644 --- a/src/panels/config/js/condition/zone.js +++ b/src/panels/config/js/condition/zone.js @@ -1,8 +1,8 @@ import { h, Component } from "preact"; -import "../../../../components/entity/ha-entity-picker.js"; -import { onChangeEvent } from "../../../../common/preact/event.js"; -import hasLocation from "../../../../common/entity/has_location.js"; -import computeStateDomain from "../../../../common/entity/compute_state_domain.js"; +import "../../../../components/entity/ha-entity-picker"; +import { onChangeEvent } from "../../../../common/preact/event"; +import hasLocation from "../../../../common/entity/has_location"; +import computeStateDomain from "../../../../common/entity/compute_state_domain"; function zoneAndLocationFilter(stateObj) { return hasLocation(stateObj) && computeStateDomain(stateObj) !== "zone"; diff --git a/src/panels/config/js/json_textarea.js b/src/panels/config/js/json_textarea.js index d3e0da263284..5903673522cb 100644 --- a/src/panels/config/js/json_textarea.js +++ b/src/panels/config/js/json_textarea.js @@ -1,5 +1,5 @@ import { h, Component } from "preact"; -import "../../../components/ha-textarea.js"; +import "../../../components/ha-textarea"; export default class JSONTextArea extends Component { constructor(props) { diff --git a/src/panels/config/js/script.js b/src/panels/config/js/script.js index 21dc481e6883..cca985573ab2 100644 --- a/src/panels/config/js/script.js +++ b/src/panels/config/js/script.js @@ -1,10 +1,10 @@ import { h, Component } from "preact"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-input/paper-input.js"; -import "../ha-config-section.js"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-input/paper-input"; +import "../ha-config-section"; -import Script from "./script/index.js"; +import Script from "./script/index"; export default class ScriptEditor extends Component { constructor() { diff --git a/src/panels/config/js/script/action_edit.js b/src/panels/config/js/script/action_edit.js index 53ffa2a6de26..b114ab512e1b 100644 --- a/src/panels/config/js/script/action_edit.js +++ b/src/panels/config/js/script/action_edit.js @@ -1,13 +1,13 @@ import { h, Component } from "preact"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import "@polymer/paper-item/paper-item.js"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light"; +import "@polymer/paper-listbox/paper-listbox"; +import "@polymer/paper-item/paper-item"; -import CallServiceAction from "./call_service.js"; -import ConditionAction from "./condition.js"; -import DelayAction from "./delay.js"; -import EventAction from "./event.js"; -import WaitAction from "./wait.js"; +import CallServiceAction from "./call_service"; +import ConditionAction from "./condition"; +import DelayAction from "./delay"; +import EventAction from "./event"; +import WaitAction from "./wait"; const TYPES = { service: CallServiceAction, diff --git a/src/panels/config/js/script/action_row.js b/src/panels/config/js/script/action_row.js index 9b9c1bc5b921..a83bbaa9ccef 100644 --- a/src/panels/config/js/script/action_row.js +++ b/src/panels/config/js/script/action_row.js @@ -1,11 +1,11 @@ import { h, Component } from "preact"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-menu-button/paper-menu-button.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-menu-button/paper-menu-button"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; -import ActionEdit from "./action_edit.js"; +import ActionEdit from "./action_edit"; export default class Action extends Component { constructor() { diff --git a/src/panels/config/js/script/call_service.js b/src/panels/config/js/script/call_service.js index ea6f793d895a..0584e9cc3cda 100644 --- a/src/panels/config/js/script/call_service.js +++ b/src/panels/config/js/script/call_service.js @@ -1,7 +1,7 @@ import { h, Component } from "preact"; -import "../../../../components/ha-service-picker.js"; +import "../../../../components/ha-service-picker"; -import JSONTextArea from "../json_textarea.js"; +import JSONTextArea from "../json_textarea"; export default class CallServiceAction extends Component { constructor() { diff --git a/src/panels/config/js/script/condition.js b/src/panels/config/js/script/condition.js index b15ffb84448d..01421c930617 100644 --- a/src/panels/config/js/script/condition.js +++ b/src/panels/config/js/script/condition.js @@ -1,7 +1,7 @@ import { h, Component } from "preact"; -import StateCondition from "../condition/state.js"; -import ConditionEdit from "../condition/condition_edit.js"; +import StateCondition from "../condition/state"; +import ConditionEdit from "../condition/condition_edit"; export default class ConditionAction extends Component { // eslint-disable-next-line diff --git a/src/panels/config/js/script/delay.js b/src/panels/config/js/script/delay.js index a14ff39e0983..0fbfcda90d21 100644 --- a/src/panels/config/js/script/delay.js +++ b/src/panels/config/js/script/delay.js @@ -1,6 +1,6 @@ import { h, Component } from "preact"; -import "@polymer/paper-input/paper-input.js"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import "@polymer/paper-input/paper-input"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class DelayAction extends Component { constructor() { diff --git a/src/panels/config/js/script/event.js b/src/panels/config/js/script/event.js index 9d53ed6236c4..f11eb12170ae 100644 --- a/src/panels/config/js/script/event.js +++ b/src/panels/config/js/script/event.js @@ -1,8 +1,8 @@ import { h, Component } from "preact"; -import "@polymer/paper-input/paper-input.js"; +import "@polymer/paper-input/paper-input"; -import JSONTextArea from "../json_textarea.js"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import JSONTextArea from "../json_textarea"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class EventAction extends Component { constructor() { diff --git a/src/panels/config/js/script/index.js b/src/panels/config/js/script/index.js index bf0eaf6cb557..1874115c530a 100644 --- a/src/panels/config/js/script/index.js +++ b/src/panels/config/js/script/index.js @@ -1,8 +1,8 @@ import { h, Component } from "preact"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-button/paper-button.js"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-button/paper-button"; -import ActionRow from "./action_row.js"; +import ActionRow from "./action_row"; export default class Script extends Component { constructor() { diff --git a/src/panels/config/js/script/wait.js b/src/panels/config/js/script/wait.js index ce258afa79f9..9691d92a0f80 100644 --- a/src/panels/config/js/script/wait.js +++ b/src/panels/config/js/script/wait.js @@ -1,9 +1,9 @@ import { h, Component } from "preact"; -import "@polymer/paper-input/paper-input.js"; +import "@polymer/paper-input/paper-input"; -import "../../../../components/ha-textarea.js"; +import "../../../../components/ha-textarea"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class WaitAction extends Component { constructor() { diff --git a/src/panels/config/js/trigger/event.js b/src/panels/config/js/trigger/event.js index 2f9cb07b34a3..c41a2faf1c4b 100644 --- a/src/panels/config/js/trigger/event.js +++ b/src/panels/config/js/trigger/event.js @@ -1,8 +1,8 @@ import { h, Component } from "preact"; -import "@polymer/paper-input/paper-input.js"; +import "@polymer/paper-input/paper-input"; -import JSONTextArea from "../json_textarea.js"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import JSONTextArea from "../json_textarea"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class EventTrigger extends Component { constructor() { diff --git a/src/panels/config/js/trigger/homeassistant.js b/src/panels/config/js/trigger/homeassistant.js index 90ecc31b64cb..732a5499875e 100644 --- a/src/panels/config/js/trigger/homeassistant.js +++ b/src/panels/config/js/trigger/homeassistant.js @@ -1,6 +1,6 @@ import { h, Component } from "preact"; -import "@polymer/paper-radio-button/paper-radio-button.js"; -import "@polymer/paper-radio-group/paper-radio-group.js"; +import "@polymer/paper-radio-button/paper-radio-button"; +import "@polymer/paper-radio-group/paper-radio-group"; export default class HassTrigger extends Component { constructor() { diff --git a/src/panels/config/js/trigger/index.js b/src/panels/config/js/trigger/index.js index aa160bc625e7..6ae1411d16cd 100644 --- a/src/panels/config/js/trigger/index.js +++ b/src/panels/config/js/trigger/index.js @@ -1,9 +1,9 @@ import { h, Component } from "preact"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-button/paper-button.js"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-button/paper-button"; -import TriggerRow from "./trigger_row.js"; -import StateTrigger from "./state.js"; +import TriggerRow from "./trigger_row"; +import StateTrigger from "./state"; export default class Trigger extends Component { constructor() { diff --git a/src/panels/config/js/trigger/mqtt.js b/src/panels/config/js/trigger/mqtt.js index 9dfd9945e003..f59c7618f573 100644 --- a/src/panels/config/js/trigger/mqtt.js +++ b/src/panels/config/js/trigger/mqtt.js @@ -1,7 +1,7 @@ import { h, Component } from "preact"; -import "@polymer/paper-input/paper-input.js"; +import "@polymer/paper-input/paper-input"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class MQTTTrigger extends Component { constructor() { diff --git a/src/panels/config/js/trigger/numeric_state.js b/src/panels/config/js/trigger/numeric_state.js index 03903904216c..41cf07838d39 100644 --- a/src/panels/config/js/trigger/numeric_state.js +++ b/src/panels/config/js/trigger/numeric_state.js @@ -1,10 +1,10 @@ import { h, Component } from "preact"; -import "@polymer/paper-input/paper-input.js"; -import "../../../../components/ha-textarea.js"; +import "@polymer/paper-input/paper-input"; +import "../../../../components/ha-textarea"; -import "../../../../components/entity/ha-entity-picker.js"; +import "../../../../components/entity/ha-entity-picker"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class NumericStateTrigger extends Component { constructor() { diff --git a/src/panels/config/js/trigger/state.js b/src/panels/config/js/trigger/state.js index 4c461f3e2b99..fe3d4e7accd1 100644 --- a/src/panels/config/js/trigger/state.js +++ b/src/panels/config/js/trigger/state.js @@ -1,9 +1,9 @@ import { h, Component } from "preact"; -import "@polymer/paper-input/paper-input.js"; -import "../../../../components/entity/ha-entity-picker.js"; +import "@polymer/paper-input/paper-input"; +import "../../../../components/entity/ha-entity-picker"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class StateTrigger extends Component { constructor() { diff --git a/src/panels/config/js/trigger/sun.js b/src/panels/config/js/trigger/sun.js index 0203c7d13d7d..a0bd5bc99082 100644 --- a/src/panels/config/js/trigger/sun.js +++ b/src/panels/config/js/trigger/sun.js @@ -1,10 +1,10 @@ import { h, Component } from "preact"; -import "@polymer/paper-input/paper-input.js"; -import "@polymer/paper-radio-button/paper-radio-button.js"; -import "@polymer/paper-radio-group/paper-radio-group.js"; +import "@polymer/paper-input/paper-input"; +import "@polymer/paper-radio-button/paper-radio-button"; +import "@polymer/paper-radio-group/paper-radio-group"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class SunTrigger extends Component { constructor() { diff --git a/src/panels/config/js/trigger/template.js b/src/panels/config/js/trigger/template.js index 9c1d1c5f3de0..f23152838cc2 100644 --- a/src/panels/config/js/trigger/template.js +++ b/src/panels/config/js/trigger/template.js @@ -1,8 +1,8 @@ import { h, Component } from "preact"; -import "../../../../components/ha-textarea.js"; +import "../../../../components/ha-textarea"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class TemplateTrigger extends Component { constructor() { diff --git a/src/panels/config/js/trigger/time.js b/src/panels/config/js/trigger/time.js index b4e226f71242..dd2c4c535dbe 100644 --- a/src/panels/config/js/trigger/time.js +++ b/src/panels/config/js/trigger/time.js @@ -1,8 +1,8 @@ import { h, Component } from "preact"; -import "@polymer/paper-input/paper-input.js"; +import "@polymer/paper-input/paper-input"; -import { onChangeEvent } from "../../../../common/preact/event.js"; +import { onChangeEvent } from "../../../../common/preact/event"; export default class TimeTrigger extends Component { constructor() { diff --git a/src/panels/config/js/trigger/trigger_edit.js b/src/panels/config/js/trigger/trigger_edit.js index 479285103e6c..6af80b3dea08 100644 --- a/src/panels/config/js/trigger/trigger_edit.js +++ b/src/panels/config/js/trigger/trigger_edit.js @@ -1,18 +1,18 @@ import { h, Component } from "preact"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; -import EventTrigger from "./event.js"; -import HassTrigger from "./homeassistant.js"; -import MQTTTrigger from "./mqtt.js"; -import NumericStateTrigger from "./numeric_state.js"; -import StateTrigger from "./state.js"; -import SunTrigger from "./sun.js"; -import TemplateTrigger from "./template.js"; -import TimeTrigger from "./time.js"; -import ZoneTrigger from "./zone.js"; +import EventTrigger from "./event"; +import HassTrigger from "./homeassistant"; +import MQTTTrigger from "./mqtt"; +import NumericStateTrigger from "./numeric_state"; +import StateTrigger from "./state"; +import SunTrigger from "./sun"; +import TemplateTrigger from "./template"; +import TimeTrigger from "./time"; +import ZoneTrigger from "./zone"; const TYPES = { event: EventTrigger, diff --git a/src/panels/config/js/trigger/trigger_row.js b/src/panels/config/js/trigger/trigger_row.js index 8030f1b41005..13f3a542dea1 100644 --- a/src/panels/config/js/trigger/trigger_row.js +++ b/src/panels/config/js/trigger/trigger_row.js @@ -1,11 +1,11 @@ import { h, Component } from "preact"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-menu-button/paper-menu-button.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-menu-button/paper-menu-button"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; -import TriggerEdit from "./trigger_edit.js"; +import TriggerEdit from "./trigger_edit"; export default class TriggerRow extends Component { constructor() { diff --git a/src/panels/config/js/trigger/zone.js b/src/panels/config/js/trigger/zone.js index 528ecc5568e7..be3b385a0160 100644 --- a/src/panels/config/js/trigger/zone.js +++ b/src/panels/config/js/trigger/zone.js @@ -1,11 +1,11 @@ import { h, Component } from "preact"; -import "@polymer/paper-radio-button/paper-radio-button.js"; -import "@polymer/paper-radio-group/paper-radio-group.js"; -import "../../../../components/entity/ha-entity-picker.js"; +import "@polymer/paper-radio-button/paper-radio-button"; +import "@polymer/paper-radio-group/paper-radio-group"; +import "../../../../components/entity/ha-entity-picker"; -import { onChangeEvent } from "../../../../common/preact/event.js"; -import hasLocation from "../../../../common/entity/has_location.js"; -import computeStateDomain from "../../../../common/entity/compute_state_domain.js"; +import { onChangeEvent } from "../../../../common/preact/event"; +import hasLocation from "../../../../common/entity/has_location"; +import computeStateDomain from "../../../../common/entity/compute_state_domain"; function zoneAndLocationFilter(stateObj) { return hasLocation(stateObj) && computeStateDomain(stateObj) !== "zone"; diff --git a/src/panels/config/script/ha-config-script.js b/src/panels/config/script/ha-config-script.js index 3fde65eb3b7c..0790d7d3beba 100644 --- a/src/panels/config/script/ha-config-script.js +++ b/src/panels/config/script/ha-config-script.js @@ -1,12 +1,12 @@ -import "@polymer/app-route/app-route.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-route/app-route"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "./ha-script-editor.js"; -import "./ha-script-picker.js"; +import "./ha-script-editor"; +import "./ha-script-picker"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import computeStateDomain from "../../../common/entity/compute_state_domain.js"; +import computeStateName from "../../../common/entity/compute_state_name"; +import computeStateDomain from "../../../common/entity/compute_state_domain"; class HaConfigScript extends PolymerElement { static get template() { diff --git a/src/panels/config/script/ha-script-editor.js b/src/panels/config/script/ha-script-editor.js index 34dd73a56adc..67876c38f4af 100644 --- a/src/panels/config/script/ha-script-editor.js +++ b/src/panels/config/script/ha-script-editor.js @@ -1,20 +1,20 @@ -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-fab/paper-fab.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-fab/paper-fab"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; import { h, render } from "preact"; -import "../../../layouts/ha-app-layout.js"; +import "../../../layouts/ha-app-layout"; -import Script from "../js/script.js"; -import unmountPreact from "../../../common/preact/unmount.js"; +import Script from "../js/script"; +import unmountPreact from "../../../common/preact/unmount"; -import computeObjectId from "../../../common/entity/compute_object_id.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import NavigateMixin from "../../../mixins/navigate-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import computeObjectId from "../../../common/entity/compute_object_id"; +import computeStateName from "../../../common/entity/compute_state_name"; +import NavigateMixin from "../../../mixins/navigate-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; function ScriptEditor(mountEl, props, mergeEl) { return render(h(Script, props), mountEl, mergeEl); diff --git a/src/panels/config/script/ha-script-picker.js b/src/panels/config/script/ha-script-picker.js index 5055c9faebac..d69917f988cd 100644 --- a/src/panels/config/script/ha-script-picker.js +++ b/src/panels/config/script/ha-script-picker.js @@ -1,20 +1,20 @@ -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-fab/paper-fab.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-item/paper-item-body.js"; -import "@polymer/paper-item/paper-item.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../layouts/ha-app-layout.js"; - -import "../ha-config-section.js"; - -import computeStateName from "../../../common/entity/compute_state_name.js"; -import NavigateMixin from "../../../mixins/navigate-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-fab/paper-fab"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-item/paper-item-body"; +import "@polymer/paper-item/paper-item"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../layouts/ha-app-layout"; + +import "../ha-config-section"; + +import computeStateName from "../../../common/entity/compute_state_name"; +import NavigateMixin from "../../../mixins/navigate-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/panels/config/users/ha-config-users.js b/src/panels/config/users/ha-config-users.js index 4e5791d53e11..6d3f4d2de029 100644 --- a/src/panels/config/users/ha-config-users.js +++ b/src/panels/config/users/ha-config-users.js @@ -1,14 +1,14 @@ -import "@polymer/app-route/app-route.js"; -import { timeOut } from "@polymer/polymer/lib/utils/async.js"; -import { Debouncer } from "@polymer/polymer/lib/utils/debounce.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/app-route/app-route"; +import { timeOut } from "@polymer/polymer/lib/utils/async"; +import { Debouncer } from "@polymer/polymer/lib/utils/debounce"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import NavigateMixin from "../../../mixins/navigate-mixin.js"; +import NavigateMixin from "../../../mixins/navigate-mixin"; -import "./ha-user-picker.js"; -import "./ha-user-editor.js"; -import { fireEvent } from "../../../common/dom/fire_event.js"; +import "./ha-user-picker"; +import "./ha-user-editor"; +import { fireEvent } from "../../../common/dom/fire_event"; /* * @appliesMixin NavigateMixin diff --git a/src/panels/config/users/ha-dialog-add-user.js b/src/panels/config/users/ha-dialog-add-user.js index 0373738cafbc..65f25d7f1fb5 100644 --- a/src/panels/config/users/ha-dialog-add-user.js +++ b/src/panels/config/users/ha-dialog-add-user.js @@ -1,12 +1,12 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-dialog/paper-dialog.js"; -import "@polymer/paper-spinner/paper-spinner.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-dialog/paper-dialog"; +import "@polymer/paper-spinner/paper-spinner"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../resources/ha-style.js"; +import "../../../resources/ha-style"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import LocalizeMixin from "../../../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/panels/config/users/ha-user-editor.js b/src/panels/config/users/ha-user-editor.js index b45ad27701c1..5de48d39151e 100644 --- a/src/panels/config/users/ha-user-editor.js +++ b/src/panels/config/users/ha-user-editor.js @@ -1,12 +1,12 @@ -import "@polymer/paper-button/paper-button.js"; -import "@polymer/paper-card/paper-card.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-button/paper-button"; +import "@polymer/paper-card/paper-card"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../layouts/hass-subpage.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; -import NavigateMixin from "../../../mixins/navigate-mixin.js"; -import EventsMixin from "../../../mixins/events-mixin.js"; +import "../../../layouts/hass-subpage"; +import LocalizeMixin from "../../../mixins/localize-mixin"; +import NavigateMixin from "../../../mixins/navigate-mixin"; +import EventsMixin from "../../../mixins/events-mixin"; /* * @appliesMixin LocalizeMixin diff --git a/src/panels/config/users/ha-user-picker.js b/src/panels/config/users/ha-user-picker.js index d09c1e7ecfd3..821a3546ca88 100644 --- a/src/panels/config/users/ha-user-picker.js +++ b/src/panels/config/users/ha-user-picker.js @@ -1,15 +1,15 @@ -import "@polymer/paper-fab/paper-fab.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-item/paper-item-body.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; +import "@polymer/paper-fab/paper-fab"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-item/paper-item-body"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; -import "../../../layouts/hass-subpage.js"; +import "../../../layouts/hass-subpage"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; -import NavigateMixin from "../../../mixins/navigate-mixin.js"; -import EventsMixin from "../../../mixins/events-mixin.js"; +import LocalizeMixin from "../../../mixins/localize-mixin"; +import NavigateMixin from "../../../mixins/navigate-mixin"; +import EventsMixin from "../../../mixins/events-mixin"; let registeredDialog = false; diff --git a/src/panels/config/zwave/ha-config-zwave.js b/src/panels/config/zwave/ha-config-zwave.js index 832c8b7bf7ef..03ec58f05fb4 100644 --- a/src/panels/config/zwave/ha-config-zwave.js +++ b/src/panels/config/zwave/ha-config-zwave.js @@ -1,35 +1,35 @@ -import "@polymer/app-layout/app-header/app-header.js"; -import "@polymer/app-layout/app-toolbar/app-toolbar.js"; -import "@polymer/paper-card/paper-card.js"; -import "@polymer/paper-dropdown-menu/paper-dropdown-menu.js"; -import "@polymer/paper-icon-button/paper-icon-button.js"; -import "@polymer/paper-input/paper-input.js"; -import "@polymer/paper-item/paper-item.js"; -import "@polymer/paper-listbox/paper-listbox.js"; -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/buttons/ha-call-service-button.js"; -import "../../../components/ha-menu-button.js"; -import "../../../components/ha-service-description.js"; -import "../../../layouts/ha-app-layout.js"; -import "../../../resources/ha-style.js"; - -import "../ha-config-section.js"; -import "../ha-form-style.js"; -import "./zwave-groups.js"; -import "./zwave-log.js"; -import "./zwave-network.js"; -import "./zwave-node-config.js"; -import "./zwave-usercodes.js"; -import "./zwave-values.js"; -import "./zwave-node-protection.js"; - -import sortByName from "../../../common/entity/states_sort_by_name.js"; -import computeStateName from "../../../common/entity/compute_state_name.js"; -import computeStateDomain from "../../../common/entity/compute_state_domain.js"; -import EventsMixin from "../../../mixins/events-mixin.js"; -import LocalizeMixin from "../../../mixins/localize-mixin.js"; +import "@polymer/app-layout/app-header/app-header"; +import "@polymer/app-layout/app-toolbar/app-toolbar"; +import "@polymer/paper-card/paper-card"; +import "@polymer/paper-dropdown-menu/paper-dropdown-menu"; +import "@polymer/paper-icon-button/paper-icon-button"; +import "@polymer/paper-input/paper-input"; +import "@polymer/paper-item/paper-item"; +import "@polymer/paper-listbox/paper-listbox"; +import { html } from "@polymer/polymer/lib/utils/html-tag"; +import { PolymerElement } from "@polymer/polymer/polymer-element"; + +import "../../../components/buttons/ha-call-service-button"; +import "../../../components/ha-menu-button"; +import "../../../components/ha-service-description"; +import "../../../layouts/ha-app-layout"; +import "../../../resources/ha-style"; + +import "../ha-config-section"; +import "../ha-form-style"; +import "./zwave-groups"; +import "./zwave-log"; +import "./zwave-network"; +import "./zwave-node-config"; +import "./zwave-usercodes"; +import "./zwave-values"; +import "./zwave-node-protection"; + +import sortByName from "../../../common/entity/states_sort_by_name"; +import computeStateName from "../../../common/entity/compute_state_name"; +import computeStateDomain from "../../../common/entity/compute_state_domain"; +import EventsMixin from "../../../mixins/events-mixin"; +import LocalizeMixin from "../../../mixins/localize-mixin"; /* * @appliesMixin LocalizeMixin @@ -297,7 +297,7 @@ class HaConfigZwave extends LocalizeMixin(EventsMixin(PolymerElement)) { selected-node="[[selectedNode]]" protection="[[_protection]]" > - +