From 05113e18094cd96c68d4a3269a0b0267ffb59245 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 31 Jan 2020 12:14:21 +0100 Subject: [PATCH 01/11] Styling zone menu (#4684) * Styling zone menu * Update ha-device-entities-card.ts --- .../config/devices/device-detail/ha-device-entities-card.ts | 2 +- src/panels/config/zone/ha-config-zone.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/panels/config/devices/device-detail/ha-device-entities-card.ts b/src/panels/config/devices/device-detail/ha-device-entities-card.ts index b8540b6309..60c9301c51 100644 --- a/src/panels/config/devices/device-detail/ha-device-entities-card.ts +++ b/src/panels/config/devices/device-detail/ha-device-entities-card.ts @@ -179,7 +179,7 @@ export class HaDeviceEntitiesCard extends LitElement { color: var(--secondary-text-color); } #entities > * { - margin: 8px; + margin: 8px 16px 8px 8px; } paper-icon-item { min-height: 40px; diff --git a/src/panels/config/zone/ha-config-zone.ts b/src/panels/config/zone/ha-config-zone.ts index 1b9560b691..d35928dced 100644 --- a/src/panels/config/zone/ha-config-zone.ts +++ b/src/panels/config/zone/ha-config-zone.ts @@ -436,6 +436,8 @@ ${this.hass!.localize("ui.panel.config.zone.confirm_delete2")}`) .flex .empty { border-left: 1px solid var(--divider-color); width: 250px; + min-height: 100%; + box-sizing: border-box; } paper-icon-item { padding-top: 4px; From 57fc56f8366a60e75606de71358e200564bcd912 Mon Sep 17 00:00:00 2001 From: Ian Richardson Date: Fri, 31 Jan 2020 10:19:08 -0600 Subject: [PATCH 02/11] =?UTF-8?q?=F0=9F=90=9B=20fix=20tabindex=20for=20def?= =?UTF-8?q?ault=20entity=20more-info=20actions=20(#4697)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 fix tabindex for default entity more-info actions * Update hui-state-label-badge.ts --- src/panels/lovelace/badges/hui-state-label-badge.ts | 4 +++- src/panels/lovelace/cards/hui-picture-entity-card.ts | 4 +++- src/panels/lovelace/components/hui-generic-entity-row.ts | 4 +--- .../lovelace/entity-rows/hui-input-select-entity-row.ts | 4 +--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/panels/lovelace/badges/hui-state-label-badge.ts b/src/panels/lovelace/badges/hui-state-label-badge.ts index 5ebea58d8b..25b7f3c8fa 100644 --- a/src/panels/lovelace/badges/hui-state-label-badge.ts +++ b/src/panels/lovelace/badges/hui-state-label-badge.ts @@ -49,7 +49,9 @@ export class HuiStateLabelBadge extends LitElement implements LovelaceBadge { hasDoubleClick: hasAction(this._config!.double_tap_action), })} tabindex=${ifDefined( - hasAction(this._config.tap_action) ? "0" : undefined + hasAction(this._config.tap_action) || this._config.entity + ? "0" + : undefined )} > `; diff --git a/src/panels/lovelace/cards/hui-picture-entity-card.ts b/src/panels/lovelace/cards/hui-picture-entity-card.ts index 8e47402538..187da7ec35 100644 --- a/src/panels/lovelace/cards/hui-picture-entity-card.ts +++ b/src/panels/lovelace/cards/hui-picture-entity-card.ts @@ -158,7 +158,9 @@ class HuiPictureEntityCard extends LitElement implements LovelaceCard { hasDoubleClick: hasAction(this._config!.double_tap_action), })} tabindex=${ifDefined( - hasAction(this._config.tap_action) ? "0" : undefined + hasAction(this._config.tap_action) || this._config.entity + ? "0" + : undefined )} class=${classMap({ clickable: stateObj.state !== UNAVAILABLE, diff --git a/src/panels/lovelace/components/hui-generic-entity-row.ts b/src/panels/lovelace/components/hui-generic-entity-row.ts index e0e61d4639..50fa3cb1ed 100644 --- a/src/panels/lovelace/components/hui-generic-entity-row.ts +++ b/src/panels/lovelace/components/hui-generic-entity-row.ts @@ -74,9 +74,7 @@ class HuiGenericEntityRow extends LitElement { hasHold: hasAction(this.config!.hold_action), hasDoubleClick: hasAction(this.config!.double_tap_action), })} - tabindex=${ifDefined( - hasAction(this.config.tap_action) ? "0" : undefined - )} + tabindex=${ifDefined(pointer ? "0" : undefined)} >
Date: Sat, 1 Feb 2020 09:26:22 +0100 Subject: [PATCH 03/11] Change map settings icon (#4701) * Change map settings icon Closes #4694 * hide for demo --- src/panels/map/ha-panel-map.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/panels/map/ha-panel-map.js b/src/panels/map/ha-panel-map.js index bf62930e59..110dffd636 100644 --- a/src/panels/map/ha-panel-map.js +++ b/src/panels/map/ha-panel-map.js @@ -34,10 +34,12 @@ class HaPanelMap extends LocalizeMixin(PolymerElement) {
[[localize('panel.map')]]
- +
@@ -72,6 +74,10 @@ class HaPanelMap extends LocalizeMixin(PolymerElement) { } } + computeDemo() { + return __DEMO__; + } + openZonesEditor() { navigate(this, "/config/zone"); } From 1dad7c81dab7e29d494ec9e61c0727e3db3f698c Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 4 Feb 2020 07:32:22 +0100 Subject: [PATCH 04/11] Fix passive color radius and fix switch label clicks (#4703) --- src/components/ha-switch.ts | 35 ++++++++++++++++++-- src/components/map/ha-location-editor.ts | 14 +++++++- src/components/map/ha-locations-editor.ts | 3 +- src/data/zone.ts | 4 +++ src/panels/config/zone/dialog-zone-detail.ts | 9 ++++- src/panels/config/zone/ha-config-zone.ts | 11 +++--- src/panels/map/ha-panel-map.js | 3 +- 7 files changed, 69 insertions(+), 10 deletions(-) diff --git a/src/components/ha-switch.ts b/src/components/ha-switch.ts index 9426082439..a33f513bbb 100644 --- a/src/components/ha-switch.ts +++ b/src/components/ha-switch.ts @@ -1,9 +1,10 @@ -import { customElement, CSSResult, css, query } from "lit-element"; +import { customElement, CSSResult, css, query, html } from "lit-element"; import "@material/mwc-switch"; import { style } from "@material/mwc-switch/mwc-switch-css"; // tslint:disable-next-line import { Switch } from "@material/mwc-switch"; import { Constructor } from "../types"; +import { ripple } from "@material/mwc-ripple/ripple-directive"; // tslint:disable-next-line const MwcSwitch = customElements.get("mwc-switch") as Constructor; @@ -21,7 +22,31 @@ export class HaSwitch extends MwcSwitch { "slotted", Boolean(this._slot.assignedNodes().length) ); - this._slot.addEventListener("click", () => (this.checked = !this.checked)); + } + + protected render() { + return html` +
+
+
+
+ +
+
+
+ + `; } protected static get styles(): CSSResult[] { @@ -55,6 +80,12 @@ export class HaSwitch extends MwcSwitch { `, ]; } + + private _haChangeHandler(e: Event) { + this.mdcFoundation.handleChange(e); + // catch "click" event and sync properties + this.checked = this.formElement.checked; + } } declare global { diff --git a/src/components/map/ha-location-editor.ts b/src/components/map/ha-location-editor.ts index a24ceba338..f5ad735329 100644 --- a/src/components/map/ha-location-editor.ts +++ b/src/components/map/ha-location-editor.ts @@ -23,11 +23,13 @@ import { } from "../../common/dom/setup-leaflet-map"; import { fireEvent } from "../../common/dom/fire_event"; import { nextRender } from "../../common/util/render-status"; +import { defaultRadiusColor } from "../../data/zone"; @customElement("ha-location-editor") class LocationEditor extends LitElement { @property() public location?: [number, number]; @property() public radius?: number; + @property() public radiusColor?: string; @property() public icon?: string; public fitZoom = 16; private _iconEl?: DivIcon; @@ -83,6 +85,9 @@ class LocationEditor extends LitElement { if (changedProps.has("radius")) { this._updateRadius(); } + if (changedProps.has("radiusColor")) { + this._updateRadiusColor(); + } if (changedProps.has("icon")) { this._updateIcon(); } @@ -213,7 +218,7 @@ class LocationEditor extends LitElement { this._leafletMap!.addLayer(this._locationMarker); } else { this._locationMarker = this.Leaflet!.circle(this.location, { - color: "#FF9800", + color: this.radiusColor || defaultRadiusColor, radius: this.radius, }); this._leafletMap!.addLayer(this._locationMarker); @@ -228,6 +233,13 @@ class LocationEditor extends LitElement { (this._locationMarker as Circle).setRadius(this.radius); } + private _updateRadiusColor(): void { + if (!this._locationMarker || !this.radius) { + return; + } + (this._locationMarker as Circle).setStyle({ color: this.radiusColor }); + } + static get styles(): CSSResult { return css` :host { diff --git a/src/components/map/ha-locations-editor.ts b/src/components/map/ha-locations-editor.ts index 11de3b91c3..3cb70c0f93 100644 --- a/src/components/map/ha-locations-editor.ts +++ b/src/components/map/ha-locations-editor.ts @@ -22,6 +22,7 @@ import { LeafletModuleType, } from "../../common/dom/setup-leaflet-map"; import { fireEvent } from "../../common/dom/fire_event"; +import { defaultRadiusColor } from "../../data/zone"; declare global { // for fire event @@ -202,7 +203,7 @@ export class HaLocationsEditor extends LitElement { const circle = this.Leaflet!.circle( [location.latitude, location.longitude], { - color: location.radius_color ? location.radius_color : "#FF9800", + color: location.radius_color || defaultRadiusColor, radius: location.radius, } ); diff --git a/src/data/zone.ts b/src/data/zone.ts index 1bd97a4351..85464a975b 100644 --- a/src/data/zone.ts +++ b/src/data/zone.ts @@ -1,5 +1,9 @@ import { HomeAssistant } from "../types"; +export const defaultRadiusColor = "#FF9800"; +export const homeRadiusColor: string = "#03a9f4"; +export const passiveRadiusColor: string = "#9b9b9b"; + export interface Zone { id: string; name: string; diff --git a/src/panels/config/zone/dialog-zone-detail.ts b/src/panels/config/zone/dialog-zone-detail.ts index 869c1c24ec..850b78133b 100644 --- a/src/panels/config/zone/dialog-zone-detail.ts +++ b/src/panels/config/zone/dialog-zone-detail.ts @@ -16,7 +16,11 @@ import "../../../components/ha-dialog"; import { ZoneDetailDialogParams } from "./show-dialog-zone-detail"; import { HomeAssistant } from "../../../types"; -import { ZoneMutableParams } from "../../../data/zone"; +import { + ZoneMutableParams, + passiveRadiusColor, + defaultRadiusColor, +} from "../../../data/zone"; import { addDistanceToCoord } from "../../../common/location/add_distance_to_coord"; class DialogZoneDetail extends LitElement { @@ -127,6 +131,9 @@ class DialogZoneDetail extends LitElement { class="flex" .location=${this._locationValue} .radius=${this._radius} + .radiusColor=${this._passive + ? passiveRadiusColor + : defaultRadiusColor} .icon=${this._icon} @change=${this._locationChanged} > diff --git a/src/panels/config/zone/ha-config-zone.ts b/src/panels/config/zone/ha-config-zone.ts index d35928dced..52a734ab04 100644 --- a/src/panels/config/zone/ha-config-zone.ts +++ b/src/panels/config/zone/ha-config-zone.ts @@ -31,6 +31,9 @@ import { updateZone, deleteZone, ZoneMutableParams, + homeRadiusColor, + passiveRadiusColor, + defaultRadiusColor, } from "../../../data/zone"; // tslint:disable-next-line import { @@ -68,17 +71,17 @@ export class HaConfigZone extends SubscribeMixin(LitElement) { radius: state.attributes.radius, radius_color: state.entity_id === "zone.home" - ? "#03a9f4" + ? homeRadiusColor : state.attributes.passive - ? "#9b9b9b" - : "#FF9800", + ? passiveRadiusColor + : defaultRadiusColor, editable: false, }; }); const storageLocations: MarkerLocation[] = storageItems.map((zone) => { return { ...zone, - radius_color: zone.passive ? "#9b9b9b" : "#FF9800", + radius_color: zone.passive ? passiveRadiusColor : defaultRadiusColor, editable: true, }; }); diff --git a/src/panels/map/ha-panel-map.js b/src/panels/map/ha-panel-map.js index 110dffd636..3fbf540354 100644 --- a/src/panels/map/ha-panel-map.js +++ b/src/panels/map/ha-panel-map.js @@ -12,6 +12,7 @@ import { computeStateDomain } from "../../common/entity/compute_state_domain"; import { computeStateName } from "../../common/entity/compute_state_name"; import LocalizeMixin from "../../mixins/localize-mixin"; import { setupLeafletMap } from "../../common/dom/setup-leaflet-map"; +import { defaultRadiusColor } from "../../data/zone"; /* * @appliesMixin LocalizeMixin @@ -175,7 +176,7 @@ class HaPanelMap extends LocalizeMixin(PolymerElement) { [entity.attributes.latitude, entity.attributes.longitude], { interactive: false, - color: "#FF9800", + color: defaultRadiusColor, radius: entity.attributes.radius, } ).addTo(map) From de1b127ac2c8479ee0916c8d00d1c80a272762f3 Mon Sep 17 00:00:00 2001 From: "David F. Mulcahey" Date: Mon, 3 Feb 2020 03:29:13 -0500 Subject: [PATCH 05/11] fix loading groups (#4727) --- src/panels/config/zha/zha-device-page.ts | 25 +----------------------- 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/src/panels/config/zha/zha-device-page.ts b/src/panels/config/zha/zha-device-page.ts index ebda46f890..c1c9a8f9fa 100755 --- a/src/panels/config/zha/zha-device-page.ts +++ b/src/panels/config/zha/zha-device-page.ts @@ -44,23 +44,6 @@ export class ZHADevicePage extends LitElement { @property() private _bindableDevices: ZHADevice[] = []; @property() private _groups: ZHAGroup[] = []; - private _firstUpdatedCalled: boolean = false; - - public connectedCallback(): void { - super.connectedCallback(); - if (this.hass && this._firstUpdatedCalled) { - this._fetchGroups(); - } - } - - protected firstUpdated(changedProperties: PropertyValues): void { - super.firstUpdated(changedProperties); - if (this.hass) { - this._fetchGroups(); - } - this._firstUpdatedCalled = true; - } - protected updated(changedProperties: PropertyValues): void { if (changedProperties.has("ieee")) { this._fetchData(); @@ -148,16 +131,10 @@ export class ZHADevicePage extends LitElement { sortZHADevices ) : []; + this._groups = (await fetchGroups(this.hass!)).sort(sortZHAGroups); } } - private async _fetchGroups() { - this._groups = - this.device && this.device.device_type !== "Coordinator" - ? (await fetchGroups(this.hass!)).sort(sortZHAGroups) - : []; - } - static get styles(): CSSResult[] { return [ haStyle, From e176357fbfdf924da0cf4add869fb259672a1e1a Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 4 Feb 2020 15:15:15 +0100 Subject: [PATCH 06/11] Tweak badge focus padding (#4750) --- src/panels/lovelace/badges/hui-state-label-badge.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/panels/lovelace/badges/hui-state-label-badge.ts b/src/panels/lovelace/badges/hui-state-label-badge.ts index 25b7f3c8fa..1535a68963 100644 --- a/src/panels/lovelace/badges/hui-state-label-badge.ts +++ b/src/panels/lovelace/badges/hui-state-label-badge.ts @@ -70,8 +70,8 @@ export class HuiStateLabelBadge extends LitElement implements LovelaceBadge { } ha-state-label-badge { display: inline-block; - padding: 4px; - margin: -4px 0 -4px 0; + padding: 4px 2px 4px 2px; + margin: -4px -2px -4px -2px; } `; } From 50d0671abe797ac64a3b99191957ea682d6b1b68 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 4 Feb 2020 15:38:03 +0100 Subject: [PATCH 07/11] Bumped version to 20200130.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fcfceecf0f..ea8f3f56c7 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20200130.0", + version="20200130.1", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", From 97a6354a72cf12cb8473d8c596f69753505e0da4 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 12 Feb 2020 13:47:56 +0100 Subject: [PATCH 08/11] Fix tap firing twice on iOS (#4841) --- src/panels/lovelace/cards/hui-entity-button-card.ts | 6 ++++-- .../lovelace/common/directives/action-handler-directive.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/panels/lovelace/cards/hui-entity-button-card.ts b/src/panels/lovelace/cards/hui-entity-button-card.ts index c6cccaadb8..707e4f60ed 100644 --- a/src/panels/lovelace/cards/hui-entity-button-card.ts +++ b/src/panels/lovelace/cards/hui-entity-button-card.ts @@ -138,7 +138,10 @@ class HuiEntityButtonCard extends LitElement implements LovelaceCard { hasDoubleClick: hasAction(this._config!.double_tap_action), })} tabindex=${ifDefined( - hasAction(this._config.tap_action) ? "0" : undefined + hasAction(this._config.tap_action) || + this._config.tap_action === undefined + ? "0" + : undefined )} > ${this._config.show_icon @@ -203,7 +206,6 @@ class HuiEntityButtonCard extends LitElement implements LovelaceCard { ha-card:focus { outline: none; - background: var(--divider-color); } ha-icon { diff --git a/src/panels/lovelace/common/directives/action-handler-directive.ts b/src/panels/lovelace/common/directives/action-handler-directive.ts index 87c5168019..a4e3a2b1ac 100644 --- a/src/panels/lovelace/common/directives/action-handler-directive.ts +++ b/src/panels/lovelace/common/directives/action-handler-directive.ts @@ -177,7 +177,7 @@ class ActionHandler extends HTMLElement implements ActionHandler { } else { fireEvent(element, "action", { action: "tap" }); } - window.setTimeout(() => (this.touch = undefined), 100); + window.setTimeout(() => (this.touch = undefined), this.holdTime); }; element.addEventListener("touchstart", touchStart, { passive: true }); From 156d944ca1931ca0f55dedc97310592741bbf6c8 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 12 Feb 2020 13:49:20 +0100 Subject: [PATCH 09/11] Fix translations for update button config entry system options (#4837) --- .../dialog-config-entry-system-options.ts | 2 +- src/translations/en.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dialogs/config-entry-system-options/dialog-config-entry-system-options.ts b/src/dialogs/config-entry-system-options/dialog-config-entry-system-options.ts index e660f44019..e60552b32b 100644 --- a/src/dialogs/config-entry-system-options/dialog-config-entry-system-options.ts +++ b/src/dialogs/config-entry-system-options/dialog-config-entry-system-options.ts @@ -115,7 +115,7 @@ class DialogConfigEntrySystemOptions extends LitElement { .disabled=${this._submitting} > ${this.hass.localize( - "ui.panel.config.entities.editor.update" + "ui.dialogs.config_entry_system_options.update" )}
diff --git a/src/translations/en.json b/src/translations/en.json index 74af9fff7e..1720719120 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -649,7 +649,8 @@ "config_entry_system_options": { "title": "System Options for {integration}", "enable_new_entities_label": "Enable newly added entities.", - "enable_new_entities_description": "If disabled, newly discovered entities for {integration} will not be automatically added to Home Assistant." + "enable_new_entities_description": "If disabled, newly discovered entities for {integration} will not be automatically added to Home Assistant.", + "update": "Update" }, "zha_device_info": { "manuf": "by {manufacturer}", From 5c2004bcc1f625ff2ade87353946e94376bb642b Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 12 Feb 2020 21:56:03 +0100 Subject: [PATCH 10/11] Bumped version to 20200130.2 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ea8f3f56c7..741a7ada48 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20200130.1", + version="20200130.2", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", From 785aefa02842400322850429e47de04e02dfed51 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 12 Feb 2020 21:58:59 +0100 Subject: [PATCH 11/11] Bumped version to 20200130.3 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 741a7ada48..6ec0659e68 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20200130.2", + version="20200130.3", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors",