mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 02:06:42 +00:00
Improve device info add to Lovelace (#10413)
This commit is contained in:
parent
0b2404a0f2
commit
e50d2e16a7
@ -187,7 +187,8 @@ export class HaDeviceEntitiesCard extends LitElement {
|
|||||||
this.hass,
|
this.hass,
|
||||||
this.entities
|
this.entities
|
||||||
.filter((entity) => !entity.disabled_by)
|
.filter((entity) => !entity.disabled_by)
|
||||||
.map((entity) => entity.entity_id)
|
.map((entity) => entity.entity_id),
|
||||||
|
this.deviceName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import {
|
|||||||
AlarmPanelCardConfig,
|
AlarmPanelCardConfig,
|
||||||
EntitiesCardConfig,
|
EntitiesCardConfig,
|
||||||
HumidifierCardConfig,
|
HumidifierCardConfig,
|
||||||
LightCardConfig,
|
|
||||||
PictureEntityCardConfig,
|
PictureEntityCardConfig,
|
||||||
ThermostatCardConfig,
|
ThermostatCardConfig,
|
||||||
} from "../cards/types";
|
} from "../cards/types";
|
||||||
@ -84,8 +83,7 @@ const splitByAreas = (
|
|||||||
|
|
||||||
export const computeCards = (
|
export const computeCards = (
|
||||||
states: Array<[string, HassEntity?]>,
|
states: Array<[string, HassEntity?]>,
|
||||||
entityCardOptions: Partial<EntitiesCardConfig>,
|
entityCardOptions: Partial<EntitiesCardConfig>
|
||||||
single = false
|
|
||||||
): LovelaceCardConfig[] => {
|
): LovelaceCardConfig[] => {
|
||||||
const cards: LovelaceCardConfig[] = [];
|
const cards: LovelaceCardConfig[] = [];
|
||||||
|
|
||||||
@ -123,12 +121,6 @@ export const computeCards = (
|
|||||||
entity: entityId,
|
entity: entityId,
|
||||||
};
|
};
|
||||||
cards.push(cardConfig);
|
cards.push(cardConfig);
|
||||||
} else if (domain === "light" && single) {
|
|
||||||
const cardConfig: LightCardConfig = {
|
|
||||||
type: "light",
|
|
||||||
entity: entityId,
|
|
||||||
};
|
|
||||||
cards.push(cardConfig);
|
|
||||||
} else if (domain === "media_player") {
|
} else if (domain === "media_player") {
|
||||||
const cardConfig = {
|
const cardConfig = {
|
||||||
type: "media-control",
|
type: "media-control",
|
||||||
|
@ -13,8 +13,10 @@ import { showSelectViewDialog } from "./select-view/show-select-view-dialog";
|
|||||||
export const addEntitiesToLovelaceView = async (
|
export const addEntitiesToLovelaceView = async (
|
||||||
element: HTMLElement,
|
element: HTMLElement,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entities: string[]
|
entities: string[],
|
||||||
|
cardTitle?: string
|
||||||
) => {
|
) => {
|
||||||
|
hass.loadFragmentTranslation("lovelace");
|
||||||
const dashboards = await fetchDashboards(hass);
|
const dashboards = await fetchDashboards(hass);
|
||||||
|
|
||||||
const storageDashs = dashboards.filter(
|
const storageDashs = dashboards.filter(
|
||||||
@ -30,6 +32,7 @@ export const addEntitiesToLovelaceView = async (
|
|||||||
showSuggestCardDialog(element, {
|
showSuggestCardDialog(element, {
|
||||||
entities,
|
entities,
|
||||||
yaml: true,
|
yaml: true,
|
||||||
|
cardTitle,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -68,6 +71,7 @@ export const addEntitiesToLovelaceView = async (
|
|||||||
showSuggestCardDialog(element, {
|
showSuggestCardDialog(element, {
|
||||||
entities,
|
entities,
|
||||||
yaml: true,
|
yaml: true,
|
||||||
|
cardTitle,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// all storage dashboards are generated
|
// all storage dashboards are generated
|
||||||
@ -87,6 +91,7 @@ export const addEntitiesToLovelaceView = async (
|
|||||||
|
|
||||||
if (!storageDashs.length && lovelaceConfig.views.length === 1) {
|
if (!storageDashs.length && lovelaceConfig.views.length === 1) {
|
||||||
showSuggestCardDialog(element, {
|
showSuggestCardDialog(element, {
|
||||||
|
cardTitle,
|
||||||
lovelaceConfig: lovelaceConfig!,
|
lovelaceConfig: lovelaceConfig!,
|
||||||
saveConfig: async (newConfig: LovelaceConfig): Promise<void> => {
|
saveConfig: async (newConfig: LovelaceConfig): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
@ -107,9 +112,11 @@ export const addEntitiesToLovelaceView = async (
|
|||||||
lovelaceConfig,
|
lovelaceConfig,
|
||||||
urlPath,
|
urlPath,
|
||||||
allowDashboardChange: true,
|
allowDashboardChange: true,
|
||||||
|
actionLabel: hass.localize("ui.common.next"),
|
||||||
dashboards,
|
dashboards,
|
||||||
viewSelectedCallback: (newUrlPath, selectedDashConfig, viewIndex) => {
|
viewSelectedCallback: (newUrlPath, selectedDashConfig, viewIndex) => {
|
||||||
showSuggestCardDialog(element, {
|
showSuggestCardDialog(element, {
|
||||||
|
cardTitle,
|
||||||
lovelaceConfig: selectedDashConfig,
|
lovelaceConfig: selectedDashConfig,
|
||||||
saveConfig: async (newConfig: LovelaceConfig): Promise<void> => {
|
saveConfig: async (newConfig: LovelaceConfig): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
|
@ -35,8 +35,9 @@ export class HuiDialogSuggestCard extends LitElement {
|
|||||||
entityId,
|
entityId,
|
||||||
this.hass.states[entityId],
|
this.hass.states[entityId],
|
||||||
]),
|
]),
|
||||||
{},
|
{
|
||||||
true
|
title: params.cardTitle,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
if (!Object.isFrozen(this._cardConfig)) {
|
if (!Object.isFrozen(this._cardConfig)) {
|
||||||
this._cardConfig = deepFreeze(this._cardConfig);
|
this._cardConfig = deepFreeze(this._cardConfig);
|
||||||
|
@ -2,6 +2,7 @@ import { fireEvent } from "../../../../common/dom/fire_event";
|
|||||||
import { LovelaceCardConfig, LovelaceConfig } from "../../../../data/lovelace";
|
import { LovelaceCardConfig, LovelaceConfig } from "../../../../data/lovelace";
|
||||||
|
|
||||||
export interface SuggestCardDialogParams {
|
export interface SuggestCardDialogParams {
|
||||||
|
cardTitle?: string;
|
||||||
lovelaceConfig?: LovelaceConfig;
|
lovelaceConfig?: LovelaceConfig;
|
||||||
yaml?: boolean;
|
yaml?: boolean;
|
||||||
saveConfig?: (config: LovelaceConfig) => void;
|
saveConfig?: (config: LovelaceConfig) => void;
|
||||||
|
@ -131,7 +131,7 @@ export class HuiDialogSelectView extends LitElement {
|
|||||||
${this.hass!.localize("ui.common.cancel")}
|
${this.hass!.localize("ui.common.cancel")}
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
<mwc-button slot="primaryAction" @click=${this._selectView}>
|
<mwc-button slot="primaryAction" @click=${this._selectView}>
|
||||||
${this.hass!.localize("ui.common.move")}
|
${this._params.actionLabel || this.hass!.localize("ui.common.move")}
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
</ha-dialog>
|
</ha-dialog>
|
||||||
`;
|
`;
|
||||||
|
@ -7,6 +7,7 @@ export interface SelectViewDialogParams {
|
|||||||
dashboards?: LovelaceDashboard[];
|
dashboards?: LovelaceDashboard[];
|
||||||
urlPath?: string | null;
|
urlPath?: string | null;
|
||||||
header?: string;
|
header?: string;
|
||||||
|
actionLabel?: string;
|
||||||
viewSelectedCallback: (
|
viewSelectedCallback: (
|
||||||
urlPath: string | null,
|
urlPath: string | null,
|
||||||
config: LovelaceConfig,
|
config: LovelaceConfig,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user