- ${this._traces && this._traces.length > 0
- ? html`
+
+
+ ${this._traces === undefined
+ ? "Loading…"
+ : this._traces.length === 0
+ ? "No traces found"
+ : this._trace === undefined
? ""
: html`
-
-
-
-${safeDump(getDataFromPath(this._trace.config, this._path))}
-
-
-
-${safeDump(
- (this._path.split("/")[0] === "condition"
- ? this._trace.condition_trace
- : this._trace.action_trace)[this._path]
- )}
-
+
+
+
+
+
+
+
+ ${[
+ ["details", "Step Details"],
+ ["timeline", "Trace Timeline"],
+ ["config", "Automation Config"],
+ ].map(
+ ([view, label]) => html`
+
+ ${label}
+
+ `
+ )}
+
+ ${this._selected === undefined ||
+ this._logbookEntries === undefined ||
+ trackedNodes === undefined
+ ? ""
+ : this._view === "details"
+ ? html`
+
+ `
+ : this._view === "config"
+ ? html`
+
+ `
+ : html`
+
+ `}
+
`}
@@ -185,13 +247,25 @@ ${safeDump(
}
}
- private _pickTrace(ev) {
- this._runId = ev.target.value;
- this._path = undefined;
+ private _pickOlderTrace() {
+ const curIndex = this._traces!.findIndex((tr) => tr.run_id === this._runId);
+ this._runId = this._traces![curIndex + 1].run_id;
+ this._selected = undefined;
}
- private _pickPath(ev) {
- this._path = ev.detail.value;
+ private _pickNewerTrace() {
+ const curIndex = this._traces!.findIndex((tr) => tr.run_id === this._runId);
+ this._runId = this._traces![curIndex - 1].run_id;
+ this._selected = undefined;
+ }
+
+ private _pickTrace(ev) {
+ this._runId = ev.target.value;
+ this._selected = undefined;
+ }
+
+ private _pickNode(ev) {
+ this._selected = ev.detail;
}
private async _loadTraces(runId?: string) {
@@ -209,7 +283,7 @@ ${safeDump(
!this._traces.some((trace) => trace.run_id === this._runId)
) {
this._runId = undefined;
- this._path = undefined;
+ this._selected = undefined;
// If we came here from a trace passed into the url, clear it.
if (runId) {
@@ -271,30 +345,55 @@ ${safeDump(
aEl.click();
}
+ private _showTab(ev) {
+ this._view = (ev.target as any).view;
+ }
+
+ private _timelinePathPicked(ev) {
+ const path = ev.detail.value;
+ const nodes = this.shadowRoot!.querySelector(
+ "hat-script-graph"
+ )!.getTrackedNodes();
+ this._selected = nodes[path].nodeInfo;
+ }
+
static get styles(): CSSResult[] {
return [
haStyle,
+ traceTabStyles,
css`
- ha-card {
- max-width: 800px;
- margin: 24px auto;
- }
-
- .actions {
- position: absolute;
- top: 8px;
- right: 8px;
- }
-
- .details {
+ .toolbar {
display: flex;
- margin: 0 16px;
+ align-items: center;
+ justify-content: space-between;
+ font-size: 20px;
+ height: var(--header-height);
+ padding: 0 16px;
+ background-color: var(--primary-background-color);
+ font-weight: 400;
+ color: var(--app-header-text-color, white);
+ border-bottom: var(--app-header-border-bottom, none);
+ box-sizing: border-box;
}
- .details > * {
- flex: 1 1 0px;
+
+ .toolbar > * {
+ display: flex;
+ align-items: center;
}
- .details > *:first-child {
- margin-right: 16px;
+
+ .main {
+ height: calc(100% - 56px);
+ display: flex;
+ background-color: var(--card-background-color);
+ }
+
+ .graph {
+ border-right: 1px solid var(--divider-color);
+ }
+
+ .info {
+ flex: 1;
+ background-color: var(--card-background-color);
}
`,
];
diff --git a/src/panels/config/automation/trace/styles.ts b/src/panels/config/automation/trace/styles.ts
new file mode 100644
index 0000000000..87d1375939
--- /dev/null
+++ b/src/panels/config/automation/trace/styles.ts
@@ -0,0 +1,28 @@
+import { css } from "lit-element";
+
+export const traceTabStyles = css`
+ .tabs {
+ background-color: var(--primary-background-color);
+ border-top: 1px solid var(--divider-color);
+ border-bottom: 1px solid var(--divider-color);
+ display: flex;
+ padding-left: 4px;
+ }
+
+ .tabs.top {
+ border-top: none;
+ }
+
+ .tabs > * {
+ padding: 2px 16px;
+ cursor: pointer;
+ position: relative;
+ bottom: -1px;
+ border-bottom: 2px solid transparent;
+ user-select: none;
+ }
+
+ .tabs > *.active {
+ border-bottom-color: var(--accent-color);
+ }
+`;
diff --git a/src/translations/en.json b/src/translations/en.json
index fd2fb79fba..d411fffc92 100755
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -1211,6 +1211,7 @@
},
"editor": {
"enable_disable": "Enable/Disable automation",
+ "show_trace": "Show trace",
"introduction": "Use automations to bring your home to life.",
"default_name": "New Automation",
"load_error_not_editable": "Only automations in automations.yaml are editable.",