Skip to content

Commit 69bc4cb

Browse files
authored
Debug UI: Fix update progres and add share button (#814)
1 parent 06365dd commit 69bc4cb

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

dashboard/src/pages/components/node-details.ts

+29-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "@material/web/divider/divider";
55
import "@material/web/iconbutton/icon-button";
66
import "@material/web/list/list";
77
import "@material/web/list/list-item";
8-
import { mdiChatProcessing, mdiTrashCan, mdiUpdate } from "@mdi/js";
8+
import { mdiChatProcessing, mdiShareVariant, mdiTrashCan, mdiUpdate } from "@mdi/js";
99
import { LitElement, css, html, nothing } from "lit";
1010
import { customElement, property, state } from "lit/decorators.js";
1111
import { MatterClient } from "../../client/client";
@@ -85,11 +85,12 @@ export class NodeDetails extends LitElement {
8585
}
8686
</md-list-item>
8787
<md-list-item class="btn">
88-
<span>
8988
<md-outlined-button @click=${this._reinterview}>Interview<ha-svg-icon slot="icon" .path=${mdiChatProcessing}></ha-svg-icon></md-outlined-button>
90-
${this.node.updateStateProgress != null || this._updateInitiated ? html`
91-
<md-outlined-button disabled>Update (${this.node.updateStateProgress || 0}%)<ha-svg-icon slot="icon" .path=${mdiUpdate}></ha-svg-icon></md-outlined-button>`
89+
${this._updateInitiated || (this.node.updateState || 0) > 1 ? html`
90+
<md-outlined-button disabled>Update in progress (${this.node.updateStateProgress || 0}%)<ha-svg-icon slot="icon" .path=${mdiUpdate}></ha-svg-icon></md-outlined-button>`
9291
: html`<md-outlined-button @click=${this._searchUpdate}>Update<ha-svg-icon slot="icon" .path=${mdiUpdate}></ha-svg-icon></md-outlined-button>`}
92+
93+
<md-outlined-button @click=${this._openCommissioningWindow}>Share<ha-svg-icon slot="icon" .path=${mdiShareVariant}></ha-svg-icon></md-outlined-button>
9394
<md-outlined-button @click=${this._remove}>Remove<ha-svg-icon slot="icon" .path=${mdiTrashCan}></ha-svg-icon></md-outlined-button>
9495
</md-list-item>
9596
</md-list>
@@ -178,6 +179,30 @@ export class NodeDetails extends LitElement {
178179
}
179180
}
180181

182+
private async _openCommissioningWindow() {
183+
if (
184+
!(await showPromptDialog({
185+
title: "Share device",
186+
text: "Do you want to share this device with another Matter controller (open commissioning window)?",
187+
confirmText: "Share",
188+
}))
189+
) {
190+
return;
191+
}
192+
try {
193+
const shareCode = await this.client.openCommissioningWindow(this.node!.node_id);
194+
showAlertDialog({
195+
title: "Share device",
196+
text: `Setup code: ${shareCode.setup_manual_code}`,
197+
});
198+
} catch (err: any) {
199+
showAlertDialog({
200+
title: "Failed to open commissioning window on node",
201+
text: err.message,
202+
});
203+
}
204+
}
205+
181206
static styles = css`
182207
.btn {
183208
--md-outlined-button-container-shape: 0px;

0 commit comments

Comments
 (0)