From b855176ff12587210c2f7f01a01549b4b750c99c Mon Sep 17 00:00:00 2001 From: Marte Tassyns Date: Sun, 1 Dec 2024 00:22:27 +0000 Subject: [PATCH 1/2] Refresh graph after topology scan and indicate in progress --- .../zha/zha-network-visualization-page.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/panels/config/integrations/integration-panels/zha/zha-network-visualization-page.ts b/src/panels/config/integrations/integration-panels/zha/zha-network-visualization-page.ts index 5283ae348fbe..5212103a6721 100644 --- a/src/panels/config/integrations/integration-panels/zha/zha-network-visualization-page.ts +++ b/src/panels/config/integrations/integration-panels/zha/zha-network-visualization-page.ts @@ -9,6 +9,7 @@ import "../../../../../components/search-input"; import "../../../../../components/device/ha-device-picker"; import "../../../../../components/ha-button-menu"; import "../../../../../components/ha-checkbox"; +import "../../../../../components/ha-svg-icon"; import type { HaCheckbox } from "../../../../../components/ha-checkbox"; import "../../../../../components/ha-formfield"; import type { DeviceRegistryEntry } from "../../../../../data/device_registry"; @@ -22,6 +23,7 @@ import type { } from "../../../../../types"; import { formatAsPaddedHex } from "./functions"; import { zhaTabs } from "./zha-config-dashboard"; +import { mdiTimerSand } from "@mdi/js"; @customElement("zha-network-visualization-page") export class ZHANetworkVisualizationPage extends LitElement { @@ -61,6 +63,9 @@ export class ZHANetworkVisualizationPage extends LitElement { private _enablePhysics = true; + @state() + private _refreshingTopology = false; + protected firstUpdated(changedProperties: PropertyValues): void { super.firstUpdated(changedProperties); @@ -202,7 +207,13 @@ export class ZHANetworkVisualizationPage extends LitElement { > - + + ${this._refreshingTopology + ? html`` + : ""} ${this.hass!.localize( "ui.panel.config.zha.visualization.refresh_topology" )} @@ -392,7 +403,13 @@ export class ZHANetworkVisualizationPage extends LitElement { } private async _refreshTopology(): Promise { - await refreshTopology(this.hass); + this._refreshingTopology = true; + try { + await refreshTopology(this.hass); + await this._fetchData(); + } finally { + this._refreshingTopology = false; + } } private _filterDevices = (device: DeviceRegistryEntry): boolean => { From 386581bd8b39d5eede9131ea77e851c6f6eac735 Mon Sep 17 00:00:00 2001 From: Marte Tassyns Date: Sun, 1 Dec 2024 00:26:57 +0000 Subject: [PATCH 2/2] mdi import should be before common/navigate --- .../integration-panels/zha/zha-network-visualization-page.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/config/integrations/integration-panels/zha/zha-network-visualization-page.ts b/src/panels/config/integrations/integration-panels/zha/zha-network-visualization-page.ts index 5212103a6721..82129257ddd6 100644 --- a/src/panels/config/integrations/integration-panels/zha/zha-network-visualization-page.ts +++ b/src/panels/config/integrations/integration-panels/zha/zha-network-visualization-page.ts @@ -2,6 +2,7 @@ import "@material/mwc-button"; import type { CSSResultGroup, PropertyValues } from "lit"; import { css, html, LitElement } from "lit"; import { customElement, property, query, state } from "lit/decorators"; +import { mdiTimerSand } from "@mdi/js"; import type { Edge, EdgeOptions, Node } from "vis-network/peer/esm/vis-network"; import { Network } from "vis-network/peer/esm/vis-network"; import { navigate } from "../../../../../common/navigate"; @@ -23,7 +24,6 @@ import type { } from "../../../../../types"; import { formatAsPaddedHex } from "./functions"; import { zhaTabs } from "./zha-config-dashboard"; -import { mdiTimerSand } from "@mdi/js"; @customElement("zha-network-visualization-page") export class ZHANetworkVisualizationPage extends LitElement {