From 1421df2a5aa224396caccb80d6bc69aa9b679217 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 29 Apr 2022 23:30:40 +0200 Subject: [PATCH] Add if, parallel and stop action to trace graph (#12520) --- src/components/trace/hat-script-graph.ts | 106 ++++++++++++++++++++++- src/data/trace.ts | 8 ++ 2 files changed, 113 insertions(+), 1 deletion(-) diff --git a/src/components/trace/hat-script-graph.ts b/src/components/trace/hat-script-graph.ts index 61555e01d2..7441bdebae 100644 --- a/src/components/trace/hat-script-graph.ts +++ b/src/components/trace/hat-script-graph.ts @@ -1,7 +1,11 @@ import { mdiAbTesting, + mdiAlertOctagon, + mdiArrowDecision, mdiArrowUp, mdiAsterisk, + mdiCallMissed, + mdiCallReceived, mdiCallSplit, mdiCheckboxBlankOutline, mdiCheckboxMarkedOutline, @@ -9,10 +13,12 @@ import { mdiChevronRight, mdiChevronUp, mdiClose, + mdiCloseOctagon, mdiCodeBrackets, mdiDevices, mdiExclamation, mdiRefresh, + mdiShuffleDisabled, mdiTimerOutline, mdiTrafficLight, } from "@mdi/js"; @@ -27,6 +33,8 @@ import { DelayAction, DeviceAction, EventAction, + IfAction, + ParallelAction, RepeatAction, SceneAction, ServiceAction, @@ -36,6 +44,8 @@ import { import { ChooseActionTraceStep, ConditionTraceStep, + IfActionTraceStep, + StopActionTraceStep, TraceExtended, } from "../../data/trace"; import "../ha-icon-button"; @@ -110,6 +120,9 @@ export class HatScriptGraph extends LitElement { repeat: this.render_repeat_node, choose: this.render_choose_node, device_id: this.render_device_node, + if: this.render_if_node, + stop: this.render_stop_node, + parallel: this.render_parallel_node, other: this.render_other_node, }; @@ -146,7 +159,7 @@ export class HatScriptGraph extends LitElement { > + + ${config.else + ? html`
+ ${ensureArray(config.else).map((action, j) => + this.render_action_node(action, `${path}/else/${j}`) + )} +
` + : html``} +
+ + ${ensureArray(config.then).map((action, j) => + this.render_action_node(action, `${path}/then/${j}`) + )} +
+ + `; + } + private render_condition_node( node: Condition, path: string, @@ -392,6 +453,49 @@ export class HatScriptGraph extends LitElement { `; } + private render_parallel_node( + node: ParallelAction, + path: string, + graphStart = false + ) { + const trace: any = this.trace.trace[path]; + return html` + + + ${ensureArray(node.parallel).map((action, i) => + this.render_action_node(action, `${path}/parallel/${i}/0`) + )} + + `; + } + + private render_stop_node(node: Action, path: string, graphStart = false) { + const trace = this.trace.trace[path] as StopActionTraceStep[] | undefined; + return html` + + `; + } + private render_other_node(node: Action, path: string, graphStart = false) { return html`