mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Add download button to assist sentence parser dev tool (#17265)
* Add download button to assist sentence parser dev tool * Use outlined button * BLOCK
This commit is contained in:
parent
52d717a86b
commit
5ed348aa56
@ -12,6 +12,7 @@ export class HaButton extends Button {
|
|||||||
margin-inline-start: 0px;
|
margin-inline-start: 0px;
|
||||||
margin-inline-end: 8px;
|
margin-inline-end: 8px;
|
||||||
direction: var(--direction);
|
direction: var(--direction);
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
.mdc-button {
|
.mdc-button {
|
||||||
height: var(--button-height, 36px);
|
height: var(--button-height, 36px);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { mdiDownload } from "@mdi/js";
|
||||||
import { dump } from "js-yaml";
|
import { dump } from "js-yaml";
|
||||||
import { CSSResultGroup, LitElement, css, html, nothing } from "lit";
|
import { CSSResultGroup, LitElement, css, html, nothing } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
@ -16,6 +17,7 @@ import { haStyle } from "../../../resources/styles";
|
|||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { formatLanguageCode } from "../../../common/language/format_language";
|
import { formatLanguageCode } from "../../../common/language/format_language";
|
||||||
import { storage } from "../../../common/decorators/storage";
|
import { storage } from "../../../common/decorators/storage";
|
||||||
|
import { fileDownload } from "../../../util/file_download";
|
||||||
|
|
||||||
type SentenceParsingResult = {
|
type SentenceParsingResult = {
|
||||||
sentence: string;
|
sentence: string;
|
||||||
@ -146,6 +148,16 @@ class HaPanelDevAssist extends SubscribeMixin(LitElement) {
|
|||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
|
|
||||||
|
${this._results.length
|
||||||
|
? html`
|
||||||
|
<div class="result-toolbar">
|
||||||
|
<ha-button outlined @click=${this._download}>
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiDownload}></ha-svg-icon>
|
||||||
|
Download Results
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
: ""}
|
||||||
${this._results.map((r) => {
|
${this._results.map((r) => {
|
||||||
const { sentence, result, language } = r;
|
const { sentence, result, language } = r;
|
||||||
const matched = result != null;
|
const matched = result != null;
|
||||||
@ -182,6 +194,15 @@ class HaPanelDevAssist extends SubscribeMixin(LitElement) {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _download() {
|
||||||
|
fileDownload(
|
||||||
|
`data:text/plain;charset=utf-8,${encodeURIComponent(
|
||||||
|
JSON.stringify({ results: this._results }, null, 2)
|
||||||
|
)}`,
|
||||||
|
`intent_results.json`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
haStyle,
|
haStyle,
|
||||||
@ -208,6 +229,10 @@ class HaPanelDevAssist extends SubscribeMixin(LitElement) {
|
|||||||
.form {
|
.form {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
.result-toolbar {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
.result {
|
.result {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user