mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-08 09:56:36 +00:00
Add download button
This commit is contained in:
parent
7bd4eeb0df
commit
2cf63cda08
@ -62,9 +62,14 @@ export class HaAutomationTrace extends LitElement {
|
|||||||
stateObj?.attributes.friendly_name || this._entityId
|
stateObj?.attributes.friendly_name || this._entityId
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<button class="load-last" @click=${this._loadTrace}>
|
<div class="actions">
|
||||||
|
<button @click=${this._loadTrace}>
|
||||||
Load last trace
|
Load last trace
|
||||||
</button>
|
</button>
|
||||||
|
<button @click=${this._downloadTrace}>
|
||||||
|
Download
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
${this._trace
|
${this._trace
|
||||||
? html`
|
? html`
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
@ -135,6 +140,22 @@ export class HaAutomationTrace extends LitElement {
|
|||||||
history.back();
|
history.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _downloadTrace() {
|
||||||
|
const aEl = document.createElement("a");
|
||||||
|
aEl.download = `trace-${this._entityId}.json`;
|
||||||
|
aEl.href = `data:application/json;charset=utf-8,${encodeURI(
|
||||||
|
JSON.stringify(
|
||||||
|
{
|
||||||
|
trace: this._trace,
|
||||||
|
logbookEntries: this._logbookEntries,
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
2
|
||||||
|
)
|
||||||
|
)}`;
|
||||||
|
aEl.click();
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResult[] {
|
static get styles(): CSSResult[] {
|
||||||
return [
|
return [
|
||||||
haStyle,
|
haStyle,
|
||||||
@ -144,7 +165,7 @@ export class HaAutomationTrace extends LitElement {
|
|||||||
margin: 24px auto;
|
margin: 24px auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.load-last {
|
.actions {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 8px;
|
top: 8px;
|
||||||
right: 8px;
|
right: 8px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user