mirror of
				https://github.com/home-assistant/frontend.git
				synced 2025-11-04 00:19:47 +00:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			20251001.4
			...
			data_disk_
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					d1605ba196 | 
@@ -1,5 +1,4 @@
 | 
			
		||||
import "@material/mwc-button";
 | 
			
		||||
import { ActionDetail } from "@material/mwc-list/mwc-list-foundation";
 | 
			
		||||
import "@material/mwc-list/mwc-list-item";
 | 
			
		||||
import { mdiDotsVertical } from "@mdi/js";
 | 
			
		||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
 | 
			
		||||
@@ -19,6 +18,7 @@ import { fetchHassioHardwareInfo } from "../../../src/data/hassio/hardware";
 | 
			
		||||
import {
 | 
			
		||||
  changeHostOptions,
 | 
			
		||||
  configSyncOS,
 | 
			
		||||
  dataDiskMove,
 | 
			
		||||
  rebootHost,
 | 
			
		||||
  shutdownHost,
 | 
			
		||||
  updateOS,
 | 
			
		||||
@@ -180,21 +180,27 @@ class HassioHostInfo extends LitElement {
 | 
			
		||||
              `
 | 
			
		||||
            : ""}
 | 
			
		||||
 | 
			
		||||
          <ha-button-menu
 | 
			
		||||
            corner="BOTTOM_START"
 | 
			
		||||
            @action=${this._handleMenuAction}
 | 
			
		||||
          >
 | 
			
		||||
          <ha-button-menu corner="BOTTOM_START">
 | 
			
		||||
            <mwc-icon-button slot="trigger">
 | 
			
		||||
              <ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
 | 
			
		||||
            </mwc-icon-button>
 | 
			
		||||
            <mwc-list-item>
 | 
			
		||||
            <mwc-list-item @click=${() => this._handleMenuAction("hardware")}>
 | 
			
		||||
              ${this.supervisor.localize("system.host.hardware")}
 | 
			
		||||
            </mwc-list-item>
 | 
			
		||||
            ${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")}
 | 
			
		||||
                </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>
 | 
			
		||||
        </div>
 | 
			
		||||
      </ha-card>
 | 
			
		||||
@@ -216,14 +222,17 @@ class HassioHostInfo extends LitElement {
 | 
			
		||||
    return network_info.interfaces.find((a) => a.primary)?.ipv4?.address![0];
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  private async _handleMenuAction(ev: CustomEvent<ActionDetail>) {
 | 
			
		||||
    switch (ev.detail.index) {
 | 
			
		||||
      case 0:
 | 
			
		||||
  private async _handleMenuAction(action: string) {
 | 
			
		||||
    switch (action) {
 | 
			
		||||
      case "hardware":
 | 
			
		||||
        await this._showHardware();
 | 
			
		||||
        break;
 | 
			
		||||
      case 1:
 | 
			
		||||
      case "import_from_usb":
 | 
			
		||||
        await this._importFromUSB();
 | 
			
		||||
        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> {
 | 
			
		||||
    if (atLeastVersion(this.hass.config.version, 2021, 2, 4)) {
 | 
			
		||||
      fireEvent(this, "supervisor-collection-refresh", {
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,7 @@ export interface HassioHassOSInfo {
 | 
			
		||||
  update_available: boolean;
 | 
			
		||||
  version_latest: string | null;
 | 
			
		||||
  version: string | null;
 | 
			
		||||
  data_disk: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const fetchHassioHostInfo = async (
 | 
			
		||||
@@ -113,6 +114,19 @@ export const configSyncOS = async (hass: HomeAssistant) => {
 | 
			
		||||
  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) => {
 | 
			
		||||
  if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
 | 
			
		||||
    return hass.callWS({
 | 
			
		||||
 
 | 
			
		||||
@@ -4099,6 +4099,7 @@
 | 
			
		||||
        "failed_to_shutdown": "Failed to shutdown the host",
 | 
			
		||||
        "failed_to_set_hostname": "Setting hostname failed",
 | 
			
		||||
        "failed_to_import_from_usb": "Failed to import from USB",
 | 
			
		||||
        "failed_to_move": "Failed to move data disk",
 | 
			
		||||
        "used_space": "Used space",
 | 
			
		||||
        "hostname": "Hostname",
 | 
			
		||||
        "change_hostname": "Change Hostname",
 | 
			
		||||
@@ -4114,7 +4115,8 @@
 | 
			
		||||
        "confirm_shutdown": "Are you sure you want to shutdown the host?",
 | 
			
		||||
        "shutdown_host": "Shutdown host",
 | 
			
		||||
        "hardware": "Hardware",
 | 
			
		||||
        "import_from_usb": "Import from USB"
 | 
			
		||||
        "import_from_usb": "Import from USB",
 | 
			
		||||
        "data_disk_move": "Move to data disk"
 | 
			
		||||
      },
 | 
			
		||||
      "core": {
 | 
			
		||||
        "cpu_usage": "Core CPU Usage",
 | 
			
		||||
@@ -4201,6 +4203,12 @@
 | 
			
		||||
        "id": "ID",
 | 
			
		||||
        "attributes": "Attributes",
 | 
			
		||||
        "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"
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user