mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
🧹 remove unused configs when empty (#2347)
* Remove unused configs when empty * Handle unused numbers & fix glance entities * Sneak in the chunk names
This commit is contained in:
parent
849ed80e78
commit
c47ba65c3b
@ -41,7 +41,7 @@ export interface Config extends LovelaceCardConfig {
|
|||||||
class HuiAlarmPanelCard extends hassLocalizeLitMixin(LitElement)
|
class HuiAlarmPanelCard extends hassLocalizeLitMixin(LitElement)
|
||||||
implements LovelaceCard {
|
implements LovelaceCard {
|
||||||
public static async getConfigElement() {
|
public static async getConfigElement() {
|
||||||
await import("../editor/config-elements/hui-alarm-panel-card-editor");
|
await import(/* webpackChunkName: "hui-alarm-panel-card-editor" */ "../editor/config-elements/hui-alarm-panel-card-editor");
|
||||||
return document.createElement("hui-alarm-panel-card-editor");
|
return document.createElement("hui-alarm-panel-card-editor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ export interface Config extends LovelaceCardConfig {
|
|||||||
class HuiEntitiesCard extends hassLocalizeLitMixin(LitElement)
|
class HuiEntitiesCard extends hassLocalizeLitMixin(LitElement)
|
||||||
implements LovelaceCard {
|
implements LovelaceCard {
|
||||||
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
||||||
await import("../editor/config-elements/hui-entities-card-editor");
|
await import(/* webpackChunkName: "hui-entities-card-editor" */ "../editor/config-elements/hui-entities-card-editor");
|
||||||
return document.createElement("hui-entities-card-editor");
|
return document.createElement("hui-entities-card-editor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ export const severityMap = {
|
|||||||
|
|
||||||
class HuiGaugeCard extends LitElement implements LovelaceCard {
|
class HuiGaugeCard extends LitElement implements LovelaceCard {
|
||||||
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
||||||
await import("../editor/config-elements/hui-gauge-card-editor");
|
await import(/* webpackChunkName: "hui-gauge-card-editor" */ "../editor/config-elements/hui-gauge-card-editor");
|
||||||
return document.createElement("hui-gauge-card-editor");
|
return document.createElement("hui-gauge-card-editor");
|
||||||
}
|
}
|
||||||
public static getStubConfig(): object {
|
public static getStubConfig(): object {
|
||||||
|
@ -41,7 +41,7 @@ export interface Config extends LovelaceCardConfig {
|
|||||||
export class HuiGlanceCard extends hassLocalizeLitMixin(LitElement)
|
export class HuiGlanceCard extends hassLocalizeLitMixin(LitElement)
|
||||||
implements LovelaceCard {
|
implements LovelaceCard {
|
||||||
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
||||||
await import("../editor/config-elements/hui-glance-card-editor");
|
await import(/* webpackChunkName: "hui-glance-card-editor" */ "../editor/config-elements/hui-glance-card-editor");
|
||||||
return document.createElement("hui-glance-card-editor");
|
return document.createElement("hui-glance-card-editor");
|
||||||
}
|
}
|
||||||
public static getStubConfig(): object {
|
public static getStubConfig(): object {
|
||||||
|
@ -15,7 +15,7 @@ export interface Config extends LovelaceCardConfig {
|
|||||||
|
|
||||||
export class HuiIframeCard extends LitElement implements LovelaceCard {
|
export class HuiIframeCard extends LitElement implements LovelaceCard {
|
||||||
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
||||||
await import("../editor/config-elements/hui-iframe-card-editor");
|
await import(/* webpackChunkName: "hui-iframe-card-editor" */ "../editor/config-elements/hui-iframe-card-editor");
|
||||||
return document.createElement("hui-iframe-card-editor");
|
return document.createElement("hui-iframe-card-editor");
|
||||||
}
|
}
|
||||||
public static getStubConfig(): object {
|
public static getStubConfig(): object {
|
||||||
|
@ -48,7 +48,7 @@ export interface Config extends LovelaceCardConfig {
|
|||||||
export class HuiLightCard extends hassLocalizeLitMixin(LitElement)
|
export class HuiLightCard extends hassLocalizeLitMixin(LitElement)
|
||||||
implements LovelaceCard {
|
implements LovelaceCard {
|
||||||
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
||||||
await import("../editor/config-elements/hui-light-card-editor");
|
await import(/* webpackChunkName: "hui-light-card-editor" */ "../editor/config-elements/hui-light-card-editor");
|
||||||
return document.createElement("hui-light-card-editor");
|
return document.createElement("hui-light-card-editor");
|
||||||
}
|
}
|
||||||
public static getStubConfig(): object {
|
public static getStubConfig(): object {
|
||||||
|
@ -15,7 +15,7 @@ export interface Config extends LovelaceCardConfig {
|
|||||||
|
|
||||||
export class HuiMarkdownCard extends LitElement implements LovelaceCard {
|
export class HuiMarkdownCard extends LitElement implements LovelaceCard {
|
||||||
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
||||||
await import("../editor/config-elements/hui-markdown-card-editor");
|
await import(/* webpackChunkName: "hui-markdown-card-editor" */ "../editor/config-elements/hui-markdown-card-editor");
|
||||||
return document.createElement("hui-markdown-card-editor");
|
return document.createElement("hui-markdown-card-editor");
|
||||||
}
|
}
|
||||||
public static getStubConfig(): object {
|
public static getStubConfig(): object {
|
||||||
|
@ -9,7 +9,7 @@ export const Config = {
|
|||||||
|
|
||||||
class HuiMediaControlCard extends LegacyWrapperCard {
|
class HuiMediaControlCard extends LegacyWrapperCard {
|
||||||
static async getConfigElement() {
|
static async getConfigElement() {
|
||||||
await import("../editor/config-elements/hui-media-control-card-editor");
|
await import(/* webpackChunkName: "hui-media-control-card-editor" */ "../editor/config-elements/hui-media-control-card-editor");
|
||||||
return document.createElement("hui-media-control-card-editor");
|
return document.createElement("hui-media-control-card-editor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ export const Config = {
|
|||||||
|
|
||||||
class HuiPlantStatusCard extends LegacyWrapperCard {
|
class HuiPlantStatusCard extends LegacyWrapperCard {
|
||||||
static async getConfigElement() {
|
static async getConfigElement() {
|
||||||
await import("../editor/config-elements/hui-plant-status-card-editor");
|
await import(/* webpackChunkName: "hui-plant-status-card-editor" */ "../editor/config-elements/hui-plant-status-card-editor");
|
||||||
return document.createElement("hui-plant-status-card-editor");
|
return document.createElement("hui-plant-status-card-editor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ export interface Config extends LovelaceCardConfig {
|
|||||||
|
|
||||||
class HuiSensorCard extends LitElement implements LovelaceCard {
|
class HuiSensorCard extends LitElement implements LovelaceCard {
|
||||||
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
||||||
await import("../editor/config-elements/hui-sensor-card-editor");
|
await import(/* webpackChunkName: "hui-sensor-card-editor" */ "../editor/config-elements/hui-sensor-card-editor");
|
||||||
return document.createElement("hui-sensor-card-editor");
|
return document.createElement("hui-sensor-card-editor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ export interface Config extends LovelaceCardConfig {
|
|||||||
class HuiShoppingListCard extends hassLocalizeLitMixin(LitElement)
|
class HuiShoppingListCard extends hassLocalizeLitMixin(LitElement)
|
||||||
implements LovelaceCard {
|
implements LovelaceCard {
|
||||||
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
||||||
await import("../editor/config-elements/hui-shopping-list-editor");
|
await import(/* webpackChunkName: "hui-shopping-list-editor" */ "../editor/config-elements/hui-shopping-list-editor");
|
||||||
return document.createElement("hui-shopping-list-card-editor");
|
return document.createElement("hui-shopping-list-card-editor");
|
||||||
}
|
}
|
||||||
public static getStubConfig(): object {
|
public static getStubConfig(): object {
|
||||||
|
@ -58,7 +58,7 @@ function formatTemp(temps: string[]): string {
|
|||||||
export class HuiThermostatCard extends hassLocalizeLitMixin(LitElement)
|
export class HuiThermostatCard extends hassLocalizeLitMixin(LitElement)
|
||||||
implements LovelaceCard {
|
implements LovelaceCard {
|
||||||
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
||||||
await import("../editor/config-elements/hui-thermostat-card-editor");
|
await import(/* webpackChunkName: "hui-thermostat-card-editor" */ "../editor/config-elements/hui-thermostat-card-editor");
|
||||||
return document.createElement("hui-thermostat-card-editor");
|
return document.createElement("hui-thermostat-card-editor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,10 +173,14 @@ export class HuiAlarmPanelCardEditor extends hassLocalizeLitMixin(LitElement)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (target.configValue) {
|
if (target.configValue) {
|
||||||
this._config = {
|
if (target.value === "") {
|
||||||
...this._config,
|
delete this._config[target.configValue!];
|
||||||
[target.configValue!]: target.value,
|
} else {
|
||||||
};
|
this._config = {
|
||||||
|
...this._config,
|
||||||
|
[target.configValue!]: target.value,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fireEvent(this, "config-changed", { config: this._config });
|
fireEvent(this, "config-changed", { config: this._config });
|
||||||
}
|
}
|
||||||
|
@ -115,11 +115,15 @@ export class HuiEntitiesCardEditor extends hassLocalizeLitMixin(LitElement)
|
|||||||
this._config.entities = ev.detail.entities;
|
this._config.entities = ev.detail.entities;
|
||||||
this._configEntities = processEditorEntities(this._config.entities);
|
this._configEntities = processEditorEntities(this._config.entities);
|
||||||
} else if (target.configValue) {
|
} else if (target.configValue) {
|
||||||
this._config = {
|
if (target.value === "") {
|
||||||
...this._config,
|
delete this._config[target.configValue!];
|
||||||
[target.configValue]:
|
} else {
|
||||||
target.checked !== undefined ? target.checked : target.value,
|
this._config = {
|
||||||
};
|
...this._config,
|
||||||
|
[target.configValue]:
|
||||||
|
target.checked !== undefined ? target.checked : target.value,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fireEvent(this, "config-changed", { config: this._config });
|
fireEvent(this, "config-changed", { config: this._config });
|
||||||
|
@ -218,11 +218,18 @@ export class HuiGaugeCardEditor extends hassLocalizeLitMixin(LitElement)
|
|||||||
const target = ev.target! as EditorTarget;
|
const target = ev.target! as EditorTarget;
|
||||||
|
|
||||||
if (target.configValue) {
|
if (target.configValue) {
|
||||||
let value: any = target.value;
|
if (
|
||||||
if (target.type === "number") {
|
target.value === "" ||
|
||||||
value = Number(value);
|
(target.type === "number" && isNaN(Number(target.value)))
|
||||||
|
) {
|
||||||
|
delete this._config[target.configValue!];
|
||||||
|
} else {
|
||||||
|
let value: any = target.value;
|
||||||
|
if (target.type === "number") {
|
||||||
|
value = Number(value);
|
||||||
|
}
|
||||||
|
this._config = { ...this._config, [target.configValue!]: value };
|
||||||
}
|
}
|
||||||
this._config = { ...this._config, [target.configValue!]: value };
|
|
||||||
}
|
}
|
||||||
fireEvent(this, "config-changed", { config: this._config });
|
fireEvent(this, "config-changed", { config: this._config });
|
||||||
}
|
}
|
||||||
|
@ -64,8 +64,8 @@ export class HuiGlanceCardEditor extends hassLocalizeLitMixin(LitElement)
|
|||||||
return this._config!.theme || "Backend-selected";
|
return this._config!.theme || "Backend-selected";
|
||||||
}
|
}
|
||||||
|
|
||||||
get _columns(): string {
|
get _columns(): number {
|
||||||
return this._config!.columns ? String(this._config!.columns) : "";
|
return this._config!.columns || NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
@ -126,22 +126,29 @@ export class HuiGlanceCardEditor extends hassLocalizeLitMixin(LitElement)
|
|||||||
}
|
}
|
||||||
const target = ev.target! as EditorTarget;
|
const target = ev.target! as EditorTarget;
|
||||||
|
|
||||||
if (this[`_${target.configValue}`] === target.value) {
|
if (target.configValue && this[`_${target.configValue}`] === target.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ev.detail && ev.detail.entities) {
|
if (ev.detail && ev.detail.entities) {
|
||||||
this._config.entities = ev.detail.entities;
|
this._config.entities = ev.detail.entities;
|
||||||
this._configEntities = processEditorEntities(this._config.entities);
|
this._configEntities = processEditorEntities(this._config.entities);
|
||||||
} else if (target.configValue) {
|
} else if (target.configValue) {
|
||||||
let value: any = target.value;
|
if (
|
||||||
if (target.type === "number") {
|
target.value === "" ||
|
||||||
value = Number(value);
|
(target.type === "number" && isNaN(Number(target.value)))
|
||||||
|
) {
|
||||||
|
delete this._config[target.configValue!];
|
||||||
|
} else {
|
||||||
|
let value: any = target.value;
|
||||||
|
if (target.type === "number") {
|
||||||
|
value = Number(value);
|
||||||
|
}
|
||||||
|
this._config = {
|
||||||
|
...this._config,
|
||||||
|
[target.configValue!]:
|
||||||
|
target.checked !== undefined ? target.checked : value,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
this._config = {
|
|
||||||
...this._config,
|
|
||||||
[target.configValue!]:
|
|
||||||
target.checked !== undefined ? target.checked : value,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
fireEvent(this, "config-changed", { config: this._config });
|
fireEvent(this, "config-changed", { config: this._config });
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,11 @@ export class HuiIframeCardEditor extends hassLocalizeLitMixin(LitElement)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (target.configValue) {
|
if (target.configValue) {
|
||||||
this._config = { ...this._config, [target.configValue!]: value };
|
if (target.value === "") {
|
||||||
|
delete this._config[target.configValue!];
|
||||||
|
} else {
|
||||||
|
this._config = { ...this._config, [target.configValue!]: value };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fireEvent(this, "config-changed", { config: this._config });
|
fireEvent(this, "config-changed", { config: this._config });
|
||||||
}
|
}
|
||||||
|
@ -91,10 +91,14 @@ export class HuiLightCardEditor extends hassLocalizeLitMixin(LitElement)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (target.configValue) {
|
if (target.configValue) {
|
||||||
this._config = {
|
if (target.value === "") {
|
||||||
...this._config,
|
delete this._config[target.configValue!];
|
||||||
[target.configValue!]: target.value,
|
} else {
|
||||||
};
|
this._config = {
|
||||||
|
...this._config,
|
||||||
|
[target.configValue!]: target.value,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fireEvent(this, "config-changed", { config: this._config });
|
fireEvent(this, "config-changed", { config: this._config });
|
||||||
}
|
}
|
||||||
|
@ -77,10 +77,14 @@ export class HuiMarkdownCardEditor extends hassLocalizeLitMixin(LitElement)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (target.configValue) {
|
if (target.configValue) {
|
||||||
this._config = {
|
if (target.value === "") {
|
||||||
...this._config,
|
delete this._config[target.configValue!];
|
||||||
[target.configValue!]: target.value,
|
} else {
|
||||||
};
|
this._config = {
|
||||||
|
...this._config,
|
||||||
|
[target.configValue!]: target.value,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fireEvent(this, "config-changed", { config: this._config });
|
fireEvent(this, "config-changed", { config: this._config });
|
||||||
}
|
}
|
||||||
|
@ -62,10 +62,14 @@ export class HuiMediaControlCardEditor extends hassLocalizeLitMixin(LitElement)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (target.configValue) {
|
if (target.configValue) {
|
||||||
this._config = {
|
if (target.value === "") {
|
||||||
...this._config,
|
delete this._config[target.configValue!];
|
||||||
[target.configValue!]: target.value,
|
} else {
|
||||||
};
|
this._config = {
|
||||||
|
...this._config,
|
||||||
|
[target.configValue!]: target.value,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fireEvent(this, "config-changed", { config: this._config });
|
fireEvent(this, "config-changed", { config: this._config });
|
||||||
}
|
}
|
||||||
|
@ -79,10 +79,14 @@ export class HuiPlantStatusCardEditor extends hassLocalizeLitMixin(LitElement)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (target.configValue) {
|
if (target.configValue) {
|
||||||
this._config = {
|
if (target.value === "") {
|
||||||
...this._config,
|
delete this._config[target.configValue!];
|
||||||
[target.configValue!]: target.value,
|
} else {
|
||||||
};
|
this._config = {
|
||||||
|
...this._config,
|
||||||
|
[target.configValue!]: target.value,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fireEvent(this, "config-changed", { config: this._config });
|
fireEvent(this, "config-changed", { config: this._config });
|
||||||
}
|
}
|
||||||
|
@ -171,14 +171,18 @@ export class HuiSensorCardEditor extends hassLocalizeLitMixin(LitElement)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (target.configValue) {
|
if (target.configValue) {
|
||||||
let value: any = target.value;
|
if (
|
||||||
if (target.type === "number") {
|
target.value === "" ||
|
||||||
value = Number(value);
|
(target.type === "number" && isNaN(Number(target.value)))
|
||||||
|
) {
|
||||||
|
delete this._config[target.configValue!];
|
||||||
|
} else {
|
||||||
|
let value: any = target.value;
|
||||||
|
if (target.type === "number") {
|
||||||
|
value = Number(value);
|
||||||
|
}
|
||||||
|
this._config = { ...this._config, [target.configValue!]: value };
|
||||||
}
|
}
|
||||||
this._config = {
|
|
||||||
...this._config,
|
|
||||||
[target.configValue!]: value,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
fireEvent(this, "config-changed", { config: this._config });
|
fireEvent(this, "config-changed", { config: this._config });
|
||||||
}
|
}
|
||||||
|
@ -60,10 +60,14 @@ export class HuiShoppingListEditor extends hassLocalizeLitMixin(LitElement)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (target.configValue) {
|
if (target.configValue) {
|
||||||
this._config = {
|
if (target.value === "") {
|
||||||
...this._config,
|
delete this._config[target.configValue!];
|
||||||
[target.configValue!]: target.value,
|
} else {
|
||||||
};
|
this._config = {
|
||||||
|
...this._config,
|
||||||
|
[target.configValue!]: target.value,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fireEvent(this, "config-changed", { config: this._config });
|
fireEvent(this, "config-changed", { config: this._config });
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,11 @@ export class HuiThermostatCardEditor extends hassLocalizeLitMixin(LitElement)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (target.configValue) {
|
if (target.configValue) {
|
||||||
this._config = { ...this._config, [target.configValue!]: target.value };
|
if (target.value === "") {
|
||||||
|
delete this._config[target.configValue!];
|
||||||
|
} else {
|
||||||
|
this._config = { ...this._config, [target.configValue!]: target.value };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fireEvent(this, "config-changed", { config: this._config });
|
fireEvent(this, "config-changed", { config: this._config });
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user