mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 16:26:43 +00:00
Link the device info BLE address to the Advertisement Monitor (#25044)
* Link the device info BLE address to the Advertisement Monitor * Link the device info BLE address to the Advertisement Monitor * preen
This commit is contained in:
parent
8fb7c1594a
commit
8ad4385d67
@ -7,6 +7,7 @@ import "../../../../components/ha-card";
|
|||||||
import type { DeviceRegistryEntry } from "../../../../data/device_registry";
|
import type { DeviceRegistryEntry } from "../../../../data/device_registry";
|
||||||
import { haStyle } from "../../../../resources/styles";
|
import { haStyle } from "../../../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
import { createSearchParam } from "../../../../common/url/search-params";
|
||||||
|
|
||||||
@customElement("ha-device-info-card")
|
@customElement("ha-device-info-card")
|
||||||
export class HaDeviceCard extends LitElement {
|
export class HaDeviceCard extends LitElement {
|
||||||
@ -102,8 +103,16 @@ export class HaDeviceCard extends LitElement {
|
|||||||
${this._getAddresses().map(
|
${this._getAddresses().map(
|
||||||
([type, value]) => html`
|
([type, value]) => html`
|
||||||
<div class="extra-info">
|
<div class="extra-info">
|
||||||
${type === "mac" ? "MAC" : titleCase(type)}:
|
${type === "bluetooth"
|
||||||
${value.toUpperCase()}
|
? html`${titleCase(type)}
|
||||||
|
<a
|
||||||
|
href="/config/bluetooth/advertisement-monitor?${createSearchParam(
|
||||||
|
{ address: value }
|
||||||
|
)}"
|
||||||
|
>${value.toUpperCase()}</a
|
||||||
|
>`
|
||||||
|
: html`${type === "mac" ? "MAC" : titleCase(type)}:
|
||||||
|
${value.toUpperCase()}`}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
import type { CSSResultGroup, TemplateResult } from "lit";
|
import type { CSSResultGroup, TemplateResult, PropertyValues } from "lit";
|
||||||
import { html, LitElement } from "lit";
|
import { html, LitElement } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
@ -10,6 +10,7 @@ import type {
|
|||||||
DataTableColumnContainer,
|
DataTableColumnContainer,
|
||||||
RowClickedEvent,
|
RowClickedEvent,
|
||||||
} from "../../../../../components/data-table/ha-data-table";
|
} from "../../../../../components/data-table/ha-data-table";
|
||||||
|
import { extractSearchParamsObject } from "../../../../../common/url/search-params";
|
||||||
import "../../../../../components/ha-fab";
|
import "../../../../../components/ha-fab";
|
||||||
import "../../../../../components/ha-icon-button";
|
import "../../../../../components/ha-icon-button";
|
||||||
import "../../../../../components/ha-relative-time";
|
import "../../../../../components/ha-relative-time";
|
||||||
@ -33,6 +34,8 @@ export class BluetoothAdvertisementMonitorPanel extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public route!: Route;
|
@property({ attribute: false }) public route!: Route;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public address?: string;
|
||||||
|
|
||||||
@property({ type: Boolean }) public narrow = false;
|
@property({ type: Boolean }) public narrow = false;
|
||||||
|
|
||||||
@property({ attribute: "is-wide", type: Boolean }) public isWide = false;
|
@property({ attribute: "is-wide", type: Boolean }) public isWide = false;
|
||||||
@ -104,6 +107,20 @@ export class BluetoothAdvertisementMonitorPanel extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected willUpdate(changedProps: PropertyValues) {
|
||||||
|
super.willUpdate(changedProps);
|
||||||
|
|
||||||
|
if (this.hasUpdated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchParams = extractSearchParamsObject();
|
||||||
|
const address = searchParams.address;
|
||||||
|
if (address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _columns = memoizeOne(
|
private _columns = memoizeOne(
|
||||||
(localize: LocalizeFunc): DataTableColumnContainer => {
|
(localize: LocalizeFunc): DataTableColumnContainer => {
|
||||||
const columns: DataTableColumnContainer<BluetoothDeviceData> = {
|
const columns: DataTableColumnContainer<BluetoothDeviceData> = {
|
||||||
@ -198,6 +215,7 @@ export class BluetoothAdvertisementMonitorPanel extends LitElement {
|
|||||||
.initialCollapsedGroups=${this._activeCollapsed}
|
.initialCollapsedGroups=${this._activeCollapsed}
|
||||||
@grouping-changed=${this._handleGroupingChanged}
|
@grouping-changed=${this._handleGroupingChanged}
|
||||||
@collapsed-changed=${this._handleCollapseChanged}
|
@collapsed-changed=${this._handleCollapseChanged}
|
||||||
|
filter=${this.address || ""}
|
||||||
clickable
|
clickable
|
||||||
></hass-tabs-subpage-data-table>
|
></hass-tabs-subpage-data-table>
|
||||||
`;
|
`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user