mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 16:26:43 +00:00
Add service icons to traces (again :D) (#19728)
* Add service icons to traces (again :D) * Update hat-graph-node.ts
This commit is contained in:
parent
b1e1b44c75
commit
23cbecb2c4
@ -3,7 +3,6 @@
|
|||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import "../../../../src/components/ha-card";
|
import "../../../../src/components/ha-card";
|
||||||
import "../../../../src/components/trace/hat-script-graph";
|
|
||||||
import "../../../../src/components/trace/hat-trace-timeline";
|
import "../../../../src/components/trace/hat-trace-timeline";
|
||||||
import { provideHass } from "../../../../src/fake_data/provide_hass";
|
import { provideHass } from "../../../../src/fake_data/provide_hass";
|
||||||
import { HomeAssistant } from "../../../../src/types";
|
import { HomeAssistant } from "../../../../src/types";
|
||||||
|
@ -5,6 +5,7 @@ import {
|
|||||||
html,
|
html,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
svg,
|
svg,
|
||||||
|
nothing,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { NODE_SIZE, SPACING } from "./hat-graph-const";
|
import { NODE_SIZE, SPACING } from "./hat-graph-const";
|
||||||
@ -51,7 +52,7 @@ export class HatGraphNode extends LitElement {
|
|||||||
: Math.ceil((NODE_SIZE + SPACING * 2) / 2)} ${width} ${height}"
|
: Math.ceil((NODE_SIZE + SPACING * 2) / 2)} ${width} ${height}"
|
||||||
>
|
>
|
||||||
${this.graphStart
|
${this.graphStart
|
||||||
? ``
|
? nothing
|
||||||
: svg`
|
: svg`
|
||||||
<path
|
<path
|
||||||
class="connector"
|
class="connector"
|
||||||
@ -64,7 +65,6 @@ export class HatGraphNode extends LitElement {
|
|||||||
`}
|
`}
|
||||||
<g class="node">
|
<g class="node">
|
||||||
<circle cx="0" cy="0" r=${NODE_SIZE / 2} />
|
<circle cx="0" cy="0" r=${NODE_SIZE / 2} />
|
||||||
}
|
|
||||||
${this.badge
|
${this.badge
|
||||||
? svg`
|
? svg`
|
||||||
<g class="number">
|
<g class="number">
|
||||||
@ -81,9 +81,11 @@ export class HatGraphNode extends LitElement {
|
|||||||
>${this.badge > 9 ? "9+" : this.badge}</text>
|
>${this.badge > 9 ? "9+" : this.badge}</text>
|
||||||
</g>
|
</g>
|
||||||
`
|
`
|
||||||
: ""}
|
: nothing}
|
||||||
<g style="pointer-events: none" transform="translate(${-12} ${-12})">
|
<g style="pointer-events: none" transform="translate(${-12} ${-12})">
|
||||||
${this.iconPath ? svg`<path class="icon" d=${this.iconPath}/>` : ""}
|
${this.iconPath
|
||||||
|
? svg`<path class="icon" d=${this.iconPath}/>`
|
||||||
|
: svg`<foreignObject><span class="icon"><slot name="icon"></slot></span></foreignObject>`}
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
@ -152,6 +154,13 @@ export class HatGraphNode extends LitElement {
|
|||||||
path.icon {
|
path.icon {
|
||||||
fill: var(--icon-clr);
|
fill: var(--icon-clr);
|
||||||
}
|
}
|
||||||
|
foreignObject {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
.icon {
|
||||||
|
color: var(--icon-clr);
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,10 @@ import {
|
|||||||
mdiRoomService,
|
mdiRoomService,
|
||||||
mdiShuffleDisabled,
|
mdiShuffleDisabled,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import { LitElement, PropertyValues, css, html } from "lit";
|
import { LitElement, PropertyValues, css, html, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { ensureArray } from "../../common/array/ensure-array";
|
import { ensureArray } from "../../common/array/ensure-array";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { ACTION_ICONS } from "../../data/action";
|
|
||||||
import { Condition, Trigger } from "../../data/automation";
|
import { Condition, Trigger } from "../../data/automation";
|
||||||
import {
|
import {
|
||||||
Action,
|
Action,
|
||||||
@ -41,11 +40,14 @@ import {
|
|||||||
IfActionTraceStep,
|
IfActionTraceStep,
|
||||||
TraceExtended,
|
TraceExtended,
|
||||||
} from "../../data/trace";
|
} from "../../data/trace";
|
||||||
|
import { HomeAssistant } from "../../types";
|
||||||
import "../ha-icon-button";
|
import "../ha-icon-button";
|
||||||
|
import "../ha-service-icon";
|
||||||
import "./hat-graph-branch";
|
import "./hat-graph-branch";
|
||||||
import { BRANCH_HEIGHT, NODE_SIZE, SPACING } from "./hat-graph-const";
|
import { BRANCH_HEIGHT, NODE_SIZE, SPACING } from "./hat-graph-const";
|
||||||
import "./hat-graph-node";
|
import "./hat-graph-node";
|
||||||
import "./hat-graph-spacer";
|
import "./hat-graph-spacer";
|
||||||
|
import { ACTION_ICONS } from "../../data/action";
|
||||||
|
|
||||||
export interface NodeInfo {
|
export interface NodeInfo {
|
||||||
path: string;
|
path: string;
|
||||||
@ -64,6 +66,8 @@ export class HatScriptGraph extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public selected?: string;
|
@property({ attribute: false }) public selected?: string;
|
||||||
|
|
||||||
|
public hass!: HomeAssistant;
|
||||||
|
|
||||||
public renderedNodes: Record<string, NodeInfo> = {};
|
public renderedNodes: Record<string, NodeInfo> = {};
|
||||||
|
|
||||||
public trackedNodes: Record<string, NodeInfo> = {};
|
public trackedNodes: Record<string, NodeInfo> = {};
|
||||||
@ -415,13 +419,21 @@ export class HatScriptGraph extends LitElement {
|
|||||||
return html`
|
return html`
|
||||||
<hat-graph-node
|
<hat-graph-node
|
||||||
.graphStart=${graphStart}
|
.graphStart=${graphStart}
|
||||||
.iconPath=${mdiRoomService}
|
.iconPath=${node.service ? undefined : mdiRoomService}
|
||||||
@focus=${this.selectNode(node, path)}
|
@focus=${this.selectNode(node, path)}
|
||||||
?track=${path in this.trace.trace}
|
?track=${path in this.trace.trace}
|
||||||
?active=${this.selected === path}
|
?active=${this.selected === path}
|
||||||
.notEnabled=${disabled || node.enabled === false}
|
.notEnabled=${disabled || node.enabled === false}
|
||||||
tabindex=${this.trace && path in this.trace.trace ? "0" : "-1"}
|
tabindex=${this.trace && path in this.trace.trace ? "0" : "-1"}
|
||||||
></hat-graph-node>
|
>
|
||||||
|
${node.service
|
||||||
|
? html`<ha-service-icon
|
||||||
|
slot="icon"
|
||||||
|
.hass=${this.hass}
|
||||||
|
.service=${node.service}
|
||||||
|
></ha-service-icon>`
|
||||||
|
: nothing}
|
||||||
|
</hat-graph-node>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,8 +679,6 @@ export class HatScriptGraph extends LitElement {
|
|||||||
}
|
}
|
||||||
.parent {
|
.parent {
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
margin-inline-start: 8px;
|
|
||||||
margin-inline-end: initial;
|
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
.error {
|
.error {
|
||||||
|
@ -232,6 +232,7 @@ export class HaAutomationTrace extends LitElement {
|
|||||||
<div class="main">
|
<div class="main">
|
||||||
<div class="graph">
|
<div class="graph">
|
||||||
<hat-script-graph
|
<hat-script-graph
|
||||||
|
.hass=${this.hass}
|
||||||
.trace=${this._trace}
|
.trace=${this._trace}
|
||||||
.selected=${this._selected?.path}
|
.selected=${this._selected?.path}
|
||||||
@graph-node-selected=${this._pickNode}
|
@graph-node-selected=${this._pickNode}
|
||||||
|
@ -217,6 +217,7 @@ export class HaScriptTrace extends LitElement {
|
|||||||
<div class="main">
|
<div class="main">
|
||||||
<div class="graph">
|
<div class="graph">
|
||||||
<hat-script-graph
|
<hat-script-graph
|
||||||
|
.hass=${this.hass}
|
||||||
.trace=${this._trace}
|
.trace=${this._trace}
|
||||||
.selected=${this._selected?.path}
|
.selected=${this._selected?.path}
|
||||||
@graph-node-selected=${this._pickNode}
|
@graph-node-selected=${this._pickNode}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user