mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Correctly wrap weblink entities (#2440)
This commit is contained in:
parent
1d4f74cda3
commit
94df67a7cb
@ -13,6 +13,7 @@ import computeObjectId from "../../../common/entity/compute_object_id";
|
|||||||
import computeStateDomain from "../../../common/entity/compute_state_domain";
|
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";
|
||||||
|
import { EntityRowConfig, WeblinkConfig } from "../entity-rows/types";
|
||||||
|
|
||||||
const DEFAULT_VIEW_ENTITY_ID = "group.default_view";
|
const DEFAULT_VIEW_ENTITY_ID = "group.default_view";
|
||||||
const DOMAINS_BADGES = [
|
const DOMAINS_BADGES = [
|
||||||
@ -32,9 +33,9 @@ const computeCards = (
|
|||||||
const cards: LovelaceCardConfig[] = [];
|
const cards: LovelaceCardConfig[] = [];
|
||||||
|
|
||||||
// For entity card
|
// For entity card
|
||||||
const entities: string[] = [];
|
const entities: Array<string | EntityRowConfig> = [];
|
||||||
|
|
||||||
for (const [entityId /*, stateObj */] of states) {
|
for (const [entityId, stateObj] of states) {
|
||||||
const domain = computeDomain(entityId);
|
const domain = computeDomain(entityId);
|
||||||
|
|
||||||
if (domain === "alarm_control_panel") {
|
if (domain === "alarm_control_panel") {
|
||||||
@ -67,6 +68,16 @@ const computeCards = (
|
|||||||
type: "weather-forecast",
|
type: "weather-forecast",
|
||||||
entity: entityId,
|
entity: entityId,
|
||||||
});
|
});
|
||||||
|
} else if (domain === "weblink") {
|
||||||
|
const conf: WeblinkConfig = {
|
||||||
|
type: "weblink",
|
||||||
|
url: stateObj.state,
|
||||||
|
name: computeStateName(stateObj),
|
||||||
|
};
|
||||||
|
if ("icon" in stateObj.attributes) {
|
||||||
|
conf.icon = stateObj.attributes.icon;
|
||||||
|
}
|
||||||
|
entities.push(conf);
|
||||||
} else {
|
} else {
|
||||||
entities.push(entityId);
|
entities.push(entityId);
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,15 @@ export interface EntityConfig {
|
|||||||
icon?: string;
|
icon?: string;
|
||||||
}
|
}
|
||||||
export interface DividerConfig {
|
export interface DividerConfig {
|
||||||
|
type: string;
|
||||||
style: string;
|
style: string;
|
||||||
}
|
}
|
||||||
export interface SectionConfig {
|
export interface SectionConfig {
|
||||||
|
type: string;
|
||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
export interface WeblinkConfig {
|
export interface WeblinkConfig {
|
||||||
|
type: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
@ -35,7 +35,7 @@ class HuiWeblinkRow extends LitElement implements EntityRow {
|
|||||||
|
|
||||||
return html`
|
return html`
|
||||||
${this.renderStyle()}
|
${this.renderStyle()}
|
||||||
<a href="${this._config.url}">
|
<a href="${this._config.url}" target="_blank">
|
||||||
<ha-icon .icon="${this._config.icon}"></ha-icon>
|
<ha-icon .icon="${this._config.icon}"></ha-icon>
|
||||||
<div>${this._config.name}</div>
|
<div>${this._config.name}</div>
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user