mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-30 12:46:35 +00:00
Type LovelaceConfig -> LovelaceCardConfig (#2103)
* LovelaceConfig -> LovelaceCardConfig * Typo
This commit is contained in:
parent
412b7595d2
commit
101a364a83
@ -1,7 +1,7 @@
|
|||||||
import createCardElement from "../common/create-card-element";
|
import createCardElement from "../common/create-card-element";
|
||||||
import { computeCardSize } from "../common/compute-card-size";
|
import { computeCardSize } from "../common/compute-card-size";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
|
|
||||||
interface Condition {
|
interface Condition {
|
||||||
entity: string;
|
entity: string;
|
||||||
@ -9,8 +9,8 @@ interface Condition {
|
|||||||
state_not?: string;
|
state_not?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
card: LovelaceConfig;
|
card: LovelaceCardConfig;
|
||||||
conditions: Condition[];
|
conditions: Condition[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import { DOMAINS_HIDE_MORE_INFO } from "../../../common/const";
|
|||||||
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { EntityConfig, EntityRow } from "../entity-rows/types";
|
import { EntityConfig, EntityRow } from "../entity-rows/types";
|
||||||
import { LovelaceCard, LovelaceConfig, LovelaceCardEditor } from "../types";
|
import { LovelaceCard, LovelaceCardConfig, LovelaceCardEditor } from "../types";
|
||||||
import processConfigEntities from "../common/process-config-entities";
|
import processConfigEntities from "../common/process-config-entities";
|
||||||
import createRowElement from "../common/create-row-element";
|
import createRowElement from "../common/create-row-element";
|
||||||
import computeDomain from "../../../common/entity/compute_domain";
|
import computeDomain from "../../../common/entity/compute_domain";
|
||||||
@ -29,7 +29,7 @@ export interface ConfigEntity extends EntityConfig {
|
|||||||
url?: string;
|
url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Config extends LovelaceConfig {
|
export interface Config extends LovelaceCardConfig {
|
||||||
show_header_toggle?: boolean;
|
show_header_toggle?: boolean;
|
||||||
title?: string;
|
title?: string;
|
||||||
entities: ConfigEntity[];
|
entities: ConfigEntity[];
|
||||||
|
@ -18,11 +18,11 @@ import applyThemesOnElement from "../../../common/dom/apply_themes_on_element";
|
|||||||
import { toggleEntity } from "../common/entity/toggle-entity";
|
import { toggleEntity } from "../common/entity/toggle-entity";
|
||||||
import { HomeAssistant, LightEntity } from "../../../types";
|
import { HomeAssistant, LightEntity } from "../../../types";
|
||||||
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
import { longPress } from "../common/directives/long-press-directive";
|
import { longPress } from "../common/directives/long-press-directive";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
|
|
||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
entity: string;
|
entity: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { html, LitElement } from "@polymer/lit-element";
|
import { html, LitElement } from "@polymer/lit-element";
|
||||||
|
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
import { TemplateResult } from "lit-html";
|
import { TemplateResult } from "lit-html";
|
||||||
|
|
||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
error: string;
|
error: string;
|
||||||
origConfig: LovelaceConfig;
|
origConfig: LovelaceCardConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
class HuiErrorCard extends LitElement implements LovelaceCard {
|
class HuiErrorCard extends LitElement implements LovelaceCard {
|
||||||
@ -50,7 +50,7 @@ class HuiErrorCard extends LitElement implements LovelaceCard {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _toStr(config: LovelaceConfig): string {
|
private _toStr(config: LovelaceCardConfig): string {
|
||||||
return JSON.stringify(config, null, 2);
|
return JSON.stringify(config, null, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
} from "@polymer/lit-element";
|
} from "@polymer/lit-element";
|
||||||
import { TemplateResult } from "lit-html";
|
import { TemplateResult } from "lit-html";
|
||||||
|
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ import { hasConfigOrEntityChanged } from "../common/has-changed";
|
|||||||
|
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
|
|
||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
entity: string;
|
entity: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
unit_of_measurement?: string;
|
unit_of_measurement?: string;
|
||||||
|
@ -10,7 +10,7 @@ import { classMap } from "lit-html/directives/classMap";
|
|||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { LovelaceCard, LovelaceConfig, LovelaceCardEditor } from "../types";
|
import { LovelaceCard, LovelaceCardConfig, LovelaceCardEditor } from "../types";
|
||||||
import { longPress } from "../common/directives/long-press-directive";
|
import { longPress } from "../common/directives/long-press-directive";
|
||||||
import { EntityConfig } from "../entity-rows/types";
|
import { EntityConfig } from "../entity-rows/types";
|
||||||
import { toggleEntity } from "../common/entity/toggle-entity";
|
import { toggleEntity } from "../common/entity/toggle-entity";
|
||||||
@ -31,7 +31,7 @@ export interface ConfigEntity extends EntityConfig {
|
|||||||
service_data?: object;
|
service_data?: object;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Config extends LovelaceConfig {
|
export interface Config extends LovelaceCardConfig {
|
||||||
show_name?: boolean;
|
show_name?: boolean;
|
||||||
show_state?: boolean;
|
show_state?: boolean;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
@ -2,11 +2,11 @@ import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element";
|
|||||||
|
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
|
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
import { TemplateResult } from "lit-html";
|
import { TemplateResult } from "lit-html";
|
||||||
import { styleMap } from "lit-html/directives/styleMap";
|
import { styleMap } from "lit-html/directives/styleMap";
|
||||||
|
|
||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
aspect_ratio?: string;
|
aspect_ratio?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
@ -12,7 +12,7 @@ import { jQuery } from "../../../resources/jquery";
|
|||||||
import { roundSliderStyle } from "../../../resources/jquery.roundslider";
|
import { roundSliderStyle } from "../../../resources/jquery.roundslider";
|
||||||
import { HomeAssistant, LightEntity } from "../../../types";
|
import { HomeAssistant, LightEntity } from "../../../types";
|
||||||
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
import { longPress } from "../common/directives/long-press-directive";
|
import { longPress } from "../common/directives/long-press-directive";
|
||||||
|
|
||||||
import stateIcon from "../../../common/entity/state_icon";
|
import stateIcon from "../../../common/entity/state_icon";
|
||||||
@ -37,7 +37,7 @@ const lightConfig = {
|
|||||||
showTooltip: false,
|
showTooltip: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
entity: string;
|
entity: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
theme?: string;
|
theme?: string;
|
||||||
|
@ -4,10 +4,10 @@ import { classMap } from "lit-html/directives/classMap";
|
|||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-markdown";
|
import "../../../components/ha-markdown";
|
||||||
|
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
import { TemplateResult } from "lit-html";
|
import { TemplateResult } from "lit-html";
|
||||||
|
|
||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
content: string;
|
content: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@ import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element";
|
|||||||
|
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
|
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
import { navigate } from "../../../common/navigate";
|
import { navigate } from "../../../common/navigate";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { TemplateResult } from "lit-html";
|
import { TemplateResult } from "lit-html";
|
||||||
import { classMap } from "lit-html/directives/classMap";
|
import { classMap } from "lit-html/directives/classMap";
|
||||||
|
|
||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
image?: string;
|
image?: string;
|
||||||
navigation_path?: string;
|
navigation_path?: string;
|
||||||
service?: string;
|
service?: string;
|
||||||
|
@ -3,11 +3,11 @@ import { TemplateResult } from "lit-html";
|
|||||||
|
|
||||||
import createHuiElement from "../common/create-hui-element";
|
import createHuiElement from "../common/create-hui-element";
|
||||||
|
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { LovelaceElementConfig, LovelaceElement } from "../elements/types";
|
import { LovelaceElementConfig, LovelaceElement } from "../elements/types";
|
||||||
|
|
||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
title?: string;
|
title?: string;
|
||||||
image: string;
|
image: string;
|
||||||
elements: LovelaceElementConfig[];
|
elements: LovelaceElementConfig[];
|
||||||
|
@ -5,7 +5,7 @@ import { TemplateResult } from "lit-html";
|
|||||||
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import { DOMAINS_TOGGLE } from "../../../common/const";
|
import { DOMAINS_TOGGLE } from "../../../common/const";
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
import { EntityConfig } from "../entity-rows/types";
|
import { EntityConfig } from "../entity-rows/types";
|
||||||
import { navigate } from "../../../common/navigate";
|
import { navigate } from "../../../common/navigate";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
@ -23,7 +23,7 @@ import "../components/hui-image";
|
|||||||
|
|
||||||
const STATES_OFF = new Set(["closed", "locked", "not_home", "off"]);
|
const STATES_OFF = new Set(["closed", "locked", "not_home", "off"]);
|
||||||
|
|
||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
entities: EntityConfig[];
|
entities: EntityConfig[];
|
||||||
title?: string;
|
title?: string;
|
||||||
navigation_path?: string;
|
navigation_path?: string;
|
||||||
|
@ -9,7 +9,7 @@ import "../../../components/ha-icon";
|
|||||||
|
|
||||||
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
import {
|
import {
|
||||||
fetchItems,
|
fetchItems,
|
||||||
completeItem,
|
completeItem,
|
||||||
@ -19,7 +19,7 @@ import {
|
|||||||
addItem,
|
addItem,
|
||||||
} from "../../../data/shopping-list";
|
} from "../../../data/shopping-list";
|
||||||
|
|
||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
title?: string;
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@ import { TemplateResult } from "lit-html";
|
|||||||
|
|
||||||
import createCardElement from "../common/create-card-element";
|
import createCardElement from "../common/create-card-element";
|
||||||
|
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
|
|
||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
cards: LovelaceConfig[];
|
cards: LovelaceCardConfig[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class HuiStackCard extends LitElement implements LovelaceCard {
|
export abstract class HuiStackCard extends LitElement implements LovelaceCard {
|
||||||
|
@ -15,7 +15,7 @@ import { hasConfigOrEntityChanged } from "../common/has-changed";
|
|||||||
import { roundSliderStyle } from "../../../resources/jquery.roundslider";
|
import { roundSliderStyle } from "../../../resources/jquery.roundslider";
|
||||||
import { HomeAssistant, ClimateEntity } from "../../../types";
|
import { HomeAssistant, ClimateEntity } from "../../../types";
|
||||||
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
|
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-icon";
|
import "../../../components/ha-icon";
|
||||||
@ -43,7 +43,7 @@ const modeIcons = {
|
|||||||
idle: "hass:power-sleep",
|
idle: "hass:power-sleep",
|
||||||
};
|
};
|
||||||
|
|
||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceCardConfig {
|
||||||
entity: string;
|
entity: string;
|
||||||
theme?: string;
|
theme?: string;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { LovelaceConfig } from "../types";
|
import { LovelaceCardConfig } from "../types";
|
||||||
|
|
||||||
export const getCardConfig = (
|
export const getCardConfig = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -13,7 +13,7 @@ export const getCardConfig = (
|
|||||||
export const updateCardConfig = (
|
export const updateCardConfig = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
cardId: string,
|
cardId: string,
|
||||||
config: LovelaceConfig | string,
|
config: LovelaceCardConfig | string,
|
||||||
configFormat: "json" | "yaml"
|
configFormat: "json" | "yaml"
|
||||||
): Promise<void> =>
|
): Promise<void> =>
|
||||||
hass.callWS({
|
hass.callWS({
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
import { HomeAssistant, GroupEntity } from "../../../types";
|
import { HomeAssistant, GroupEntity } from "../../../types";
|
||||||
|
import {
|
||||||
|
LovelaceConfig,
|
||||||
|
LovelaceCardConfig,
|
||||||
|
LovelaceViewConfig,
|
||||||
|
} from "../types";
|
||||||
import { HassEntity, HassEntities } from "home-assistant-js-websocket";
|
import { HassEntity, HassEntities } from "home-assistant-js-websocket";
|
||||||
import extractViews from "../../../common/entity/extract_views";
|
import extractViews from "../../../common/entity/extract_views";
|
||||||
import getViewEntities from "../../../common/entity/get_view_entities";
|
import getViewEntities from "../../../common/entity/get_view_entities";
|
||||||
@ -9,26 +14,6 @@ import computeStateDomain from "../../../common/entity/compute_state_domain";
|
|||||||
import { LocalizeFunc } from "../../../mixins/localize-base-mixin";
|
import { LocalizeFunc } from "../../../mixins/localize-base-mixin";
|
||||||
import computeDomain from "../../../common/entity/compute_domain";
|
import computeDomain from "../../../common/entity/compute_domain";
|
||||||
|
|
||||||
interface CardConfig {
|
|
||||||
id?: string;
|
|
||||||
type: string;
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ViewConfig {
|
|
||||||
title?: string;
|
|
||||||
badges?: string[];
|
|
||||||
cards?: CardConfig[];
|
|
||||||
id?: string;
|
|
||||||
icon?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface LovelaceConfig {
|
|
||||||
_frontendAuto: boolean;
|
|
||||||
title?: string;
|
|
||||||
views: ViewConfig[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const DEFAULT_VIEW_ENTITY_ID = "group.default_view";
|
const DEFAULT_VIEW_ENTITY_ID = "group.default_view";
|
||||||
const DOMAINS_BADGES = [
|
const DOMAINS_BADGES = [
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
@ -43,8 +28,8 @@ const HIDE_DOMAIN = new Set(["persistent_notification", "configurator"]);
|
|||||||
const computeCards = (
|
const computeCards = (
|
||||||
title: string,
|
title: string,
|
||||||
states: Array<[string, HassEntity]>
|
states: Array<[string, HassEntity]>
|
||||||
): CardConfig[] => {
|
): LovelaceCardConfig[] => {
|
||||||
const cards: CardConfig[] = [];
|
const cards: LovelaceCardConfig[] = [];
|
||||||
|
|
||||||
// For entity card
|
// For entity card
|
||||||
const entities: string[] = [];
|
const entities: string[] = [];
|
||||||
@ -109,7 +94,7 @@ const generateViewConfig = (
|
|||||||
icon: string | undefined,
|
icon: string | undefined,
|
||||||
entities: HassEntities,
|
entities: HassEntities,
|
||||||
groupOrders: { [entityId: string]: number }
|
groupOrders: { [entityId: string]: number }
|
||||||
): ViewConfig => {
|
): LovelaceViewConfig => {
|
||||||
const splitted = splitByGroups(entities);
|
const splitted = splitByGroups(entities);
|
||||||
splitted.groups.sort(
|
splitted.groups.sort(
|
||||||
(gr1, gr2) => groupOrders[gr1.entity_id] - groupOrders[gr2.entity_id]
|
(gr1, gr2) => groupOrders[gr1.entity_id] - groupOrders[gr2.entity_id]
|
||||||
@ -141,7 +126,7 @@ const generateViewConfig = (
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let cards: CardConfig[] = [];
|
let cards: LovelaceCardConfig[] = [];
|
||||||
|
|
||||||
splitted.groups.forEach((groupEntity) => {
|
splitted.groups.forEach((groupEntity) => {
|
||||||
cards = cards.concat(
|
cards = cards.concat(
|
||||||
|
@ -2,12 +2,12 @@ import "@polymer/paper-button/paper-button";
|
|||||||
import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element";
|
import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { LovelaceConfig } from "../types";
|
import { LovelaceCardConfig } from "../types";
|
||||||
|
|
||||||
let registeredDialog = false;
|
let registeredDialog = false;
|
||||||
|
|
||||||
export class HuiCardOptions extends LitElement {
|
export class HuiCardOptions extends LitElement {
|
||||||
public cardConfig?: LovelaceConfig;
|
public cardConfig?: LovelaceCardConfig;
|
||||||
protected hass?: HomeAssistant;
|
protected hass?: HomeAssistant;
|
||||||
|
|
||||||
static get properties(): PropertyDeclarations {
|
static get properties(): PropertyDeclarations {
|
||||||
|
@ -3,7 +3,7 @@ import "@polymer/paper-input/paper-textarea";
|
|||||||
import createCardElement from "../common/create-card-element";
|
import createCardElement from "../common/create-card-element";
|
||||||
import createErrorCardConfig from "../common/create-error-card-config";
|
import createErrorCardConfig from "../common/create-error-card-config";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { LovelaceCard, LovelaceConfig } from "../types";
|
import { LovelaceCard, LovelaceCardConfig } from "../types";
|
||||||
import { ConfigError } from "./types";
|
import { ConfigError } from "./types";
|
||||||
|
|
||||||
const CUSTOM_TYPE_PREFIX = "custom:";
|
const CUSTOM_TYPE_PREFIX = "custom:";
|
||||||
@ -28,7 +28,7 @@ export class HuiCardPreview extends HTMLElement {
|
|||||||
this._createCard(configValue);
|
this._createCard(configValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
set config(configValue: LovelaceConfig) {
|
set config(configValue: LovelaceCardConfig) {
|
||||||
if (!configValue) {
|
if (!configValue) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ export class HuiCardPreview extends HTMLElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _createCard(configValue: LovelaceConfig): void {
|
private _createCard(configValue: LovelaceCardConfig): void {
|
||||||
if (this._element) {
|
if (this._element) {
|
||||||
this.removeChild(this._element);
|
this.removeChild(this._element);
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@ import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element";
|
|||||||
import { TemplateResult } from "lit-html";
|
import { TemplateResult } from "lit-html";
|
||||||
|
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { LovelaceConfig } from "../types";
|
import { LovelaceCardConfig } from "../types";
|
||||||
import "./hui-edit-card";
|
import "./hui-edit-card";
|
||||||
import "./hui-migrate-config";
|
import "./hui-migrate-config";
|
||||||
|
|
||||||
export class HuiDialogEditCard extends LitElement {
|
export class HuiDialogEditCard extends LitElement {
|
||||||
protected _hass?: HomeAssistant;
|
protected _hass?: HomeAssistant;
|
||||||
private _cardConfig?: LovelaceConfig;
|
private _cardConfig?: LovelaceCardConfig;
|
||||||
private _reloadLovelace?: () => void;
|
private _reloadLovelace?: () => void;
|
||||||
|
|
||||||
static get properties(): PropertyDeclarations {
|
static get properties(): PropertyDeclarations {
|
||||||
|
@ -21,7 +21,7 @@ import "./hui-card-preview";
|
|||||||
// This is not a duplicate import, one is for types, one is for element.
|
// This is not a duplicate import, one is for types, one is for element.
|
||||||
// tslint:disable-next-line
|
// tslint:disable-next-line
|
||||||
import { HuiCardPreview } from "./hui-card-preview";
|
import { HuiCardPreview } from "./hui-card-preview";
|
||||||
import { LovelaceCardEditor, LovelaceConfig } from "../types";
|
import { LovelaceCardEditor, LovelaceCardConfig } from "../types";
|
||||||
import { YamlChangedEvent, ConfigValue, ConfigError } from "./types";
|
import { YamlChangedEvent, ConfigValue, ConfigError } from "./types";
|
||||||
import { extYamlSchema } from "./yaml-ext-schema";
|
import { extYamlSchema } from "./yaml-ext-schema";
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ const CUSTOM_TYPE_PREFIX = "custom:";
|
|||||||
export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
|
export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
|
||||||
protected hass?: HomeAssistant;
|
protected hass?: HomeAssistant;
|
||||||
private _cardId?: string;
|
private _cardId?: string;
|
||||||
private _originalConfig?: LovelaceConfig;
|
private _originalConfig?: LovelaceCardConfig;
|
||||||
private _configElement?: LovelaceCardEditor | null;
|
private _configElement?: LovelaceCardEditor | null;
|
||||||
private _uiEditor?: boolean;
|
private _uiEditor?: boolean;
|
||||||
private _configValue?: ConfigValue;
|
private _configValue?: ConfigValue;
|
||||||
@ -59,7 +59,7 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
|
|||||||
this._saving = false;
|
this._saving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
set cardConfig(cardConfig: LovelaceConfig) {
|
set cardConfig(cardConfig: LovelaceCardConfig) {
|
||||||
this._originalConfig = cardConfig;
|
this._originalConfig = cardConfig;
|
||||||
if (String(cardConfig.id) !== this._cardId) {
|
if (String(cardConfig.id) !== this._cardId) {
|
||||||
this._loading = true;
|
this._loading = true;
|
||||||
@ -210,7 +210,8 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
|
|||||||
schema: extYamlSchema,
|
schema: extYamlSchema,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
this._configElement.setConfig(this._configValue!.value as LovelaceConfig);
|
this._configElement.setConfig(this._configValue!
|
||||||
|
.value as LovelaceCardConfig);
|
||||||
this._uiEditor = !this._uiEditor;
|
this._uiEditor = !this._uiEditor;
|
||||||
}
|
}
|
||||||
this._resizeDialog();
|
this._resizeDialog();
|
||||||
@ -274,7 +275,7 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
|
|||||||
try {
|
try {
|
||||||
const config = yaml.safeLoad(this._configValue.value, {
|
const config = yaml.safeLoad(this._configValue.value, {
|
||||||
schema: extYamlSchema,
|
schema: extYamlSchema,
|
||||||
}) as LovelaceConfig;
|
}) as LovelaceCardConfig;
|
||||||
this._updatePreview(config);
|
this._updatePreview(config);
|
||||||
this._configState = "OK";
|
this._configState = "OK";
|
||||||
if (!this._isToggleAvailable && this._configElement !== null) {
|
if (!this._isToggleAvailable && this._configElement !== null) {
|
||||||
@ -290,12 +291,12 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleUIConfigChanged(value: LovelaceConfig): void {
|
private _handleUIConfigChanged(value: LovelaceCardConfig): void {
|
||||||
this._configValue = { format: "json", value };
|
this._configValue = { format: "json", value };
|
||||||
this._updatePreview(value);
|
this._updatePreview(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _updatePreview(config: LovelaceConfig) {
|
private _updatePreview(config: LovelaceCardConfig) {
|
||||||
if (!this._previewEl) {
|
if (!this._previewEl) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { LovelaceConfig } from "../types";
|
import { LovelaceCardConfig } from "../types";
|
||||||
import { EntityConfig } from "../entity-rows/types";
|
import { EntityConfig } from "../entity-rows/types";
|
||||||
|
|
||||||
export interface YamlChangedEvent extends Event {
|
export interface YamlChangedEvent extends Event {
|
||||||
@ -9,7 +9,7 @@ export interface YamlChangedEvent extends Event {
|
|||||||
|
|
||||||
export interface ConfigValue {
|
export interface ConfigValue {
|
||||||
format: "json" | "yaml";
|
format: "json" | "yaml";
|
||||||
value?: string | LovelaceConfig;
|
value?: string | LovelaceCardConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfigError {
|
export interface ConfigError {
|
||||||
|
@ -1,17 +1,31 @@
|
|||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
|
|
||||||
export interface LovelaceConfig {
|
export interface LovelaceCardConfig {
|
||||||
|
id?: string;
|
||||||
type: string;
|
type: string;
|
||||||
id: string;
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LovelaceViewConfig {
|
||||||
|
title?: string;
|
||||||
|
badges?: string[];
|
||||||
|
cards?: LovelaceCardConfig[];
|
||||||
|
id?: string;
|
||||||
|
icon?: string;
|
||||||
|
}
|
||||||
|
export interface LovelaceConfig {
|
||||||
|
_frontendAuto: boolean;
|
||||||
|
title?: string;
|
||||||
|
views: LovelaceViewConfig[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LovelaceCard extends HTMLElement {
|
export interface LovelaceCard extends HTMLElement {
|
||||||
hass?: HomeAssistant;
|
hass?: HomeAssistant;
|
||||||
getCardSize(): number;
|
getCardSize(): number;
|
||||||
setConfig(config: LovelaceConfig): void;
|
setConfig(config: LovelaceCardConfig): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LovelaceCardEditor extends HTMLElement {
|
export interface LovelaceCardEditor extends HTMLElement {
|
||||||
hass?: HomeAssistant;
|
hass?: HomeAssistant;
|
||||||
setConfig(config: LovelaceConfig): void;
|
setConfig(config: LovelaceCardConfig): void;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user