From 5b95bdb6b73a827cd305bb93086e65c16b0d6495 Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 16 Mar 2020 08:15:18 -0500 Subject: [PATCH 1/5] Minor corrections and cosmetic improvements Updated the correct file this time... --- src/translations/en.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/translations/en.json b/src/translations/en.json index 9a844b9499..2bc657ef29 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -642,7 +642,7 @@ "control": "Control", "related": "Related", "dismiss": "Dismiss", - "no_unique_id": "This entity does not have a unique ID, therefore it's settings can not be managed from the UI.", + "no_unique_id": "This entity does not have a unique ID, therefore its settings cannot be managed from the UI.", "editor": { "name": "Name Override", "icon": "Icon Override", @@ -659,8 +659,8 @@ } }, "helper_settings": { - "platform_not_loaded": "The {platform} integration is not loaded, please add it your configuration. Either by adding 'default_config:' or '{platform}:'.", - "yaml_not_editable": "The settings of this entity can not be edited from the UI. Only entities setup from the UI are configurable from the UI.", + "platform_not_loaded": "The {platform} integration is not loaded. Please add it your configuration either by adding 'default_config:' or '{platform}:'.", + "yaml_not_editable": "The settings of this entity cannot be edited from the UI. Only entities set up from the UI are configurable from the UI.", "required_error_msg": "This field is required", "generic": { "name": "Name", @@ -876,8 +876,8 @@ "add_dashboard": "Add dashboard" }, "confirm_delete": "Are you sure you want to delete this dashboard?", - "cant_edit_yaml": "Dashboards defined in YAML can not be edited from the UI. Change them in configuration.yaml.", - "cant_edit_default": "The standard Lovelace dashboard can not be edited from the UI. You can hide it by setting another dashboard as default.", + "cant_edit_yaml": "Dashboards defined in YAML cannot be edited from the UI. Change them in configuration.yaml.", + "cant_edit_default": "The standard Lovelace dashboard cannot be edited from the UI. You can hide it by setting another dashboard as default.", "detail": { "edit_dashboard": "Edit dashboard", "new_dashboard": "Add new dashboard", @@ -887,7 +887,7 @@ "title": "Title", "title_required": "Title is required.", "url": "Url", - "url_error_msg": "The url should contain a - and can not contain spaces or special characters, except for _ and -", + "url_error_msg": "The url should contain a - and cannot contain spaces or special characters, except for _ and -", "require_admin": "Admin only", "delete": "Delete", "update": "Update", @@ -915,7 +915,7 @@ "confirm_delete": "Are you sure you want to delete this resource?", "refresh_header": "Do you want to refresh?", "refresh_body": "You have to refresh the page to complete the removal, do you want to refresh now?", - "cant_edit_yaml": "You are using Lovelace in YAML mode, therefore you can not manage your resources through the UI. Manage them in configuration.yaml.", + "cant_edit_yaml": "You are using Lovelace in YAML mode, therefore you cannot manage your resources through the UI. Manage them in configuration.yaml.", "detail": { "new_resource": "Add new resource", "dismiss": "Close", @@ -1588,7 +1588,7 @@ }, "integrations": { "caption": "Integrations", - "description": "Manage and setup integrations", + "description": "Manage and set up integrations", "discovered": "Discovered", "configured": "Configured", "new": "Set up a new integration", @@ -1602,7 +1602,7 @@ "ignore": { "ignore": "Ignore", "confirm_ignore_title": "Ignore discovery of {name}?", - "confirm_ignore": "Are you sure you don't want to setup this integration? You can undo this by clicking the 'Show ignored integrations' in the overflow menu on the top right.", + "confirm_ignore": "Are you sure you don't want to set up this integration? You can undo this by clicking the 'Show ignored integrations' in the overflow menu on the top right.", "show_ignored": "Show ignored integrations", "hide_ignored": "Hide ignored integrations", "ignored": "Ignored", @@ -1877,7 +1877,7 @@ "last_changed": "Last Changed" }, "add_entities": { - "yaml_unsupported": "You can not use this function when using Lovelace UI in YAML mode.", + "yaml_unsupported": "You cannot use this function when using Lovelace UI in YAML mode.", "generated_unsupported": "You can only use this function when you have taken control of the Lovelace UI.", "saving_failed": "Saving Lovelace UI configuration failed." }, @@ -1957,7 +1957,7 @@ "header": "Take control of your Lovelace UI", "para": "By default Home Assistant will maintain your user interface, updating it when new entities or Lovelace UI components become available. If you take control we will no longer make changes automatically for you.", "para_sure": "Are you sure you want to take control of your user interface?", - "yaml_mode": "You are using YAML mode, that means you can not change your Lovelace config from the UI. If you want to change Lovelace from the UI, remove the 'mode: yaml' from your Lovelace configuration in 'configuration.yaml.'", + "yaml_mode": "You are using YAML mode, which means you cannot change your Lovelace config from the UI. If you want to change Lovelace from the UI, remove 'mode: yaml' from your Lovelace configuration in 'configuration.yaml.'", "yaml_control": "To take control in YAML mode, create a YAML file with the name you specified in your config for this dashboard, or the default 'ui-lovelace.yaml'.", "yaml_config": "To help you start here is the current config of this dashboard:", "cancel": "Never mind", From a88321d2431ac0c86fdc33977094be17cf0ce596 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Mon, 16 Mar 2020 20:32:13 +0100 Subject: [PATCH 2/5] Only show url path field in advanced mode (#5233) --- .../dashboards/dialog-lovelace-dashboard-detail.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/panels/config/lovelace/dashboards/dialog-lovelace-dashboard-detail.ts b/src/panels/config/lovelace/dashboards/dialog-lovelace-dashboard-detail.ts index 6a87e7ec48..d090fa0bae 100644 --- a/src/panels/config/lovelace/dashboards/dialog-lovelace-dashboard-detail.ts +++ b/src/panels/config/lovelace/dashboards/dialog-lovelace-dashboard-detail.ts @@ -99,7 +99,9 @@ export class DialogLovelaceDashboardDetail extends LitElement { .label=${this.hass.localize( "ui.panel.config.lovelace.dashboards.detail.title" )} - @blur=${this._fillUrlPath} + @blur=${this.hass.userData?.showAdvanced + ? this._fillUrlPath + : undefined} .invalid=${titleInvalid} .errorMessage=${this.hass.localize( "ui.panel.config.lovelace.dashboards.detail.title_required" @@ -113,7 +115,7 @@ export class DialogLovelaceDashboardDetail extends LitElement { "ui.panel.config.lovelace.dashboards.detail.icon" )} > - ${!this._params.dashboard + ${!this._params.dashboard && this.hass.userData?.showAdvanced ? html` ) { this._error = undefined; this._title = ev.detail.value; + if (!this.hass.userData?.showAdvanced) { + this._fillUrlPath(); + } } private _fillUrlPath() { - if (this._urlPath || !this._title) { + if ((this.hass.userData?.showAdvanced && this._urlPath) || !this._title) { return; } const parts = this._title.toLowerCase().split(" "); From 8bc8761af606f70abb1e9f2e03dd75779d2e9095 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Mon, 16 Mar 2020 20:32:59 +0100 Subject: [PATCH 3/5] Bumped version to 20200316.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c6f70de66e..49a129fa48 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20200316.0", + version="20200316.1", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", From 127aaba47b883b3722cfbd67465f5695a79168c4 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Mon, 16 Mar 2020 20:52:21 +0100 Subject: [PATCH 4/5] Add UI for reload resources service (#5229) * Add UI for reload resources service * Update hui-root.ts * Check for config of main panel --- .../resources/ha-config-lovelace-resources.ts | 4 +-- src/panels/lovelace/hui-root.ts | 35 +++++++++++++++++-- src/translations/en.json | 5 +++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/panels/config/lovelace/resources/ha-config-lovelace-resources.ts b/src/panels/config/lovelace/resources/ha-config-lovelace-resources.ts index 4bd0fd538b..bccecb2ce3 100644 --- a/src/panels/config/lovelace/resources/ha-config-lovelace-resources.ts +++ b/src/panels/config/lovelace/resources/ha-config-lovelace-resources.ts @@ -154,14 +154,14 @@ export class HaConfigLovelaceRescources extends LitElement { this._resources = this._resources!.concat(created).sort((res1, res2) => compare(res1.url, res2.url) ); - loadLovelaceResources(this._resources, this.hass!.auth.data.hassUrl); + loadLovelaceResources([created], this.hass!.auth.data.hassUrl); }, updateResource: async (values) => { const updated = await updateResource(this.hass!, resource!.id, values); this._resources = this._resources!.map((res) => res === resource ? updated : res ); - loadLovelaceResources(this._resources, this.hass!.auth.data.hassUrl); + loadLovelaceResources([updated], this.hass!.auth.data.hassUrl); }, removeResource: async () => { if ( diff --git a/src/panels/lovelace/hui-root.ts b/src/panels/lovelace/hui-root.ts index 51b9224dc5..72a2036879 100644 --- a/src/panels/lovelace/hui-root.ts +++ b/src/panels/lovelace/hui-root.ts @@ -29,7 +29,7 @@ import "../../components/ha-paper-icon-button-arrow-prev"; import "../../components/ha-icon"; import { debounce } from "../../common/util/debounce"; import { HomeAssistant } from "../../types"; -import { LovelaceConfig } from "../../data/lovelace"; +import { LovelaceConfig, LovelacePanelConfig } from "../../data/lovelace"; import { navigate } from "../../common/navigate"; import { fireEvent } from "../../common/dom/fire_event"; import { swapView } from "./editor/config-util"; @@ -49,7 +49,10 @@ import { haStyle } from "../../resources/styles"; import { computeRTLDirection } from "../../common/util/compute_rtl"; import { showVoiceCommandDialog } from "../../dialogs/voice-command-dialog/show-ha-voice-command-dialog"; import { isComponentLoaded } from "../../common/config/is_component_loaded"; -import { showAlertDialog } from "../../dialogs/generic/show-dialog-box"; +import { + showAlertDialog, + showConfirmationDialog, +} from "../../dialogs/generic/show-dialog-box"; import memoizeOne from "memoize-one"; class HUIRoot extends LitElement { @@ -225,6 +228,21 @@ class HUIRoot extends LitElement { ` : ""} + ${(this.hass.panels.lovelace + ?.config as LovelacePanelConfig)?.mode === "yaml" + ? html` + + ${this.hass!.localize( + "ui.panel.lovelace.menu.reload_resources" + )} + + ` + : ""} ${this.hass!.user!.is_admin && !this.hass!.config.safe_mode ? html` @@ -550,6 +568,19 @@ class HUIRoot extends LitElement { fireEvent(this, "config-refresh"); } + private _handleReloadResources(): void { + this.hass.callService("lovelace", "reload_resources"); + showConfirmationDialog(this, { + title: this.hass!.localize( + "ui.panel.lovelace.reload_resources.refresh_header" + ), + text: this.hass!.localize( + "ui.panel.lovelace.reload_resources.refresh_body" + ), + confirm: () => location.reload(), + }); + } + private _handleUnusedEntities(): void { navigate(this, `${this.route?.prefix}/hass-unused-entities`); } diff --git a/src/translations/en.json b/src/translations/en.json index 2bc657ef29..1e85c72144 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1891,9 +1891,14 @@ "configure_ui": "Configure UI", "help": "Help", "refresh": "Refresh", + "reload_resources": "Reload resources", "exit_edit_mode": "Exit UI edit mode", "close": "Close" }, + "reload_resources": { + "refresh_header": "Do you want to refresh?", + "refresh_body": "You have to refresh the page to complete the reload, do you want to refresh now?" + }, "editor": { "header": "Edit UI", "menu": { From 2925b930ade3d636ef3cf4faa10bece4af896383 Mon Sep 17 00:00:00 2001 From: Aidan Timson Date: Mon, 16 Mar 2020 19:54:55 +0000 Subject: [PATCH 5/5] Set Title to Current Panel (#5220) * Set title to current panel * Move to mixin * Naming * guard clause --- src/data/panel.ts | 23 +++++++++++++++++++++++ src/state/hass-element.ts | 2 ++ src/state/panel-title-mixin.ts | 30 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 src/data/panel.ts create mode 100644 src/state/panel-title-mixin.ts diff --git a/src/data/panel.ts b/src/data/panel.ts new file mode 100644 index 0000000000..67439e2d55 --- /dev/null +++ b/src/data/panel.ts @@ -0,0 +1,23 @@ +import { HomeAssistant, PanelInfo } from "../types"; +import { DEFAULT_PANEL } from "../common/const"; + +export const getPanelTitle = (hass: HomeAssistant): string | undefined => { + let title: string = ""; + const panel = Object.values(hass.panels).find( + (p: PanelInfo): boolean => p.url_path === hass.panelUrl + ); + if (!panel) { + return; + } + const defaultPanel = + hass.panels[localStorage.defaultPage || DEFAULT_PANEL] || + hass.panels[DEFAULT_PANEL]; + title = + panel.url_path === "profile" + ? hass.localize("panel.profile") + : hass.localize(`panel.${panel.title}`) || + panel.title || + defaultPanel.title || + hass.localize("panel.states"); + return title; +}; diff --git a/src/state/hass-element.ts b/src/state/hass-element.ts index 9aaa9ccc6a..a81856bfd6 100644 --- a/src/state/hass-element.ts +++ b/src/state/hass-element.ts @@ -12,6 +12,7 @@ import { hapticMixin } from "./haptic-mixin"; import { urlSyncMixin } from "./url-sync-mixin"; import { Constructor } from "../types"; import { HassBaseEl } from "./hass-base-mixin"; +import { panelTitleMixin } from "./panel-title-mixin"; const ext = (baseClass: T, mixins): T => mixins.reduceRight((base, mixin) => mixin(base), baseClass); @@ -29,4 +30,5 @@ export class HassElement extends ext(HassBaseEl, [ urlSyncMixin, ZHADialogMixin, hapticMixin, + panelTitleMixin, ]) {} diff --git a/src/state/panel-title-mixin.ts b/src/state/panel-title-mixin.ts new file mode 100644 index 0000000000..0f24daeef5 --- /dev/null +++ b/src/state/panel-title-mixin.ts @@ -0,0 +1,30 @@ +import { getPanelTitle } from "../data/panel"; +import { HassBaseEl } from "./hass-base-mixin"; +import { HomeAssistant, Constructor } from "../types"; + +export const panelTitleMixin = >( + superClass: T +) => + class extends superClass { + private _oldHass?: HomeAssistant; + + protected updated(changedProps) { + super.updated(changedProps); + if (!changedProps.has("hass") || !this.hass) { + return; + } + if (!this._oldHass) { + this.setTitle(getPanelTitle(this.hass)); + } + this._oldHass = changedProps.get("hass") as HomeAssistant | undefined; + if (!this._oldHass || this._oldHass.panelUrl !== this.hass.panelUrl) { + this.setTitle(getPanelTitle(this.hass)); + } + } + + private setTitle(title: string | undefined) { + document.title = title + ? `${title} - ${this.hass!.localize("domain.homeassistant")}` + : this.hass!.localize("domain.homeassistant"); + } + };