From da1541e6d9b2f7631731b44c90dfce43e7b0154d Mon Sep 17 00:00:00 2001 From: Marte Tassyns Date: Sun, 1 Dec 2024 00:22:27 +0000 Subject: [PATCH 1/3] 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 966be94a0cc98df54fce840d5ee5afdcae729c93 Mon Sep 17 00:00:00 2001 From: Marte Tassyns Date: Sun, 1 Dec 2024 00:26:57 +0000 Subject: [PATCH 2/3] 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 { From 7a7da939af4878d70e34dce44f96f7063eedb0fd Mon Sep 17 00:00:00 2001 From: Marte Tassyns Date: Wed, 4 Dec 2024 11:10:02 +0000 Subject: [PATCH 3/3] applied pull request review comment --- .../zha/zha-network-visualization-page.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 82129257ddd6..f3aa9d96db37 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,7 +2,6 @@ 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"; @@ -10,8 +9,8 @@ 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-circular-progress"; import "../../../../../components/ha-formfield"; import type { DeviceRegistryEntry } from "../../../../../data/device_registry"; import type { ZHADevice } from "../../../../../data/zha"; @@ -212,7 +211,10 @@ export class ZHANetworkVisualizationPage extends LitElement { .disabled=${this._refreshingTopology} > ${this._refreshingTopology - ? html`` + ? html`` : ""} ${this.hass!.localize( "ui.panel.config.zha.visualization.refresh_topology"