From aba83cf6fed433dae114f234e9c6504c43b5c875 Mon Sep 17 00:00:00 2001 From: karwosts Date: Thu, 9 Nov 2023 18:45:21 -0800 Subject: [PATCH] Add link from energy dashboard to energy settings --- src/panels/energy/ha-panel-energy.ts | 1 + .../components/hui-energy-period-selector.ts | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/panels/energy/ha-panel-energy.ts b/src/panels/energy/ha-panel-energy.ts index c9cf85f45bce..27c22ccf3913 100644 --- a/src/panels/energy/ha-panel-energy.ts +++ b/src/panels/energy/ha-panel-energy.ts @@ -70,6 +70,7 @@ class PanelEnergy extends LitElement { diff --git a/src/panels/lovelace/components/hui-energy-period-selector.ts b/src/panels/lovelace/components/hui-energy-period-selector.ts index c06d3ab21063..5c167ef23b74 100644 --- a/src/panels/lovelace/components/hui-energy-period-selector.ts +++ b/src/panels/lovelace/components/hui-energy-period-selector.ts @@ -1,6 +1,6 @@ import "@material/mwc-button/mwc-button"; import type { RequestSelectedDetail } from "@material/mwc-list/mwc-list-item"; -import { mdiDotsVertical } from "@mdi/js"; +import { mdiDotsVertical, mdiPencil } from "@mdi/js"; import { addDays, addMonths, @@ -42,6 +42,7 @@ import { formatDateYear, } from "../../../common/datetime/format_date"; import { debounce } from "../../../common/util/debounce"; +import { navigate } from "../../../common/navigate"; import "../../../components/ha-button-menu"; import "../../../components/ha-check-list-item"; import "../../../components/ha-date-range-picker"; @@ -61,6 +62,8 @@ export class HuiEnergyPeriodSelector extends SubscribeMixin(LitElement) { @property({ type: Boolean, reflect: true }) public narrow?; + @property({ type: Boolean }) public showConfig = false; + @state() _startDate?: Date; @state() _endDate?: Date; @@ -278,11 +281,27 @@ export class HuiEnergyPeriodSelector extends SubscribeMixin(LitElement) { "ui.panel.lovelace.components.energy_period_selector.compare" )} + ${this.showConfig && this.hass.user?.is_admin + ? html` + + + ${this.hass!.localize("ui.panel.lovelace.menu.configure_ui")} + + ` + : nothing} `; } + private _navigateConfig(ev) { + ev.stopPropagation(); + navigate("/config/energy?historyBack=1"); + } + private _simpleRange = memoizeOne( (startDate, endDate, locale, config): string => { if (differenceInDays(endDate!, startDate!) === 0) {