mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Allow to copy IP address of Matter devices to clipboard (#24983)
Often when debugging it is actually helpful to copy the IP address for further investigation. This PR changes the list to allow interaction and copies the IP address when clicked on a list item.
This commit is contained in:
parent
228acf1fae
commit
ddc04dd48a
@ -5,6 +5,7 @@ import type { CSSResultGroup } from "lit";
|
|||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||||
|
import { copyToClipboard } from "../../../../../common/util/copy-clipboard";
|
||||||
import "../../../../../components/ha-spinner";
|
import "../../../../../components/ha-spinner";
|
||||||
import "../../../../../components/ha-list-item";
|
import "../../../../../components/ha-list-item";
|
||||||
import { createCloseHeading } from "../../../../../components/ha-dialog";
|
import { createCloseHeading } from "../../../../../components/ha-dialog";
|
||||||
@ -12,6 +13,7 @@ import { pingMatterNode } from "../../../../../data/matter";
|
|||||||
import { haStyle, haStyleDialog } from "../../../../../resources/styles";
|
import { haStyle, haStyleDialog } from "../../../../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../../../../types";
|
import type { HomeAssistant } from "../../../../../types";
|
||||||
import type { MatterPingNodeDialogParams } from "./show-dialog-matter-ping-node";
|
import type { MatterPingNodeDialogParams } from "./show-dialog-matter-ping-node";
|
||||||
|
import { showToast } from "../../../../../util/toast";
|
||||||
|
|
||||||
@customElement("dialog-matter-ping-node")
|
@customElement("dialog-matter-ping-node")
|
||||||
class DialogMatterPingNode extends LitElement {
|
class DialogMatterPingNode extends LitElement {
|
||||||
@ -30,6 +32,14 @@ class DialogMatterPingNode extends LitElement {
|
|||||||
this.device_id = params.device_id;
|
this.device_id = params.device_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _copyIpToClipboard(ev) {
|
||||||
|
const ip = ev.currentTarget.ip;
|
||||||
|
await copyToClipboard(ip);
|
||||||
|
showToast(this, {
|
||||||
|
message: this.hass.localize("ui.common.copied_clipboard"),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (!this.device_id) {
|
if (!this.device_id) {
|
||||||
return nothing;
|
return nothing;
|
||||||
@ -75,7 +85,10 @@ class DialogMatterPingNode extends LitElement {
|
|||||||
<mwc-list>
|
<mwc-list>
|
||||||
${this._pingResultEntries.map(
|
${this._pingResultEntries.map(
|
||||||
([ip, success]) =>
|
([ip, success]) =>
|
||||||
html`<ha-list-item hasMeta noninteractive
|
html`<ha-list-item
|
||||||
|
hasMeta
|
||||||
|
.ip=${ip}
|
||||||
|
@click=${this._copyIpToClipboard}
|
||||||
>${ip}
|
>${ip}
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="meta"
|
slot="meta"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user