mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-15 05:16:34 +00:00
Place System Dashboards at the top with a colored icon in the Dashboard Configuration (#11500)
This commit is contained in:
parent
58ba3e5c22
commit
cc2db9a761
@ -7,6 +7,7 @@ import {
|
|||||||
import "@polymer/paper-tooltip/paper-tooltip";
|
import "@polymer/paper-tooltip/paper-tooltip";
|
||||||
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import memoize from "memoize-one";
|
import memoize from "memoize-one";
|
||||||
import { isComponentLoaded } from "../../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../../common/config/is_component_loaded";
|
||||||
import { navigate } from "../../../../common/navigate";
|
import { navigate } from "../../../../common/navigate";
|
||||||
@ -53,9 +54,19 @@ export class HaConfigLovelaceDashboards extends LitElement {
|
|||||||
icon: {
|
icon: {
|
||||||
title: "",
|
title: "",
|
||||||
type: "icon",
|
type: "icon",
|
||||||
template: (icon) =>
|
template: (icon, dashboard) =>
|
||||||
icon
|
icon
|
||||||
? html` <ha-icon slot="item-icon" .icon=${icon}></ha-icon> `
|
? html`
|
||||||
|
<ha-icon
|
||||||
|
slot="item-icon"
|
||||||
|
.icon=${icon}
|
||||||
|
style=${ifDefined(
|
||||||
|
dashboard.iconColor
|
||||||
|
? `color: ${dashboard.iconColor}`
|
||||||
|
: undefined
|
||||||
|
)}
|
||||||
|
></ha-icon>
|
||||||
|
`
|
||||||
: html``,
|
: html``,
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
@ -64,7 +75,6 @@ export class HaConfigLovelaceDashboards extends LitElement {
|
|||||||
),
|
),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
direction: "asc",
|
|
||||||
grows: true,
|
grows: true,
|
||||||
template: (title, dashboard: any) => {
|
template: (title, dashboard: any) => {
|
||||||
const titleTemplate = html`
|
const titleTemplate = html`
|
||||||
@ -194,12 +204,8 @@ export class HaConfigLovelaceDashboards extends LitElement {
|
|||||||
url_path: "lovelace",
|
url_path: "lovelace",
|
||||||
mode: defaultMode,
|
mode: defaultMode,
|
||||||
filename: defaultMode === "yaml" ? "ui-lovelace.yaml" : "",
|
filename: defaultMode === "yaml" ? "ui-lovelace.yaml" : "",
|
||||||
|
iconColor: "var(--primary-color)",
|
||||||
},
|
},
|
||||||
...dashboards.map((dashboard) => ({
|
|
||||||
filename: "",
|
|
||||||
...dashboard,
|
|
||||||
default: defaultUrlPath === dashboard.url_path,
|
|
||||||
})),
|
|
||||||
];
|
];
|
||||||
if (isComponentLoaded(this.hass, "energy")) {
|
if (isComponentLoaded(this.hass, "energy")) {
|
||||||
result.push({
|
result.push({
|
||||||
@ -209,8 +215,19 @@ export class HaConfigLovelaceDashboards extends LitElement {
|
|||||||
mode: "storage",
|
mode: "storage",
|
||||||
url_path: "energy",
|
url_path: "energy",
|
||||||
filename: "",
|
filename: "",
|
||||||
|
iconColor: "var(--label-badge-yellow)",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.push(
|
||||||
|
...dashboards
|
||||||
|
.sort((a, b) => stringCompare(a.title, b.title))
|
||||||
|
.map((dashboard) => ({
|
||||||
|
filename: "",
|
||||||
|
...dashboard,
|
||||||
|
default: defaultUrlPath === dashboard.url_path,
|
||||||
|
}))
|
||||||
|
);
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user