@matter-server/dashboard 0.6.1 → 0.6.2-alpha.0-20260421-bc2093e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +19 -0
  2. package/dist/esm/client/models/descriptions.d.ts +10 -0
  3. package/dist/esm/client/models/descriptions.d.ts.map +1 -1
  4. package/dist/esm/client/models/descriptions.js +5684 -1881
  5. package/dist/esm/client/models/descriptions.js.map +1 -1
  6. package/dist/esm/components/dialog-box/dialog-box.d.ts.map +1 -1
  7. package/dist/esm/components/dialog-box/show-dialog-box.d.ts.map +1 -1
  8. package/dist/esm/components/dialogs/acl/model.d.ts.map +1 -1
  9. package/dist/esm/components/dialogs/binding/model.d.ts.map +1 -1
  10. package/dist/esm/components/dialogs/binding/node-binding-dialog.d.ts.map +1 -1
  11. package/dist/esm/components/dialogs/binding/show-node-binding-dialog.d.ts.map +1 -1
  12. package/dist/esm/components/dialogs/commission-node-dialog/commission-node-dialog.d.ts.map +1 -1
  13. package/dist/esm/components/dialogs/commission-node-dialog/commission-node-existing.d.ts.map +1 -1
  14. package/dist/esm/components/dialogs/commission-node-dialog/commission-node-thread.d.ts.map +1 -1
  15. package/dist/esm/components/dialogs/commission-node-dialog/commission-node-wifi.d.ts.map +1 -1
  16. package/dist/esm/components/dialogs/commission-node-dialog/show-commission-node-dialog.d.ts.map +1 -1
  17. package/dist/esm/components/dialogs/dev/attribute-write-dialog.d.ts +34 -0
  18. package/dist/esm/components/dialogs/dev/attribute-write-dialog.d.ts.map +1 -0
  19. package/dist/esm/components/dialogs/dev/attribute-write-dialog.js +187 -0
  20. package/dist/esm/components/dialogs/dev/attribute-write-dialog.js.map +6 -0
  21. package/dist/esm/components/dialogs/dev/command-invoke-dialog.d.ts +33 -0
  22. package/dist/esm/components/dialogs/dev/command-invoke-dialog.d.ts.map +1 -0
  23. package/dist/esm/components/dialogs/dev/command-invoke-dialog.js +221 -0
  24. package/dist/esm/components/dialogs/dev/command-invoke-dialog.js.map +6 -0
  25. package/dist/esm/components/dialogs/dev/parse-json-payload.d.ts +27 -0
  26. package/dist/esm/components/dialogs/dev/parse-json-payload.d.ts.map +1 -0
  27. package/dist/esm/components/dialogs/dev/parse-json-payload.js +25 -0
  28. package/dist/esm/components/dialogs/dev/parse-json-payload.js.map +6 -0
  29. package/dist/esm/components/dialogs/dev/show-attribute-write-dialog.d.ts +17 -0
  30. package/dist/esm/components/dialogs/dev/show-attribute-write-dialog.d.ts.map +1 -0
  31. package/dist/esm/components/dialogs/dev/show-attribute-write-dialog.js +21 -0
  32. package/dist/esm/components/dialogs/dev/show-attribute-write-dialog.js.map +6 -0
  33. package/dist/esm/components/dialogs/dev/show-command-invoke-dialog.d.ts +16 -0
  34. package/dist/esm/components/dialogs/dev/show-command-invoke-dialog.d.ts.map +1 -0
  35. package/dist/esm/components/dialogs/dev/show-command-invoke-dialog.js +20 -0
  36. package/dist/esm/components/dialogs/dev/show-command-invoke-dialog.js.map +6 -0
  37. package/dist/esm/components/dialogs/settings/log-level-dialog.d.ts +2 -11
  38. package/dist/esm/components/dialogs/settings/log-level-dialog.d.ts.map +1 -1
  39. package/dist/esm/components/dialogs/settings/log-level-dialog.js +13 -140
  40. package/dist/esm/components/dialogs/settings/log-level-dialog.js.map +1 -1
  41. package/dist/esm/components/dialogs/settings/log-level-section.d.ts +34 -0
  42. package/dist/esm/components/dialogs/settings/log-level-section.d.ts.map +1 -0
  43. package/dist/esm/components/dialogs/settings/log-level-section.js +181 -0
  44. package/dist/esm/components/dialogs/settings/log-level-section.js.map +6 -0
  45. package/dist/esm/components/dialogs/settings/settings-dialog.d.ts +31 -0
  46. package/dist/esm/components/dialogs/settings/settings-dialog.d.ts.map +1 -0
  47. package/dist/esm/components/dialogs/settings/settings-dialog.js +165 -0
  48. package/dist/esm/components/dialogs/settings/settings-dialog.js.map +6 -0
  49. package/dist/esm/components/dialogs/settings/show-log-level-dialog.d.ts.map +1 -1
  50. package/dist/esm/components/dialogs/settings/show-settings-dialog.d.ts +8 -0
  51. package/dist/esm/components/dialogs/settings/show-settings-dialog.d.ts.map +1 -0
  52. package/dist/esm/components/dialogs/settings/show-settings-dialog.js +15 -0
  53. package/dist/esm/components/dialogs/settings/show-settings-dialog.js.map +6 -0
  54. package/dist/esm/components/ha-svg-icon.d.ts.map +1 -1
  55. package/dist/esm/pages/cluster-commands/base-cluster-commands.d.ts.map +1 -1
  56. package/dist/esm/pages/cluster-commands/clusters/basic-information-commands.d.ts.map +1 -1
  57. package/dist/esm/pages/cluster-commands/clusters/level-control-commands.d.ts.map +1 -1
  58. package/dist/esm/pages/cluster-commands/clusters/on-off-commands.d.ts.map +1 -1
  59. package/dist/esm/pages/components/footer.d.ts.map +1 -1
  60. package/dist/esm/pages/components/header.d.ts +2 -0
  61. package/dist/esm/pages/components/header.d.ts.map +1 -1
  62. package/dist/esm/pages/components/header.js +47 -3
  63. package/dist/esm/pages/components/header.js.map +1 -1
  64. package/dist/esm/pages/components/node-details.d.ts.map +1 -1
  65. package/dist/esm/pages/components/server-details.d.ts.map +1 -1
  66. package/dist/esm/pages/matter-cluster-view.d.ts +13 -2
  67. package/dist/esm/pages/matter-cluster-view.d.ts.map +1 -1
  68. package/dist/esm/pages/matter-cluster-view.js +338 -4
  69. package/dist/esm/pages/matter-cluster-view.js.map +2 -2
  70. package/dist/esm/pages/matter-dashboard-app.d.ts.map +1 -1
  71. package/dist/esm/pages/matter-endpoint-view.d.ts.map +1 -1
  72. package/dist/esm/pages/matter-network-view.d.ts.map +1 -1
  73. package/dist/esm/pages/matter-node-view.d.ts.map +1 -1
  74. package/dist/esm/pages/matter-server-view.d.ts.map +1 -1
  75. package/dist/esm/pages/network/base-network-graph.d.ts.map +1 -1
  76. package/dist/esm/pages/network/device-panel.d.ts.map +1 -1
  77. package/dist/esm/pages/network/network-details.d.ts.map +1 -1
  78. package/dist/esm/pages/network/thread-graph.d.ts.map +1 -1
  79. package/dist/esm/pages/network/update-connections-dialog.d.ts.map +1 -1
  80. package/dist/esm/pages/network/wifi-graph.d.ts.map +1 -1
  81. package/dist/esm/util/clone_class.d.ts.map +1 -1
  82. package/dist/esm/util/dev-mode-service.d.ts +14 -0
  83. package/dist/esm/util/dev-mode-service.d.ts.map +1 -0
  84. package/dist/esm/util/dev-mode-service.js +37 -0
  85. package/dist/esm/util/dev-mode-service.js.map +6 -0
  86. package/dist/esm/util/fire_event.d.ts.map +1 -1
  87. package/dist/esm/util/prevent_default.d.ts.map +1 -1
  88. package/dist/esm/util/theme-service.d.ts.map +1 -1
  89. package/dist/web/index.html +6 -0
  90. package/dist/web/js/attribute-write-dialog-B1tIg_0G.js +166 -0
  91. package/dist/web/js/command-invoke-dialog-T_pcKaIB.js +192 -0
  92. package/dist/web/js/{commission-node-dialog-DfwKU9qk.js → commission-node-dialog-WS5qDOnU.js} +4 -4
  93. package/dist/web/js/{commission-node-existing-C7ITvNfj.js → commission-node-existing-Bb10H55l.js} +2 -2
  94. package/dist/web/js/{commission-node-thread-D-icSzto.js → commission-node-thread-B0wMe4Wq.js} +2 -2
  95. package/dist/web/js/{commission-node-wifi-DwUkXlWz.js → commission-node-wifi-Bjdqn47D.js} +2 -2
  96. package/dist/web/js/{dialog-box-BmpaTrvT.js → dialog-box-DtMt9N0h.js} +1 -1
  97. package/dist/web/js/{fire_event-2ZxL-AHZ.js → fire_event-BL87hqSP.js} +1 -1
  98. package/dist/web/js/main.js +2 -2
  99. package/dist/web/js/{matter-dashboard-app-BtHTmAPq.js → matter-dashboard-app-F5wNhZIe.js} +6200 -1897
  100. package/dist/web/js/{node-binding-dialog-MMx9rkCF.js → node-binding-dialog-BEs5k-yQ.js} +1 -1
  101. package/dist/web/js/parse-json-payload-DU9TWKdu.js +32 -0
  102. package/dist/web/js/{log-level-dialog-D4hubdib.js → settings-dialog-DNiYIToE.js} +583 -69
  103. package/package.json +29 -29
  104. package/src/client/models/descriptions.ts +5690 -1878
  105. package/src/components/dialogs/dev/attribute-write-dialog.ts +169 -0
  106. package/src/components/dialogs/dev/command-invoke-dialog.ts +204 -0
  107. package/src/components/dialogs/dev/parse-json-payload.ts +37 -0
  108. package/src/components/dialogs/dev/show-attribute-write-dialog.ts +30 -0
  109. package/src/components/dialogs/dev/show-command-invoke-dialog.ts +28 -0
  110. package/src/components/dialogs/settings/log-level-dialog.ts +15 -138
  111. package/src/components/dialogs/settings/log-level-section.ts +174 -0
  112. package/src/components/dialogs/settings/settings-dialog.ts +165 -0
  113. package/src/components/dialogs/settings/show-settings-dialog.ts +14 -0
  114. package/src/pages/components/header.ts +47 -3
  115. package/src/pages/matter-cluster-view.ts +366 -4
  116. package/src/tsconfig.json +7 -2
  117. package/src/util/dev-mode-service.ts +44 -0
@@ -0,0 +1,169 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025-2026 Open Home Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import "@material/web/button/text-button";
8
+ import "@material/web/dialog/dialog";
9
+ import type { MdDialog } from "@material/web/dialog/dialog.js";
10
+ import { MatterClient, toBigIntAwareJson } from "@matter-server/ws-client";
11
+ import { css, html, LitElement, nothing } from "lit";
12
+ import { customElement, property, query, state } from "lit/decorators.js";
13
+ import { handleAsync } from "../../../util/async-handler.js";
14
+ import { formatHex } from "../../../util/format_hex.js";
15
+ import { preventDefault } from "../../../util/prevent_default.js";
16
+ import { parseJsonPayload } from "./parse-json-payload.js";
17
+
18
+ @customElement("attribute-write-dialog")
19
+ export class AttributeWriteDialog extends LitElement {
20
+ @property({ attribute: false })
21
+ public client!: MatterClient;
22
+
23
+ @property({ type: Number }) public nodeId!: number | bigint;
24
+ @property({ type: Number }) public endpointId!: number;
25
+ @property({ type: Number }) public clusterId!: number;
26
+ @property({ type: Number }) public attributeId!: number;
27
+ @property({ type: String }) public label!: string;
28
+ @property({ attribute: false }) public currentValue: unknown = null;
29
+
30
+ @state() private _busy = false;
31
+ @state() private _error: string | null = null;
32
+
33
+ @query("textarea") private _textarea!: HTMLTextAreaElement;
34
+
35
+ protected override firstUpdated() {
36
+ // Seed the textarea once, bypassing the render cycle so later state updates
37
+ // (busy/error) don't clobber the user's edits.
38
+ if (this._textarea && this._textarea.value === "") {
39
+ this._textarea.value = toBigIntAwareJson(this.currentValue ?? null, 2);
40
+ }
41
+ }
42
+
43
+ private get _attributePath(): string {
44
+ return `${this.endpointId}/${this.clusterId}/${this.attributeId}`;
45
+ }
46
+
47
+ private _close() {
48
+ this.shadowRoot!.querySelector<MdDialog>("md-dialog")!.close();
49
+ }
50
+
51
+ private _handleClosed() {
52
+ this.parentNode!.removeChild(this);
53
+ }
54
+
55
+ private async _write() {
56
+ this._error = null;
57
+ const parsed = parseJsonPayload(this._textarea.value);
58
+ if (!parsed.ok) {
59
+ this._error = `Invalid JSON: ${parsed.error}`;
60
+ return;
61
+ }
62
+ this._busy = true;
63
+ try {
64
+ await this.client.writeAttribute(this.nodeId, this._attributePath, parsed.value);
65
+ this._close();
66
+ } catch (err) {
67
+ this._error = err instanceof Error ? err.message : String(err);
68
+ } finally {
69
+ this._busy = false;
70
+ }
71
+ }
72
+
73
+ protected override render() {
74
+ return html`
75
+ <md-dialog open @cancel=${preventDefault} @closed=${this._handleClosed}>
76
+ <div slot="headline">Write ${this.label}</div>
77
+ <div slot="content">
78
+ <p class="path" id="write-path">
79
+ Path <code>${this._attributePath}</code>
80
+ (${formatHex(this.endpointId)}/${formatHex(this.clusterId)}/${formatHex(this.attributeId)})
81
+ </p>
82
+ <label class="textarea-label" for="write-payload">Value (JSON)</label>
83
+ <textarea
84
+ id="write-payload"
85
+ class="payload"
86
+ spellcheck="false"
87
+ autocomplete="off"
88
+ autocapitalize="off"
89
+ aria-describedby="write-path${this._error ? " write-error" : ""}"
90
+ rows="10"
91
+ ></textarea>
92
+ ${this._error
93
+ ? html`<div id="write-error" class="error" role="alert">${this._error}</div>`
94
+ : nothing}
95
+ </div>
96
+ <div slot="actions">
97
+ <md-text-button @click=${this._close} ?disabled=${this._busy}>Cancel</md-text-button>
98
+ <md-text-button @click=${handleAsync(() => this._write())} ?disabled=${this._busy}>
99
+ ${this._busy ? "Writing..." : "Write"}
100
+ </md-text-button>
101
+ </div>
102
+ </md-dialog>
103
+ `;
104
+ }
105
+
106
+ static override styles = css`
107
+ md-dialog {
108
+ min-width: 520px;
109
+ max-width: 720px;
110
+ }
111
+
112
+ .path {
113
+ margin: 0 0 12px 0;
114
+ font-size: 0.85rem;
115
+ color: var(--md-sys-color-on-surface-variant);
116
+ }
117
+
118
+ .path code {
119
+ font-family: var(--monospace-font);
120
+ background: var(--md-sys-color-surface-container-high);
121
+ padding: 0 4px;
122
+ border-radius: 3px;
123
+ }
124
+
125
+ .textarea-label {
126
+ display: block;
127
+ margin: 0 0 6px 0;
128
+ font-size: 0.85rem;
129
+ font-weight: 500;
130
+ color: var(--md-sys-color-on-surface);
131
+ }
132
+
133
+ .payload {
134
+ width: 100%;
135
+ box-sizing: border-box;
136
+ font-family: var(--monospace-font);
137
+ font-size: 0.9rem;
138
+ padding: 8px;
139
+ background: var(--md-sys-color-surface-container-low);
140
+ color: var(--md-sys-color-on-surface);
141
+ border: 1px solid var(--md-sys-color-outline);
142
+ border-radius: 6px;
143
+ resize: vertical;
144
+ min-height: 140px;
145
+ }
146
+
147
+ .payload:focus {
148
+ outline: 2px solid var(--dev-color);
149
+ outline-offset: -1px;
150
+ }
151
+
152
+ .error {
153
+ margin-top: 10px;
154
+ padding: 10px 12px;
155
+ background: var(--md-sys-color-error-container);
156
+ color: var(--md-sys-color-on-error-container);
157
+ border-radius: 6px;
158
+ font-size: 0.875rem;
159
+ white-space: pre-wrap;
160
+ word-break: break-word;
161
+ }
162
+ `;
163
+ }
164
+
165
+ declare global {
166
+ interface HTMLElementTagNameMap {
167
+ "attribute-write-dialog": AttributeWriteDialog;
168
+ }
169
+ }
@@ -0,0 +1,204 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025-2026 Open Home Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import "@material/web/button/text-button";
8
+ import "@material/web/dialog/dialog";
9
+ import type { MdDialog } from "@material/web/dialog/dialog.js";
10
+ import { MatterClient, toBigIntAwareJson } from "@matter-server/ws-client";
11
+ import { css, html, LitElement, nothing } from "lit";
12
+ import { customElement, property, query, state } from "lit/decorators.js";
13
+ import { handleAsync } from "../../../util/async-handler.js";
14
+ import { formatHex } from "../../../util/format_hex.js";
15
+ import { preventDefault } from "../../../util/prevent_default.js";
16
+ import { isPlainObject, parseJsonPayload } from "./parse-json-payload.js";
17
+
18
+ @customElement("command-invoke-dialog")
19
+ export class CommandInvokeDialog extends LitElement {
20
+ @property({ attribute: false })
21
+ public client!: MatterClient;
22
+
23
+ @property({ type: Number }) public nodeId!: number | bigint;
24
+ @property({ type: Number }) public endpointId!: number;
25
+ @property({ type: Number }) public clusterId!: number;
26
+ @property({ type: String }) public commandName!: string;
27
+ @property({ type: String }) public commandLabel!: string;
28
+
29
+ @state() private _busy = false;
30
+ @state() private _error: string | null = null;
31
+ @state() private _response: string | null = null;
32
+
33
+ @query("textarea") private _textarea!: HTMLTextAreaElement;
34
+
35
+ protected override firstUpdated() {
36
+ // Seed the textarea once, bypassing the render cycle so later state updates
37
+ // (busy/error/response) don't clobber the user's edits.
38
+ if (this._textarea && this._textarea.value === "") {
39
+ this._textarea.value = "{}";
40
+ }
41
+ }
42
+
43
+ private _close() {
44
+ this.shadowRoot!.querySelector<MdDialog>("md-dialog")!.close();
45
+ }
46
+
47
+ private _handleClosed() {
48
+ this.parentNode!.removeChild(this);
49
+ }
50
+
51
+ private async _invoke() {
52
+ this._error = null;
53
+ const parsed = parseJsonPayload(this._textarea.value);
54
+ if (!parsed.ok) {
55
+ this._error = `Invalid JSON: ${parsed.error}`;
56
+ this._response = null;
57
+ return;
58
+ }
59
+ const payload = parsed.value;
60
+ if (!isPlainObject(payload)) {
61
+ this._error = "Payload must be a JSON object (use {} for commands with no arguments).";
62
+ this._response = null;
63
+ return;
64
+ }
65
+ this._busy = true;
66
+ try {
67
+ const result = await this.client.deviceCommand(
68
+ this.nodeId,
69
+ this.endpointId,
70
+ this.clusterId,
71
+ this.commandName,
72
+ payload,
73
+ );
74
+ this._response = toBigIntAwareJson(result ?? null, 2);
75
+ this._error = null;
76
+ } catch (err) {
77
+ this._error = err instanceof Error ? err.message : String(err);
78
+ this._response = null;
79
+ } finally {
80
+ this._busy = false;
81
+ }
82
+ }
83
+
84
+ protected override render() {
85
+ return html`
86
+ <md-dialog open @cancel=${preventDefault} @closed=${this._handleClosed}>
87
+ <div slot="headline">Invoke ${this.commandLabel}</div>
88
+ <div slot="content">
89
+ <p class="path" id="invoke-path">
90
+ Cluster <code>${this.clusterId}</code> (${formatHex(this.clusterId)}) · Endpoint
91
+ <code>${this.endpointId}</code> · Command <code>${this.commandName}</code>
92
+ </p>
93
+ <label class="textarea-label" for="payload">Payload (JSON)</label>
94
+ <textarea
95
+ id="payload"
96
+ class="payload"
97
+ spellcheck="false"
98
+ autocomplete="off"
99
+ autocapitalize="off"
100
+ aria-describedby="invoke-path${this._error ? " invoke-error" : ""}"
101
+ rows="8"
102
+ ></textarea>
103
+ ${this._error
104
+ ? html`<div id="invoke-error" class="error" role="alert">${this._error}</div>`
105
+ : nothing}
106
+ ${this._response !== null
107
+ ? html`
108
+ <label class="textarea-label">Response</label>
109
+ <pre class="response"><code>${this._response}</code></pre>
110
+ `
111
+ : nothing}
112
+ </div>
113
+ <div slot="actions">
114
+ <md-text-button @click=${this._close} ?disabled=${this._busy}>Close</md-text-button>
115
+ <md-text-button @click=${handleAsync(() => this._invoke())} ?disabled=${this._busy}>
116
+ ${this._busy ? "Invoking..." : "Invoke"}
117
+ </md-text-button>
118
+ </div>
119
+ </md-dialog>
120
+ `;
121
+ }
122
+
123
+ static override styles = css`
124
+ md-dialog {
125
+ min-width: 520px;
126
+ max-width: 720px;
127
+ }
128
+
129
+ .path {
130
+ margin: 0 0 12px 0;
131
+ font-size: 0.85rem;
132
+ color: var(--md-sys-color-on-surface-variant);
133
+ }
134
+
135
+ .path code {
136
+ font-family: var(--monospace-font);
137
+ background: var(--md-sys-color-surface-container-high);
138
+ padding: 0 4px;
139
+ border-radius: 3px;
140
+ }
141
+
142
+ .textarea-label {
143
+ display: block;
144
+ margin: 6px 0 6px 0;
145
+ font-size: 0.85rem;
146
+ font-weight: 500;
147
+ color: var(--md-sys-color-on-surface);
148
+ }
149
+
150
+ .payload {
151
+ width: 100%;
152
+ box-sizing: border-box;
153
+ font-family: var(--monospace-font);
154
+ font-size: 0.9rem;
155
+ padding: 8px;
156
+ background: var(--md-sys-color-surface-container-low);
157
+ color: var(--md-sys-color-on-surface);
158
+ border: 1px solid var(--md-sys-color-outline);
159
+ border-radius: 6px;
160
+ resize: vertical;
161
+ min-height: 120px;
162
+ }
163
+
164
+ .payload:focus {
165
+ outline: 2px solid var(--dev-color);
166
+ outline-offset: -1px;
167
+ }
168
+
169
+ .error {
170
+ margin-top: 10px;
171
+ padding: 10px 12px;
172
+ background: var(--md-sys-color-error-container);
173
+ color: var(--md-sys-color-on-error-container);
174
+ border-radius: 6px;
175
+ font-size: 0.875rem;
176
+ white-space: pre-wrap;
177
+ word-break: break-word;
178
+ }
179
+
180
+ .response {
181
+ margin: 6px 0 0 0;
182
+ padding: 10px 12px;
183
+ background: var(--md-sys-color-surface-container-low);
184
+ color: var(--md-sys-color-on-surface);
185
+ border: 1px solid var(--md-sys-color-outline);
186
+ border-radius: 6px;
187
+ max-height: 260px;
188
+ overflow: auto;
189
+ font-size: 0.85rem;
190
+ }
191
+
192
+ .response code {
193
+ font-family: var(--monospace-font);
194
+ white-space: pre-wrap;
195
+ word-break: break-word;
196
+ }
197
+ `;
198
+ }
199
+
200
+ declare global {
201
+ interface HTMLElementTagNameMap {
202
+ "command-invoke-dialog": CommandInvokeDialog;
203
+ }
204
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025-2026 Open Home Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { parseBigIntAwareJson } from "@matter-server/ws-client";
8
+
9
+ export type ParsedPayload = { ok: true; value: unknown } | { ok: false; error: string };
10
+
11
+ /**
12
+ * Parse a JSON payload from a developer-facing textarea.
13
+ *
14
+ * Uses {@link parseBigIntAwareJson} so that literals exceeding `Number.MAX_SAFE_INTEGER`
15
+ * round-trip as `bigint` on the wire (matching the rest of the WebSocket client).
16
+ */
17
+ export function parseJsonPayload(text: string): ParsedPayload {
18
+ const trimmed = text.trim();
19
+ if (trimmed.length === 0) {
20
+ return { ok: false, error: "Payload must not be empty" };
21
+ }
22
+ try {
23
+ return { ok: true, value: parseBigIntAwareJson(trimmed) };
24
+ } catch (err) {
25
+ return { ok: false, error: err instanceof Error ? err.message : String(err) };
26
+ }
27
+ }
28
+
29
+ /**
30
+ * True if the value is a JSON object (non-null, non-array, plain record shape).
31
+ *
32
+ * Matter command payloads are struct-shaped, so invoking with a raw array / string /
33
+ * number is almost certainly a user mistake.
34
+ */
35
+ export function isPlainObject(value: unknown): value is Record<string, unknown> {
36
+ return typeof value === "object" && value !== null && !Array.isArray(value);
37
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025-2026 Open Home Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { MatterClient } from "@matter-server/ws-client";
8
+
9
+ export interface ShowAttributeWriteDialogOptions {
10
+ client: MatterClient;
11
+ nodeId: number | bigint;
12
+ endpointId: number;
13
+ clusterId: number;
14
+ attributeId: number;
15
+ label: string;
16
+ currentValue: unknown;
17
+ }
18
+
19
+ export const showAttributeWriteDialog = async (options: ShowAttributeWriteDialogOptions) => {
20
+ await import("./attribute-write-dialog.js");
21
+ const dialog = document.createElement("attribute-write-dialog");
22
+ dialog.client = options.client;
23
+ dialog.nodeId = options.nodeId;
24
+ dialog.endpointId = options.endpointId;
25
+ dialog.clusterId = options.clusterId;
26
+ dialog.attributeId = options.attributeId;
27
+ dialog.label = options.label;
28
+ dialog.currentValue = options.currentValue;
29
+ document.querySelector("matter-dashboard-app")?.renderRoot.appendChild(dialog);
30
+ };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025-2026 Open Home Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { MatterClient } from "@matter-server/ws-client";
8
+
9
+ export interface ShowCommandInvokeDialogOptions {
10
+ client: MatterClient;
11
+ nodeId: number | bigint;
12
+ endpointId: number;
13
+ clusterId: number;
14
+ commandName: string;
15
+ commandLabel: string;
16
+ }
17
+
18
+ export const showCommandInvokeDialog = async (options: ShowCommandInvokeDialogOptions) => {
19
+ await import("./command-invoke-dialog.js");
20
+ const dialog = document.createElement("command-invoke-dialog");
21
+ dialog.client = options.client;
22
+ dialog.nodeId = options.nodeId;
23
+ dialog.endpointId = options.endpointId;
24
+ dialog.clusterId = options.clusterId;
25
+ dialog.commandName = options.commandName;
26
+ dialog.commandLabel = options.commandLabel;
27
+ document.querySelector("matter-dashboard-app")?.renderRoot.appendChild(dialog);
28
+ };
@@ -7,79 +7,17 @@
7
7
  import "@material/web/button/text-button";
8
8
  import "@material/web/dialog/dialog";
9
9
  import type { MdDialog } from "@material/web/dialog/dialog.js";
10
- import "@material/web/select/outlined-select";
11
- import type { MdOutlinedSelect } from "@material/web/select/outlined-select.js";
12
- import "@material/web/select/select-option";
13
- import { LogLevelString, MatterClient } from "@matter-server/ws-client";
14
- import { css, html, LitElement, nothing } from "lit";
15
- import { customElement, property, query, state } from "lit/decorators.js";
16
- import { fireAndForget, handleAsync } from "../../../util/async-handler.js";
10
+ import { MatterClient } from "@matter-server/ws-client";
11
+ import { css, html, LitElement } from "lit";
12
+ import { customElement, property } from "lit/decorators.js";
17
13
  import { preventDefault } from "../../../util/prevent_default.js";
18
- import { showAlertDialog } from "../../dialog-box/show-dialog-box.js";
19
-
20
- const LOG_LEVELS: { value: LogLevelString; label: string }[] = [
21
- { value: "critical", label: "Critical" },
22
- { value: "error", label: "Error" },
23
- { value: "warning", label: "Warning" },
24
- { value: "info", label: "Info" },
25
- { value: "debug", label: "Debug" },
26
- ];
14
+ import "./log-level-section.js";
27
15
 
28
16
  @customElement("log-level-dialog")
29
17
  export class LogLevelDialog extends LitElement {
30
18
  @property({ attribute: false })
31
19
  public client!: MatterClient;
32
20
 
33
- @state() private _consoleLevel: LogLevelString = "info";
34
- @state() private _fileLevel: LogLevelString | null = null;
35
- @state() private _loading = true;
36
- @state() private _applying = false;
37
-
38
- @query("md-outlined-select[name='console']")
39
- private _consoleSelect!: MdOutlinedSelect;
40
-
41
- @query("md-outlined-select[name='file']")
42
- private _fileSelect?: MdOutlinedSelect;
43
-
44
- override connectedCallback() {
45
- super.connectedCallback();
46
- fireAndForget(this._loadLogLevels());
47
- }
48
-
49
- private async _loadLogLevels() {
50
- try {
51
- const result = await this.client.getLogLevel();
52
- this._consoleLevel = result.console_loglevel;
53
- this._fileLevel = result.file_loglevel;
54
- } catch (err) {
55
- console.error("Failed to load log levels:", err);
56
- } finally {
57
- this._loading = false;
58
- }
59
- }
60
-
61
- private async _apply() {
62
- this._applying = true;
63
- try {
64
- const consoleLevel = this._consoleSelect.value as LogLevelString;
65
- const fileLevel = this._fileSelect?.value as LogLevelString | undefined;
66
-
67
- const result = await this.client.setLogLevel(
68
- consoleLevel,
69
- this._fileLevel !== null ? fileLevel : undefined,
70
- );
71
-
72
- this._consoleLevel = result.console_loglevel;
73
- this._fileLevel = result.file_loglevel;
74
- this._close();
75
- } catch (err) {
76
- console.error("Failed to apply log levels:", err);
77
- showAlertDialog({ title: "Error", text: "Failed to apply log levels" });
78
- } finally {
79
- this._applying = false;
80
- }
81
- }
82
-
83
21
  private _close() {
84
22
  this.shadowRoot!.querySelector<MdDialog>("md-dialog")!.close();
85
23
  }
@@ -88,91 +26,30 @@ export class LogLevelDialog extends LitElement {
88
26
  this.parentNode!.removeChild(this);
89
27
  }
90
28
 
29
+ private _handleApplied() {
30
+ this._close();
31
+ }
32
+
91
33
  protected override render() {
92
34
  return html`
93
35
  <md-dialog open @cancel=${preventDefault} @closed=${this._handleClosed}>
94
36
  <div slot="headline">Server Log Settings</div>
95
37
  <div slot="content">
96
- ${this._loading
97
- ? html` <p class="loading">Loading...</p> `
98
- : html`
99
- <p class="hint">Changes are temporary and will be reset on the next server restart.</p>
100
- <div class="form-field">
101
- <label>Console Log Level</label>
102
- <md-outlined-select name="console" .value=${this._consoleLevel}>
103
- ${LOG_LEVELS.map(
104
- level => html`
105
- <md-select-option
106
- value=${level.value}
107
- ?selected=${level.value === this._consoleLevel}
108
- >
109
- <div slot="headline">${level.label}</div>
110
- </md-select-option>
111
- `,
112
- )}
113
- </md-outlined-select>
114
- </div>
115
- ${this._fileLevel !== null
116
- ? html`
117
- <div class="form-field">
118
- <label>File Log Level</label>
119
- <md-outlined-select name="file" .value=${this._fileLevel}>
120
- ${LOG_LEVELS.map(
121
- level => html`
122
- <md-select-option
123
- value=${level.value}
124
- ?selected=${level.value === this._fileLevel}
125
- >
126
- <div slot="headline">${level.label}</div>
127
- </md-select-option>
128
- `,
129
- )}
130
- </md-outlined-select>
131
- </div>
132
- `
133
- : nothing}
134
- `}
38
+ <log-level-section
39
+ .client=${this.client}
40
+ @log-level-applied=${this._handleApplied}
41
+ ></log-level-section>
135
42
  </div>
136
43
  <div slot="actions">
137
- <md-text-button @click=${this._close}>Cancel</md-text-button>
138
- <md-text-button
139
- @click=${handleAsync(() => this._apply())}
140
- ?disabled=${this._loading || this._applying}
141
- >
142
- ${this._applying ? "Applying..." : "Apply"}
143
- </md-text-button>
44
+ <md-text-button @click=${this._close}>Close</md-text-button>
144
45
  </div>
145
46
  </md-dialog>
146
47
  `;
147
48
  }
148
49
 
149
50
  static override styles = css`
150
- .loading {
151
- text-align: center;
152
- padding: 24px;
153
- color: var(--md-sys-color-on-surface-variant);
154
- }
155
-
156
- .hint {
157
- font-size: 0.875rem;
158
- color: var(--md-sys-color-on-surface-variant);
159
- margin: 0 0 16px 0;
160
- font-style: italic;
161
- }
162
-
163
- .form-field {
164
- margin-bottom: 16px;
165
- }
166
-
167
- .form-field label {
168
- display: block;
169
- margin-bottom: 8px;
170
- font-weight: 500;
171
- color: var(--md-sys-color-on-surface);
172
- }
173
-
174
- md-outlined-select {
175
- width: 100%;
51
+ md-dialog {
52
+ min-width: 360px;
176
53
  }
177
54
  `;
178
55
  }