mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-02 05:57:54 +00:00
Keep snapshot download details untill dialog is closed
This commit is contained in:
parent
4773c39a57
commit
7ed4a9f693
@ -10,6 +10,7 @@ import {
|
|||||||
internalProperty,
|
internalProperty,
|
||||||
LitElement,
|
LitElement,
|
||||||
property,
|
property,
|
||||||
|
query,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||||
@ -90,6 +91,8 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
|
|
||||||
@internalProperty() private _restoreHass: boolean | null | undefined = true;
|
@internalProperty() private _restoreHass: boolean | null | undefined = true;
|
||||||
|
|
||||||
|
@query("#download", true) private _downloadBtn!: HTMLAnchorElement;
|
||||||
|
|
||||||
public async showDialog(params: HassioSnapshotDialogParams) {
|
public async showDialog(params: HassioSnapshotDialogParams) {
|
||||||
this._snapshot = await fetchHassioSnapshotInfo(this.hass, params.slug);
|
this._snapshot = await fetchHassioSnapshotInfo(this.hass, params.slug);
|
||||||
this._folders = _computeFolders(
|
this._folders = _computeFolders(
|
||||||
@ -231,6 +234,7 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
<span class="warning">Delete Snapshot</span>
|
<span class="warning">Delete Snapshot</span>
|
||||||
</mwc-button>`
|
</mwc-button>`
|
||||||
: ""}
|
: ""}
|
||||||
|
<a id="download"></a>
|
||||||
</ha-dialog>
|
</ha-dialog>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -269,6 +273,9 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
--mdc-theme-primary: var(--mdc-theme-surface);
|
--mdc-theme-primary: var(--mdc-theme-surface);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
#download {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
/* overrule the ha-style-dialog max-height on small screens */
|
/* overrule the ha-style-dialog max-height on small screens */
|
||||||
@media all and (max-width: 450px), all and (max-height: 500px) {
|
@media all and (max-width: 450px), all and (max-height: 500px) {
|
||||||
ha-header-bar {
|
ha-header-bar {
|
||||||
@ -457,12 +464,10 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const name = this._computeName.replace(/[^a-z0-9]+/gi, "_");
|
const name = this._computeName.replace(/[^a-z0-9]+/gi, "_");
|
||||||
const a = document.createElement("a");
|
|
||||||
a.href = signedPath.path;
|
this._downloadBtn.href = signedPath.path;
|
||||||
a.download = `Hass_io_${name}.tar`;
|
this._downloadBtn.download = `Snapshot_${name}.tar`;
|
||||||
this.shadowRoot!.appendChild(a);
|
this._downloadBtn.click();
|
||||||
a.click();
|
|
||||||
this.shadowRoot!.removeChild(a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private get _computeName() {
|
private get _computeName() {
|
||||||
@ -487,6 +492,8 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _closeDialog() {
|
private _closeDialog() {
|
||||||
|
this._downloadBtn.href = "";
|
||||||
|
this._downloadBtn.download = "";
|
||||||
this._dialogParams = undefined;
|
this._dialogParams = undefined;
|
||||||
this._snapshot = undefined;
|
this._snapshot = undefined;
|
||||||
this._snapshotPassword = "";
|
this._snapshotPassword = "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user