Improve Lovelace types (#18652)
This commit is contained in:
parent
b9c62c34a0
commit
1cf928b425
|
@ -3,7 +3,7 @@ import { mdiCast, mdiCastConnected } from "@mdi/js";
|
|||
import "@polymer/paper-item/paper-icon-item";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import { Auth, Connection } from "home-assistant-js-websocket";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { CSSResultGroup, LitElement, TemplateResult, css, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { CastManager } from "../../../../src/cast/cast_manager";
|
||||
import {
|
||||
|
@ -22,8 +22,9 @@ import "../../../../src/components/ha-svg-icon";
|
|||
import {
|
||||
getLegacyLovelaceCollection,
|
||||
getLovelaceCollection,
|
||||
LovelaceConfig,
|
||||
} from "../../../../src/data/lovelace";
|
||||
import { isStrategyDashboard } from "../../../../src/data/lovelace/config/types";
|
||||
import { LovelaceViewConfig } from "../../../../src/data/lovelace/config/view";
|
||||
import "../../../../src/layouts/hass-loading-screen";
|
||||
import { generateDefaultViewConfig } from "../../../../src/panels/lovelace/common/generate-lovelace-config";
|
||||
import "./hc-layout";
|
||||
|
@ -38,10 +39,10 @@ class HcCast extends LitElement {
|
|||
|
||||
@state() private askWrite = false;
|
||||
|
||||
@state() private lovelaceConfig?: LovelaceConfig | null;
|
||||
@state() private lovelaceViews?: LovelaceViewConfig[] | null;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (this.lovelaceConfig === undefined) {
|
||||
if (this.lovelaceViews === undefined) {
|
||||
return html`<hass-loading-screen no-toolbar></hass-loading-screen>`;
|
||||
}
|
||||
|
||||
|
@ -86,9 +87,10 @@ class HcCast extends LitElement {
|
|||
attr-for-selected="data-path"
|
||||
.selected=${this.castManager.status.lovelacePath || ""}
|
||||
>
|
||||
${(this.lovelaceConfig
|
||||
? this.lovelaceConfig.views
|
||||
: [generateDefaultViewConfig({}, {}, {}, {}, () => "")]
|
||||
${(
|
||||
this.lovelaceViews ?? [
|
||||
generateDefaultViewConfig({}, {}, {}, {}, () => ""),
|
||||
]
|
||||
).map(
|
||||
(view, idx) => html`
|
||||
<paper-icon-item
|
||||
|
@ -136,11 +138,15 @@ class HcCast extends LitElement {
|
|||
llColl.refresh().then(
|
||||
() => {
|
||||
llColl.subscribe((config) => {
|
||||
this.lovelaceConfig = config;
|
||||
if (isStrategyDashboard(config)) {
|
||||
this.lovelaceViews = null;
|
||||
} else {
|
||||
this.lovelaceViews = config.views;
|
||||
}
|
||||
});
|
||||
},
|
||||
async () => {
|
||||
this.lovelaceConfig = null;
|
||||
this.lovelaceViews = null;
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -159,9 +165,7 @@ class HcCast extends LitElement {
|
|||
toggleAttribute(
|
||||
this,
|
||||
"hide-icons",
|
||||
this.lovelaceConfig
|
||||
? !this.lovelaceConfig.views.some((view) => view.icon)
|
||||
: true
|
||||
this.lovelaceViews ? !this.lovelaceViews.some((view) => view.icon) : true
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import {
|
||||
LovelaceCardConfig,
|
||||
LovelaceConfig,
|
||||
} from "../../../../src/data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../../src/data/lovelace/config/card";
|
||||
import { LovelaceConfig } from "../../../../src/data/lovelace/config/types";
|
||||
import { castContext } from "../cast_context";
|
||||
|
||||
export const castDemoLovelace: () => LovelaceConfig = () => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { html, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { mockHistory } from "../../../../demo/src/stubs/history";
|
||||
import { LovelaceConfig } from "../../../../src/data/lovelace";
|
||||
import { LovelaceConfig } from "../../../../src/data/lovelace/config/types";
|
||||
import {
|
||||
MockHomeAssistant,
|
||||
provideHass,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement, property, query } from "lit/decorators";
|
||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||
import { LovelaceConfig } from "../../../../src/data/lovelace";
|
||||
import { LovelaceConfig } from "../../../../src/data/lovelace/config/types";
|
||||
import { Lovelace } from "../../../../src/panels/lovelace/types";
|
||||
import "../../../../src/panels/lovelace/views/hui-view";
|
||||
import { HomeAssistant } from "../../../../src/types";
|
||||
|
@ -14,7 +14,8 @@ import "./hc-launch-screen";
|
|||
class HcLovelace extends LitElement {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@property({ attribute: false }) public lovelaceConfig!: LovelaceConfig;
|
||||
@property({ attribute: false })
|
||||
public lovelaceConfig!: LovelaceConfig;
|
||||
|
||||
@property() public viewPath?: string | number;
|
||||
|
||||
|
|
|
@ -21,18 +21,26 @@ import {
|
|||
import { atLeastVersion } from "../../../../src/common/config/version";
|
||||
import { isNavigationClick } from "../../../../src/common/dom/is-navigation-click";
|
||||
import {
|
||||
fetchResources,
|
||||
getLegacyLovelaceCollection,
|
||||
getLovelaceCollection,
|
||||
} from "../../../../src/data/lovelace";
|
||||
import {
|
||||
isStrategyDashboard,
|
||||
LegacyLovelaceConfig,
|
||||
LovelaceConfig,
|
||||
} from "../../../../src/data/lovelace";
|
||||
LovelaceDashboardStrategyConfig,
|
||||
} from "../../../../src/data/lovelace/config/types";
|
||||
import { fetchResources } from "../../../../src/data/lovelace/resource";
|
||||
import { loadLovelaceResources } from "../../../../src/panels/lovelace/common/load-resources";
|
||||
import { HassElement } from "../../../../src/state/hass-element";
|
||||
import { castContext } from "../cast_context";
|
||||
import "./hc-launch-screen";
|
||||
|
||||
const DEFAULT_STRATEGY = "original-states";
|
||||
const DEFAULT_CONFIG: LovelaceDashboardStrategyConfig = {
|
||||
strategy: {
|
||||
type: "original-states",
|
||||
},
|
||||
};
|
||||
|
||||
let resourcesLoaded = false;
|
||||
@customElement("hc-main")
|
||||
|
@ -93,7 +101,7 @@ export class HcMain extends HassElement {
|
|||
.lovelaceConfig=${this._lovelaceConfig}
|
||||
.viewPath=${this._lovelacePath}
|
||||
.urlPath=${this._urlPath}
|
||||
@config-refresh=${this._generateLovelaceConfig}
|
||||
@config-refresh=${this._generateDefaultLovelaceConfig}
|
||||
></hc-lovelace>
|
||||
`;
|
||||
}
|
||||
|
@ -284,9 +292,20 @@ export class HcMain extends HassElement {
|
|||
// configuration.
|
||||
try {
|
||||
await llColl.refresh();
|
||||
this._unsubLovelace = llColl.subscribe((lovelaceConfig) =>
|
||||
this._handleNewLovelaceConfig(lovelaceConfig)
|
||||
);
|
||||
this._unsubLovelace = llColl.subscribe(async (rawConfig) => {
|
||||
if (isStrategyDashboard(rawConfig)) {
|
||||
const { generateLovelaceDashboardStrategy } = await import(
|
||||
"../../../../src/panels/lovelace/strategies/get-strategy"
|
||||
);
|
||||
const config = await generateLovelaceDashboardStrategy(
|
||||
rawConfig.strategy,
|
||||
this.hass!
|
||||
);
|
||||
this._handleNewLovelaceConfig(config);
|
||||
} else {
|
||||
this._handleNewLovelaceConfig(rawConfig);
|
||||
}
|
||||
});
|
||||
} catch (err: any) {
|
||||
if (
|
||||
atLeastVersion(this.hass.connection.haVersion, 0, 107) &&
|
||||
|
@ -300,7 +319,7 @@ export class HcMain extends HassElement {
|
|||
}
|
||||
// Generate a Lovelace config.
|
||||
this._unsubLovelace = () => undefined;
|
||||
await this._generateLovelaceConfig();
|
||||
await this._generateDefaultLovelaceConfig();
|
||||
}
|
||||
}
|
||||
if (!resourcesLoaded) {
|
||||
|
@ -316,15 +335,13 @@ export class HcMain extends HassElement {
|
|||
this._sendStatus();
|
||||
}
|
||||
|
||||
private async _generateLovelaceConfig() {
|
||||
private async _generateDefaultLovelaceConfig() {
|
||||
const { generateLovelaceDashboardStrategy } = await import(
|
||||
"../../../../src/panels/lovelace/strategies/get-strategy"
|
||||
);
|
||||
this._handleNewLovelaceConfig(
|
||||
await generateLovelaceDashboardStrategy(
|
||||
{
|
||||
type: DEFAULT_STRATEGY,
|
||||
},
|
||||
DEFAULT_CONFIG.strategy,
|
||||
this.hass!
|
||||
)
|
||||
);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { LocalizeFunc } from "../../../src/common/translations/localize";
|
||||
import { LovelaceConfig } from "../../../src/data/lovelace";
|
||||
import { LovelaceConfig } from "../../../src/data/lovelace/config/types";
|
||||
import { Entity } from "../../../src/fake_data/entity";
|
||||
|
||||
export interface DemoConfig {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { customElement, property, state } from "lit/decorators";
|
|||
import { until } from "lit/directives/until";
|
||||
import "../../../src/components/ha-card";
|
||||
import "../../../src/components/ha-circular-progress";
|
||||
import { LovelaceCardConfig } from "../../../src/data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../src/data/lovelace/config/card";
|
||||
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
import { Lovelace, LovelaceCard } from "../../../src/panels/lovelace/types";
|
||||
import {
|
||||
|
|
|
@ -2,7 +2,7 @@ import "@material/mwc-button";
|
|||
import { css, html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
import "../../../../src/components/ha-card";
|
||||
import { ActionHandlerEvent } from "../../../../src/data/lovelace";
|
||||
import { ActionHandlerEvent } from "../../../../src/data/lovelace/action_handler";
|
||||
import { actionHandler } from "../../../../src/panels/lovelace/common/directives/action-handler-directive";
|
||||
|
||||
@customElement("demo-misc-util-long-press")
|
||||
|
|
|
@ -3,12 +3,9 @@ import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
|
|||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { titleCase } from "../common/string/title-case";
|
||||
import {
|
||||
fetchConfig,
|
||||
LovelaceConfig,
|
||||
LovelaceViewConfig,
|
||||
} from "../data/lovelace";
|
||||
import { ValueChangedEvent, HomeAssistant, PanelInfo } from "../types";
|
||||
import { fetchConfig } from "../data/lovelace/config/types";
|
||||
import { LovelaceViewRawConfig } from "../data/lovelace/config/view";
|
||||
import { HomeAssistant, PanelInfo, ValueChangedEvent } from "../types";
|
||||
import "./ha-combo-box";
|
||||
import type { HaComboBox } from "./ha-combo-box";
|
||||
import "./ha-icon";
|
||||
|
@ -32,7 +29,7 @@ const rowRenderer: ComboBoxLitRenderer<NavigationItem> = (item) => html`
|
|||
|
||||
const createViewNavigationItem = (
|
||||
prefix: string,
|
||||
view: LovelaceViewConfig,
|
||||
view: LovelaceViewRawConfig,
|
||||
index: number
|
||||
) => ({
|
||||
path: `/${prefix}/${view.path ?? index}`,
|
||||
|
@ -121,7 +118,7 @@ export class HaNavigationPicker extends LitElement {
|
|||
panel.url_path === "lovelace" ? null : panel.url_path,
|
||||
true
|
||||
)
|
||||
.then((config) => [panel.id, config] as [string, LovelaceConfig])
|
||||
.then((config) => [panel.id, config] as [string, typeof config])
|
||||
.catch((_) => [panel.id, undefined] as [string, undefined])
|
||||
)
|
||||
);
|
||||
|
@ -135,7 +132,7 @@ export class HaNavigationPicker extends LitElement {
|
|||
|
||||
const config = panelViewConfig.get(panel.id);
|
||||
|
||||
if (!config) continue;
|
||||
if (!config || !("views" in config)) continue;
|
||||
|
||||
config.views.forEach((view, index) =>
|
||||
this.navigationItems.push(
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { ActionConfig } from "../../data/lovelace/config/action";
|
||||
import { UiActionSelector } from "../../data/selector";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import "../../panels/lovelace/components/hui-action-editor";
|
||||
import { ActionConfig } from "../../data/lovelace";
|
||||
import { HomeAssistant } from "../../types";
|
||||
|
||||
@customElement("ha-selector-ui_action")
|
||||
export class HaSelectorUiAction extends LitElement {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { ActionConfig } from "../../data/lovelace";
|
||||
import { UiColorSelector } from "../../data/selector";
|
||||
import "../../panels/lovelace/components/hui-color-picker";
|
||||
import { HomeAssistant } from "../../types";
|
||||
|
@ -12,7 +11,7 @@ export class HaSelectorUiColor extends LitElement {
|
|||
|
||||
@property() public selector!: UiColorSelector;
|
||||
|
||||
@property() public value?: ActionConfig;
|
||||
@property() public value?: string;
|
||||
|
||||
@property() public label?: string;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ import { toggleAttribute } from "../common/dom/toggle_attribute";
|
|||
import { stringCompare } from "../common/string/compare";
|
||||
import { computeRTL } from "../common/util/compute_rtl";
|
||||
import { throttle } from "../common/util/throttle";
|
||||
import { ActionHandlerDetail } from "../data/lovelace";
|
||||
import { ActionHandlerDetail } from "../data/lovelace/action_handler";
|
||||
import {
|
||||
PersistentNotification,
|
||||
subscribeNotifications,
|
||||
|
|
|
@ -2,9 +2,7 @@ import {
|
|||
Connection,
|
||||
getCollection,
|
||||
HassEventBase,
|
||||
HassServiceTarget,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { HASSDomEvent } from "../common/dom/fire_event";
|
||||
import { HuiErrorCard } from "../panels/lovelace/cards/hui-error-card";
|
||||
import {
|
||||
Lovelace,
|
||||
|
@ -12,90 +10,13 @@ import {
|
|||
LovelaceCard,
|
||||
} from "../panels/lovelace/types";
|
||||
import { HomeAssistant } from "../types";
|
||||
import { fetchConfig, LegacyLovelaceConfig } from "./lovelace/config/types";
|
||||
import { LovelaceViewConfig } from "./lovelace/config/view";
|
||||
|
||||
export interface LovelacePanelConfig {
|
||||
mode: "yaml" | "storage";
|
||||
}
|
||||
|
||||
export type LovelaceStrategyConfig = {
|
||||
type: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
export interface LovelaceConfig {
|
||||
title?: string;
|
||||
strategy?: LovelaceStrategyConfig;
|
||||
views: LovelaceViewConfig[];
|
||||
background?: string;
|
||||
}
|
||||
|
||||
export interface LegacyLovelaceConfig extends LovelaceConfig {
|
||||
resources?: LovelaceResource[];
|
||||
}
|
||||
|
||||
export interface LovelaceResource {
|
||||
id: string;
|
||||
type: "css" | "js" | "module" | "html";
|
||||
url: string;
|
||||
}
|
||||
|
||||
export interface LovelaceResourcesMutableParams {
|
||||
res_type: LovelaceResource["type"];
|
||||
url: string;
|
||||
}
|
||||
|
||||
export type LovelaceDashboard =
|
||||
| LovelaceYamlDashboard
|
||||
| LovelaceStorageDashboard;
|
||||
|
||||
interface LovelaceGenericDashboard {
|
||||
id: string;
|
||||
url_path: string;
|
||||
require_admin: boolean;
|
||||
show_in_sidebar: boolean;
|
||||
icon?: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
export interface LovelaceYamlDashboard extends LovelaceGenericDashboard {
|
||||
mode: "yaml";
|
||||
filename: string;
|
||||
}
|
||||
|
||||
export interface LovelaceStorageDashboard extends LovelaceGenericDashboard {
|
||||
mode: "storage";
|
||||
}
|
||||
|
||||
export interface LovelaceDashboardMutableParams {
|
||||
require_admin: boolean;
|
||||
show_in_sidebar: boolean;
|
||||
icon?: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
export interface LovelaceDashboardCreateParams
|
||||
extends LovelaceDashboardMutableParams {
|
||||
url_path: string;
|
||||
mode: "storage";
|
||||
}
|
||||
|
||||
export interface LovelaceViewConfig {
|
||||
index?: number;
|
||||
title?: string;
|
||||
type?: string;
|
||||
strategy?: LovelaceStrategyConfig;
|
||||
badges?: Array<string | LovelaceBadgeConfig>;
|
||||
cards?: LovelaceCardConfig[];
|
||||
path?: string;
|
||||
icon?: string;
|
||||
theme?: string;
|
||||
panel?: boolean;
|
||||
background?: string;
|
||||
visible?: boolean | ShowViewConfig[];
|
||||
subview?: boolean;
|
||||
back_path?: string;
|
||||
}
|
||||
|
||||
export interface LovelaceViewElement extends HTMLElement {
|
||||
hass?: HomeAssistant;
|
||||
lovelace?: Lovelace;
|
||||
|
@ -107,89 +28,6 @@ export interface LovelaceViewElement extends HTMLElement {
|
|||
setConfig(config: LovelaceViewConfig): void;
|
||||
}
|
||||
|
||||
export interface ShowViewConfig {
|
||||
user?: string;
|
||||
}
|
||||
|
||||
export interface LovelaceBadgeConfig {
|
||||
type?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface LovelaceCardConfig {
|
||||
index?: number;
|
||||
view_index?: number;
|
||||
view_layout?: any;
|
||||
type: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface ToggleActionConfig extends BaseActionConfig {
|
||||
action: "toggle";
|
||||
}
|
||||
|
||||
export interface CallServiceActionConfig extends BaseActionConfig {
|
||||
action: "call-service";
|
||||
service: string;
|
||||
target?: HassServiceTarget;
|
||||
// "service_data" is kept for backwards compatibility. Replaced by "data".
|
||||
service_data?: Record<string, unknown>;
|
||||
data?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface NavigateActionConfig extends BaseActionConfig {
|
||||
action: "navigate";
|
||||
navigation_path: string;
|
||||
navigation_replace?: boolean;
|
||||
}
|
||||
|
||||
export interface UrlActionConfig extends BaseActionConfig {
|
||||
action: "url";
|
||||
url_path: string;
|
||||
}
|
||||
|
||||
export interface MoreInfoActionConfig extends BaseActionConfig {
|
||||
action: "more-info";
|
||||
}
|
||||
|
||||
export interface AssistActionConfig extends BaseActionConfig {
|
||||
action: "assist";
|
||||
pipeline_id?: string;
|
||||
start_listening?: boolean;
|
||||
}
|
||||
|
||||
export interface NoActionConfig extends BaseActionConfig {
|
||||
action: "none";
|
||||
}
|
||||
|
||||
export interface CustomActionConfig extends BaseActionConfig {
|
||||
action: "fire-dom-event";
|
||||
}
|
||||
|
||||
export interface BaseActionConfig {
|
||||
action: string;
|
||||
confirmation?: ConfirmationRestrictionConfig;
|
||||
}
|
||||
|
||||
export interface ConfirmationRestrictionConfig {
|
||||
text?: string;
|
||||
exemptions?: RestrictionConfig[];
|
||||
}
|
||||
|
||||
export interface RestrictionConfig {
|
||||
user: string;
|
||||
}
|
||||
|
||||
export type ActionConfig =
|
||||
| ToggleActionConfig
|
||||
| CallServiceActionConfig
|
||||
| NavigateActionConfig
|
||||
| UrlActionConfig
|
||||
| MoreInfoActionConfig
|
||||
| AssistActionConfig
|
||||
| NoActionConfig
|
||||
| CustomActionConfig;
|
||||
|
||||
type LovelaceUpdatedEvent = HassEventBase & {
|
||||
event_type: "lovelace_updated";
|
||||
data: {
|
||||
|
@ -198,101 +36,6 @@ type LovelaceUpdatedEvent = HassEventBase & {
|
|||
};
|
||||
};
|
||||
|
||||
export const fetchResources = (conn: Connection): Promise<LovelaceResource[]> =>
|
||||
conn.sendMessagePromise({
|
||||
type: "lovelace/resources",
|
||||
});
|
||||
|
||||
export const createResource = (
|
||||
hass: HomeAssistant,
|
||||
values: LovelaceResourcesMutableParams
|
||||
) =>
|
||||
hass.callWS<LovelaceResource>({
|
||||
type: "lovelace/resources/create",
|
||||
...values,
|
||||
});
|
||||
|
||||
export const updateResource = (
|
||||
hass: HomeAssistant,
|
||||
id: string,
|
||||
updates: Partial<LovelaceResourcesMutableParams>
|
||||
) =>
|
||||
hass.callWS<LovelaceResource>({
|
||||
type: "lovelace/resources/update",
|
||||
resource_id: id,
|
||||
...updates,
|
||||
});
|
||||
|
||||
export const deleteResource = (hass: HomeAssistant, id: string) =>
|
||||
hass.callWS({
|
||||
type: "lovelace/resources/delete",
|
||||
resource_id: id,
|
||||
});
|
||||
|
||||
export const fetchDashboards = (
|
||||
hass: HomeAssistant
|
||||
): Promise<LovelaceDashboard[]> =>
|
||||
hass.callWS({
|
||||
type: "lovelace/dashboards/list",
|
||||
});
|
||||
|
||||
export const createDashboard = (
|
||||
hass: HomeAssistant,
|
||||
values: LovelaceDashboardCreateParams
|
||||
) =>
|
||||
hass.callWS<LovelaceDashboard>({
|
||||
type: "lovelace/dashboards/create",
|
||||
...values,
|
||||
});
|
||||
|
||||
export const updateDashboard = (
|
||||
hass: HomeAssistant,
|
||||
id: string,
|
||||
updates: Partial<LovelaceDashboardMutableParams>
|
||||
) =>
|
||||
hass.callWS<LovelaceDashboard>({
|
||||
type: "lovelace/dashboards/update",
|
||||
dashboard_id: id,
|
||||
...updates,
|
||||
});
|
||||
|
||||
export const deleteDashboard = (hass: HomeAssistant, id: string) =>
|
||||
hass.callWS({
|
||||
type: "lovelace/dashboards/delete",
|
||||
dashboard_id: id,
|
||||
});
|
||||
|
||||
export const fetchConfig = (
|
||||
conn: Connection,
|
||||
urlPath: string | null,
|
||||
force: boolean
|
||||
): Promise<LovelaceConfig> =>
|
||||
conn.sendMessagePromise({
|
||||
type: "lovelace/config",
|
||||
url_path: urlPath,
|
||||
force,
|
||||
});
|
||||
|
||||
export const saveConfig = (
|
||||
hass: HomeAssistant,
|
||||
urlPath: string | null,
|
||||
config: LovelaceConfig
|
||||
): Promise<void> =>
|
||||
hass.callWS({
|
||||
type: "lovelace/config/save",
|
||||
url_path: urlPath,
|
||||
config,
|
||||
});
|
||||
|
||||
export const deleteConfig = (
|
||||
hass: HomeAssistant,
|
||||
urlPath: string | null
|
||||
): Promise<void> =>
|
||||
hass.callWS({
|
||||
type: "lovelace/config/delete",
|
||||
url_path: urlPath,
|
||||
});
|
||||
|
||||
export const subscribeLovelaceUpdates = (
|
||||
conn: Connection,
|
||||
urlPath: string | null,
|
||||
|
@ -324,7 +67,7 @@ export const getLovelaceCollection = (
|
|||
const fetchLegacyConfig = (
|
||||
conn: Connection,
|
||||
force: boolean
|
||||
): Promise<LovelaceConfig> =>
|
||||
): Promise<LegacyLovelaceConfig> =>
|
||||
conn.sendMessagePromise({
|
||||
type: "lovelace/config",
|
||||
force,
|
||||
|
@ -347,15 +90,3 @@ export const getLegacyLovelaceCollection = (conn: Connection) =>
|
|||
)
|
||||
)
|
||||
);
|
||||
|
||||
export interface ActionHandlerOptions {
|
||||
hasHold?: boolean;
|
||||
hasDoubleClick?: boolean;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export interface ActionHandlerDetail {
|
||||
action: "hold" | "tap" | "double_tap";
|
||||
}
|
||||
|
||||
export type ActionHandlerEvent = HASSDomEvent<ActionHandlerDetail>;
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import { HASSDomEvent } from "../../common/dom/fire_event";
|
||||
|
||||
export interface ActionHandlerOptions {
|
||||
hasHold?: boolean;
|
||||
hasDoubleClick?: boolean;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export interface ActionHandlerDetail {
|
||||
action: "hold" | "tap" | "double_tap";
|
||||
}
|
||||
|
||||
export type ActionHandlerEvent = HASSDomEvent<ActionHandlerDetail>;
|
|
@ -0,0 +1,67 @@
|
|||
import type { HassServiceTarget } from "home-assistant-js-websocket";
|
||||
|
||||
export interface ToggleActionConfig extends BaseActionConfig {
|
||||
action: "toggle";
|
||||
}
|
||||
|
||||
export interface CallServiceActionConfig extends BaseActionConfig {
|
||||
action: "call-service";
|
||||
service: string;
|
||||
target?: HassServiceTarget;
|
||||
// "service_data" is kept for backwards compatibility. Replaced by "data".
|
||||
service_data?: Record<string, unknown>;
|
||||
data?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface NavigateActionConfig extends BaseActionConfig {
|
||||
action: "navigate";
|
||||
navigation_path: string;
|
||||
navigation_replace?: boolean;
|
||||
}
|
||||
|
||||
export interface UrlActionConfig extends BaseActionConfig {
|
||||
action: "url";
|
||||
url_path: string;
|
||||
}
|
||||
|
||||
export interface MoreInfoActionConfig extends BaseActionConfig {
|
||||
action: "more-info";
|
||||
}
|
||||
|
||||
export interface AssistActionConfig extends BaseActionConfig {
|
||||
action: "assist";
|
||||
pipeline_id?: string;
|
||||
start_listening?: boolean;
|
||||
}
|
||||
|
||||
export interface NoActionConfig extends BaseActionConfig {
|
||||
action: "none";
|
||||
}
|
||||
|
||||
export interface CustomActionConfig extends BaseActionConfig {
|
||||
action: "fire-dom-event";
|
||||
}
|
||||
|
||||
export interface BaseActionConfig {
|
||||
action: string;
|
||||
confirmation?: ConfirmationRestrictionConfig;
|
||||
}
|
||||
|
||||
export interface ConfirmationRestrictionConfig {
|
||||
text?: string;
|
||||
exemptions?: RestrictionConfig[];
|
||||
}
|
||||
|
||||
export interface RestrictionConfig {
|
||||
user: string;
|
||||
}
|
||||
|
||||
export type ActionConfig =
|
||||
| ToggleActionConfig
|
||||
| CallServiceActionConfig
|
||||
| NavigateActionConfig
|
||||
| UrlActionConfig
|
||||
| MoreInfoActionConfig
|
||||
| AssistActionConfig
|
||||
| NoActionConfig
|
||||
| CustomActionConfig;
|
|
@ -0,0 +1,4 @@
|
|||
export interface LovelaceBadgeConfig {
|
||||
type?: string;
|
||||
[key: string]: any;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
export interface LovelaceCardConfig {
|
||||
index?: number;
|
||||
view_index?: number;
|
||||
view_layout?: any;
|
||||
type: string;
|
||||
[key: string]: any;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
export interface LovelaceStrategyConfig {
|
||||
type: string;
|
||||
[key: string]: any;
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
import type { Connection } from "home-assistant-js-websocket";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { LovelaceResource } from "../resource";
|
||||
import type { LovelaceStrategyConfig } from "./strategy";
|
||||
import type { LovelaceViewRawConfig } from "./view";
|
||||
|
||||
export interface LovelaceDashboardBaseConfig {}
|
||||
|
||||
export interface LovelaceConfig extends LovelaceDashboardBaseConfig {
|
||||
title?: string;
|
||||
background?: string;
|
||||
views: LovelaceViewRawConfig[];
|
||||
}
|
||||
|
||||
export interface LovelaceDashboardStrategyConfig
|
||||
extends LovelaceDashboardBaseConfig {
|
||||
strategy: LovelaceStrategyConfig;
|
||||
}
|
||||
|
||||
export interface LegacyLovelaceConfig extends LovelaceConfig {
|
||||
resources?: LovelaceResource[];
|
||||
}
|
||||
|
||||
export type LovelaceRawConfig =
|
||||
| LovelaceConfig
|
||||
| LovelaceDashboardStrategyConfig;
|
||||
|
||||
export function isStrategyDashboard(
|
||||
config: LovelaceRawConfig
|
||||
): config is LovelaceDashboardStrategyConfig {
|
||||
return "strategy" in config;
|
||||
}
|
||||
|
||||
export const fetchConfig = (
|
||||
conn: Connection,
|
||||
urlPath: string | null,
|
||||
force: boolean
|
||||
): Promise<LovelaceRawConfig> =>
|
||||
conn.sendMessagePromise({
|
||||
type: "lovelace/config",
|
||||
url_path: urlPath,
|
||||
force,
|
||||
});
|
||||
|
||||
export const saveConfig = (
|
||||
hass: HomeAssistant,
|
||||
urlPath: string | null,
|
||||
config: LovelaceRawConfig
|
||||
): Promise<void> =>
|
||||
hass.callWS({
|
||||
type: "lovelace/config/save",
|
||||
url_path: urlPath,
|
||||
config,
|
||||
});
|
||||
|
||||
export const deleteConfig = (
|
||||
hass: HomeAssistant,
|
||||
urlPath: string | null
|
||||
): Promise<void> =>
|
||||
hass.callWS({
|
||||
type: "lovelace/config/delete",
|
||||
url_path: urlPath,
|
||||
});
|
|
@ -0,0 +1,40 @@
|
|||
import type { LovelaceBadgeConfig } from "./badge";
|
||||
import type { LovelaceCardConfig } from "./card";
|
||||
import type { LovelaceStrategyConfig } from "./strategy";
|
||||
|
||||
export interface ShowViewConfig {
|
||||
user?: string;
|
||||
}
|
||||
|
||||
export interface LovelaceBaseViewConfig {
|
||||
index?: number;
|
||||
title?: string;
|
||||
path?: string;
|
||||
icon?: string;
|
||||
theme?: string;
|
||||
panel?: boolean;
|
||||
background?: string;
|
||||
visible?: boolean | ShowViewConfig[];
|
||||
subview?: boolean;
|
||||
back_path?: string;
|
||||
}
|
||||
|
||||
export interface LovelaceViewConfig extends LovelaceBaseViewConfig {
|
||||
type?: string;
|
||||
badges?: Array<string | LovelaceBadgeConfig>;
|
||||
cards?: LovelaceCardConfig[];
|
||||
}
|
||||
|
||||
export interface LovelaceStrategyViewConfig extends LovelaceBaseViewConfig {
|
||||
strategy: LovelaceStrategyConfig;
|
||||
}
|
||||
|
||||
export type LovelaceViewRawConfig =
|
||||
| LovelaceViewConfig
|
||||
| LovelaceStrategyViewConfig;
|
||||
|
||||
export function isStrategyView(
|
||||
view: LovelaceViewRawConfig
|
||||
): view is LovelaceStrategyViewConfig {
|
||||
return "strategy" in view;
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
import type { HomeAssistant } from "../../types";
|
||||
|
||||
export type LovelaceDashboard =
|
||||
| LovelaceYamlDashboard
|
||||
| LovelaceStorageDashboard;
|
||||
|
||||
interface LovelaceGenericDashboard {
|
||||
id: string;
|
||||
url_path: string;
|
||||
require_admin: boolean;
|
||||
show_in_sidebar: boolean;
|
||||
icon?: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
export interface LovelaceYamlDashboard extends LovelaceGenericDashboard {
|
||||
mode: "yaml";
|
||||
filename: string;
|
||||
}
|
||||
|
||||
export interface LovelaceStorageDashboard extends LovelaceGenericDashboard {
|
||||
mode: "storage";
|
||||
}
|
||||
|
||||
export interface LovelaceDashboardMutableParams {
|
||||
require_admin: boolean;
|
||||
show_in_sidebar: boolean;
|
||||
icon?: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
export interface LovelaceDashboardCreateParams
|
||||
extends LovelaceDashboardMutableParams {
|
||||
url_path: string;
|
||||
mode: "storage";
|
||||
}
|
||||
|
||||
export const fetchDashboards = (
|
||||
hass: HomeAssistant
|
||||
): Promise<LovelaceDashboard[]> =>
|
||||
hass.callWS({
|
||||
type: "lovelace/dashboards/list",
|
||||
});
|
||||
|
||||
export const createDashboard = (
|
||||
hass: HomeAssistant,
|
||||
values: LovelaceDashboardCreateParams
|
||||
) =>
|
||||
hass.callWS<LovelaceDashboard>({
|
||||
type: "lovelace/dashboards/create",
|
||||
...values,
|
||||
});
|
||||
|
||||
export const updateDashboard = (
|
||||
hass: HomeAssistant,
|
||||
id: string,
|
||||
updates: Partial<LovelaceDashboardMutableParams>
|
||||
) =>
|
||||
hass.callWS<LovelaceDashboard>({
|
||||
type: "lovelace/dashboards/update",
|
||||
dashboard_id: id,
|
||||
...updates,
|
||||
});
|
||||
|
||||
export const deleteDashboard = (hass: HomeAssistant, id: string) =>
|
||||
hass.callWS({
|
||||
type: "lovelace/dashboards/delete",
|
||||
dashboard_id: id,
|
||||
});
|
|
@ -0,0 +1,44 @@
|
|||
import type { Connection } from "home-assistant-js-websocket";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
|
||||
export type LovelaceResource = {
|
||||
id: string;
|
||||
type: "css" | "js" | "module" | "html";
|
||||
url: string;
|
||||
};
|
||||
|
||||
export type LovelaceResourcesMutableParams = {
|
||||
res_type: LovelaceResource["type"];
|
||||
url: string;
|
||||
};
|
||||
|
||||
export const fetchResources = (conn: Connection): Promise<LovelaceResource[]> =>
|
||||
conn.sendMessagePromise({
|
||||
type: "lovelace/resources",
|
||||
});
|
||||
|
||||
export const createResource = (
|
||||
hass: HomeAssistant,
|
||||
values: LovelaceResourcesMutableParams
|
||||
) =>
|
||||
hass.callWS<LovelaceResource>({
|
||||
type: "lovelace/resources/create",
|
||||
...values,
|
||||
});
|
||||
|
||||
export const updateResource = (
|
||||
hass: HomeAssistant,
|
||||
id: string,
|
||||
updates: Partial<LovelaceResourcesMutableParams>
|
||||
) =>
|
||||
hass.callWS<LovelaceResource>({
|
||||
type: "lovelace/resources/update",
|
||||
resource_id: id,
|
||||
...updates,
|
||||
});
|
||||
|
||||
export const deleteResource = (hass: HomeAssistant, id: string) =>
|
||||
hass.callWS({
|
||||
type: "lovelace/resources/delete",
|
||||
resource_id: id,
|
||||
});
|
|
@ -1,8 +1,9 @@
|
|||
import { LovelaceConfig, LovelaceResource } from "./lovelace";
|
||||
import { LovelaceRawConfig } from "./lovelace/config/types";
|
||||
import { LovelaceResource } from "./lovelace/resource";
|
||||
import { RecorderInfo } from "./recorder";
|
||||
|
||||
export interface WindowWithPreloads extends Window {
|
||||
llConfProm?: Promise<LovelaceConfig>;
|
||||
llConfProm?: Promise<LovelaceRawConfig>;
|
||||
llResProm?: Promise<LovelaceResource[]>;
|
||||
recorderInfoProm?: Promise<RecorderInfo>;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ import { hassUrl } from "../data/auth";
|
|||
import { isExternal } from "../data/external";
|
||||
import { getRecorderInfo } from "../data/recorder";
|
||||
import { subscribeFrontendUserData } from "../data/frontend";
|
||||
import { fetchConfig, fetchResources } from "../data/lovelace";
|
||||
import { fetchConfig } from "../data/lovelace/config/types";
|
||||
import { fetchResources } from "../data/lovelace/resource";
|
||||
import { subscribePanels } from "../data/ws-panels";
|
||||
import { subscribeThemes } from "../data/ws-themes";
|
||||
import { subscribeRepairsIssueRegistry } from "../data/repairs";
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
LovelaceDashboard,
|
||||
LovelaceDashboardCreateParams,
|
||||
LovelaceDashboardMutableParams,
|
||||
} from "../../../../data/lovelace";
|
||||
} from "../../../../data/lovelace/dashboard";
|
||||
import { DEFAULT_PANEL, setDefaultPanel } from "../../../../data/panel";
|
||||
import { haStyleDialog } from "../../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../../types";
|
||||
|
|
|
@ -28,15 +28,15 @@ import {
|
|||
fetchDashboards,
|
||||
LovelaceDashboard,
|
||||
LovelaceDashboardCreateParams,
|
||||
LovelacePanelConfig,
|
||||
updateDashboard,
|
||||
} from "../../../../data/lovelace";
|
||||
} from "../../../../data/lovelace/dashboard";
|
||||
import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box";
|
||||
import "../../../../layouts/hass-loading-screen";
|
||||
import "../../../../layouts/hass-tabs-subpage-data-table";
|
||||
import { HomeAssistant, Route } from "../../../../types";
|
||||
import { lovelaceTabs } from "../ha-config-lovelace";
|
||||
import { showDashboardDetailDialog } from "./show-dialog-lovelace-dashboard-detail";
|
||||
import { LovelacePanelConfig } from "../../../../data/lovelace";
|
||||
|
||||
type DataTableItem = Pick<
|
||||
LovelaceDashboard,
|
||||
|
|
|
@ -3,7 +3,7 @@ import {
|
|||
LovelaceDashboard,
|
||||
LovelaceDashboardCreateParams,
|
||||
LovelaceDashboardMutableParams,
|
||||
} from "../../../../data/lovelace";
|
||||
} from "../../../../data/lovelace/dashboard";
|
||||
|
||||
export interface LovelaceDashboardDetailsDialogParams {
|
||||
dashboard?: LovelaceDashboard;
|
||||
|
|
|
@ -6,7 +6,7 @@ import { fireEvent } from "../../../../common/dom/fire_event";
|
|||
import { createCloseHeading } from "../../../../components/ha-dialog";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
import { SchemaUnion } from "../../../../components/ha-form/types";
|
||||
import { LovelaceResourcesMutableParams } from "../../../../data/lovelace";
|
||||
import { LovelaceResourcesMutableParams } from "../../../../data/lovelace/resource";
|
||||
import { haStyleDialog } from "../../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../../types";
|
||||
import { LovelaceResourceDetailsDialogParams } from "./show-dialog-lovelace-resource-detail";
|
||||
|
|
|
@ -23,7 +23,7 @@ import {
|
|||
fetchResources,
|
||||
LovelaceResource,
|
||||
updateResource,
|
||||
} from "../../../../data/lovelace";
|
||||
} from "../../../../data/lovelace/resource";
|
||||
import {
|
||||
showAlertDialog,
|
||||
showConfirmationDialog,
|
||||
|
|
|
@ -2,7 +2,7 @@ import { fireEvent } from "../../../../common/dom/fire_event";
|
|||
import {
|
||||
LovelaceResource,
|
||||
LovelaceResourcesMutableParams,
|
||||
} from "../../../../data/lovelace";
|
||||
} from "../../../../data/lovelace/resource";
|
||||
|
||||
export interface LovelaceResourceDetailsDialogParams {
|
||||
resource?: LovelaceResource;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import "@material/mwc-button/mwc-button";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
|
@ -7,18 +8,17 @@ import {
|
|||
getEnergyInfo,
|
||||
saveEnergyPreferences,
|
||||
} from "../../../data/energy";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||
import { haStyle } from "../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { LovelaceCard, Lovelace } from "../../lovelace/types";
|
||||
import "@material/mwc-button/mwc-button";
|
||||
import "../../config/energy/components/ha-energy-battery-settings";
|
||||
import "../../config/energy/components/ha-energy-device-settings";
|
||||
import "../../config/energy/components/ha-energy-gas-settings";
|
||||
import "../../config/energy/components/ha-energy-grid-settings";
|
||||
import "../../config/energy/components/ha-energy-solar-settings";
|
||||
import "../../config/energy/components/ha-energy-battery-settings";
|
||||
import "../../config/energy/components/ha-energy-gas-settings";
|
||||
import "../../config/energy/components/ha-energy-water-settings";
|
||||
import "../../config/energy/components/ha-energy-device-settings";
|
||||
import { haStyle } from "../../../resources/styles";
|
||||
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||
import { Lovelace, LovelaceCard } from "../../lovelace/types";
|
||||
|
||||
@customElement("energy-setup-wizard-card")
|
||||
export class EnergySetupWizard extends LitElement implements LovelaceCard {
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
import {
|
||||
css,
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
css,
|
||||
html,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import "../../components/ha-menu-button";
|
||||
import { LovelaceConfig } from "../../data/lovelace";
|
||||
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 "../../components/ha-top-app-bar-fixed";
|
||||
|
||||
const ENERGY_LOVELACE_CONFIG: LovelaceConfig = {
|
||||
views: [
|
||||
|
|
|
@ -5,11 +5,9 @@ import {
|
|||
getEnergyPreferences,
|
||||
GridSourceTypeEnergyPreference,
|
||||
} from "../../../data/energy";
|
||||
import {
|
||||
LovelaceStrategyConfig,
|
||||
LovelaceViewConfig,
|
||||
} from "../../../data/lovelace";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
||||
import { LovelaceStrategyConfig } from "../../../data/lovelace/config/strategy";
|
||||
|
||||
const setupWizard = async (): Promise<LovelaceViewConfig> => {
|
||||
await import("../cards/energy-setup-wizard-card");
|
||||
|
|
|
@ -2,13 +2,13 @@ import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
|||
import { customElement, property } from "lit/decorators";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import "../../../components/entity/ha-state-label-badge";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
import { handleAction } from "../common/handle-action";
|
||||
import { hasAction } from "../common/has-action";
|
||||
import { LovelaceBadge } from "../types";
|
||||
import { StateLabelBadgeConfig } from "./types";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||
|
||||
@customElement("hui-state-label-badge")
|
||||
export class HuiStateLabelBadge extends LitElement implements LovelaceBadge {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { ActionConfig, LovelaceBadgeConfig } from "../../../data/lovelace";
|
||||
import { ActionConfig } from "../../../data/lovelace/config/action";
|
||||
import { LovelaceBadgeConfig } from "../../../data/lovelace/config/badge";
|
||||
import { EntityFilterEntityConfig } from "../entity-rows/types";
|
||||
|
||||
export interface EntityFilterBadgeConfig extends LovelaceBadgeConfig {
|
||||
|
|
|
@ -44,7 +44,7 @@ import {
|
|||
themesContext,
|
||||
} from "../../../data/context";
|
||||
import { EntityRegistryDisplayEntry } from "../../../data/entity_registry";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||
import { FrontendLocaleData } from "../../../data/translation";
|
||||
import { Themes } from "../../../data/ws-themes";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { customElement } from "lit/decorators";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import { computeCardSize } from "../common/compute-card-size";
|
||||
import { HuiConditionalBase } from "../components/hui-conditional-base";
|
||||
import { createCardElement } from "../create-element/create-card-element";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { PropertyValues, ReactiveElement } from "lit";
|
||||
import { property, state } from "lit/decorators";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { computeCardSize } from "../common/compute-card-size";
|
||||
import { evaluateFilter } from "../common/evaluate-filter";
|
||||
|
|
|
@ -18,24 +18,24 @@ import "../../../components/ha-card";
|
|||
import "../../../components/ha-icon";
|
||||
import "../../../components/ha-relative-time";
|
||||
import { isUnavailableState } from "../../../data/entity";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||
import {
|
||||
ActionHandlerEvent,
|
||||
CallServiceActionConfig,
|
||||
MoreInfoActionConfig,
|
||||
} from "../../../data/lovelace";
|
||||
} from "../../../data/lovelace/config/action";
|
||||
import { SENSOR_DEVICE_CLASS_TIMESTAMP } from "../../../data/sensor";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
import { findEntities } from "../common/find-entities";
|
||||
import { handleAction } from "../common/handle-action";
|
||||
import { hasAction } from "../common/has-action";
|
||||
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
|
||||
import { processConfigEntities } from "../common/process-config-entities";
|
||||
import "../components/hui-timestamp-display";
|
||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||
import "../components/hui-warning-element";
|
||||
import { LovelaceCard, LovelaceCardEditor } from "../types";
|
||||
import { GlanceCardConfig, GlanceConfigEntity } from "./types";
|
||||
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
|
||||
|
||||
@customElement("hui-glance-card")
|
||||
export class HuiGlanceCard extends LitElement implements LovelaceCard {
|
||||
|
|
|
@ -20,7 +20,7 @@ import "../../../components/ha-icon-button";
|
|||
import "../../../components/ha-state-icon";
|
||||
import { UNAVAILABLE, isUnavailableState } from "../../../data/entity";
|
||||
import { LightEntity, lightSupportsBrightness } from "../../../data/light";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
import { findEntities } from "../common/find-entities";
|
||||
|
|
|
@ -12,7 +12,7 @@ import { ifDefined } from "lit/directives/if-defined";
|
|||
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
||||
import "../../../components/ha-card";
|
||||
import { computeImageUrl, ImageEntity } from "../../../data/image";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
import { handleAction } from "../common/handle-action";
|
||||
|
|
|
@ -14,7 +14,7 @@ import { computeDomain } from "../../../common/entity/compute_domain";
|
|||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||
import "../../../components/ha-card";
|
||||
import { ImageEntity, computeImageUrl } from "../../../data/image";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
import { findEntities } from "../common/find-entities";
|
||||
|
|
|
@ -18,7 +18,7 @@ import "../../../components/ha-card";
|
|||
import "../../../components/ha-icon-button";
|
||||
import "../../../components/ha-state-icon";
|
||||
import { computeImageUrl, ImageEntity } from "../../../data/image";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
import { findEntities } from "../common/find-entities";
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
nothing,
|
||||
} from "lit";
|
||||
import { property, state } from "lit/decorators";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { createCardElement } from "../create-element/create-card-element";
|
||||
import { LovelaceCard, LovelaceCardEditor } from "../types";
|
||||
|
|
|
@ -12,7 +12,7 @@ import { customElement, property } from "lit/decorators";
|
|||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import "../../../components/ha-card";
|
||||
import "../../../components/ha-circular-progress";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { LovelaceCard } from "../types";
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import "../../../components/tile/ha-tile-image";
|
|||
import "../../../components/tile/ha-tile-info";
|
||||
import { cameraUrlWithWidthHeight } from "../../../data/camera";
|
||||
import { isUnavailableState } from "../../../data/entity";
|
||||
import type { ActionHandlerEvent } from "../../../data/lovelace";
|
||||
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||
import { SENSOR_DEVICE_CLASS_TIMESTAMP } from "../../../data/sensor";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
|
|
|
@ -18,7 +18,7 @@ import { debounce } from "../../../common/util/debounce";
|
|||
import "../../../components/ha-card";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import { UNAVAILABLE } from "../../../data/entity";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||
import {
|
||||
ForecastEvent,
|
||||
WeatherEntity,
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import { HaDurationData } from "../../../components/ha-duration-input";
|
||||
import { ActionConfig } from "../../../data/lovelace/config/action";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import { Statistic, StatisticType } from "../../../data/recorder";
|
||||
import { ActionConfig, LovelaceCardConfig } from "../../../data/lovelace";
|
||||
import { ForecastType } from "../../../data/weather";
|
||||
import { FullCalendarView, TranslationDict } from "../../../types";
|
||||
import { Condition, LegacyCondition } from "../common/validate-condition";
|
||||
import { HuiImage } from "../components/hui-image";
|
||||
|
@ -10,9 +13,7 @@ import {
|
|||
LovelaceRowConfig,
|
||||
} from "../entity-rows/types";
|
||||
import { LovelaceHeaderFooterConfig } from "../header-footer/types";
|
||||
import { HaDurationData } from "../../../components/ha-duration-input";
|
||||
import { LovelaceTileFeatureConfig } from "../tile-features/types";
|
||||
import { ForecastType } from "../../../data/weather";
|
||||
|
||||
export type AlarmPanelCardConfigState =
|
||||
| "arm_away"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||
import { ActionConfig } from "../../../data/lovelace";
|
||||
import { ActionConfig } from "../../../data/lovelace/config/action";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
|
||||
interface Config {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { ActionConfig, LovelaceConfig } from "../../../data/lovelace";
|
||||
import { ActionConfig } from "../../../data/lovelace/config/action";
|
||||
import { LovelaceConfig } from "../../../data/lovelace/config/types";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
|
||||
export const EXCLUDED_DOMAINS = ["zone", "persistent_notification"];
|
||||
|
|
|
@ -13,7 +13,7 @@ import { deepEqual } from "../../../../common/util/deep-equal";
|
|||
import {
|
||||
ActionHandlerDetail,
|
||||
ActionHandlerOptions,
|
||||
} from "../../../../data/lovelace";
|
||||
} from "../../../../data/lovelace/action_handler";
|
||||
|
||||
const isTouch =
|
||||
"ontouchstart" in window ||
|
||||
|
|
|
@ -12,7 +12,8 @@ import {
|
|||
GridSourceTypeEnergyPreference,
|
||||
} from "../../../data/energy";
|
||||
import { domainToName } from "../../../data/integration";
|
||||
import { LovelaceCardConfig, LovelaceViewConfig } from "../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
||||
import { computeUserInitials } from "../../../data/user";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { HELPER_DOMAINS } from "../../config/helpers/const";
|
||||
|
|
|
@ -2,7 +2,7 @@ import { fireEvent } from "../../../common/dom/fire_event";
|
|||
import { navigate } from "../../../common/navigate";
|
||||
import { forwardHaptic } from "../../../data/haptics";
|
||||
import { domainToName } from "../../../data/integration";
|
||||
import { ActionConfig } from "../../../data/lovelace";
|
||||
import { ActionConfig } from "../../../data/lovelace/config/action";
|
||||
import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||
import { showVoiceCommandDialog } from "../../../dialogs/voice-command-dialog/show-ha-voice-command-dialog";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ActionConfig } from "../../../data/lovelace";
|
||||
import { ActionConfig } from "../../../data/lovelace/config/action";
|
||||
|
||||
export function hasAction(config?: ActionConfig): boolean {
|
||||
return config !== undefined && config.action !== "none";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { loadCSS, loadJS, loadModule } from "../../../common/dom/load_resource";
|
||||
import { LovelaceResource } from "../../../data/lovelace";
|
||||
import { LovelaceResource } from "../../../data/lovelace/resource";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
|
||||
// CSS and JS should only be imported once. Modules and HTML are safe.
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
CallServiceActionConfig,
|
||||
NavigateActionConfig,
|
||||
UrlActionConfig,
|
||||
} from "../../../data/lovelace";
|
||||
} from "../../../data/lovelace/config/action";
|
||||
import { ServiceAction } from "../../../data/script";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { EditorTarget } from "../editor/types";
|
||||
|
|
|
@ -2,7 +2,7 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
|||
import { customElement, state, property } from "lit/decorators";
|
||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||
import "../../../components/entity/state-badge";
|
||||
import type { ActionHandlerEvent } from "../../../data/lovelace";
|
||||
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { EntitiesCardEntityConfig } from "../cards/types";
|
||||
import { computeTooltip } from "../common/compute-tooltip";
|
||||
|
|
|
@ -26,7 +26,9 @@ import { fireEvent } from "../../../common/dom/fire_event";
|
|||
import "../../../components/ha-button-menu";
|
||||
import "../../../components/ha-icon-button";
|
||||
import "../../../components/ha-list-item";
|
||||
import { LovelaceCardConfig, saveConfig } from "../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import { saveConfig } from "../../../data/lovelace/config/types";
|
||||
import { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
||||
import {
|
||||
showAlertDialog,
|
||||
showPromptDialog,
|
||||
|
@ -80,6 +82,10 @@ export class HuiCardOptions extends LitElement {
|
|||
);
|
||||
}
|
||||
|
||||
private get _currentView() {
|
||||
return this.lovelace!.config.views[this.path![0]] as LovelaceViewConfig;
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<div class="card"><slot></slot></div>
|
||||
|
@ -118,8 +124,7 @@ export class HuiCardOptions extends LitElement {
|
|||
.path=${mdiPlus}
|
||||
class="move-arrow"
|
||||
@click=${this._increaseCardPosition}
|
||||
.disabled=${this.lovelace!.config.views[this.path![0]]
|
||||
.cards!.length ===
|
||||
.disabled=${this._currentView.cards!.length ===
|
||||
this.path![1] + 1}
|
||||
></ha-icon-button>
|
||||
`
|
||||
|
@ -267,7 +272,7 @@ export class HuiCardOptions extends LitElement {
|
|||
|
||||
private _duplicateCard(): void {
|
||||
const path = this.path!;
|
||||
const cardConfig = this.lovelace!.config.views[path[0]].cards![path[1]];
|
||||
const cardConfig = this._currentView.cards![path[1]];
|
||||
showEditCardDialog(this, {
|
||||
lovelaceConfig: this.lovelace!.config,
|
||||
cardConfig,
|
||||
|
@ -286,8 +291,7 @@ export class HuiCardOptions extends LitElement {
|
|||
}
|
||||
|
||||
private _copyCard(): void {
|
||||
const cardConfig =
|
||||
this.lovelace!.config.views[this.path![0]].cards![this.path![1]];
|
||||
const cardConfig = this._currentView.cards![this.path![1]];
|
||||
this._clipboard = deepClone(cardConfig);
|
||||
}
|
||||
|
||||
|
@ -353,7 +357,7 @@ export class HuiCardOptions extends LitElement {
|
|||
addCard(
|
||||
selectedDashConfig,
|
||||
[viewIndex],
|
||||
this.lovelace!.config.views[this.path![0]].cards![this.path![1]]
|
||||
this._currentView.cards![this.path![1]]
|
||||
)
|
||||
);
|
||||
this.lovelace!.saveConfig(
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import {
|
||||
css,
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
css,
|
||||
html,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { property } from "lit/decorators";
|
||||
|
@ -16,7 +16,7 @@ import { computeStateName } from "../../../common/entity/compute_state_name";
|
|||
import { computeRTL } from "../../../common/util/compute_rtl";
|
||||
import "../../../components/entity/state-badge";
|
||||
import "../../../components/ha-relative-time";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { EntitiesCardEntityConfig } from "../cards/types";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { LovelaceCardConfig } from "../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import { Condition } from "../common/validate-condition";
|
||||
import { LovelaceElementConfig } from "../elements/types";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { LovelaceBadgeConfig } from "../../../data/lovelace";
|
||||
import { LovelaceBadgeConfig } from "../../../data/lovelace/config/badge";
|
||||
import "../badges/hui-state-label-badge";
|
||||
import { createLovelaceElement } from "./create-element-base";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { LovelaceCardConfig } from "../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import "../cards/hui-button-card";
|
||||
import "../cards/hui-calendar-card";
|
||||
import "../cards/hui-entities-card";
|
||||
|
@ -9,8 +9,8 @@ import "../cards/hui-grid-card";
|
|||
import "../cards/hui-light-card";
|
||||
import "../cards/hui-sensor-card";
|
||||
import "../cards/hui-thermostat-card";
|
||||
import "../cards/hui-weather-forecast-card";
|
||||
import "../cards/hui-tile-card";
|
||||
import "../cards/hui-weather-forecast-card";
|
||||
import {
|
||||
createLovelaceElement,
|
||||
getLovelaceElementClass,
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import {
|
||||
LovelaceBadgeConfig,
|
||||
LovelaceCardConfig,
|
||||
LovelaceViewConfig,
|
||||
LovelaceViewElement,
|
||||
} from "../../../data/lovelace";
|
||||
import { LovelaceViewElement } from "../../../data/lovelace";
|
||||
import { LovelaceBadgeConfig } from "../../../data/lovelace/config/badge";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
||||
import {
|
||||
isCustomType,
|
||||
stripCustomPrefix,
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import {
|
||||
LovelaceViewConfig,
|
||||
LovelaceViewElement,
|
||||
} from "../../../data/lovelace";
|
||||
import { LovelaceViewElement } from "../../../data/lovelace";
|
||||
import { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
||||
import { HuiErrorCard } from "../cards/hui-error-card";
|
||||
import "../views/hui-masonry-view";
|
||||
import { createLovelaceElement } from "./create-element-base";
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { LovelacePanelConfig } from "../../../data/lovelace";
|
||||
import {
|
||||
fetchConfig,
|
||||
fetchDashboards,
|
||||
LovelaceConfig,
|
||||
LovelacePanelConfig,
|
||||
fetchConfig,
|
||||
saveConfig,
|
||||
} from "../../../data/lovelace";
|
||||
} from "../../../data/lovelace/config/types";
|
||||
import { fetchDashboards } from "../../../data/lovelace/dashboard";
|
||||
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { showSuggestCardDialog } from "./card-editor/show-suggest-card-dialog";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { customElement } from "lit/decorators";
|
||||
import type { LovelaceCardConfig } from "../../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||
import { getCardElementClass } from "../../create-element/create-card-element";
|
||||
import type { LovelaceCardEditor, LovelaceConfigForm } from "../../types";
|
||||
import { HuiElementEditor } from "../hui-element-editor";
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import Fuse, { IFuseOptions } from "fuse.js";
|
||||
import {
|
||||
css,
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
css,
|
||||
html,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
|
@ -18,14 +18,12 @@ import { fireEvent } from "../../../../common/dom/fire_event";
|
|||
import "../../../../components/ha-circular-progress";
|
||||
import "../../../../components/search-input";
|
||||
import { isUnavailableState } from "../../../../data/entity";
|
||||
import type {
|
||||
LovelaceCardConfig,
|
||||
LovelaceConfig,
|
||||
} from "../../../../data/lovelace";
|
||||
import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||
import type { LovelaceConfig } from "../../../../data/lovelace/config/types";
|
||||
import {
|
||||
CUSTOM_TYPE_PREFIX,
|
||||
CustomCardEntry,
|
||||
customCards,
|
||||
CUSTOM_TYPE_PREFIX,
|
||||
getCustomCardEntry,
|
||||
} from "../../../../data/lovelace_custom_cards";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { PropertyValues, ReactiveElement } from "lit";
|
||||
import { property } from "lit/decorators";
|
||||
import { computeRTL } from "../../../../common/util/compute_rtl";
|
||||
import { LovelaceCardConfig } from "../../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||
import { HomeAssistant } from "../../../../types";
|
||||
import { createCardElement } from "../../create-element/create-card-element";
|
||||
import { createErrorCardConfig } from "../../create-element/create-element-base";
|
||||
|
|
|
@ -12,7 +12,7 @@ import { computeStateName } from "../../../../common/entity/compute_state_name";
|
|||
import { DataTableRowData } from "../../../../components/data-table/ha-data-table";
|
||||
import "../../../../components/ha-dialog";
|
||||
import "../../../../components/ha-dialog-header";
|
||||
import type { LovelaceViewConfig } from "../../../../data/lovelace";
|
||||
import type { LovelaceViewConfig } from "../../../../data/lovelace/config/view";
|
||||
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||
import { haStyleDialog } from "../../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
|
|
|
@ -2,7 +2,7 @@ import deepFreeze from "deep-freeze";
|
|||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import type { LovelaceCardConfig } from "../../../../data/lovelace";
|
||||
import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||
import { haStyleDialog } from "../../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import "./hui-card-preview";
|
||||
|
|
|
@ -16,10 +16,6 @@ import "../../../../components/ha-circular-progress";
|
|||
import "../../../../components/ha-dialog";
|
||||
import "../../../../components/ha-dialog-header";
|
||||
import "../../../../components/ha-icon-button";
|
||||
import type {
|
||||
LovelaceCardConfig,
|
||||
LovelaceViewConfig,
|
||||
} from "../../../../data/lovelace";
|
||||
import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box";
|
||||
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||
import { haStyleDialog } from "../../../../resources/styles";
|
||||
|
@ -33,6 +29,8 @@ import "./hui-card-element-editor";
|
|||
import type { HuiCardElementEditor } from "./hui-card-element-editor";
|
||||
import "./hui-card-preview";
|
||||
import type { EditCardDialogParams } from "./show-edit-card-dialog";
|
||||
import { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||
import { LovelaceViewConfig } from "../../../../data/lovelace/config/view";
|
||||
|
||||
declare global {
|
||||
// for fire event
|
||||
|
|
|
@ -4,7 +4,7 @@ import { customElement, property, query, state } from "lit/decorators";
|
|||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import "../../../../components/ha-yaml-editor";
|
||||
import type { HaYamlEditor } from "../../../../components/ha-yaml-editor";
|
||||
import { LovelaceCardConfig } from "../../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||
import { haStyleDialog } from "../../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../../types";
|
||||
import { showSaveSuccessToast } from "../../../../util/toast-saved-success";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { LovelaceConfig } from "../../../../data/lovelace";
|
||||
import type { LovelaceConfig } from "../../../../data/lovelace/config/types";
|
||||
|
||||
export interface CreateCardDialogParams {
|
||||
lovelaceConfig: LovelaceConfig;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { LovelaceCardConfig } from "../../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||
|
||||
export interface DeleteCardDialogParams {
|
||||
deleteCard: () => void;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { LovelaceCardConfig, LovelaceConfig } from "../../../../data/lovelace";
|
||||
import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||
import type { LovelaceConfig } from "../../../../data/lovelace/config/types";
|
||||
|
||||
export interface EditCardDialogParams {
|
||||
lovelaceConfig: LovelaceConfig;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { LovelaceCardConfig, LovelaceConfig } from "../../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||
import { LovelaceConfig } from "../../../../data/lovelace/config/types";
|
||||
|
||||
export interface SuggestCardDialogParams {
|
||||
cardTitle?: string;
|
||||
|
|
|
@ -11,10 +11,8 @@ import { HASSDomEvent, fireEvent } from "../../../../common/dom/fire_event";
|
|||
import "../../../../components/ha-button";
|
||||
import "../../../../components/ha-list-item";
|
||||
import "../../../../components/ha-svg-icon";
|
||||
import type {
|
||||
LovelaceCardConfig,
|
||||
LovelaceConfig,
|
||||
} from "../../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||
import { LovelaceConfig } from "../../../../data/lovelace/config/types";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type { ConditionalCardConfig } from "../../cards/types";
|
||||
import type { LovelaceCardEditor } from "../../types";
|
||||
|
|
|
@ -5,7 +5,7 @@ import { capitalizeFirstLetter } from "../../../../common/string/capitalize-firs
|
|||
import { LocalizeFunc } from "../../../../common/translations/localize";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
import type { HaFormSchema } from "../../../../components/ha-form/types";
|
||||
import { LovelaceCardConfig } from "../../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type { LovelaceGenericElementEditor } from "../../types";
|
||||
import { configElementStyle } from "./config-elements-style";
|
||||
|
|
|
@ -4,7 +4,7 @@ import { array, assert, assign, object, optional, string } from "superstruct";
|
|||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||
import type { ActionConfig } from "../../../../data/lovelace";
|
||||
import type { ActionConfig } from "../../../../data/lovelace/config/action";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type { PictureGlanceCardConfig } from "../../cards/types";
|
||||
import "../../components/hui-entity-editor";
|
||||
|
|
|
@ -25,7 +25,8 @@ import {
|
|||
import { storage } from "../../../../common/decorators/storage";
|
||||
import { HASSDomEvent, fireEvent } from "../../../../common/dom/fire_event";
|
||||
import "../../../../components/ha-icon-button";
|
||||
import { LovelaceCardConfig, LovelaceConfig } from "../../../../data/lovelace";
|
||||
import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||
import type { LovelaceConfig } from "../../../../data/lovelace/config/types";
|
||||
import { HomeAssistant } from "../../../../types";
|
||||
import { StackCardConfig } from "../../cards/types";
|
||||
import { LovelaceCardEditor } from "../../types";
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import { LovelaceConfig } from "../../../data/lovelace/config/types";
|
||||
import {
|
||||
LovelaceCardConfig,
|
||||
LovelaceConfig,
|
||||
LovelaceViewConfig,
|
||||
} from "../../../data/lovelace";
|
||||
isStrategyView,
|
||||
} from "../../../data/lovelace/config/view";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
|
||||
export const addCard = (
|
||||
|
@ -19,6 +20,10 @@ export const addCard = (
|
|||
return;
|
||||
}
|
||||
|
||||
if (isStrategyView(viewConf)) {
|
||||
throw new Error("You cannot add a card in a strategy view.");
|
||||
}
|
||||
|
||||
const cards = viewConf.cards
|
||||
? [...viewConf.cards, cardConfig]
|
||||
: [cardConfig];
|
||||
|
@ -49,6 +54,10 @@ export const addCards = (
|
|||
return;
|
||||
}
|
||||
|
||||
if (isStrategyView(viewConf)) {
|
||||
throw new Error("You cannot add cards in a strategy view.");
|
||||
}
|
||||
|
||||
const cards = viewConf.cards
|
||||
? [...viewConf.cards, ...cardConfigs]
|
||||
: [...cardConfigs];
|
||||
|
@ -79,6 +88,10 @@ export const replaceCard = (
|
|||
return;
|
||||
}
|
||||
|
||||
if (isStrategyView(viewConf)) {
|
||||
throw new Error("You cannot replace a card in a strategy view.");
|
||||
}
|
||||
|
||||
views.push({
|
||||
...viewConf,
|
||||
cards: (viewConf.cards || []).map((origConf, ind) =>
|
||||
|
@ -106,6 +119,10 @@ export const deleteCard = (
|
|||
return;
|
||||
}
|
||||
|
||||
if (isStrategyView(viewConf)) {
|
||||
throw new Error("You cannot delete a card in a strategy view.");
|
||||
}
|
||||
|
||||
views.push({
|
||||
...viewConf,
|
||||
cards: (viewConf.cards || []).filter(
|
||||
|
@ -134,6 +151,10 @@ export const insertCard = (
|
|||
return;
|
||||
}
|
||||
|
||||
if (isStrategyView(viewConf)) {
|
||||
throw new Error("You cannot insert a card in a strategy view.");
|
||||
}
|
||||
|
||||
const cards = viewConf.cards
|
||||
? [
|
||||
...viewConf.cards.slice(0, cardIndex),
|
||||
|
@ -159,10 +180,16 @@ export const swapCard = (
|
|||
path1: [number, number],
|
||||
path2: [number, number]
|
||||
): LovelaceConfig => {
|
||||
const card1 = config.views[path1[0]].cards![path1[1]];
|
||||
const card2 = config.views[path2[0]].cards![path2[1]];
|
||||
|
||||
const origView1 = config.views[path1[0]];
|
||||
const origView2 = config.views[path2[0]];
|
||||
|
||||
if (isStrategyView(origView1) || isStrategyView(origView2)) {
|
||||
throw new Error("You cannot move swap cards in a strategy view.");
|
||||
}
|
||||
|
||||
const card1 = origView1.cards![path1[1]];
|
||||
const card2 = origView2.cards![path2[1]];
|
||||
|
||||
const newView1 = {
|
||||
...origView1,
|
||||
cards: origView1.cards!.map((origCard, index) =>
|
||||
|
@ -170,10 +197,10 @@ export const swapCard = (
|
|||
),
|
||||
};
|
||||
|
||||
const origView2 = path1[0] === path2[0] ? newView1 : config.views[path2[0]];
|
||||
const updatedOrigView2 = path1[0] === path2[0] ? newView1 : origView2;
|
||||
const newView2 = {
|
||||
...origView2,
|
||||
cards: origView2.cards!.map((origCard, index) =>
|
||||
...updatedOrigView2,
|
||||
cards: updatedOrigView2.cards!.map((origCard, index) =>
|
||||
index === path2[1] ? card1 : origCard
|
||||
),
|
||||
};
|
||||
|
@ -190,9 +217,13 @@ export const moveCardToPosition = (
|
|||
config: LovelaceConfig,
|
||||
path: [number, number],
|
||||
position: number
|
||||
) => {
|
||||
): LovelaceConfig => {
|
||||
const view = config.views[path[0]];
|
||||
|
||||
if (isStrategyView(view)) {
|
||||
throw new Error("You cannot move a card in a strategy view.");
|
||||
}
|
||||
|
||||
const oldIndex = path[1];
|
||||
const newIndex = Math.max(Math.min(position - 1, view.cards!.length - 1), 0);
|
||||
|
||||
|
@ -224,6 +255,16 @@ export const moveCard = (
|
|||
throw new Error("You cannot move a card to the view it is in.");
|
||||
}
|
||||
const fromView = config.views[fromPath[0]];
|
||||
const toView = config.views[toPath[0]];
|
||||
|
||||
if (isStrategyView(fromView)) {
|
||||
throw new Error("You cannot move a card from a strategy view.");
|
||||
}
|
||||
|
||||
if (isStrategyView(toView)) {
|
||||
throw new Error("You cannot move a card to a strategy view.");
|
||||
}
|
||||
|
||||
const card = fromView.cards![fromPath[1]];
|
||||
|
||||
const newView1 = {
|
||||
|
@ -233,7 +274,6 @@ export const moveCard = (
|
|||
),
|
||||
};
|
||||
|
||||
const toView = config.views[toPath[0]];
|
||||
const cards = toView.cards ? [...toView.cards, card] : [card];
|
||||
|
||||
const newView2 = {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { isStrategyView } from "../../../data/lovelace/config/view";
|
||||
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { showDeleteSuccessToast } from "../../../util/toast-deleted-success";
|
||||
|
@ -11,7 +12,11 @@ export async function confDeleteCard(
|
|||
lovelace: Lovelace,
|
||||
path: [number, number]
|
||||
): Promise<void> {
|
||||
const cardConfig = lovelace.config.views[path[0]].cards![path[1]];
|
||||
const view = lovelace.config.views[path[0]];
|
||||
if (isStrategyView(view)) {
|
||||
throw new Error("Deleting cards in a strategy view is not supported.");
|
||||
}
|
||||
const cardConfig = view.cards![path[1]];
|
||||
showDeleteCardDialog(element, {
|
||||
cardConfig,
|
||||
deleteCard: async () => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { LovelaceCardConfig } from "../../../data/lovelace";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { getCardElementClass } from "../create-element/create-card-element";
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { mdiClose, mdiPencil, mdiPlus } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { CSSResultGroup, LitElement, TemplateResult, css, html } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import "../../../../components/ha-icon-button";
|
||||
import type { LovelaceConfig } from "../../../../data/lovelace";
|
||||
import type { LovelaceConfig } from "../../../../data/lovelace/config/types";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type { LovelaceHeaderFooterConfig } from "../../header-footer/types";
|
||||
import { showCreateHeaderFooterDialog } from "./show-create-headerfooter-dialog";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { computeRTL } from "../../../common/util/compute_rtl";
|
||||
import "../../../components/entity/ha-state-label-badge";
|
||||
import { LovelaceBadgeConfig } from "../../../data/lovelace";
|
||||
import { LovelaceBadgeConfig } from "../../../data/lovelace/config/badge";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { createErrorBadgeConfig } from "../badges/hui-error-badge";
|
||||
import { createBadgeElement } from "../create-element/create-badge-element";
|
||||
|
|
|
@ -10,7 +10,7 @@ import "../../../components/ha-formfield";
|
|||
import "../../../components/ha-icon-button";
|
||||
import "../../../components/ha-switch";
|
||||
import "../../../components/ha-yaml-editor";
|
||||
import type { LovelaceConfig } from "../../../data/lovelace";
|
||||
import { LovelaceConfig } from "../../../data/lovelace/config/types";
|
||||
import type { HassDialog } from "../../../dialogs/make-dialog-manager";
|
||||
import { haStyleDialog } from "../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import "@material/mwc-button";
|
||||
import { dump, load } from "js-yaml";
|
||||
import {
|
||||
css,
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
css,
|
||||
html,
|
||||
} from "lit";
|
||||
import { property, query, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
|
@ -16,10 +16,8 @@ import "../../../components/ha-alert";
|
|||
import "../../../components/ha-circular-progress";
|
||||
import "../../../components/ha-code-editor";
|
||||
import type { HaCodeEditor } from "../../../components/ha-code-editor";
|
||||
import type {
|
||||
LovelaceCardConfig,
|
||||
LovelaceConfig,
|
||||
} from "../../../data/lovelace";
|
||||
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import type { LovelaceConfig } from "../../../data/lovelace/config/types";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { LovelaceRowConfig } from "../entity-rows/types";
|
||||
import { LovelaceHeaderFooterConfig } from "../header-footer/types";
|
||||
|
|
|
@ -4,11 +4,11 @@ import { customElement, property, state } from "lit/decorators";
|
|||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import "../../../../components/ha-circular-progress";
|
||||
import "../../../../components/ha-dialog";
|
||||
import type { LovelaceConfig } from "../../../../data/lovelace";
|
||||
import { haStyleDialog } from "../../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type { Lovelace } from "../../types";
|
||||
import "./hui-lovelace-editor";
|
||||
import { LovelaceConfig } from "../../../../data/lovelace/config/types";
|
||||
|
||||
@customElement("hui-dialog-edit-lovelace")
|
||||
export class HuiDialogEditLovelace extends LitElement {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import "../../../../components/ha-textfield";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { LovelaceConfig } from "../../../../data/lovelace";
|
||||
import "../../../../components/ha-textfield";
|
||||
import type { LovelaceConfig } from "../../../../data/lovelace/config/types";
|
||||
import { HomeAssistant } from "../../../../types";
|
||||
import { EditorTarget } from "../types";
|
||||
|
||||
|
|
|
@ -10,10 +10,12 @@ import "../../../../components/ha-icon";
|
|||
import "../../../../components/ha-select";
|
||||
import {
|
||||
fetchConfig,
|
||||
fetchDashboards,
|
||||
LovelaceConfig,
|
||||
} from "../../../../data/lovelace/config/types";
|
||||
import {
|
||||
fetchDashboards,
|
||||
LovelaceDashboard,
|
||||
} from "../../../../data/lovelace";
|
||||
} from "../../../../data/lovelace/dashboard";
|
||||
import { haStyleDialog } from "../../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../../types";
|
||||
import type { SelectViewDialogParams } from "./show-select-view-dialog";
|
||||
|
@ -155,7 +157,11 @@ export class HuiDialogSelectView extends LitElement {
|
|||
this._urlPath = urlPath;
|
||||
this._selectedViewIdx = 0;
|
||||
try {
|
||||
this._config = await fetchConfig(this.hass.connection, urlPath, false);
|
||||
this._config = (await fetchConfig(
|
||||
this.hass.connection,
|
||||
urlPath,
|
||||
false
|
||||
)) as LovelaceConfig;
|
||||
} catch (err: any) {
|
||||
this._config = undefined;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { LovelaceConfig, LovelaceDashboard } from "../../../../data/lovelace";
|
||||
import { LovelaceConfig } from "../../../../data/lovelace/config/types";
|
||||
import { LovelaceDashboard } from "../../../../data/lovelace/dashboard";
|
||||
|
||||
export interface SelectViewDialogParams {
|
||||
lovelaceConfig: LovelaceConfig;
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
type,
|
||||
union,
|
||||
} from "superstruct";
|
||||
import { BaseActionConfig } from "../../../../data/lovelace";
|
||||
import { BaseActionConfig } from "../../../../data/lovelace/config/action";
|
||||
|
||||
const actionConfigStructUser = object({
|
||||
user: string(),
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { ActionConfig } from "../../../data/lovelace/config/action";
|
||||
import { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import {
|
||||
ActionConfig,
|
||||
LovelaceCardConfig,
|
||||
LovelaceViewConfig,
|
||||
ShowViewConfig,
|
||||
} from "../../../data/lovelace";
|
||||
} from "../../../data/lovelace/config/view";
|
||||
import { EntityConfig, LovelaceRowConfig } from "../entity-rows/types";
|
||||
import { LovelaceHeaderFooterConfig } from "../header-footer/types";
|
||||
import { LovelaceTileFeatureConfig } from "../tile-features/types";
|
||||
|
|
|
@ -15,13 +15,13 @@ import { computeRTL } from "../../../../common/util/compute_rtl";
|
|||
import type { DataTableRowData } from "../../../../components/data-table/ha-data-table";
|
||||
import "../../../../components/ha-fab";
|
||||
import "../../../../components/ha-svg-icon";
|
||||
import type { LovelaceConfig } from "../../../../data/lovelace";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import { computeUnusedEntities } from "../../common/compute-unused-entities";
|
||||
import type { Lovelace } from "../../types";
|
||||
import "../card-editor/hui-entity-picker-table";
|
||||
import { showSuggestCardDialog } from "../card-editor/show-suggest-card-dialog";
|
||||
import { showSelectViewDialog } from "../select-view/show-select-view-dialog";
|
||||
import { LovelaceConfig } from "../../../../data/lovelace/config/types";
|
||||
|
||||
@customElement("hui-unused-entities")
|
||||
export class HuiUnusedEntities extends LitElement {
|
||||
|
|
|
@ -23,11 +23,6 @@ import "../../../../components/ha-dialog";
|
|||
import "../../../../components/ha-dialog-header";
|
||||
import "../../../../components/ha-yaml-editor";
|
||||
import type { HaYamlEditor } from "../../../../components/ha-yaml-editor";
|
||||
import type {
|
||||
LovelaceBadgeConfig,
|
||||
LovelaceCardConfig,
|
||||
LovelaceViewConfig,
|
||||
} from "../../../../data/lovelace";
|
||||
import {
|
||||
showAlertDialog,
|
||||
showConfirmationDialog,
|
||||
|
@ -51,6 +46,12 @@ import {
|
|||
import "./hui-view-editor";
|
||||
import "./hui-view-visibility-editor";
|
||||
import { EditViewDialogParams } from "./show-edit-view-dialog";
|
||||
import {
|
||||
LovelaceViewConfig,
|
||||
isStrategyView,
|
||||
} from "../../../../data/lovelace/config/view";
|
||||
import { LovelaceBadgeConfig } from "../../../../data/lovelace/config/badge";
|
||||
import { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||
|
||||
@customElement("hui-dialog-edit-view")
|
||||
export class HuiDialogEditView extends LitElement {
|
||||
|
@ -103,13 +104,21 @@ export class HuiDialogEditView extends LitElement {
|
|||
this._badges = [];
|
||||
this._cards = [];
|
||||
this._dirty = false;
|
||||
} else {
|
||||
const { cards, badges, ...viewConfig } =
|
||||
this._params.lovelace!.config.views[this._params.viewIndex];
|
||||
this._config = viewConfig;
|
||||
this._badges = badges ? processEditorEntities(badges) : [];
|
||||
this._cards = cards;
|
||||
return;
|
||||
}
|
||||
const view = this._params.lovelace!.config.views[this._params.viewIndex];
|
||||
// Todo : add better support for strategy views
|
||||
if (isStrategyView(view)) {
|
||||
const { strategy, ...viewConfig } = view;
|
||||
this._config = viewConfig;
|
||||
this._badges = [];
|
||||
this._cards = [];
|
||||
return;
|
||||
}
|
||||
const { cards, badges, ...viewConfig } = view;
|
||||
this._config = viewConfig;
|
||||
this._badges = badges ? processEditorEntities(badges) : [];
|
||||
this._cards = cards;
|
||||
}
|
||||
|
||||
public closeDialog(): void {
|
||||
|
|
|
@ -6,13 +6,13 @@ import { slugify } from "../../../../common/string/slugify";
|
|||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||
import type { LovelaceViewConfig } from "../../../../data/lovelace";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import {
|
||||
DEFAULT_VIEW_LAYOUT,
|
||||
PANEL_VIEW_LAYOUT,
|
||||
SIDEBAR_VIEW_LAYOUT,
|
||||
} from "../../views/const";
|
||||
import { LovelaceViewConfig } from "../../../../data/lovelace/config/view";
|
||||
|
||||
declare global {
|
||||
interface HASSDomEvents {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import "@material/mwc-list/mwc-list-item";
|
||||
import {
|
||||
css,
|
||||
CSSResultGroup,
|
||||
html,
|
||||
LitElement,
|
||||
PropertyValues,
|
||||
css,
|
||||
html,
|
||||
nothing,
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
|
@ -13,8 +13,11 @@ import { fireEvent } from "../../../../common/dom/fire_event";
|
|||
import { stringCompare } from "../../../../common/string/compare";
|
||||
import { HaSwitch } from "../../../../components/ha-switch";
|
||||
import "../../../../components/user/ha-user-badge";
|
||||
import { LovelaceViewConfig, ShowViewConfig } from "../../../../data/lovelace";
|
||||
import { fetchUsers, User } from "../../../../data/user";
|
||||
import {
|
||||
LovelaceViewConfig,
|
||||
ShowViewConfig,
|
||||
} from "../../../../data/lovelace/config/view";
|
||||
import { User, fetchUsers } from "../../../../data/user";
|
||||
import { HomeAssistant } from "../../../../types";
|
||||
|
||||
declare global {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { fireEvent, HASSDomEvent } from "../../../../common/dom/fire_event";
|
||||
import { LovelaceViewConfig } from "../../../../data/lovelace";
|
||||
import { LovelaceViewConfig } from "../../../../data/lovelace/config/view";
|
||||
import { Lovelace } from "../../types";
|
||||
|
||||
declare global {
|
||||
|
|
|
@ -2,13 +2,13 @@ import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
|||
import { customElement, state } from "lit/decorators";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import "../../../components/ha-icon";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { computeTooltip } from "../common/compute-tooltip";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
import { handleAction } from "../common/handle-action";
|
||||
import { hasAction } from "../common/has-action";
|
||||
import { IconElementConfig, LovelaceElement } from "./types";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||
|
||||
@customElement("hui-icon-element")
|
||||
export class HuiIconElement extends LitElement implements LovelaceElement {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import { ImageEntity, computeImageUrl } from "../../../data/image";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace";
|
||||
import { computeImageUrl, ImageEntity } from "../../../data/image";
|
||||
import { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { computeTooltip } from "../common/compute-tooltip";
|
||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue