Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/components/trace/hat-logbook-note.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { LitElement, css, html, customElement } from "lit-element";

@customElement("hat-logbook-note")
class HatLogbookNote extends LitElement {
render() {
return html`
Not all shown logbook entries might be related to this automation.
`;
}

static styles = css`
:host {
display: block;
text-align: center;
font-style: italic;
padding: 16px;
margin-top: 8px;
}
`;
}

declare global {
interface HTMLElementTagNameMap {
"hat-logbook-note": HatLogbookNote;
}
}
54 changes: 54 additions & 0 deletions src/panels/config/automation/trace/ha-automation-trace-logbook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {
css,
CSSResult,
customElement,
html,
LitElement,
property,
TemplateResult,
} from "lit-element";
import type { HomeAssistant } from "../../../../types";
import type { LogbookEntry } from "../../../../data/logbook";
import "../../../../components/trace/hat-logbook-note";
import "../../../logbook/ha-logbook";

@customElement("ha-automation-trace-logbook")
export class HaAutomationTraceLogbook extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;

@property({ type: Boolean, reflect: true }) public narrow!: boolean;

@property({ attribute: false }) public logbookEntries!: LogbookEntry[];

protected render(): TemplateResult {
return this.logbookEntries.length
? html`
<ha-logbook
relative-time
.hass=${this.hass}
.entries=${this.logbookEntries}
.narrow=${this.narrow}
></ha-logbook>
<hat-logbook-note></hat-logbook-note>
`
: html`<div class="padded-box">
No Logbook entries found for this step.
</div>`;
}

static get styles(): CSSResult[] {
return [
css`
.padded-box {
padding: 16px;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means we now have extra padding on the logbook entries that already have padding?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh this should have been on the note. oops.

}
`,
];
}
}

declare global {
interface HTMLElementTagNameMap {
"ha-automation-trace-logbook": HaAutomationTraceLogbook;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
property,
TemplateResult,
} from "lit-element";
import { classMap } from "lit-html/directives/class-map";
import {
ActionTraceStep,
AutomationTraceExtended,
Expand All @@ -18,11 +19,11 @@ import {
import "../../../../components/ha-icon-button";
import "../../../../components/ha-code-editor";
import type { NodeInfo } from "../../../../components/trace/hat-graph";
import "../../../../components/trace/hat-logbook-note";
import { HomeAssistant } from "../../../../types";
import { formatDateTimeWithSeconds } from "../../../../common/datetime/format_date_time";
import { LogbookEntry } from "../../../../data/logbook";
import { traceTabStyles } from "./styles";
import { classMap } from "lit-html/directives/class-map";
import "../../../logbook/ha-logbook";

@customElement("ha-automation-trace-path-details")
Expand Down Expand Up @@ -205,12 +206,15 @@ ${safeDump(trace.changed_variables).trimRight()}</pre
}

return entries.length
? html`<ha-logbook
relative-time
.hass=${this.hass}
.entries=${entries}
.narrow=${this.narrow}
></ha-logbook>`
? html`
<ha-logbook
relative-time
.hass=${this.hass}
.entries=${entries}
.narrow=${this.narrow}
></ha-logbook>
<hat-logbook-note></hat-logbook-note>
`
: html`<div class="padded-box">
No Logbook entries found for this step.
</div>`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@ import {
property,
TemplateResult,
} from "lit-element";
import { AutomationTraceExtended } from "../../../../data/trace";
import { HomeAssistant } from "../../../../types";
import { LogbookEntry } from "../../../../data/logbook";
import type { AutomationTraceExtended } from "../../../../data/trace";
import type { HomeAssistant } from "../../../../types";
import type { LogbookEntry } from "../../../../data/logbook";
import "../../../../components/trace/hat-trace-timeline";
import { NodeInfo } from "../../../../components/trace/hat-graph";
import type { NodeInfo } from "../../../../components/trace/hat-graph";
import "../../../../components/trace/hat-logbook-note";

@customElement("ha-automation-trace-timeline")
export class HaAutomationTraceTimeline extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;

@property() public trace!: AutomationTraceExtended;
@property({ attribute: false }) public trace!: AutomationTraceExtended;

@property() public logbookEntries!: LogbookEntry[];
@property({ attribute: false }) public logbookEntries!: LogbookEntry[];

@property() public selected!: NodeInfo;

Expand All @@ -33,6 +34,7 @@ export class HaAutomationTraceTimeline extends LitElement {
allowPick
>
</hat-trace-timeline>
<hat-logbook-note></hat-logbook-note>
`;
}

Expand Down
7 changes: 4 additions & 3 deletions src/panels/config/automation/trace/ha-automation-trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { showAlertDialog } from "../../../../dialogs/generic/show-dialog-box";
import "./ha-automation-trace-path-details";
import "./ha-automation-trace-timeline";
import "./ha-automation-trace-config";
import "./ha-automation-trace-logbook";
import { classMap } from "lit-html/directives/class-map";
import { traceTabStyles } from "./styles";
import {
Expand Down Expand Up @@ -238,10 +239,10 @@ export class HaAutomationTrace extends LitElement {
`
: this._view === "logbook"
? html`
<ha-logbook
<ha-automation-trace-logbook
.hass=${this.hass}
.entries=${this._logbookEntries}
></ha-logbook>
.logbookEntries=${this._logbookEntries}
></ha-automation-trace-logbook>
`
: this._view === "blueprint"
? html`
Expand Down