mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 01:36:49 +00:00
warning-element (#3006)
* warning-element * add warning-element to picture-glance * add glance-card
This commit is contained in:
parent
3b8f8f8189
commit
324f0bb8a2
@ -25,7 +25,7 @@ import applyThemesOnElement from "../../../common/dom/apply_themes_on_element";
|
|||||||
import "../../../components/entity/state-badge";
|
import "../../../components/entity/state-badge";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-icon";
|
import "../../../components/ha-icon";
|
||||||
import "../components/hui-warning";
|
import "../components/hui-warning-element";
|
||||||
|
|
||||||
export interface ConfigEntity extends EntityConfig {
|
export interface ConfigEntity extends EntityConfig {
|
||||||
tap_action?: ActionConfig;
|
tap_action?: ActionConfig;
|
||||||
@ -184,13 +184,13 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
if (!stateObj) {
|
if (!stateObj) {
|
||||||
return html`
|
return html`
|
||||||
<hui-warning
|
<hui-warning-element
|
||||||
>${this.hass!.localize(
|
label=${this.hass!.localize(
|
||||||
"ui.panel.lovelace.warning.entity_not_found",
|
"ui.panel.lovelace.warning.entity_not_found",
|
||||||
"entity",
|
"entity",
|
||||||
entityConf.entity
|
entityConf.entity
|
||||||
)}</hui-warning
|
)}
|
||||||
>
|
></hui-warning-element>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ import stateIcon from "../../../common/entity/state_icon";
|
|||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-icon";
|
import "../../../components/ha-icon";
|
||||||
import "../components/hui-image";
|
import "../components/hui-image";
|
||||||
|
import "../components/hui-warning-element";
|
||||||
|
|
||||||
import { handleClick } from "../common/handle-click";
|
import { handleClick } from "../common/handle-click";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import { toggleEntity } from "../common/entity/toggle-entity";
|
import { toggleEntity } from "../common/entity/toggle-entity";
|
||||||
@ -138,7 +140,15 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
|
|||||||
const stateObj = this.hass!.states[entityConf.entity];
|
const stateObj = this.hass!.states[entityConf.entity];
|
||||||
|
|
||||||
if (!stateObj) {
|
if (!stateObj) {
|
||||||
return html``;
|
return html`
|
||||||
|
<hui-warning-element
|
||||||
|
label=${this.hass!.localize(
|
||||||
|
"ui.panel.lovelace.warning.entity_not_found",
|
||||||
|
"entity",
|
||||||
|
entityConf.entity
|
||||||
|
)}
|
||||||
|
></hui-warning-element>
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
36
src/panels/lovelace/components/hui-warning-element.ts
Normal file
36
src/panels/lovelace/components/hui-warning-element.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import {
|
||||||
|
html,
|
||||||
|
LitElement,
|
||||||
|
TemplateResult,
|
||||||
|
CSSResult,
|
||||||
|
css,
|
||||||
|
customElement,
|
||||||
|
property,
|
||||||
|
} from "lit-element";
|
||||||
|
|
||||||
|
import "../../../components/ha-icon";
|
||||||
|
|
||||||
|
@customElement("hui-warning-element")
|
||||||
|
export class HuiWarningElement extends LitElement {
|
||||||
|
@property() public label?: string;
|
||||||
|
|
||||||
|
protected render(): TemplateResult | void {
|
||||||
|
return html`
|
||||||
|
<ha-icon icon="hass:alert" .title="${this.label}"></ha-icon>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get styles(): CSSResult {
|
||||||
|
return css`
|
||||||
|
ha-icon {
|
||||||
|
color: #fce588;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"hui-warning-element": HuiWarningElement;
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ import {
|
|||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
|
||||||
import "../../../components/entity/ha-state-label-badge";
|
import "../../../components/entity/ha-state-label-badge";
|
||||||
import "../components/hui-warning";
|
import "../components/hui-warning-element";
|
||||||
|
|
||||||
import computeStateName from "../../../common/entity/compute_state_name";
|
import computeStateName from "../../../common/entity/compute_state_name";
|
||||||
import { LovelaceElement, LovelaceElementConfig } from "./types";
|
import { LovelaceElement, LovelaceElementConfig } from "./types";
|
||||||
@ -40,13 +40,13 @@ export class HuiStateBadgeElement extends LitElement
|
|||||||
|
|
||||||
if (!stateObj) {
|
if (!stateObj) {
|
||||||
return html`
|
return html`
|
||||||
<hui-warning
|
<hui-warning-element
|
||||||
>${this.hass.localize(
|
label="${this.hass.localize(
|
||||||
"ui.panel.lovelace.warning.entity_not_found",
|
"ui.panel.lovelace.warning.entity_not_found",
|
||||||
"entity",
|
"entity",
|
||||||
this._config.entity
|
this._config.entity
|
||||||
)}</hui-warning
|
)}"
|
||||||
>
|
></hui-warning-element>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import {
|
|||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
|
||||||
import "../../../components/entity/state-badge";
|
import "../../../components/entity/state-badge";
|
||||||
import "../components/hui-warning";
|
import "../components/hui-warning-element";
|
||||||
|
|
||||||
import { computeTooltip } from "../common/compute-tooltip";
|
import { computeTooltip } from "../common/compute-tooltip";
|
||||||
import { handleClick } from "../common/handle-click";
|
import { handleClick } from "../common/handle-click";
|
||||||
@ -46,13 +46,13 @@ export class HuiStateIconElement extends LitElement implements LovelaceElement {
|
|||||||
|
|
||||||
if (!stateObj) {
|
if (!stateObj) {
|
||||||
return html`
|
return html`
|
||||||
<hui-warning
|
<hui-warning-element
|
||||||
>${this.hass.localize(
|
label=${this.hass.localize(
|
||||||
"ui.panel.lovelace.warning.entity_not_found",
|
"ui.panel.lovelace.warning.entity_not_found",
|
||||||
"entity",
|
"entity",
|
||||||
this._config.entity
|
this._config.entity
|
||||||
)}</hui-warning
|
)}
|
||||||
>
|
></hui-warning-element>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import {
|
|||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
|
||||||
import "../../../components/entity/ha-state-label-badge";
|
import "../../../components/entity/ha-state-label-badge";
|
||||||
import "../components/hui-warning";
|
import "../components/hui-warning-element";
|
||||||
|
|
||||||
import computeStateDisplay from "../../../common/entity/compute_state_display";
|
import computeStateDisplay from "../../../common/entity/compute_state_display";
|
||||||
import { computeTooltip } from "../common/compute-tooltip";
|
import { computeTooltip } from "../common/compute-tooltip";
|
||||||
@ -49,13 +49,13 @@ class HuiStateLabelElement extends LitElement implements LovelaceElement {
|
|||||||
|
|
||||||
if (!stateObj) {
|
if (!stateObj) {
|
||||||
return html`
|
return html`
|
||||||
<hui-warning
|
<hui-warning-element
|
||||||
>${this.hass.localize(
|
label=${this.hass.localize(
|
||||||
"ui.panel.lovelace.warning.entity_not_found",
|
"ui.panel.lovelace.warning.entity_not_found",
|
||||||
"entity",
|
"entity",
|
||||||
this._config.entity
|
this._config.entity
|
||||||
)}</hui-warning
|
)}
|
||||||
>
|
></hui-warning-element>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user