mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Improve error display in automation/script traces (#19920)
This commit is contained in:
parent
2af3400464
commit
4f01348ffb
@ -163,21 +163,22 @@ export class HaTracePathDetails extends LitElement {
|
|||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
<br />
|
<br />
|
||||||
|
${error
|
||||||
|
? html`<div class="error">
|
||||||
|
${this.hass!.localize(
|
||||||
|
"ui.panel.config.automation.trace.path.error",
|
||||||
|
{
|
||||||
|
error: error,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</div>`
|
||||||
|
: nothing}
|
||||||
${result
|
${result
|
||||||
? html`${this.hass!.localize(
|
? html`${this.hass!.localize(
|
||||||
"ui.panel.config.automation.trace.path.result"
|
"ui.panel.config.automation.trace.path.result"
|
||||||
)}
|
)}
|
||||||
<pre>${dump(result)}</pre>`
|
<pre>${dump(result)}</pre>`
|
||||||
: error
|
: nothing}
|
||||||
? html`<div class="error">
|
|
||||||
${this.hass!.localize(
|
|
||||||
"ui.panel.config.automation.trace.path.error",
|
|
||||||
{
|
|
||||||
error: error,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
</div>`
|
|
||||||
: nothing}
|
|
||||||
${Object.keys(rest).length === 0
|
${Object.keys(rest).length === 0
|
||||||
? nothing
|
? nothing
|
||||||
: html`<pre>${dump(rest)}</pre>`}
|
: html`<pre>${dump(rest)}</pre>`}
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
|
import { mdiExclamationThick } from "@mdi/js";
|
||||||
import {
|
import {
|
||||||
css,
|
|
||||||
LitElement,
|
LitElement,
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
html,
|
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
svg,
|
css,
|
||||||
|
html,
|
||||||
nothing,
|
nothing,
|
||||||
|
svg,
|
||||||
} 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 { isSafari } from "../../util/is_safari";
|
import { isSafari } from "../../util/is_safari";
|
||||||
|
import { NODE_SIZE, SPACING } from "./hat-graph-const";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @attribute active
|
* @attribute active
|
||||||
@ -21,6 +22,8 @@ export class HatGraphNode extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean, reflect: true }) public disabled = false;
|
@property({ type: Boolean, reflect: true }) public disabled = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public error = false;
|
||||||
|
|
||||||
@property({ reflect: true, type: Boolean }) notEnabled = false;
|
@property({ reflect: true, type: Boolean }) notEnabled = false;
|
||||||
|
|
||||||
@property({ reflect: true, type: Boolean }) graphStart = false;
|
@property({ reflect: true, type: Boolean }) graphStart = false;
|
||||||
@ -65,16 +68,28 @@ 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.error
|
||||||
|
? svg`
|
||||||
|
<g class="error">
|
||||||
|
<circle
|
||||||
|
cx="-12"
|
||||||
|
cy=${-NODE_SIZE / 2}
|
||||||
|
r="8"
|
||||||
|
></circle>
|
||||||
|
<path transform="translate(-18 -21) scale(.5)" class="exclamation" d=${mdiExclamationThick}/>
|
||||||
|
</g>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
${this.badge
|
${this.badge
|
||||||
? svg`
|
? svg`
|
||||||
<g class="number">
|
<g class="number">
|
||||||
<circle
|
<circle
|
||||||
cx="8"
|
cx="12"
|
||||||
cy=${-NODE_SIZE / 2}
|
cy=${-NODE_SIZE / 2}
|
||||||
r="8"
|
r="8"
|
||||||
></circle>
|
></circle>
|
||||||
<text
|
<text
|
||||||
x="8"
|
x="12"
|
||||||
y=${-NODE_SIZE / 2}
|
y=${-NODE_SIZE / 2}
|
||||||
text-anchor="middle"
|
text-anchor="middle"
|
||||||
alignment-baseline="middle"
|
alignment-baseline="middle"
|
||||||
@ -82,7 +97,7 @@ export class HatGraphNode extends LitElement {
|
|||||||
</g>
|
</g>
|
||||||
`
|
`
|
||||||
: nothing}
|
: nothing}
|
||||||
<g style="pointer-events: none" transform="translate(${-12} ${-12})">
|
<g style="pointer-events: none" transform="translate(-12 -12)">
|
||||||
${this.iconPath
|
${this.iconPath
|
||||||
? svg`<path class="icon" d=${this.iconPath}/>`
|
? svg`<path class="icon" d=${this.iconPath}/>`
|
||||||
: svg`<foreignObject><span class="icon"><slot name="icon"></slot></span></foreignObject>`}
|
: svg`<foreignObject><span class="icon"><slot name="icon"></slot></span></foreignObject>`}
|
||||||
@ -143,13 +158,22 @@ export class HatGraphNode extends LitElement {
|
|||||||
fill: var(--background-clr);
|
fill: var(--background-clr);
|
||||||
stroke: var(--circle-clr, var(--stroke-clr));
|
stroke: var(--circle-clr, var(--stroke-clr));
|
||||||
}
|
}
|
||||||
|
.error circle {
|
||||||
|
fill: var(--error-color);
|
||||||
|
stroke: none;
|
||||||
|
stroke-width: 0;
|
||||||
|
}
|
||||||
|
.error .exclamation {
|
||||||
|
fill: var(--text-primary-color);
|
||||||
|
}
|
||||||
.number circle {
|
.number circle {
|
||||||
fill: var(--track-clr);
|
fill: var(--track-clr);
|
||||||
stroke: none;
|
stroke: none;
|
||||||
stroke-width: 0;
|
stroke-width: 0;
|
||||||
}
|
}
|
||||||
.number text {
|
.number text {
|
||||||
font-size: smaller;
|
font-size: 10px;
|
||||||
|
fill: var(--text-primary-color);
|
||||||
}
|
}
|
||||||
path.icon {
|
path.icon {
|
||||||
fill: var(--icon-clr);
|
fill: var(--icon-clr);
|
||||||
|
@ -93,6 +93,7 @@ export class HatScriptGraph extends LitElement {
|
|||||||
?active=${this.selected === path}
|
?active=${this.selected === path}
|
||||||
.iconPath=${mdiAsterisk}
|
.iconPath=${mdiAsterisk}
|
||||||
.notEnabled=${config.enabled === false}
|
.notEnabled=${config.enabled === false}
|
||||||
|
.error=${this.trace.trace[path]?.some((tr) => tr.error)}
|
||||||
tabindex=${track ? "0" : "-1"}
|
tabindex=${track ? "0" : "-1"}
|
||||||
></hat-graph-node>
|
></hat-graph-node>
|
||||||
`;
|
`;
|
||||||
@ -171,6 +172,7 @@ export class HatScriptGraph extends LitElement {
|
|||||||
?track=${trace !== undefined}
|
?track=${trace !== undefined}
|
||||||
?active=${this.selected === path}
|
?active=${this.selected === path}
|
||||||
.notEnabled=${disabled || config.enabled === false}
|
.notEnabled=${disabled || config.enabled === false}
|
||||||
|
.error=${this.trace.trace[path]?.some((tr) => tr.error)}
|
||||||
slot="head"
|
slot="head"
|
||||||
nofocus
|
nofocus
|
||||||
></hat-graph-node>
|
></hat-graph-node>
|
||||||
@ -424,6 +426,7 @@ export class HatScriptGraph extends LitElement {
|
|||||||
?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}
|
||||||
|
.error=${this.trace.trace[path]?.some((tr) => tr.error)}
|
||||||
tabindex=${this.trace && path in this.trace.trace ? "0" : "-1"}
|
tabindex=${this.trace && path in this.trace.trace ? "0" : "-1"}
|
||||||
>
|
>
|
||||||
${node.service
|
${node.service
|
||||||
@ -451,6 +454,7 @@ export class HatScriptGraph extends LitElement {
|
|||||||
?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}
|
||||||
|
.error=${this.trace.trace[path]?.some((tr) => tr.error)}
|
||||||
tabindex=${this.trace && path in this.trace.trace ? "0" : "-1"}
|
tabindex=${this.trace && path in this.trace.trace ? "0" : "-1"}
|
||||||
></hat-graph-node>
|
></hat-graph-node>
|
||||||
`;
|
`;
|
||||||
@ -517,6 +521,7 @@ export class HatScriptGraph extends LitElement {
|
|||||||
@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}
|
||||||
|
.error=${this.trace.trace[path]?.some((tr) => tr.error)}
|
||||||
.notEnabled=${disabled || node.enabled === false}
|
.notEnabled=${disabled || node.enabled === false}
|
||||||
></hat-graph-node>
|
></hat-graph-node>
|
||||||
`;
|
`;
|
||||||
|
@ -93,7 +93,7 @@ export class HaAutomationTrace extends LitElement {
|
|||||||
|
|
||||||
let devButtons: TemplateResult | string = "";
|
let devButtons: TemplateResult | string = "";
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
devButtons = html`<div style="position: absolute; right: 0;">
|
devButtons = html`<div style="position: absolute; right: 0; z-index: 1;">
|
||||||
<button @click=${this._importTrace}>Import trace</button>
|
<button @click=${this._importTrace}>Import trace</button>
|
||||||
<button @click=${this._loadLocalStorageTrace}>Load stored trace</button>
|
<button @click=${this._loadLocalStorageTrace}>Load stored trace</button>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user