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