diff --git a/src/panels/config/hardware/dialog-hardware-available.ts b/src/panels/config/hardware/dialog-hardware-available.ts index 15cec4b227..fe6eccbd92 100644 --- a/src/panels/config/hardware/dialog-hardware-available.ts +++ b/src/panels/config/hardware/dialog-hardware-available.ts @@ -1,4 +1,3 @@ -import { mdiClose } from "@mdi/js"; import { dump } from "js-yaml"; import type { CSSResultGroup } from "lit"; import { css, html, LitElement, nothing } from "lit"; @@ -6,16 +5,16 @@ import { customElement, property, state } from "lit/decorators"; import memoizeOne from "memoize-one"; import { fireEvent } from "../../../common/dom/fire_event"; import { stringCompare } from "../../../common/string/compare"; -import "../../../components/ha-dialog"; import "../../../components/ha-expansion-panel"; import "../../../components/ha-icon-next"; +import "../../../components/ha-wa-dialog"; import "../../../components/search-input"; import { extractApiErrorMessage } from "../../../data/hassio/common"; import type { HassioHardwareInfo } from "../../../data/hassio/hardware"; import { fetchHassioHardwareInfo } from "../../../data/hassio/hardware"; import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box"; import type { HassDialog } from "../../../dialogs/make-dialog-manager"; -import { haStyle, haStyleDialog } from "../../../resources/styles"; +import { haStyleScrollbar } from "../../../resources/styles"; import type { HomeAssistant } from "../../../types"; const _filterDevices = memoizeOne( @@ -48,9 +47,12 @@ class DialogHardwareAvailable extends LitElement implements HassDialog { @state() private _filter?: string; + @state() private _open = false; + public async showDialog(): Promise> { try { this._hardware = await fetchHassioHardwareInfo(this.hass); + this._open = true; } catch (err: any) { await showAlertDialog(this, { title: this.hass.localize( @@ -61,10 +63,15 @@ class DialogHardwareAvailable extends LitElement implements HassDialog { } } - public closeDialog() { + public closeDialog(): boolean { + this._open = false; + return true; + } + + private _dialogClosed() { + this._open = false; this._hardware = undefined; fireEvent(this, "dialog-closed", { dialog: this.localName }); - return true; } protected render() { @@ -80,26 +87,18 @@ class DialogHardwareAvailable extends LitElement implements HassDialog { ); return html` - -
-

- ${this.hass.localize( - "ui.panel.config.hardware.available_hardware.title" - )} -

- +
+
+ ${devices.map( + (device) => html` + +
+ + ${this.hass.localize( + "ui.panel.config.hardware.available_hardware.subsystem" + )}: + + ${device.subsystem} +
+
+ + ${this.hass.localize( + "ui.panel.config.hardware.available_hardware.device_path" + )}: + + ${device.dev_path} +
+ ${device.by_id + ? html` +
+ + ${this.hass.localize( + "ui.panel.config.hardware.available_hardware.id" + )}: + + ${device.by_id} +
+ ` + : nothing} +
+ + ${this.hass.localize( + "ui.panel.config.hardware.available_hardware.attributes" + )}: + +
${dump(device.attributes, { indent: 2 })}
+
+
+ ` + )} +
- ${devices.map( - (device) => html` - -
- - ${this.hass.localize( - "ui.panel.config.hardware.available_hardware.subsystem" - )}: - - ${device.subsystem} -
-
- - ${this.hass.localize( - "ui.panel.config.hardware.available_hardware.device_path" - )}: - - ${device.dev_path} -
- ${device.by_id - ? html` -
- - ${this.hass.localize( - "ui.panel.config.hardware.available_hardware.id" - )}: - - ${device.by_id} -
- ` - : ""} -
- - ${this.hass.localize( - "ui.panel.config.hardware.available_hardware.attributes" - )}: - -
${dump(device.attributes, { indent: 2 })}
-
-
- ` - )} - + `; } @@ -165,27 +166,26 @@ class DialogHardwareAvailable extends LitElement implements HassDialog { static get styles(): CSSResultGroup { return [ - haStyle, - haStyleDialog, + haStyleScrollbar, css` - ha-icon-button { - position: absolute; - right: 16px; - inset-inline-end: 16px; - inset-inline-start: initial; - top: 10px; - inset-inline-end: 16px; - inset-inline-start: initial; - text-decoration: none; - color: var(--primary-text-color); + ha-wa-dialog { + --dialog-content-padding: 0; } - h2 { - margin: 18px 42px 0 18px; - margin-inline-start: 18px; - margin-inline-end: 42px; - color: var(--primary-text-color); + .content-container { + display: flex; + flex-direction: column; + flex: 1; + min-height: 0; + overflow: hidden; + } + .devices-container { + padding: var(--ha-space-6); + overflow-y: auto; + flex: 1; + min-height: 0; } ha-expansion-panel { + flex: 1; margin: 4px 0; } pre,