mirror of
https://github.com/home-assistant/frontend.git
synced 2026-02-14 23:18:21 +00:00
Migrate bluetooth device info dialog to wa (#29546)
Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com>
This commit is contained in:
@@ -4,28 +4,34 @@ import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||
import { copyToClipboard } from "../../../../../common/util/copy-clipboard";
|
||||
import "../../../../../components/ha-button";
|
||||
import { createCloseHeading } from "../../../../../components/ha-dialog";
|
||||
import type { HassDialog } from "../../../../../dialogs/make-dialog-manager";
|
||||
import "../../../../../components/ha-dialog-footer";
|
||||
import "../../../../../components/ha-wa-dialog";
|
||||
import type { HomeAssistant } from "../../../../../types";
|
||||
import { showToast } from "../../../../../util/toast";
|
||||
import type { BluetoothDeviceInfoDialogParams } from "./show-dialog-bluetooth-device-info";
|
||||
|
||||
@customElement("dialog-bluetooth-device-info")
|
||||
class DialogBluetoothDeviceInfo extends LitElement implements HassDialog {
|
||||
class DialogBluetoothDeviceInfo extends LitElement {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@state() private _params?: BluetoothDeviceInfoDialogParams;
|
||||
|
||||
@state() private _open = false;
|
||||
|
||||
public async showDialog(
|
||||
params: BluetoothDeviceInfoDialogParams
|
||||
): Promise<void> {
|
||||
this._params = params;
|
||||
this._open = true;
|
||||
}
|
||||
|
||||
public closeDialog(): boolean {
|
||||
public closeDialog(): void {
|
||||
this._open = false;
|
||||
}
|
||||
|
||||
private _dialogClosed(): void {
|
||||
this._params = undefined;
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
return true;
|
||||
}
|
||||
|
||||
public showDataAsHex(bytestring: string): string {
|
||||
@@ -50,13 +56,13 @@ class DialogBluetoothDeviceInfo extends LitElement implements HassDialog {
|
||||
}
|
||||
|
||||
return html`
|
||||
<ha-dialog
|
||||
open
|
||||
@closed=${this.closeDialog}
|
||||
.heading=${createCloseHeading(
|
||||
this.hass,
|
||||
this.hass.localize("ui.panel.config.bluetooth.device_information")
|
||||
<ha-wa-dialog
|
||||
.hass=${this.hass}
|
||||
.open=${this._open}
|
||||
header-title=${this.hass.localize(
|
||||
"ui.panel.config.bluetooth.device_information"
|
||||
)}
|
||||
@closed=${this._dialogClosed}
|
||||
>
|
||||
<p>
|
||||
<b>${this.hass.localize("ui.panel.config.bluetooth.address")}</b>:
|
||||
@@ -116,16 +122,16 @@ class DialogBluetoothDeviceInfo extends LitElement implements HassDialog {
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ha-button
|
||||
appearance="plain"
|
||||
slot="secondaryAction"
|
||||
@click=${this._copyToClipboard}
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.bluetooth.copy_to_clipboard"
|
||||
)}</ha-button
|
||||
>
|
||||
</ha-dialog>
|
||||
<ha-dialog-footer slot="footer">
|
||||
<ha-button
|
||||
slot="secondaryAction"
|
||||
appearance="plain"
|
||||
@click=${this._copyToClipboard}
|
||||
>
|
||||
${this.hass.localize("ui.panel.config.bluetooth.copy_to_clipboard")}
|
||||
</ha-button>
|
||||
</ha-dialog-footer>
|
||||
</ha-wa-dialog>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user