mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +00:00
addressiing reviews
This commit is contained in:
parent
be63648238
commit
06aef18d0c
@ -11,11 +11,9 @@ import createRowElement from "../common/create-row-element.js";
|
|||||||
import computeDomain from "../../../common/entity/compute_domain.js";
|
import computeDomain from "../../../common/entity/compute_domain.js";
|
||||||
import processConfigEntities from "../common/process-config-entities";
|
import processConfigEntities from "../common/process-config-entities";
|
||||||
import { HomeAssistant } from "../../../types.js";
|
import { HomeAssistant } from "../../../types.js";
|
||||||
|
import { EntityConfig, EntityRow } from "../entity-rows/types.js";
|
||||||
|
|
||||||
interface EntityConfig {
|
interface ConfigEntity extends EntityConfig {
|
||||||
name?: string;
|
|
||||||
icon?: string;
|
|
||||||
entity: string;
|
|
||||||
type?: string;
|
type?: string;
|
||||||
secondary_info: "entity-id" | "last-changed";
|
secondary_info: "entity-id" | "last-changed";
|
||||||
action_name?: string;
|
action_name?: string;
|
||||||
@ -27,23 +25,22 @@ interface EntityConfig {
|
|||||||
interface Config extends LovelaceConfig {
|
interface Config extends LovelaceConfig {
|
||||||
show_header_toggle?: boolean;
|
show_header_toggle?: boolean;
|
||||||
title?: string;
|
title?: string;
|
||||||
entities: EntityConfig[];
|
entities: ConfigEntity[];
|
||||||
}
|
}
|
||||||
|
|
||||||
class HuiEntitiesCard extends HassLocalizeLitMixin(LitElement)
|
class HuiEntitiesCard extends HassLocalizeLitMixin(LitElement)
|
||||||
implements LovelaceCard {
|
implements LovelaceCard {
|
||||||
protected _hass?: HomeAssistant;
|
protected _hass?: HomeAssistant;
|
||||||
protected config?: Config;
|
protected config?: Config;
|
||||||
protected configEntities?: EntityConfig[];
|
protected configEntities?: ConfigEntity[];
|
||||||
|
|
||||||
set hass(hass) {
|
set hass(hass) {
|
||||||
this._hass = hass;
|
this._hass = hass;
|
||||||
if (this.shadowRoot && this.shadowRoot.querySelector("ha-card")) {
|
if (this.shadowRoot) {
|
||||||
this.shadowRoot
|
this.shadowRoot
|
||||||
.querySelector("ha-card")!
|
.querySelectorAll("#states > *")
|
||||||
.querySelectorAll("#states > div > *")
|
|
||||||
.forEach((element: any) => {
|
.forEach((element: any) => {
|
||||||
element.hass = hass;
|
(element as EntityRow).hass = hass;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,10 +130,10 @@ class HuiEntitiesCard extends HassLocalizeLitMixin(LitElement)
|
|||||||
#states {
|
#states {
|
||||||
margin: -4px 0;
|
margin: -4px 0;
|
||||||
}
|
}
|
||||||
#states > div {
|
#states > * {
|
||||||
margin: 4px 0;
|
margin: 4px 0;
|
||||||
}
|
}
|
||||||
#states > div > * {
|
#states > * {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.header {
|
.header {
|
||||||
@ -168,19 +165,19 @@ class HuiEntitiesCard extends HassLocalizeLitMixin(LitElement)
|
|||||||
!DOMAINS_HIDE_MORE_INFO.includes(computeDomain(entityConf.entity))
|
!DOMAINS_HIDE_MORE_INFO.includes(computeDomain(entityConf.entity))
|
||||||
) {
|
) {
|
||||||
element.classList.add("state-card-dialog");
|
element.classList.add("state-card-dialog");
|
||||||
element.onclick = this.handleClick;
|
// element.onclick = this.handleClick;
|
||||||
|
element.addEventListener("click", this.handleClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div>
|
|
||||||
${element}
|
${element}
|
||||||
</div>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleClick(ev: MouseEvent) {
|
private handleClick(ev: MouseEvent) {
|
||||||
const config = (ev.currentTarget as any).entityConf as EntityConfig;
|
const config = (ev.currentTarget as any).entityConf as ConfigEntity;
|
||||||
const entityId = config.entity;
|
const entityId = config.entity;
|
||||||
|
console.log("clicked");
|
||||||
|
|
||||||
fireEvent(this, "hass-more-info", { entityId });
|
fireEvent(this, "hass-more-info", { entityId });
|
||||||
}
|
}
|
||||||
|
12
src/panels/lovelace/entity-rows/types.ts
Normal file
12
src/panels/lovelace/entity-rows/types.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { HomeAssistant } from "../../../types";
|
||||||
|
|
||||||
|
export interface EntityConfig {
|
||||||
|
entity: string;
|
||||||
|
name: string;
|
||||||
|
icon: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EntityRow {
|
||||||
|
hass: HomeAssistant;
|
||||||
|
config: EntityConfig;
|
||||||
|
}
|
@ -1,5 +1,3 @@
|
|||||||
import { HomeAssistant } from "../../types";
|
|
||||||
|
|
||||||
export interface LovelaceConfig {
|
export interface LovelaceConfig {
|
||||||
type: string;
|
type: string;
|
||||||
}
|
}
|
||||||
@ -9,14 +7,3 @@ export interface LovelaceCard extends HTMLElement {
|
|||||||
getCardSize(): number;
|
getCardSize(): number;
|
||||||
setConfig(config: LovelaceConfig): void;
|
setConfig(config: LovelaceConfig): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EntityConfig {
|
|
||||||
entity: string;
|
|
||||||
name: string;
|
|
||||||
icon: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface EntityRow {
|
|
||||||
hass: HomeAssistant;
|
|
||||||
config: EntityConfig;
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user