mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
Use download util for diagnostics (#11349)
This commit is contained in:
parent
2d651c2a66
commit
f3642a1677
@ -330,7 +330,6 @@ class HassioBackupDialog
|
||||
}
|
||||
|
||||
fileDownload(
|
||||
this,
|
||||
signedPath.path,
|
||||
`home_assistant_backup_${slugify(this._computeName)}.tar`
|
||||
);
|
||||
|
@ -45,6 +45,7 @@ import {
|
||||
} from "../../../dialogs/generic/show-dialog-box";
|
||||
import { haStyle, haStyleScrollbar } from "../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import { fileDownload } from "../../../util/file_download";
|
||||
import type { ConfigEntryExtended } from "./ha-config-integrations";
|
||||
import "./ha-integration-header";
|
||||
|
||||
@ -647,7 +648,7 @@ export class HaIntegrationCard extends LitElement {
|
||||
this.hass,
|
||||
anchor.getAttribute("href")
|
||||
);
|
||||
document.location.assign(signedUrl.path);
|
||||
fileDownload(signedUrl.path);
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
|
@ -131,7 +131,6 @@ class ZWaveJSLogs extends SubscribeMixin(LitElement) {
|
||||
|
||||
private _downloadLogs() {
|
||||
fileDownload(
|
||||
this,
|
||||
`data:text/plain;charset=utf-8,${encodeURIComponent(
|
||||
this._textarea!.value
|
||||
)}`,
|
||||
|
@ -1,14 +1,10 @@
|
||||
export const fileDownload = (
|
||||
element: HTMLElement,
|
||||
href: string,
|
||||
filename: string
|
||||
): void => {
|
||||
export const fileDownload = (href: string, filename = ""): void => {
|
||||
const a = document.createElement("a");
|
||||
a.target = "_blank";
|
||||
a.href = href;
|
||||
a.download = filename;
|
||||
|
||||
element.shadowRoot!.appendChild(a);
|
||||
document.body.appendChild(a);
|
||||
a.dispatchEvent(new MouseEvent("click"));
|
||||
element.shadowRoot!.removeChild(a);
|
||||
document.body.removeChild(a);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user