Use the name and size from the new disks property (#15954)

* Use the name and size from the new disks property

* Move SN down to secondary
This commit is contained in:
Joakim Sørensen 2023-04-02 14:07:08 +02:00 committed by GitHub
parent ddfe02eb70
commit 6eb3fb1076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 9 deletions

View File

@ -28,8 +28,19 @@ export interface HassioHassOSInfo {
data_disk: string; data_disk: string;
} }
export interface Datadisk {
name: string;
vendor: string;
model: string;
serial: string;
size: number;
id: string;
dev_path: string;
}
export interface DatadiskList { export interface DatadiskList {
devices: string[]; devices: string[];
disks: Datadisk[];
} }
export const fetchHassioHostInfo = async ( export const fetchHassioHostInfo = async (

View File

@ -22,6 +22,7 @@ import {
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box"; import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
import { haStyle, haStyleDialog } from "../../../resources/styles"; import { haStyle, haStyleDialog } from "../../../resources/styles";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { bytesToString } from "../../../util/bytes-to-string";
import { MoveDatadiskDialogParams } from "./show-dialog-move-datadisk"; import { MoveDatadiskDialogParams } from "./show-dialog-move-datadisk";
const calculateMoveTime = memoizeOne((hostInfo: HassioHostInfo): number => { const calculateMoveTime = memoizeOne((hostInfo: HassioHostInfo): number => {
@ -39,7 +40,7 @@ class MoveDatadiskDialog extends LitElement {
@state() private _selectedDevice?: string; @state() private _selectedDevice?: string;
@state() private _devices?: DatadiskList["devices"]; @state() private _disks?: DatadiskList["disks"];
@state() private _osInfo?: HassioHassOSInfo; @state() private _osInfo?: HassioHassOSInfo;
@ -55,7 +56,7 @@ class MoveDatadiskDialog extends LitElement {
const data = await listDatadisks(this.hass); const data = await listDatadisks(this.hass);
if (data.devices.length > 0) { if (data.devices.length > 0) {
this._devices = data.devices; this._disks = data.disks;
} else { } else {
this.closeDialog(); this.closeDialog();
await showAlertDialog(this, { await showAlertDialog(this, {
@ -80,7 +81,7 @@ class MoveDatadiskDialog extends LitElement {
public closeDialog(): void { public closeDialog(): void {
this._selectedDevice = undefined; this._selectedDevice = undefined;
this._devices = undefined; this._disks = undefined;
this._moving = false; this._moving = false;
this._hostInfo = undefined; this._hostInfo = undefined;
this._osInfo = undefined; this._osInfo = undefined;
@ -88,7 +89,7 @@ class MoveDatadiskDialog extends LitElement {
} }
protected render() { protected render() {
if (!this._hostInfo || !this._osInfo || !this._devices) { if (!this._hostInfo || !this._osInfo || !this._disks) {
return nothing; return nothing;
} }
@ -132,10 +133,19 @@ class MoveDatadiskDialog extends LitElement {
dialogInitialFocus dialogInitialFocus
fixedMenuPosition fixedMenuPosition
> >
${this._devices.map( ${this._disks.map(
(device) => (disk) =>
html`<mwc-list-item .value=${device}> html`<mwc-list-item twoline .value=${disk.id}>
${device} <span>${disk.vendor} ${disk.model}</span>
<span slot="secondary">
${this.hass.localize(
"ui.panel.config.storage.datadisk.extra_information",
{
size: bytesToString(disk.size),
serial: disk.serial,
}
)}
</span>
</mwc-list-item>` </mwc-list-item>`
)} )}
</ha-select> </ha-select>

View File

@ -3861,6 +3861,7 @@
"datadisk": { "datadisk": {
"title": "Move datadisk", "title": "Move datadisk",
"description": "You are currently using ''{current_path}'' as datadisk. Moving data disks will reboot your device and it's estimated to take {time} minutes. Your Home Assistant installation will not be accessible during this period. Do not disconnect the power during the move!", "description": "You are currently using ''{current_path}'' as datadisk. Moving data disks will reboot your device and it's estimated to take {time} minutes. Your Home Assistant installation will not be accessible during this period. Do not disconnect the power during the move!",
"extra_information": "Size: {size}, S/N: {serial}",
"select_device": "Select new datadisk", "select_device": "Select new datadisk",
"no_devices_title": "No suitable storage found", "no_devices_title": "No suitable storage found",
"no_devices_text": "There is no suitable external device found. The storage capacity of the external data disk must be larger than the storage capacity of the existing disk", "no_devices_text": "There is no suitable external device found. The storage capacity of the external data disk must be larger than the storage capacity of the existing disk",
@ -4541,7 +4542,6 @@
"white": "White" "white": "White"
} }
}, },
"cardpicker": { "cardpicker": {
"no_description": "No description available.", "no_description": "No description available.",
"custom_card": "Custom", "custom_card": "Custom",