Skip to content

Commit

Permalink
Add shortcut from energy dashboard to energy settings (#18596)
Browse files Browse the repository at this point in the history
  • Loading branch information
karwosts authored Nov 19, 2023
1 parent 860ab7a commit 5ebe1e0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/panels/energy/ha-panel-energy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ import {
html,
nothing,
} from "lit";
import { mdiPencil } from "@mdi/js";
import { customElement, property, state } from "lit/decorators";
import "../../components/ha-menu-button";
import "../../components/ha-list-item";
import "../../components/ha-top-app-bar-fixed";
import { LovelaceConfig } from "../../data/lovelace/config/types";
import { haStyle } from "../../resources/styles";
import { HomeAssistant } from "../../types";
import "../lovelace/components/hui-energy-period-selector";
import { Lovelace } from "../lovelace/types";
import "../lovelace/views/hui-view";
import { navigate } from "../../common/navigate";

const ENERGY_LOVELACE_CONFIG: LovelaceConfig = {
views: [
Expand Down Expand Up @@ -71,7 +74,21 @@ class PanelEnergy extends LitElement {
<hui-energy-period-selector
.hass=${this.hass}
collectionKey="energy_dashboard"
></hui-energy-period-selector>
>
${this.hass.user?.is_admin
? html`
<ha-list-item
slot="overflow-menu"
graphic="icon"
@request-selected=${this._navigateConfig}
>
<ha-svg-icon slot="graphic" .path=${mdiPencil}>
</ha-svg-icon>
${this.hass!.localize("ui.panel.energy.configure")}
</ha-list-item>
`
: nothing}
</hui-energy-period-selector>
</div>
</div>
<hui-view
Expand Down Expand Up @@ -100,6 +117,11 @@ class PanelEnergy extends LitElement {
};
}

private _navigateConfig(ev) {
ev.stopPropagation();
navigate("/config/energy?historyBack=1");
}

private _reloadView() {
// Force strategy to be re-run by make a copy of the view
const config = this._lovelace!.config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ export class HuiEnergyPeriodSelector extends SubscribeMixin(LitElement) {
"ui.panel.lovelace.components.energy_period_selector.compare"
)}
</ha-check-list-item>
<slot name="overflow-menu"></slot>
</ha-button-menu>
</div>
`;
Expand Down
1 change: 1 addition & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6069,6 +6069,7 @@
}
},
"energy": {
"configure": "[%key:ui::dialogs::quick-bar::commands::navigation::energy%]",
"compare": {
"info": "You are comparing the period {start} with the period {end}"
},
Expand Down

0 comments on commit 5ebe1e0

Please sign in to comment.