mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-31 21:17:47 +00:00
Add move data disk
This commit is contained in:
parent
2240d019f5
commit
d1605ba196
@ -1,5 +1,4 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import { ActionDetail } from "@material/mwc-list/mwc-list-foundation";
|
|
||||||
import "@material/mwc-list/mwc-list-item";
|
import "@material/mwc-list/mwc-list-item";
|
||||||
import { mdiDotsVertical } from "@mdi/js";
|
import { mdiDotsVertical } from "@mdi/js";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
@ -19,6 +18,7 @@ import { fetchHassioHardwareInfo } from "../../../src/data/hassio/hardware";
|
|||||||
import {
|
import {
|
||||||
changeHostOptions,
|
changeHostOptions,
|
||||||
configSyncOS,
|
configSyncOS,
|
||||||
|
dataDiskMove,
|
||||||
rebootHost,
|
rebootHost,
|
||||||
shutdownHost,
|
shutdownHost,
|
||||||
updateOS,
|
updateOS,
|
||||||
@ -180,21 +180,27 @@ class HassioHostInfo extends LitElement {
|
|||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
|
|
||||||
<ha-button-menu
|
<ha-button-menu corner="BOTTOM_START">
|
||||||
corner="BOTTOM_START"
|
|
||||||
@action=${this._handleMenuAction}
|
|
||||||
>
|
|
||||||
<mwc-icon-button slot="trigger">
|
<mwc-icon-button slot="trigger">
|
||||||
<ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
|
<ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
|
||||||
</mwc-icon-button>
|
</mwc-icon-button>
|
||||||
<mwc-list-item>
|
<mwc-list-item @click=${() => this._handleMenuAction("hardware")}>
|
||||||
${this.supervisor.localize("system.host.hardware")}
|
${this.supervisor.localize("system.host.hardware")}
|
||||||
</mwc-list-item>
|
</mwc-list-item>
|
||||||
${this.supervisor.host.features.includes("haos")
|
${this.supervisor.host.features.includes("haos")
|
||||||
? html`<mwc-list-item>
|
? html`<mwc-list-item
|
||||||
|
@click=${() => this._handleMenuAction("import_from_usb")}
|
||||||
|
>
|
||||||
${this.supervisor.localize("system.host.import_from_usb")}
|
${this.supervisor.localize("system.host.import_from_usb")}
|
||||||
</mwc-list-item>`
|
</mwc-list-item>`
|
||||||
: ""}
|
: ""}
|
||||||
|
${this.supervisor.host.features.includes("agent")
|
||||||
|
? html`<mwc-list-item
|
||||||
|
@click=${() => this._handleMenuAction("data_disk_move")}
|
||||||
|
>
|
||||||
|
${this.supervisor.localize("system.host.data_disk_move")}
|
||||||
|
</mwc-list-item>`
|
||||||
|
: ""}
|
||||||
</ha-button-menu>
|
</ha-button-menu>
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
@ -216,14 +222,17 @@ class HassioHostInfo extends LitElement {
|
|||||||
return network_info.interfaces.find((a) => a.primary)?.ipv4?.address![0];
|
return network_info.interfaces.find((a) => a.primary)?.ipv4?.address![0];
|
||||||
});
|
});
|
||||||
|
|
||||||
private async _handleMenuAction(ev: CustomEvent<ActionDetail>) {
|
private async _handleMenuAction(action: string) {
|
||||||
switch (ev.detail.index) {
|
switch (action) {
|
||||||
case 0:
|
case "hardware":
|
||||||
await this._showHardware();
|
await this._showHardware();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case "import_from_usb":
|
||||||
await this._importFromUSB();
|
await this._importFromUSB();
|
||||||
break;
|
break;
|
||||||
|
case "data_disk_move":
|
||||||
|
await this._dataDiskMove();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,6 +404,34 @@ class HassioHostInfo extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _dataDiskMove(): Promise<void> {
|
||||||
|
const confirmed = await showConfirmationDialog(this, {
|
||||||
|
title: this.supervisor.localize("system.host.data_disk_move"),
|
||||||
|
text: html`${this.supervisor.localize(
|
||||||
|
"dialog.data_disk_move.description",
|
||||||
|
{ current_path: this.supervisor.os.data_disk }
|
||||||
|
)} <br /><br />${this.supervisor.localize(
|
||||||
|
"dialog.data_disk_move.confirm_text"
|
||||||
|
)}`,
|
||||||
|
confirmText: this.supervisor.localize("dialog.data_disk_move.move"),
|
||||||
|
dismissText: this.supervisor.localize("dialog.data_disk_move.cancel"),
|
||||||
|
});
|
||||||
|
if (!confirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await dataDiskMove(this.hass);
|
||||||
|
} catch (err) {
|
||||||
|
if (this.hass.connection.connected && !ignoreSupervisorError(err)) {
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: this.supervisor.localize("system.host.failed_to_move"),
|
||||||
|
text: extractApiErrorMessage(err),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async _loadData(): Promise<void> {
|
private async _loadData(): Promise<void> {
|
||||||
if (atLeastVersion(this.hass.config.version, 2021, 2, 4)) {
|
if (atLeastVersion(this.hass.config.version, 2021, 2, 4)) {
|
||||||
fireEvent(this, "supervisor-collection-refresh", {
|
fireEvent(this, "supervisor-collection-refresh", {
|
||||||
|
@ -22,6 +22,7 @@ export interface HassioHassOSInfo {
|
|||||||
update_available: boolean;
|
update_available: boolean;
|
||||||
version_latest: string | null;
|
version_latest: string | null;
|
||||||
version: string | null;
|
version: string | null;
|
||||||
|
data_disk: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetchHassioHostInfo = async (
|
export const fetchHassioHostInfo = async (
|
||||||
@ -113,6 +114,19 @@ export const configSyncOS = async (hass: HomeAssistant) => {
|
|||||||
return hass.callApi<HassioResponse<void>>("POST", "hassio/os/config/sync");
|
return hass.callApi<HassioResponse<void>>("POST", "hassio/os/config/sync");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const dataDiskMove = async (hass: HomeAssistant) => {
|
||||||
|
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
|
||||||
|
return hass.callWS({
|
||||||
|
type: "supervisor/api",
|
||||||
|
endpoint: "/os/datadisk/move",
|
||||||
|
method: "post",
|
||||||
|
timeout: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return hass.callApi<HassioResponse<void>>("POST", "hassio/os/datadisk/move");
|
||||||
|
};
|
||||||
|
|
||||||
export const changeHostOptions = async (hass: HomeAssistant, options: any) => {
|
export const changeHostOptions = async (hass: HomeAssistant, options: any) => {
|
||||||
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
|
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
|
||||||
return hass.callWS({
|
return hass.callWS({
|
||||||
|
@ -4099,6 +4099,7 @@
|
|||||||
"failed_to_shutdown": "Failed to shutdown the host",
|
"failed_to_shutdown": "Failed to shutdown the host",
|
||||||
"failed_to_set_hostname": "Setting hostname failed",
|
"failed_to_set_hostname": "Setting hostname failed",
|
||||||
"failed_to_import_from_usb": "Failed to import from USB",
|
"failed_to_import_from_usb": "Failed to import from USB",
|
||||||
|
"failed_to_move": "Failed to move data disk",
|
||||||
"used_space": "Used space",
|
"used_space": "Used space",
|
||||||
"hostname": "Hostname",
|
"hostname": "Hostname",
|
||||||
"change_hostname": "Change Hostname",
|
"change_hostname": "Change Hostname",
|
||||||
@ -4114,7 +4115,8 @@
|
|||||||
"confirm_shutdown": "Are you sure you want to shutdown the host?",
|
"confirm_shutdown": "Are you sure you want to shutdown the host?",
|
||||||
"shutdown_host": "Shutdown host",
|
"shutdown_host": "Shutdown host",
|
||||||
"hardware": "Hardware",
|
"hardware": "Hardware",
|
||||||
"import_from_usb": "Import from USB"
|
"import_from_usb": "Import from USB",
|
||||||
|
"data_disk_move": "Move to data disk"
|
||||||
},
|
},
|
||||||
"core": {
|
"core": {
|
||||||
"cpu_usage": "Core CPU Usage",
|
"cpu_usage": "Core CPU Usage",
|
||||||
@ -4201,6 +4203,12 @@
|
|||||||
"id": "ID",
|
"id": "ID",
|
||||||
"attributes": "Attributes",
|
"attributes": "Attributes",
|
||||||
"device_path": "Device path"
|
"device_path": "Device path"
|
||||||
|
},
|
||||||
|
"data_disk_move": {
|
||||||
|
"description": "The current path to the data disk is ''{current_path}'', moving the disk will require a reboot of the host which will be done automatically.",
|
||||||
|
"confirm_text": "Do you want to move now?",
|
||||||
|
"cancel": "[%key:ui::common::cancel%]",
|
||||||
|
"move": "Move"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user