@attraccess/plugin-shelly 0.1.0-nightly.990.1 → 0.1.0
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.
- package/dist/index.js +9720 -220
- package/frontend/{__federation_expose_Plugin-Dd1Vs4iR.js → __federation_expose_Plugin-CLiHEWPT.js} +983 -636
- package/frontend/host-shared-placeholder-BvRk9kiK.js +0 -0
- package/frontend/remoteEntry.js +68 -2
- package/frontend/style.css +4 -63
- package/package.json +8 -5
- package/frontend/jsx-runtime-B9Qmn8k7.js +0 -42
- package/frontend/preload-helper-DxWiKyOd.js +0 -68
- package/frontend/react-D5kF5LxZ.js +0 -383
- package/frontend/rolldown-runtime-EAsCxrDo.js +0 -14
package/frontend/{__federation_expose_Plugin-Dd1Vs4iR.js → __federation_expose_Plugin-CLiHEWPT.js}
RENAMED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { r as importShared } from "./_virtual___federation_fn_import-BXODRNto.js";
|
|
2
|
-
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
4
|
+
//#endregion
|
|
3
5
|
//#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.api-client.ts
|
|
4
6
|
var BASE_URL_GLOBAL = "__ATTRACCESS_API_BASE_URL__";
|
|
5
7
|
/** The API origin the host is talking to. Falls back to the current origin. */
|
|
@@ -60,6 +62,105 @@ function createPluginApiClient(basePath = "") {
|
|
|
60
62
|
};
|
|
61
63
|
}
|
|
62
64
|
//#endregion
|
|
65
|
+
//#region ../../../node_modules/.pnpm/react@19.2.8/node_modules/react/cjs/react-jsx-runtime.production.js
|
|
66
|
+
/**
|
|
67
|
+
* @license React
|
|
68
|
+
* react-jsx-runtime.production.js
|
|
69
|
+
*
|
|
70
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
71
|
+
*
|
|
72
|
+
* This source code is licensed under the MIT license found in the
|
|
73
|
+
* LICENSE file in the root directory of this source tree.
|
|
74
|
+
*/
|
|
75
|
+
var require_react_jsx_runtime_production = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
76
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element");
|
|
77
|
+
function jsxProd(type, config, maybeKey) {
|
|
78
|
+
var key = null;
|
|
79
|
+
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
80
|
+
void 0 !== config.key && (key = "" + config.key);
|
|
81
|
+
if ("key" in config) {
|
|
82
|
+
maybeKey = {};
|
|
83
|
+
for (var propName in config) "key" !== propName && (maybeKey[propName] = config[propName]);
|
|
84
|
+
} else maybeKey = config;
|
|
85
|
+
config = maybeKey.ref;
|
|
86
|
+
return {
|
|
87
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
88
|
+
type,
|
|
89
|
+
key,
|
|
90
|
+
ref: void 0 !== config ? config : null,
|
|
91
|
+
props: maybeKey
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
exports.jsx = jsxProd;
|
|
95
|
+
exports.jsxs = jsxProd;
|
|
96
|
+
}));
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.live-updates.tsx
|
|
99
|
+
var import_jsx_runtime = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
100
|
+
module.exports = require_react_jsx_runtime_production();
|
|
101
|
+
})))();
|
|
102
|
+
var { createContext, useCallback: useCallback$6, useContext, useEffect: useEffect$4, useRef: useRef$3 } = await importShared("react");
|
|
103
|
+
var contextKey = Symbol.for("attraccess.plugin.live-updates.context");
|
|
104
|
+
var contexts = globalThis;
|
|
105
|
+
var LiveContext = contexts[contextKey] ??= createContext(null);
|
|
106
|
+
var identityKey = Symbol.for("attraccess.plugin.live-updates.identity");
|
|
107
|
+
var identities = globalThis;
|
|
108
|
+
var IdentityContext = identities[identityKey] ??= createContext(null);
|
|
109
|
+
function usePluginLiveUpdates(props) {
|
|
110
|
+
const client = useContext(LiveContext);
|
|
111
|
+
const plugin = useContext(IdentityContext) ?? props.plugin;
|
|
112
|
+
const latest = useRef$3({
|
|
113
|
+
props,
|
|
114
|
+
client,
|
|
115
|
+
plugin
|
|
116
|
+
});
|
|
117
|
+
latest.current = {
|
|
118
|
+
props,
|
|
119
|
+
client,
|
|
120
|
+
plugin
|
|
121
|
+
};
|
|
122
|
+
const unsubscribe = useRef$3(null);
|
|
123
|
+
const { topic, identifier, enabled = true } = props;
|
|
124
|
+
useEffect$4(() => {
|
|
125
|
+
if (!client || !enabled) return;
|
|
126
|
+
let active = true;
|
|
127
|
+
const matches = () => active && latest.current.client === client && latest.current.props.enabled !== false && latest.current.plugin === plugin && latest.current.props.topic === topic && latest.current.props.identifier === identifier;
|
|
128
|
+
const remove = client.subscribe({
|
|
129
|
+
topic: `plugin:${encodeURIComponent(plugin)}:${topic}`,
|
|
130
|
+
...identifier !== void 0 ? { identifier } : {}
|
|
131
|
+
}, (payload) => {
|
|
132
|
+
if (matches()) return latest.current.props.onUpdate(payload);
|
|
133
|
+
}, () => {
|
|
134
|
+
if (matches()) return latest.current.props.onReconnect?.();
|
|
135
|
+
}, () => {
|
|
136
|
+
if (matches()) return latest.current.props.onUnavailable?.();
|
|
137
|
+
});
|
|
138
|
+
const cleanup = () => {
|
|
139
|
+
if (!active) return;
|
|
140
|
+
active = false;
|
|
141
|
+
remove();
|
|
142
|
+
};
|
|
143
|
+
unsubscribe.current = cleanup;
|
|
144
|
+
return () => {
|
|
145
|
+
cleanup();
|
|
146
|
+
if (unsubscribe.current === cleanup) unsubscribe.current = null;
|
|
147
|
+
};
|
|
148
|
+
}, [
|
|
149
|
+
client,
|
|
150
|
+
plugin,
|
|
151
|
+
topic,
|
|
152
|
+
identifier,
|
|
153
|
+
enabled
|
|
154
|
+
]);
|
|
155
|
+
return { abort: useCallback$6(() => unsubscribe.current?.(), []) };
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-drawer.tsx
|
|
159
|
+
var { StandardDrawer: SharedStandardDrawer } = await importShared("@attraccess/plugins-frontend-ui");
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-modal.tsx
|
|
162
|
+
var { StandardModal: SharedStandardModal } = await importShared("@attraccess/plugins-frontend-ui");
|
|
163
|
+
//#endregion
|
|
63
164
|
//#region frontend/src/api.ts
|
|
64
165
|
var api = createPluginApiClient("/api/shelly");
|
|
65
166
|
function listDevices() {
|
|
@@ -118,27 +219,8 @@ function discoverDevices(input = {}) {
|
|
|
118
219
|
});
|
|
119
220
|
}
|
|
120
221
|
//#endregion
|
|
121
|
-
//#region frontend/src/drawer.tsx
|
|
122
|
-
var
|
|
123
|
-
var { Button: Button$6, Description, DrawerBackdrop, DrawerContent, DrawerDialog, Input, InputGroup, Label, TextField, Tooltip: Tooltip$2 } = await importShared("@heroui/react");
|
|
124
|
-
var { EyeIcon: EyeIcon$1, EyeOffIcon: EyeOffIcon$1 } = await importShared("lucide-react");
|
|
125
|
-
var { useState: useState$6 } = await importShared("react");
|
|
126
|
-
var DRAWER_DIALOG_CLASSNAME = "sh:md:max-w-2xl sh:md:mx-auto sh:bg-surface-secondary";
|
|
127
|
-
var FIELD_CONTRAST_STYLE = {
|
|
128
|
-
["--field-border"]: "var(--border-secondary)",
|
|
129
|
-
["--border-width-field"]: "1px"
|
|
130
|
-
};
|
|
131
|
-
function StandardDrawer({ isOpen, onOpenChange, children }) {
|
|
132
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerBackdrop, {
|
|
133
|
-
isOpen,
|
|
134
|
-
onOpenChange,
|
|
135
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerContent, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerDialog, {
|
|
136
|
-
className: DRAWER_DIALOG_CLASSNAME,
|
|
137
|
-
style: FIELD_CONTRAST_STYLE,
|
|
138
|
-
children
|
|
139
|
-
}) })
|
|
140
|
-
});
|
|
141
|
-
}
|
|
222
|
+
//#region frontend/src/shared/drawer.tsx
|
|
223
|
+
var { Input, Label, TextField } = await importShared("@heroui/react");
|
|
142
224
|
function TextFieldRow({ label, value, onChange, placeholder, required, description, dataCy }) {
|
|
143
225
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField, {
|
|
144
226
|
value,
|
|
@@ -158,57 +240,281 @@ function TextFieldRow({ label, value, onChange, placeholder, required, descripti
|
|
|
158
240
|
]
|
|
159
241
|
});
|
|
160
242
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
243
|
+
var en_default = {
|
|
244
|
+
devices: {
|
|
245
|
+
"title": "Shelly Devices",
|
|
246
|
+
"table": "Shelly devices",
|
|
247
|
+
"description": "Discovered and manually added Shelly devices.",
|
|
248
|
+
"discover": "Discover",
|
|
249
|
+
"add": "Add device",
|
|
250
|
+
"loadError": "Failed to load devices",
|
|
251
|
+
"device": "Device",
|
|
252
|
+
"address": "Address",
|
|
253
|
+
"model": "Model",
|
|
254
|
+
"auth": "Auth",
|
|
255
|
+
"firmware": "Firmware",
|
|
256
|
+
"actions": "Actions",
|
|
257
|
+
"unknown": "Unknown",
|
|
258
|
+
"generation": "Gen {{generation}}",
|
|
259
|
+
"generationPlus": "Gen {{generation}}+",
|
|
260
|
+
"empty": "No devices yet. Run discovery, or add your first Shelly by its IP.",
|
|
261
|
+
"probeError": "Probe failed: {{message}}",
|
|
262
|
+
"info": "View device info",
|
|
263
|
+
"more": "More actions",
|
|
264
|
+
"deviceActions": "Device actions",
|
|
265
|
+
"manageFirmware": "Manage firmware",
|
|
266
|
+
"password": "Set admin password",
|
|
267
|
+
"reprobe": "Re-probe device",
|
|
268
|
+
"delete": "Delete device",
|
|
269
|
+
"deleteDescription": "Remove {{name}} ({{address}}) from the registry? The device itself is not changed."
|
|
270
|
+
},
|
|
271
|
+
auth: {
|
|
272
|
+
"none": "No auth",
|
|
273
|
+
"required": "Auth required",
|
|
274
|
+
"unknown": "Unknown"
|
|
275
|
+
},
|
|
276
|
+
add: {
|
|
277
|
+
"title": "Add a device",
|
|
278
|
+
"description": "Enter the device's IP address. We probe GET /shelly to detect its generation and model.",
|
|
279
|
+
"ip": "IP address",
|
|
280
|
+
"name": "Name (optional)",
|
|
281
|
+
"placeholder": "Workshop light",
|
|
282
|
+
"error": "Could not add the device",
|
|
283
|
+
"required": "IP address is required."
|
|
284
|
+
},
|
|
285
|
+
password: {
|
|
286
|
+
"title": "Admin password",
|
|
287
|
+
"description": "Set or change the admin password of {{name}} ({{address}}).",
|
|
288
|
+
"current": "Current password",
|
|
289
|
+
"currentDescription": "Required because this device already has authentication enabled.",
|
|
290
|
+
"new": "New admin password",
|
|
291
|
+
"newDescription": "Protects the device's local web interface and API.",
|
|
292
|
+
"error": "Could not set password",
|
|
293
|
+
"required": "New password is required.",
|
|
294
|
+
"save": "Save password"
|
|
295
|
+
},
|
|
296
|
+
discovery: {
|
|
297
|
+
"title": "Discover devices",
|
|
298
|
+
"description": "Listens for Shelly devices announcing over mDNS, then probes every address of a subnet. Everything found is added to the registry.",
|
|
299
|
+
"subnet": "Subnet to scan (optional)",
|
|
300
|
+
"subnetDescription": "Leave empty to scan the server's own networks. Private ranges only, /22 at most. Required when Attraccess runs in a container, since its network is not your LAN.",
|
|
301
|
+
"error": "Discovery failed",
|
|
302
|
+
"running": "Probing addresses — a /24 takes a few seconds.",
|
|
303
|
+
"start": "Start discovery",
|
|
304
|
+
"found": "Found {{count}}, added {{added}}",
|
|
305
|
+
"empty": "No devices found",
|
|
306
|
+
"mdnsOnly": "no subnet (mDNS only)",
|
|
307
|
+
"probed": {
|
|
308
|
+
"one": "Probed {{count}} address in {{subnets}}.",
|
|
309
|
+
"many": "Probed {{count}} addresses in {{subnets}}."
|
|
310
|
+
},
|
|
311
|
+
"hint": "Nothing answered GET /shelly. If Attraccess runs in a container, enter the subnet your devices are on — the container's own network is not your LAN.",
|
|
312
|
+
"via": "via {{source}}",
|
|
313
|
+
"scan": "subnet scan",
|
|
314
|
+
"added": "Added",
|
|
315
|
+
"known": "Already known"
|
|
316
|
+
},
|
|
317
|
+
info: {
|
|
318
|
+
"title": "Device info",
|
|
319
|
+
"loadError": "Could not load device info",
|
|
320
|
+
"auth": "This device requires authentication. Enter its admin password to read protected info.",
|
|
321
|
+
"passwordPlaceholder": "device admin password",
|
|
322
|
+
"load": "Load info",
|
|
323
|
+
"notReported": "Not reported",
|
|
324
|
+
"on": "On",
|
|
325
|
+
"off": "Off",
|
|
326
|
+
"name": "Name",
|
|
327
|
+
"generation": "Generation",
|
|
328
|
+
"timezone": "Timezone",
|
|
329
|
+
"uptime": "Uptime",
|
|
330
|
+
"network": "Network",
|
|
331
|
+
"wifi": "Wi-Fi network",
|
|
332
|
+
"signal": "Signal",
|
|
333
|
+
"output": "Output",
|
|
334
|
+
"state": "State",
|
|
335
|
+
"power": "Power",
|
|
336
|
+
"voltage": "Voltage",
|
|
337
|
+
"current": "Current",
|
|
338
|
+
"updated": "Updated {{time}}"
|
|
339
|
+
},
|
|
340
|
+
firmware: {
|
|
341
|
+
"checking": "Checking…",
|
|
342
|
+
"unavailable": "Unavailable",
|
|
343
|
+
"available": "{{version}} available",
|
|
344
|
+
"updateAvailable": "Firmware update available: {{version}}",
|
|
345
|
+
"empty": "No firmware info loaded yet.",
|
|
346
|
+
"installed": "Installed",
|
|
347
|
+
"stable": "Stable channel",
|
|
348
|
+
"beta": "Beta channel",
|
|
349
|
+
"upToDate": "Up to date",
|
|
350
|
+
"nothingNewer": "Nothing newer",
|
|
351
|
+
"checked": "Checked",
|
|
352
|
+
"description": "Check for and install firmware updates on {{name}} ({{address}}).",
|
|
353
|
+
"error": "Firmware check failed",
|
|
354
|
+
"running": "Update running",
|
|
355
|
+
"installing": "Installing the {{stage}} firmware{{version}}. The device reboots during the update and is offline for a moment — this page keeps checking.",
|
|
356
|
+
"finished": "Update finished",
|
|
357
|
+
"success": "The device now runs {{version}}.",
|
|
358
|
+
"recheck": "Check again",
|
|
359
|
+
"installLabel": "Install {{stage}} firmware {{version}}",
|
|
360
|
+
"install": "Install {{stage}} {{version}}",
|
|
361
|
+
"stableStage": "stable",
|
|
362
|
+
"betaStage": "beta",
|
|
363
|
+
"timeout": "The device did not report the expected firmware version within 5 minutes. Check it and re-check the firmware manually."
|
|
364
|
+
},
|
|
365
|
+
common: {
|
|
366
|
+
"cancel": "Cancel",
|
|
367
|
+
"close": "Close",
|
|
368
|
+
"delete": "Delete",
|
|
369
|
+
"done": "Done",
|
|
370
|
+
"refresh": "Refresh"
|
|
371
|
+
}
|
|
195
372
|
};
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
373
|
+
var de_default = {
|
|
374
|
+
devices: {
|
|
375
|
+
"title": "Shelly-Geräte",
|
|
376
|
+
"table": "Shelly-Geräte",
|
|
377
|
+
"description": "Automatisch erkannte und manuell hinzugefügte Shelly-Geräte.",
|
|
378
|
+
"discover": "Suchen",
|
|
379
|
+
"add": "Gerät hinzufügen",
|
|
380
|
+
"loadError": "Geräte konnten nicht geladen werden",
|
|
381
|
+
"device": "Gerät",
|
|
382
|
+
"address": "Adresse",
|
|
383
|
+
"model": "Modell",
|
|
384
|
+
"auth": "Authentifizierung",
|
|
385
|
+
"firmware": "Firmware",
|
|
386
|
+
"actions": "Aktionen",
|
|
387
|
+
"unknown": "Unbekannt",
|
|
388
|
+
"generation": "Gen {{generation}}",
|
|
389
|
+
"generationPlus": "Gen {{generation}}+",
|
|
390
|
+
"empty": "Noch keine Geräte vorhanden. Starte die Suche oder füge dein erstes Shelly-Gerät über seine IP-Adresse hinzu.",
|
|
391
|
+
"probeError": "Geräteprüfung fehlgeschlagen: {{message}}",
|
|
392
|
+
"info": "Geräteinformationen anzeigen",
|
|
393
|
+
"more": "Weitere Aktionen",
|
|
394
|
+
"deviceActions": "Geräteaktionen",
|
|
395
|
+
"manageFirmware": "Firmware verwalten",
|
|
396
|
+
"password": "Admin-Passwort festlegen",
|
|
397
|
+
"reprobe": "Gerät erneut prüfen",
|
|
398
|
+
"delete": "Gerät löschen",
|
|
399
|
+
"deleteDescription": "{{name}} ({{address}}) aus der Registrierung entfernen? Das Gerät selbst wird nicht verändert."
|
|
400
|
+
},
|
|
401
|
+
auth: {
|
|
402
|
+
"none": "Keine Authentifizierung",
|
|
403
|
+
"required": "Authentifizierung erforderlich",
|
|
404
|
+
"unknown": "Unbekannt"
|
|
405
|
+
},
|
|
406
|
+
add: {
|
|
407
|
+
"title": "Gerät hinzufügen",
|
|
408
|
+
"description": "Gib die IP-Adresse des Geräts ein. Wir prüfen GET /shelly, um Generation und Modell zu erkennen.",
|
|
409
|
+
"ip": "IP-Adresse",
|
|
410
|
+
"name": "Name (optional)",
|
|
411
|
+
"placeholder": "Werkstattbeleuchtung",
|
|
412
|
+
"error": "Gerät konnte nicht hinzugefügt werden",
|
|
413
|
+
"required": "Eine IP-Adresse ist erforderlich."
|
|
414
|
+
},
|
|
415
|
+
password: {
|
|
416
|
+
"title": "Admin-Passwort",
|
|
417
|
+
"description": "Admin-Passwort von {{name}} ({{address}}) festlegen oder ändern.",
|
|
418
|
+
"current": "Aktuelles Passwort",
|
|
419
|
+
"currentDescription": "Erforderlich, da für dieses Gerät bereits die Authentifizierung aktiviert ist.",
|
|
420
|
+
"new": "Neues Admin-Passwort",
|
|
421
|
+
"newDescription": "Schützt die lokale Weboberfläche und API des Geräts.",
|
|
422
|
+
"error": "Passwort konnte nicht festgelegt werden",
|
|
423
|
+
"required": "Ein neues Passwort ist erforderlich.",
|
|
424
|
+
"save": "Passwort speichern"
|
|
425
|
+
},
|
|
426
|
+
discovery: {
|
|
427
|
+
"title": "Geräte suchen",
|
|
428
|
+
"description": "Sucht nach Shelly-Geräten, die sich über mDNS melden, und prüft anschließend jede Adresse eines Subnetzes. Gefundene Geräte werden registriert.",
|
|
429
|
+
"subnet": "Zu durchsuchendes Subnetz (optional)",
|
|
430
|
+
"subnetDescription": "Leer lassen, um die Netzwerke des Servers zu durchsuchen. Nur private Bereiche, maximal /22. Bei Attraccess in einem Container erforderlich, da dessen Netzwerk nicht dein LAN ist.",
|
|
431
|
+
"error": "Gerätesuche fehlgeschlagen",
|
|
432
|
+
"running": "Adressen werden geprüft – ein /24-Netz dauert einige Sekunden.",
|
|
433
|
+
"start": "Suche starten",
|
|
434
|
+
"found": "{{count}} gefunden, {{added}} hinzugefügt",
|
|
435
|
+
"empty": "Keine Geräte gefunden",
|
|
436
|
+
"mdnsOnly": "kein Subnetz (nur mDNS)",
|
|
437
|
+
"probed": {
|
|
438
|
+
"one": "{{count}} Adresse in {{subnets}} geprüft.",
|
|
439
|
+
"many": "{{count}} Adressen in {{subnets}} geprüft."
|
|
440
|
+
},
|
|
441
|
+
"hint": "Kein Gerät hat auf GET /shelly geantwortet. Wenn Attraccess in einem Container läuft, gib das Subnetz deiner Geräte an. Das Netzwerk des Containers ist nicht dein LAN.",
|
|
442
|
+
"via": "über {{source}}",
|
|
443
|
+
"scan": "Subnetzsuche",
|
|
444
|
+
"added": "Hinzugefügt",
|
|
445
|
+
"known": "Bereits bekannt"
|
|
446
|
+
},
|
|
447
|
+
info: {
|
|
448
|
+
"title": "Geräteinformationen",
|
|
449
|
+
"loadError": "Geräteinformationen konnten nicht geladen werden",
|
|
450
|
+
"auth": "Dieses Gerät erfordert eine Authentifizierung. Gib sein Admin-Passwort ein, um geschützte Informationen zu lesen.",
|
|
451
|
+
"passwordPlaceholder": "Admin-Passwort des Geräts",
|
|
452
|
+
"load": "Informationen laden",
|
|
453
|
+
"notReported": "Nicht gemeldet",
|
|
454
|
+
"on": "Ein",
|
|
455
|
+
"off": "Aus",
|
|
456
|
+
"name": "Name",
|
|
457
|
+
"generation": "Generation",
|
|
458
|
+
"timezone": "Zeitzone",
|
|
459
|
+
"uptime": "Betriebszeit",
|
|
460
|
+
"network": "Netzwerk",
|
|
461
|
+
"wifi": "WLAN-Netzwerk",
|
|
462
|
+
"signal": "Signal",
|
|
463
|
+
"output": "Ausgang",
|
|
464
|
+
"state": "Zustand",
|
|
465
|
+
"power": "Leistung",
|
|
466
|
+
"voltage": "Spannung",
|
|
467
|
+
"current": "Stromstärke",
|
|
468
|
+
"updated": "Aktualisiert {{time}}"
|
|
469
|
+
},
|
|
470
|
+
firmware: {
|
|
471
|
+
"checking": "Wird geprüft…",
|
|
472
|
+
"unavailable": "Nicht verfügbar",
|
|
473
|
+
"available": "{{version}} verfügbar",
|
|
474
|
+
"updateAvailable": "Firmware-Aktualisierung verfügbar: {{version}}",
|
|
475
|
+
"empty": "Noch keine Firmware-Informationen geladen.",
|
|
476
|
+
"installed": "Installiert",
|
|
477
|
+
"stable": "Stabiler Kanal",
|
|
478
|
+
"beta": "Beta-Kanal",
|
|
479
|
+
"upToDate": "Aktuell",
|
|
480
|
+
"nothingNewer": "Keine neuere Version",
|
|
481
|
+
"checked": "Geprüft",
|
|
482
|
+
"description": "Firmware-Aktualisierungen für {{name}} ({{address}}) prüfen und installieren.",
|
|
483
|
+
"error": "Firmware-Prüfung fehlgeschlagen",
|
|
484
|
+
"running": "Aktualisierung läuft",
|
|
485
|
+
"installing": "Firmware des Kanals {{stage}}{{version}} wird installiert. Das Gerät startet während der Aktualisierung neu und ist kurzzeitig offline. Diese Seite prüft weiterhin den Status.",
|
|
486
|
+
"finished": "Aktualisierung abgeschlossen",
|
|
487
|
+
"success": "Auf dem Gerät läuft jetzt {{version}}.",
|
|
488
|
+
"recheck": "Erneut prüfen",
|
|
489
|
+
"installLabel": "Firmware {{stage}} {{version}} installieren",
|
|
490
|
+
"install": "{{stage}} {{version}} installieren",
|
|
491
|
+
"stableStage": "stabil",
|
|
492
|
+
"betaStage": "Beta",
|
|
493
|
+
"timeout": "Das Gerät hat die erwartete Firmware-Version nicht innerhalb von 5 Minuten gemeldet. Prüfe das Gerät und die Firmware manuell erneut."
|
|
494
|
+
},
|
|
495
|
+
common: {
|
|
496
|
+
"cancel": "Abbrechen",
|
|
497
|
+
"close": "Schließen",
|
|
498
|
+
"delete": "Löschen",
|
|
499
|
+
"done": "Fertig",
|
|
500
|
+
"refresh": "Aktualisieren"
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
//#endregion
|
|
504
|
+
//#region frontend/src/i18n.ts
|
|
505
|
+
var { useTranslations } = await importShared("@attraccess/plugins-frontend-ui");
|
|
506
|
+
var useShellyTranslations = () => useTranslations({
|
|
507
|
+
en: en_default,
|
|
508
|
+
de: de_default
|
|
509
|
+
}, { escapeValues: false });
|
|
206
510
|
//#endregion
|
|
207
|
-
//#region frontend/src/AddDeviceDrawer.tsx
|
|
208
|
-
var {
|
|
511
|
+
//#region frontend/src/devices/AddDeviceDrawer.tsx
|
|
512
|
+
var { DrawerBody: DrawerBody$4, DrawerHeader: DrawerHeader$4, DrawerHeading: DrawerHeading$4, Form: Form$3 } = await importShared("@heroui/react");
|
|
209
513
|
var { PlusIcon: PlusIcon$1, XIcon: XIcon$4 } = await importShared("lucide-react");
|
|
210
514
|
var { useCallback: useCallback$5, useRef: useRef$2, useState: useState$5 } = await importShared("react");
|
|
515
|
+
var { Button: Button$6, StandardDrawer: StandardDrawer$4, StatusAlert: StatusAlert$5 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
211
516
|
function AddDeviceDrawer({ isOpen, onOpenChange, onAdded }) {
|
|
517
|
+
const { t, tMessage } = useShellyTranslations();
|
|
212
518
|
const [ipAddress, setIpAddress] = useState$5("");
|
|
213
519
|
const [name, setName] = useState$5("");
|
|
214
520
|
const [submitting, setSubmitting] = useState$5(false);
|
|
@@ -219,7 +525,7 @@ function AddDeviceDrawer({ isOpen, onOpenChange, onAdded }) {
|
|
|
219
525
|
if (inFlight.current) return;
|
|
220
526
|
const ip = ipAddress.trim();
|
|
221
527
|
if (!ip) {
|
|
222
|
-
setError(
|
|
528
|
+
setError({ key: "add.required" });
|
|
223
529
|
return;
|
|
224
530
|
}
|
|
225
531
|
inFlight.current = true;
|
|
@@ -246,28 +552,24 @@ function AddDeviceDrawer({ isOpen, onOpenChange, onAdded }) {
|
|
|
246
552
|
onAdded,
|
|
247
553
|
close
|
|
248
554
|
]);
|
|
249
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardDrawer, {
|
|
555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardDrawer$4, {
|
|
250
556
|
isOpen,
|
|
251
557
|
onOpenChange,
|
|
252
558
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerHeader$4, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
253
559
|
className: "sh:flex sh:w-full sh:items-start sh:justify-between sh:gap-3",
|
|
254
560
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
255
561
|
className: "sh:flex sh:flex-col sh:gap-1",
|
|
256
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
562
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerHeading$4, {
|
|
257
563
|
className: "sh:text-lg sh:font-semibold",
|
|
258
|
-
children: "
|
|
259
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.
|
|
564
|
+
children: t("add.title")
|
|
565
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
260
566
|
className: "sh:text-sm sh:text-muted",
|
|
261
|
-
children:
|
|
262
|
-
"Enter the device's IP address. We probe ",
|
|
263
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: "GET /shelly" }),
|
|
264
|
-
" to detect its generation and model."
|
|
265
|
-
]
|
|
567
|
+
children: t("add.description")
|
|
266
568
|
})]
|
|
267
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$
|
|
569
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$6, {
|
|
268
570
|
isIconOnly: true,
|
|
269
571
|
variant: "ghost",
|
|
270
|
-
"aria-label": "
|
|
572
|
+
"aria-label": t("common.close"),
|
|
271
573
|
onPress: close,
|
|
272
574
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XIcon$4, { size: 16 })
|
|
273
575
|
})]
|
|
@@ -276,7 +578,7 @@ function AddDeviceDrawer({ isOpen, onOpenChange, onAdded }) {
|
|
|
276
578
|
className: "sh:flex sh:flex-col sh:gap-4",
|
|
277
579
|
children: [
|
|
278
580
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextFieldRow, {
|
|
279
|
-
label: "
|
|
581
|
+
label: t("add.ip"),
|
|
280
582
|
value: ipAddress,
|
|
281
583
|
onChange: setIpAddress,
|
|
282
584
|
placeholder: "192.168.1.42",
|
|
@@ -284,31 +586,35 @@ function AddDeviceDrawer({ isOpen, onOpenChange, onAdded }) {
|
|
|
284
586
|
dataCy: "shelly-add-ip"
|
|
285
587
|
}),
|
|
286
588
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextFieldRow, {
|
|
287
|
-
label: "
|
|
589
|
+
label: t("add.name"),
|
|
288
590
|
value: name,
|
|
289
591
|
onChange: setName,
|
|
290
|
-
placeholder: "
|
|
592
|
+
placeholder: t("add.placeholder"),
|
|
291
593
|
dataCy: "shelly-add-name"
|
|
292
594
|
}),
|
|
293
|
-
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert, {
|
|
595
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$5, {
|
|
294
596
|
status: "danger",
|
|
295
|
-
title: "
|
|
296
|
-
|
|
297
|
-
children: error
|
|
597
|
+
title: t("add.error"),
|
|
598
|
+
"data-cy": "shelly-add-error",
|
|
599
|
+
children: tMessage(error)
|
|
298
600
|
}),
|
|
299
601
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
300
602
|
className: "sh:flex sh:justify-end sh:gap-2 sh:pt-2",
|
|
301
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$
|
|
603
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$6, {
|
|
302
604
|
variant: "secondary",
|
|
303
605
|
onPress: close,
|
|
304
|
-
children: "
|
|
305
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$
|
|
606
|
+
children: t("common.cancel")
|
|
607
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$6, {
|
|
306
608
|
variant: "primary",
|
|
307
609
|
type: "submit",
|
|
308
610
|
isPending: submitting,
|
|
309
611
|
onPress: submit,
|
|
310
612
|
"data-cy": "shelly-add-submit",
|
|
311
|
-
children: [
|
|
613
|
+
children: [
|
|
614
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlusIcon$1, { className: "sh:h-4 sh:w-4" }),
|
|
615
|
+
" ",
|
|
616
|
+
t("devices.add")
|
|
617
|
+
]
|
|
312
618
|
})]
|
|
313
619
|
}),
|
|
314
620
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
@@ -321,10 +627,12 @@ function AddDeviceDrawer({ isOpen, onOpenChange, onAdded }) {
|
|
|
321
627
|
}
|
|
322
628
|
//#endregion
|
|
323
629
|
//#region frontend/src/AdminPasswordDrawer.tsx
|
|
324
|
-
var {
|
|
630
|
+
var { DrawerBody: DrawerBody$3, DrawerFooter: DrawerFooter$2, DrawerHeader: DrawerHeader$3, DrawerHeading: DrawerHeading$3, Form: Form$2 } = await importShared("@heroui/react");
|
|
325
631
|
var { KeyRoundIcon: KeyRoundIcon$1, XIcon: XIcon$3 } = await importShared("lucide-react");
|
|
326
632
|
var { useCallback: useCallback$4, useEffect: useEffect$3, useState: useState$4 } = await importShared("react");
|
|
633
|
+
var { Button: Button$5, PasswordInput: PasswordInput$2, StandardDrawer: StandardDrawer$3, StatusAlert: StatusAlert$4 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
327
634
|
function AdminPasswordDrawer({ device, onOpenChange, onSaved }) {
|
|
635
|
+
const { t, tMessage } = useShellyTranslations();
|
|
328
636
|
const [currentPassword, setCurrentPassword] = useState$4("");
|
|
329
637
|
const [password, setPassword] = useState$4("");
|
|
330
638
|
const [submitting, setSubmitting] = useState$4(false);
|
|
@@ -341,7 +649,7 @@ function AdminPasswordDrawer({ device, onOpenChange, onSaved }) {
|
|
|
341
649
|
if (!device) return;
|
|
342
650
|
const nextPassword = password.trim();
|
|
343
651
|
if (!nextPassword) {
|
|
344
|
-
setError("
|
|
652
|
+
setError({ key: "password.required" });
|
|
345
653
|
return;
|
|
346
654
|
}
|
|
347
655
|
setSubmitting(true);
|
|
@@ -369,7 +677,7 @@ function AdminPasswordDrawer({ device, onOpenChange, onSaved }) {
|
|
|
369
677
|
event.preventDefault();
|
|
370
678
|
submit();
|
|
371
679
|
}, [submit]);
|
|
372
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardDrawer, {
|
|
680
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardDrawer$3, {
|
|
373
681
|
isOpen: !!device,
|
|
374
682
|
onOpenChange,
|
|
375
683
|
children: [
|
|
@@ -379,24 +687,21 @@ function AdminPasswordDrawer({ device, onOpenChange, onSaved }) {
|
|
|
379
687
|
className: "sh:flex sh:min-w-0 sh:flex-col sh:gap-1",
|
|
380
688
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
381
689
|
className: "sh:flex sh:items-center sh:gap-2",
|
|
382
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(KeyRoundIcon$1, { className: "sh:h-5 sh:w-5 sh:shrink-0 sh:text-accent-soft-foreground" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
690
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(KeyRoundIcon$1, { className: "sh:h-5 sh:w-5 sh:shrink-0 sh:text-accent-soft-foreground" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerHeading$3, {
|
|
383
691
|
className: "sh:text-lg sh:font-semibold",
|
|
384
|
-
children: "
|
|
692
|
+
children: t("password.title")
|
|
385
693
|
})]
|
|
386
|
-
}), device && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
694
|
+
}), device && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
387
695
|
className: "sh:text-sm sh:text-muted",
|
|
388
|
-
children:
|
|
389
|
-
|
|
390
|
-
device.
|
|
391
|
-
|
|
392
|
-
device.ipAddress,
|
|
393
|
-
")."
|
|
394
|
-
]
|
|
696
|
+
children: t("password.description", {
|
|
697
|
+
name: device.name,
|
|
698
|
+
address: device.ipAddress
|
|
699
|
+
})
|
|
395
700
|
})]
|
|
396
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$
|
|
701
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$5, {
|
|
397
702
|
isIconOnly: true,
|
|
398
703
|
variant: "ghost",
|
|
399
|
-
"aria-label": "
|
|
704
|
+
"aria-label": t("common.close"),
|
|
400
705
|
onPress: close,
|
|
401
706
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XIcon$3, { size: 16 })
|
|
402
707
|
})]
|
|
@@ -405,28 +710,28 @@ function AdminPasswordDrawer({ device, onOpenChange, onSaved }) {
|
|
|
405
710
|
onSubmit,
|
|
406
711
|
className: "sh:flex sh:flex-col sh:gap-4",
|
|
407
712
|
children: [
|
|
408
|
-
device?.authState === "required" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
409
|
-
label: "
|
|
713
|
+
device?.authState === "required" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PasswordInput$2, {
|
|
714
|
+
label: t("password.current"),
|
|
410
715
|
value: currentPassword,
|
|
411
716
|
onChange: setCurrentPassword,
|
|
412
|
-
description: "
|
|
717
|
+
description: t("password.currentDescription"),
|
|
413
718
|
autoComplete: "current-password",
|
|
414
|
-
|
|
719
|
+
"data-cy": "shelly-auth-current-password"
|
|
415
720
|
}),
|
|
416
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
417
|
-
label: "
|
|
721
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PasswordInput$2, {
|
|
722
|
+
label: t("password.new"),
|
|
418
723
|
value: password,
|
|
419
724
|
onChange: setPassword,
|
|
420
|
-
description: "
|
|
421
|
-
|
|
725
|
+
description: t("password.newDescription"),
|
|
726
|
+
isRequired: true,
|
|
422
727
|
autoComplete: "new-password",
|
|
423
|
-
|
|
728
|
+
"data-cy": "shelly-auth-password"
|
|
424
729
|
}),
|
|
425
|
-
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert, {
|
|
730
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$4, {
|
|
426
731
|
status: "danger",
|
|
427
|
-
title: "
|
|
428
|
-
|
|
429
|
-
children: error
|
|
732
|
+
title: t("password.error"),
|
|
733
|
+
"data-cy": "shelly-auth-error",
|
|
734
|
+
children: tMessage(error)
|
|
430
735
|
}),
|
|
431
736
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
432
737
|
type: "submit",
|
|
@@ -434,28 +739,35 @@ function AdminPasswordDrawer({ device, onOpenChange, onSaved }) {
|
|
|
434
739
|
})
|
|
435
740
|
]
|
|
436
741
|
}) }),
|
|
437
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DrawerFooter$2, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$
|
|
742
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DrawerFooter$2, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$5, {
|
|
438
743
|
variant: "secondary",
|
|
439
744
|
onPress: close,
|
|
440
|
-
children: "
|
|
441
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$
|
|
745
|
+
children: t("common.cancel")
|
|
746
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$5, {
|
|
442
747
|
variant: "primary",
|
|
443
748
|
isPending: submitting,
|
|
444
749
|
onPress: () => void submit(),
|
|
445
750
|
"data-cy": "shelly-auth-submit",
|
|
446
|
-
children: [
|
|
751
|
+
children: [
|
|
752
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(KeyRoundIcon$1, { className: "sh:h-4 sh:w-4" }),
|
|
753
|
+
" ",
|
|
754
|
+
t("password.save")
|
|
755
|
+
]
|
|
447
756
|
})] })
|
|
448
757
|
]
|
|
449
758
|
});
|
|
450
759
|
}
|
|
451
760
|
//#endregion
|
|
452
|
-
//#region frontend/src/DeviceInfoDrawer.tsx
|
|
453
|
-
var { Button: Button$
|
|
454
|
-
var {
|
|
761
|
+
//#region frontend/src/devices/info/DeviceInfoDrawer.tsx
|
|
762
|
+
var { Button: Button$4, PasswordInput: PasswordInput$1, StandardDrawer: StandardDrawer$2, StatusAlert: StatusAlert$3, useDateTimeFormatter: useDateTimeFormatter$1 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
763
|
+
var { Card, DrawerBody: DrawerBody$2, DrawerFooter: DrawerFooter$1, DrawerHeader: DrawerHeader$2, DrawerHeading: DrawerHeading$2, Form: Form$1, Skeleton } = await importShared("@heroui/react");
|
|
764
|
+
var { InfoIcon: InfoIcon$1, RefreshCwIcon: RefreshCwIcon$2, XIcon: XIcon$2 } = await importShared("lucide-react");
|
|
455
765
|
var { useCallback: useCallback$3, useEffect: useEffect$2, useState: useState$3 } = await importShared("react");
|
|
456
|
-
function
|
|
457
|
-
if (
|
|
458
|
-
|
|
766
|
+
function formatInfoValue(value, t, language, suffix = "") {
|
|
767
|
+
if (value === void 0 || value === null || value === "") return t("info.notReported");
|
|
768
|
+
if (typeof value === "boolean") return t(value ? "info.on" : "info.off");
|
|
769
|
+
if (typeof value === "number") return `${value.toLocaleString(language, { maximumFractionDigits: 1 })}${suffix}`;
|
|
770
|
+
return String(value);
|
|
459
771
|
}
|
|
460
772
|
function isRecord(value) {
|
|
461
773
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -472,14 +784,8 @@ function firstValue(source, paths) {
|
|
|
472
784
|
if (value !== void 0 && value !== null && value !== "") return value;
|
|
473
785
|
}
|
|
474
786
|
}
|
|
475
|
-
function
|
|
476
|
-
if (
|
|
477
|
-
if (typeof value === "boolean") return value ? "On" : "Off";
|
|
478
|
-
if (typeof value === "number") return `${Number.isInteger(value) ? value : value.toFixed(1)}${suffix}`;
|
|
479
|
-
return String(value);
|
|
480
|
-
}
|
|
481
|
-
function formatUptime(seconds) {
|
|
482
|
-
if (typeof seconds !== "number") return formatValue(seconds);
|
|
787
|
+
function formatUptime(seconds, t, language) {
|
|
788
|
+
if (typeof seconds !== "number") return formatInfoValue(seconds, t, language);
|
|
483
789
|
const days = Math.floor(seconds / 86400);
|
|
484
790
|
const hours = Math.floor(seconds % 86400 / 3600);
|
|
485
791
|
const minutes = Math.floor(seconds % 3600 / 60);
|
|
@@ -487,60 +793,9 @@ function formatUptime(seconds) {
|
|
|
487
793
|
if (hours > 0) return `${hours}h ${minutes}m`;
|
|
488
794
|
return `${minutes}m`;
|
|
489
795
|
}
|
|
490
|
-
function AuthProtectedForm({ authState, currentPassword, onChange, loading, onLoad }) {
|
|
491
|
-
const [visible, setVisible] = useState$3(false);
|
|
492
|
-
if (authState !== "required") return null;
|
|
493
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
494
|
-
className: "sh:rounded-md sh:border-l-4 sh:border-l-warning sh:bg-warning/5 sh:p-4",
|
|
495
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Form$1, {
|
|
496
|
-
onSubmit: (e) => {
|
|
497
|
-
e.preventDefault();
|
|
498
|
-
onLoad();
|
|
499
|
-
},
|
|
500
|
-
className: "sh:flex sh:flex-col sh:gap-3",
|
|
501
|
-
children: [
|
|
502
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
503
|
-
className: "sh:text-sm",
|
|
504
|
-
children: "This device requires authentication. Enter its admin password to read protected info."
|
|
505
|
-
}),
|
|
506
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
507
|
-
className: "sh:relative",
|
|
508
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextFieldRow, {
|
|
509
|
-
label: "Admin password",
|
|
510
|
-
value: currentPassword,
|
|
511
|
-
onChange,
|
|
512
|
-
placeholder: "device admin password",
|
|
513
|
-
dataCy: "shelly-info-current-password"
|
|
514
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$3, {
|
|
515
|
-
isIconOnly: true,
|
|
516
|
-
variant: "ghost",
|
|
517
|
-
size: "sm",
|
|
518
|
-
"aria-label": visible ? "Hide password" : "Show password",
|
|
519
|
-
className: "sh:absolute sh:right-1 sh:top-6",
|
|
520
|
-
onPress: () => setVisible((v) => !v),
|
|
521
|
-
children: visible ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EyeOffIcon, { className: "sh:h-4 sh:w-4" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EyeIcon, { className: "sh:h-4 sh:w-4" })
|
|
522
|
-
})]
|
|
523
|
-
}),
|
|
524
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
525
|
-
className: "sh:flex sh:justify-end",
|
|
526
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$3, {
|
|
527
|
-
variant: "primary",
|
|
528
|
-
size: "sm",
|
|
529
|
-
isPending: loading,
|
|
530
|
-
onPress: onLoad,
|
|
531
|
-
"data-cy": "shelly-info-unlock",
|
|
532
|
-
children: "Load info"
|
|
533
|
-
})
|
|
534
|
-
}),
|
|
535
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
536
|
-
type: "submit",
|
|
537
|
-
hidden: true
|
|
538
|
-
})
|
|
539
|
-
]
|
|
540
|
-
})
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
796
|
function DeviceInfoCards({ info }) {
|
|
797
|
+
const { t, language } = useShellyTranslations();
|
|
798
|
+
const formatValue = (value, suffix = "") => formatInfoValue(value, t, language, suffix);
|
|
544
799
|
const status = info.status;
|
|
545
800
|
const config = info.config;
|
|
546
801
|
const output = firstValue(status, [
|
|
@@ -557,10 +812,10 @@ function DeviceInfoCards({ info }) {
|
|
|
557
812
|
const current = firstValue(status, ["switch:0.current", "meters.0.current"]);
|
|
558
813
|
const cards = [
|
|
559
814
|
{
|
|
560
|
-
title: "
|
|
815
|
+
title: t("devices.device"),
|
|
561
816
|
rows: [
|
|
562
817
|
{
|
|
563
|
-
label: "
|
|
818
|
+
label: t("info.name"),
|
|
564
819
|
value: formatValue(firstValue(config, [
|
|
565
820
|
"sys.device.name",
|
|
566
821
|
"name",
|
|
@@ -568,24 +823,24 @@ function DeviceInfoCards({ info }) {
|
|
|
568
823
|
]))
|
|
569
824
|
},
|
|
570
825
|
{
|
|
571
|
-
label: "
|
|
572
|
-
value:
|
|
826
|
+
label: t("info.generation"),
|
|
827
|
+
value: info.generation === null ? t("devices.unknown") : t(info.generation === 1 ? "devices.generation" : "devices.generationPlus", { generation: info.generation })
|
|
573
828
|
},
|
|
574
829
|
{
|
|
575
|
-
label: "
|
|
830
|
+
label: t("info.timezone"),
|
|
576
831
|
value: formatValue(firstValue(config, ["sys.location.tz", "timezone"]))
|
|
577
832
|
},
|
|
578
833
|
{
|
|
579
|
-
label: "
|
|
580
|
-
value: formatUptime(firstValue(status, ["sys.uptime", "uptime"]))
|
|
834
|
+
label: t("info.uptime"),
|
|
835
|
+
value: formatUptime(firstValue(status, ["sys.uptime", "uptime"]), t, language)
|
|
581
836
|
}
|
|
582
837
|
]
|
|
583
838
|
},
|
|
584
839
|
{
|
|
585
|
-
title: "
|
|
840
|
+
title: t("info.network"),
|
|
586
841
|
rows: [
|
|
587
842
|
{
|
|
588
|
-
label: "
|
|
843
|
+
label: t("add.ip"),
|
|
589
844
|
value: formatValue(firstValue(status, [
|
|
590
845
|
"wifi.sta_ip",
|
|
591
846
|
"wifi_sta.ip",
|
|
@@ -593,7 +848,7 @@ function DeviceInfoCards({ info }) {
|
|
|
593
848
|
]))
|
|
594
849
|
},
|
|
595
850
|
{
|
|
596
|
-
label: "
|
|
851
|
+
label: t("info.wifi"),
|
|
597
852
|
value: formatValue(firstValue(status, [
|
|
598
853
|
"wifi.ssid",
|
|
599
854
|
"wifi_sta.ssid",
|
|
@@ -601,28 +856,28 @@ function DeviceInfoCards({ info }) {
|
|
|
601
856
|
]))
|
|
602
857
|
},
|
|
603
858
|
{
|
|
604
|
-
label: "
|
|
859
|
+
label: t("info.signal"),
|
|
605
860
|
value: formatValue(firstValue(status, ["wifi.rssi", "wifi_sta.rssi"]), " dBm")
|
|
606
861
|
}
|
|
607
862
|
]
|
|
608
863
|
},
|
|
609
864
|
{
|
|
610
|
-
title: "
|
|
865
|
+
title: t("info.output"),
|
|
611
866
|
rows: [
|
|
612
867
|
{
|
|
613
|
-
label: "
|
|
868
|
+
label: t("info.state"),
|
|
614
869
|
value: formatValue(output)
|
|
615
870
|
},
|
|
616
871
|
{
|
|
617
|
-
label: "
|
|
872
|
+
label: t("info.power"),
|
|
618
873
|
value: formatValue(power, " W")
|
|
619
874
|
},
|
|
620
875
|
{
|
|
621
|
-
label: "
|
|
876
|
+
label: t("info.voltage"),
|
|
622
877
|
value: formatValue(voltage, " V")
|
|
623
878
|
},
|
|
624
879
|
{
|
|
625
|
-
label: "
|
|
880
|
+
label: t("info.current"),
|
|
626
881
|
value: formatValue(current, " A")
|
|
627
882
|
}
|
|
628
883
|
]
|
|
@@ -652,7 +907,55 @@ function DeviceInfoCards({ info }) {
|
|
|
652
907
|
}) })] }, card.title))
|
|
653
908
|
});
|
|
654
909
|
}
|
|
910
|
+
function AuthProtectedForm({ authState, currentPassword, onChange, loading, onLoad }) {
|
|
911
|
+
const { t } = useShellyTranslations();
|
|
912
|
+
if (authState !== "required") return null;
|
|
913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
914
|
+
className: "sh:rounded-md sh:border-l-4 sh:border-l-warning sh:bg-warning/5 sh:p-4",
|
|
915
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Form$1, {
|
|
916
|
+
onSubmit: (e) => {
|
|
917
|
+
e.preventDefault();
|
|
918
|
+
onLoad();
|
|
919
|
+
},
|
|
920
|
+
className: "sh:flex sh:flex-col sh:gap-3",
|
|
921
|
+
children: [
|
|
922
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
923
|
+
className: "sh:text-sm",
|
|
924
|
+
children: t("info.auth")
|
|
925
|
+
}),
|
|
926
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PasswordInput$1, {
|
|
927
|
+
label: t("password.title"),
|
|
928
|
+
value: currentPassword,
|
|
929
|
+
onChange,
|
|
930
|
+
placeholder: t("info.passwordPlaceholder"),
|
|
931
|
+
autoComplete: "current-password",
|
|
932
|
+
"data-cy": "shelly-info-current-password"
|
|
933
|
+
}),
|
|
934
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
935
|
+
className: "sh:flex sh:justify-end",
|
|
936
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
|
|
937
|
+
variant: "primary",
|
|
938
|
+
size: "sm",
|
|
939
|
+
isPending: loading,
|
|
940
|
+
onPress: onLoad,
|
|
941
|
+
"data-cy": "shelly-info-unlock",
|
|
942
|
+
children: t("info.load")
|
|
943
|
+
})
|
|
944
|
+
}),
|
|
945
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
946
|
+
type: "submit",
|
|
947
|
+
hidden: true
|
|
948
|
+
})
|
|
949
|
+
]
|
|
950
|
+
})
|
|
951
|
+
});
|
|
952
|
+
}
|
|
655
953
|
function DeviceInfoDrawer({ device, onOpenChange }) {
|
|
954
|
+
const { t } = useShellyTranslations();
|
|
955
|
+
const formatDateTime = useDateTimeFormatter$1({
|
|
956
|
+
showDate: false,
|
|
957
|
+
showSeconds: true
|
|
958
|
+
});
|
|
656
959
|
const [info, setInfo] = useState$3(null);
|
|
657
960
|
const [currentPassword, setCurrentPassword] = useState$3("");
|
|
658
961
|
const [loading, setLoading] = useState$3(false);
|
|
@@ -680,7 +983,7 @@ function DeviceInfoDrawer({ device, onOpenChange }) {
|
|
|
680
983
|
useEffect$2(() => {
|
|
681
984
|
if (device && device.authState !== "required") load();
|
|
682
985
|
}, [device]);
|
|
683
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardDrawer, {
|
|
986
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardDrawer$2, {
|
|
684
987
|
isOpen: !!device,
|
|
685
988
|
onOpenChange,
|
|
686
989
|
children: [
|
|
@@ -690,18 +993,18 @@ function DeviceInfoDrawer({ device, onOpenChange }) {
|
|
|
690
993
|
className: "sh:flex sh:min-w-0 sh:flex-col sh:gap-1",
|
|
691
994
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
692
995
|
className: "sh:flex sh:items-center sh:gap-2",
|
|
693
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(InfoIcon$1, { className: "sh:h-5 sh:w-5 sh:shrink-0 sh:text-accent-soft-foreground" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
996
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(InfoIcon$1, { className: "sh:h-5 sh:w-5 sh:shrink-0 sh:text-accent-soft-foreground" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerHeading$2, {
|
|
694
997
|
className: "sh:text-lg sh:font-semibold",
|
|
695
|
-
children: device?.name ?? "
|
|
998
|
+
children: device?.name ?? t("info.title")
|
|
696
999
|
})]
|
|
697
1000
|
}), device && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
698
1001
|
className: "sh:text-sm sh:text-muted",
|
|
699
1002
|
children: device.ipAddress
|
|
700
1003
|
})]
|
|
701
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$
|
|
1004
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
|
|
702
1005
|
isIconOnly: true,
|
|
703
1006
|
variant: "ghost",
|
|
704
|
-
"aria-label": "
|
|
1007
|
+
"aria-label": t("common.close"),
|
|
705
1008
|
onPress: close,
|
|
706
1009
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XIcon$2, { size: 16 })
|
|
707
1010
|
})]
|
|
@@ -716,9 +1019,9 @@ function DeviceInfoDrawer({ device, onOpenChange }) {
|
|
|
716
1019
|
loading,
|
|
717
1020
|
onLoad: () => void load()
|
|
718
1021
|
}),
|
|
719
|
-
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert, {
|
|
1022
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$3, {
|
|
720
1023
|
status: "danger",
|
|
721
|
-
title: "
|
|
1024
|
+
title: t("info.loadError"),
|
|
722
1025
|
children: error
|
|
723
1026
|
}),
|
|
724
1027
|
loading && !info ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
@@ -736,13 +1039,17 @@ function DeviceInfoDrawer({ device, onOpenChange }) {
|
|
|
736
1039
|
className: "sh:flex sh:w-full sh:items-center sh:justify-between sh:gap-3",
|
|
737
1040
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
738
1041
|
className: "sh:text-xs sh:text-default-500",
|
|
739
|
-
children: info ?
|
|
740
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$
|
|
1042
|
+
children: info ? t("info.updated", { time: formatDateTime(info.fetchedAt) }) : ""
|
|
1043
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$4, {
|
|
741
1044
|
variant: "secondary",
|
|
742
1045
|
onPress: () => void load(),
|
|
743
1046
|
isPending: loading,
|
|
744
1047
|
"data-cy": "shelly-info-refresh",
|
|
745
|
-
children: [
|
|
1048
|
+
children: [
|
|
1049
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RefreshCwIcon$2, { className: "sh:h-4 sh:w-4" }),
|
|
1050
|
+
" ",
|
|
1051
|
+
t("common.refresh")
|
|
1052
|
+
]
|
|
746
1053
|
})]
|
|
747
1054
|
}) })
|
|
748
1055
|
]
|
|
@@ -750,36 +1057,32 @@ function DeviceInfoDrawer({ device, onOpenChange }) {
|
|
|
750
1057
|
}
|
|
751
1058
|
//#endregion
|
|
752
1059
|
//#region frontend/src/DiscoverDrawer.tsx
|
|
753
|
-
var { Button: Button$
|
|
1060
|
+
var { Button: Button$3, StandardDrawer: StandardDrawer$1, StatusAlert: StatusAlert$2 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
1061
|
+
var { Chip: Chip$2, DrawerBody: DrawerBody$1, DrawerHeader: DrawerHeader$1, DrawerHeading: DrawerHeading$1, Form, Spinner: Spinner$1 } = await importShared("@heroui/react");
|
|
754
1062
|
var { SearchIcon: SearchIcon$1, XIcon: XIcon$1 } = await importShared("lucide-react");
|
|
755
1063
|
var { useCallback: useCallback$2, useRef: useRef$1, useState: useState$2 } = await importShared("react");
|
|
756
1064
|
function ResultSummary({ result }) {
|
|
1065
|
+
const { t } = useShellyTranslations();
|
|
757
1066
|
const added = result.devices.filter((device) => device.isNew).length;
|
|
758
|
-
const scanned = result.subnets.length > 0 ? result.subnets.join(", ") : "
|
|
1067
|
+
const scanned = result.subnets.length > 0 ? result.subnets.join(", ") : t("discovery.mdnsOnly");
|
|
759
1068
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
760
1069
|
className: "sh:flex sh:flex-col sh:gap-3",
|
|
761
1070
|
"data-cy": "shelly-discover-result",
|
|
762
1071
|
children: [
|
|
763
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
1072
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$2, {
|
|
764
1073
|
status: result.devices.length > 0 ? "success" : "warning",
|
|
765
|
-
title: result.devices.length > 0 ?
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
result.probed
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
"."
|
|
774
|
-
]
|
|
1074
|
+
title: result.devices.length > 0 ? t("discovery.found", {
|
|
1075
|
+
count: result.devices.length,
|
|
1076
|
+
added
|
|
1077
|
+
}) : t("discovery.empty"),
|
|
1078
|
+
children: t("discovery.probed", {
|
|
1079
|
+
count: result.probed,
|
|
1080
|
+
subnets: scanned
|
|
1081
|
+
})
|
|
775
1082
|
}),
|
|
776
|
-
result.devices.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
1083
|
+
result.devices.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
777
1084
|
className: "sh:text-sm sh:text-muted",
|
|
778
|
-
children:
|
|
779
|
-
"Nothing answered ",
|
|
780
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: "GET /shelly" }),
|
|
781
|
-
". If Attraccess runs in a container, enter the subnet your devices are on — the container's own network is not your LAN."
|
|
782
|
-
]
|
|
1085
|
+
children: t("discovery.hint")
|
|
783
1086
|
}),
|
|
784
1087
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
|
|
785
1088
|
className: "sh:flex sh:flex-col sh:gap-2",
|
|
@@ -795,16 +1098,17 @@ function ResultSummary({ result }) {
|
|
|
795
1098
|
className: "sh:text-xs sh:text-muted",
|
|
796
1099
|
children: [
|
|
797
1100
|
device.ipAddress,
|
|
798
|
-
" ·
|
|
799
|
-
device.generation,
|
|
800
|
-
" ·
|
|
801
|
-
|
|
1101
|
+
" · ",
|
|
1102
|
+
t("devices.generation", { generation: device.generation }),
|
|
1103
|
+
" ·",
|
|
1104
|
+
" ",
|
|
1105
|
+
t("discovery.via", { source: device.source === "mdns" ? "mDNS" : t("discovery.scan") })
|
|
802
1106
|
]
|
|
803
1107
|
})]
|
|
804
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip$
|
|
1108
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip$2, {
|
|
805
1109
|
variant: "soft",
|
|
806
1110
|
color: device.isNew ? "success" : "default",
|
|
807
|
-
children: device.isNew ? "
|
|
1111
|
+
children: t(device.isNew ? "discovery.added" : "discovery.known")
|
|
808
1112
|
})]
|
|
809
1113
|
}, device.deviceId))
|
|
810
1114
|
})
|
|
@@ -812,6 +1116,7 @@ function ResultSummary({ result }) {
|
|
|
812
1116
|
});
|
|
813
1117
|
}
|
|
814
1118
|
function DiscoverDrawer({ isOpen, onOpenChange, onDiscovered }) {
|
|
1119
|
+
const { t } = useShellyTranslations();
|
|
815
1120
|
const [cidr, setCidr] = useState$2("");
|
|
816
1121
|
const [running, setRunning] = useState$2(false);
|
|
817
1122
|
const [error, setError] = useState$2(null);
|
|
@@ -835,24 +1140,24 @@ function DiscoverDrawer({ isOpen, onOpenChange, onDiscovered }) {
|
|
|
835
1140
|
setRunning(false);
|
|
836
1141
|
}
|
|
837
1142
|
}, [cidr, onDiscovered]);
|
|
838
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardDrawer, {
|
|
1143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardDrawer$1, {
|
|
839
1144
|
isOpen,
|
|
840
1145
|
onOpenChange,
|
|
841
1146
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerHeader$1, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
842
1147
|
className: "sh:flex sh:w-full sh:items-start sh:justify-between sh:gap-3",
|
|
843
1148
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
844
1149
|
className: "sh:flex sh:flex-col sh:gap-1",
|
|
845
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1150
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerHeading$1, {
|
|
846
1151
|
className: "sh:text-lg sh:font-semibold",
|
|
847
|
-
children: "
|
|
1152
|
+
children: t("discovery.title")
|
|
848
1153
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
849
1154
|
className: "sh:text-sm sh:text-muted",
|
|
850
|
-
children: "
|
|
1155
|
+
children: t("discovery.description")
|
|
851
1156
|
})]
|
|
852
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$
|
|
1157
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$3, {
|
|
853
1158
|
isIconOnly: true,
|
|
854
1159
|
variant: "ghost",
|
|
855
|
-
"aria-label": "
|
|
1160
|
+
"aria-label": t("common.close"),
|
|
856
1161
|
onPress: close,
|
|
857
1162
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XIcon$1, { size: 16 })
|
|
858
1163
|
})]
|
|
@@ -861,40 +1166,44 @@ function DiscoverDrawer({ isOpen, onOpenChange, onDiscovered }) {
|
|
|
861
1166
|
className: "sh:flex sh:flex-col sh:gap-4",
|
|
862
1167
|
children: [
|
|
863
1168
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextFieldRow, {
|
|
864
|
-
label: "
|
|
1169
|
+
label: t("discovery.subnet"),
|
|
865
1170
|
value: cidr,
|
|
866
1171
|
onChange: setCidr,
|
|
867
1172
|
placeholder: "192.168.1.0/24",
|
|
868
|
-
description: "
|
|
1173
|
+
description: t("discovery.subnetDescription"),
|
|
869
1174
|
dataCy: "shelly-discover-cidr"
|
|
870
1175
|
}),
|
|
871
|
-
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert, {
|
|
1176
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$2, {
|
|
872
1177
|
status: "danger",
|
|
873
|
-
title: "
|
|
874
|
-
|
|
1178
|
+
title: t("discovery.error"),
|
|
1179
|
+
"data-cy": "shelly-discover-error",
|
|
875
1180
|
children: error
|
|
876
1181
|
}),
|
|
877
1182
|
running && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
878
1183
|
className: "sh:flex sh:items-center sh:gap-3 sh:text-sm sh:text-muted",
|
|
879
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner$
|
|
1184
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner$1, {
|
|
880
1185
|
color: "accent",
|
|
881
1186
|
size: "sm"
|
|
882
|
-
}), "
|
|
1187
|
+
}), t("discovery.running")]
|
|
883
1188
|
}),
|
|
884
1189
|
result && !running && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResultSummary, { result }),
|
|
885
1190
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
886
1191
|
className: "sh:flex sh:justify-end sh:gap-2 sh:pt-2",
|
|
887
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$
|
|
1192
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$3, {
|
|
888
1193
|
variant: "secondary",
|
|
889
1194
|
onPress: close,
|
|
890
|
-
children: result ? "
|
|
891
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$
|
|
1195
|
+
children: t(result ? "common.done" : "common.cancel")
|
|
1196
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$3, {
|
|
892
1197
|
variant: "primary",
|
|
893
1198
|
type: "submit",
|
|
894
1199
|
isPending: running,
|
|
895
1200
|
onPress: submit,
|
|
896
1201
|
"data-cy": "shelly-discover-submit",
|
|
897
|
-
children: [
|
|
1202
|
+
children: [
|
|
1203
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SearchIcon$1, { className: "sh:h-4 sh:w-4" }),
|
|
1204
|
+
" ",
|
|
1205
|
+
t("discovery.start")
|
|
1206
|
+
]
|
|
898
1207
|
})]
|
|
899
1208
|
}),
|
|
900
1209
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
@@ -906,45 +1215,138 @@ function DiscoverDrawer({ isOpen, onOpenChange, onDiscovered }) {
|
|
|
906
1215
|
});
|
|
907
1216
|
}
|
|
908
1217
|
//#endregion
|
|
909
|
-
//#region frontend/src/
|
|
910
|
-
var { Button: Button$1, DrawerBody, DrawerFooter, DrawerHeader, Spinner: Spinner$1, Tooltip: Tooltip$1 } = await importShared("@heroui/react");
|
|
911
|
-
var { ArrowUpCircleIcon, CpuIcon: CpuIcon$1, DownloadIcon, RefreshCwIcon: RefreshCwIcon$1, XIcon } = await importShared("lucide-react");
|
|
1218
|
+
//#region frontend/src/devices/firmware/useFirmwareDrawerState.tsx
|
|
912
1219
|
var { useCallback: useCallback$1, useEffect: useEffect$1, useRef, useState: useState$1 } = await importShared("react");
|
|
913
|
-
var POLL_INTERVAL_MS = 5e3;
|
|
914
1220
|
var UPDATE_TIMEOUT_MS = 3e5;
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
1221
|
+
function useFirmwareDrawerState({ device, onOpenChange, onUpdated }) {
|
|
1222
|
+
const { t, tMessage } = useShellyTranslations();
|
|
1223
|
+
const [status, setStatus] = useState$1(null);
|
|
1224
|
+
const [currentPassword, setCurrentPassword] = useState$1("");
|
|
1225
|
+
const [loading, setLoading] = useState$1(false);
|
|
1226
|
+
const [error, setError] = useState$1(null);
|
|
1227
|
+
const [installing, setInstalling] = useState$1(null);
|
|
1228
|
+
const [installedVersion, setInstalledVersion] = useState$1(null);
|
|
1229
|
+
const targetVersion = useRef(null);
|
|
1230
|
+
const deadline = useRef(0);
|
|
1231
|
+
const close = useCallback$1(() => onOpenChange(false), [onOpenChange]);
|
|
1232
|
+
const fetchStatus = useCallback$1(async () => {
|
|
1233
|
+
if (!device) return null;
|
|
1234
|
+
return getFirmware(device.id, { currentPassword: currentPassword || void 0 });
|
|
1235
|
+
}, [device, currentPassword]);
|
|
1236
|
+
const load = useCallback$1(async () => {
|
|
1237
|
+
if (!device) return;
|
|
1238
|
+
setLoading(true);
|
|
1239
|
+
setError(null);
|
|
1240
|
+
try {
|
|
1241
|
+
setStatus(await fetchStatus());
|
|
1242
|
+
} catch (err) {
|
|
1243
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
1244
|
+
} finally {
|
|
1245
|
+
setLoading(false);
|
|
1246
|
+
}
|
|
1247
|
+
}, [device, fetchStatus]);
|
|
1248
|
+
useEffect$1(() => {
|
|
1249
|
+
if (!device) return;
|
|
1250
|
+
setStatus(null);
|
|
1251
|
+
setInstalling(null);
|
|
1252
|
+
setInstalledVersion(null);
|
|
1253
|
+
setError(null);
|
|
1254
|
+
load();
|
|
1255
|
+
}, [device]);
|
|
1256
|
+
const install = useCallback$1(async (stage) => {
|
|
1257
|
+
if (!device) return;
|
|
1258
|
+
setError(null);
|
|
1259
|
+
setInstalling(stage);
|
|
1260
|
+
targetVersion.current = status?.available[stage] ?? null;
|
|
1261
|
+
deadline.current = Date.now() + UPDATE_TIMEOUT_MS;
|
|
1262
|
+
try {
|
|
1263
|
+
await startFirmwareUpdate(device.id, {
|
|
1264
|
+
stage,
|
|
1265
|
+
currentPassword: currentPassword || void 0
|
|
1266
|
+
});
|
|
1267
|
+
} catch (err) {
|
|
1268
|
+
setInstalling(null);
|
|
1269
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
1270
|
+
}
|
|
1271
|
+
}, [
|
|
1272
|
+
currentPassword,
|
|
1273
|
+
device,
|
|
1274
|
+
status
|
|
1275
|
+
]);
|
|
1276
|
+
usePluginLiveUpdates({
|
|
1277
|
+
plugin: "shelly",
|
|
1278
|
+
topic: "firmware",
|
|
1279
|
+
identifier: String(device?.id),
|
|
1280
|
+
enabled: !!installing && !!device,
|
|
1281
|
+
onUpdate: (event) => {
|
|
1282
|
+
if (event.eventType !== "snapshot") return;
|
|
1283
|
+
const next = event.value;
|
|
1284
|
+
setStatus(next);
|
|
1285
|
+
if ((targetVersion.current ? next.currentVersion === targetVersion.current : !next.hasUpdate) && next.state !== "updating" && next.state !== "pending") {
|
|
1286
|
+
setInstalling(null);
|
|
1287
|
+
setInstalledVersion(next.currentVersion);
|
|
1288
|
+
onUpdated();
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
useEffect$1(() => {
|
|
1293
|
+
if (!installing || !device) return;
|
|
1294
|
+
const timeout = setTimeout(() => {
|
|
1295
|
+
setInstalling(null);
|
|
1296
|
+
setError({ key: "firmware.timeout" });
|
|
1297
|
+
}, Math.max(0, deadline.current - Date.now()));
|
|
1298
|
+
return () => clearTimeout(timeout);
|
|
1299
|
+
}, [installing, device]);
|
|
1300
|
+
return {
|
|
1301
|
+
t,
|
|
1302
|
+
tMessage,
|
|
1303
|
+
status,
|
|
1304
|
+
currentPassword,
|
|
1305
|
+
setCurrentPassword,
|
|
1306
|
+
loading,
|
|
1307
|
+
error,
|
|
1308
|
+
installing,
|
|
1309
|
+
installedVersion,
|
|
1310
|
+
targetVersion,
|
|
1311
|
+
close,
|
|
1312
|
+
load,
|
|
1313
|
+
install,
|
|
1314
|
+
stages: ["stable", "beta"],
|
|
1315
|
+
device,
|
|
1316
|
+
onOpenChange
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
//#endregion
|
|
1320
|
+
//#region frontend/src/devices/firmware/FirmwareDrawer.tsx
|
|
1321
|
+
var { Button: Button$2, EmptyState: EmptyState$1, PasswordInput, StandardDrawer, StatusAlert: StatusAlert$1, TableDataLoadingIndicator: TableDataLoadingIndicator$1, useDateTimeFormatter } = await importShared("@attraccess/plugins-frontend-ui");
|
|
1322
|
+
var { DrawerBody, DrawerFooter, DrawerHeader, DrawerHeading, Spinner, Tooltip: Tooltip$1 } = await importShared("@heroui/react");
|
|
1323
|
+
var { ArrowUpCircleIcon, CpuIcon: CpuIcon$1, DownloadIcon, RefreshCwIcon: RefreshCwIcon$1, XIcon } = await importShared("lucide-react");
|
|
923
1324
|
function shortVersion(version) {
|
|
924
1325
|
const tail = version.split("/").pop();
|
|
925
1326
|
return tail && tail.length > 0 ? tail : version;
|
|
926
1327
|
}
|
|
927
1328
|
/** Table cell summarising a device's firmware state from the bulk overview. */
|
|
928
1329
|
function FirmwareCell({ entry }) {
|
|
1330
|
+
const { t } = useShellyTranslations();
|
|
929
1331
|
if (!entry) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
930
1332
|
className: "sh:text-sm sh:text-default-400",
|
|
931
|
-
children: "
|
|
1333
|
+
children: t("firmware.checking")
|
|
932
1334
|
});
|
|
933
1335
|
if (entry.error || !entry.status) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
934
1336
|
className: "sh:block sh:max-w-40 sh:truncate sh:text-sm sh:text-default-400",
|
|
935
1337
|
title: entry.error ?? void 0,
|
|
936
|
-
children: "
|
|
1338
|
+
children: t("firmware.unavailable")
|
|
937
1339
|
});
|
|
938
1340
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
939
1341
|
className: "sh:flex sh:flex-col sh:gap-1",
|
|
940
1342
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
941
1343
|
className: "sh:block sh:max-w-40 sh:truncate sh:text-sm sh:text-default-700",
|
|
942
1344
|
title: entry.status.currentVersion ?? void 0,
|
|
943
|
-
children: entry.status.currentVersion ? shortVersion(entry.status.currentVersion) : "
|
|
944
|
-
}), entry.status.hasUpdate && entry.status.available.stable && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
1345
|
+
children: entry.status.currentVersion ? shortVersion(entry.status.currentVersion) : t("devices.unknown")
|
|
1346
|
+
}), entry.status.hasUpdate && entry.status.available.stable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
945
1347
|
className: "sh:max-w-40 sh:truncate sh:text-xs sh:text-warning-600",
|
|
946
1348
|
title: entry.status.available.stable,
|
|
947
|
-
children:
|
|
1349
|
+
children: t("firmware.available", { version: shortVersion(entry.status.available.stable) })
|
|
948
1350
|
})]
|
|
949
1351
|
});
|
|
950
1352
|
}
|
|
@@ -955,10 +1357,11 @@ function FirmwareCell({ entry }) {
|
|
|
955
1357
|
* table's visible width on tablets.
|
|
956
1358
|
*/
|
|
957
1359
|
function UpdateAvailableIndicator({ entry }) {
|
|
1360
|
+
const { t } = useShellyTranslations();
|
|
958
1361
|
const version = entry?.status?.hasUpdate ? entry.status.available.stable : null;
|
|
959
1362
|
if (!version) return null;
|
|
960
|
-
const label =
|
|
961
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tooltip$1, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$
|
|
1363
|
+
const label = t("firmware.updateAvailable", { version: shortVersion(version) });
|
|
1364
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tooltip$1, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip$1.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
|
|
962
1365
|
variant: "ghost",
|
|
963
1366
|
size: "sm",
|
|
964
1367
|
isIconOnly: true,
|
|
@@ -982,119 +1385,38 @@ function VersionRow({ label, value }) {
|
|
|
982
1385
|
});
|
|
983
1386
|
}
|
|
984
1387
|
function FirmwareDetails({ status }) {
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
});
|
|
1388
|
+
const { t } = useShellyTranslations();
|
|
1389
|
+
const formatDateTime = useDateTimeFormatter({ showSeconds: true });
|
|
1390
|
+
if (!status) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyState$1, { message: t("firmware.empty") });
|
|
989
1391
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
|
|
990
1392
|
className: "sh:rounded-xl sh:border sh:border-default-200 sh:bg-surface sh:p-4",
|
|
991
1393
|
"data-cy": "shelly-firmware-details",
|
|
992
1394
|
children: [
|
|
993
1395
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(VersionRow, {
|
|
994
|
-
label: "
|
|
995
|
-
value: status.currentVersion ?? "
|
|
1396
|
+
label: t("firmware.installed"),
|
|
1397
|
+
value: status.currentVersion ?? t("devices.unknown")
|
|
996
1398
|
}),
|
|
997
1399
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(VersionRow, {
|
|
998
|
-
label: "
|
|
999
|
-
value: status.available.stable ?? "
|
|
1400
|
+
label: t("firmware.stable"),
|
|
1401
|
+
value: status.available.stable ?? t("firmware.upToDate")
|
|
1000
1402
|
}),
|
|
1001
1403
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(VersionRow, {
|
|
1002
|
-
label: "
|
|
1003
|
-
value: status.available.beta ?? "
|
|
1404
|
+
label: t("firmware.beta"),
|
|
1405
|
+
value: status.available.beta ?? t("firmware.nothingNewer")
|
|
1004
1406
|
}),
|
|
1005
1407
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(VersionRow, {
|
|
1006
|
-
label: "
|
|
1007
|
-
value:
|
|
1408
|
+
label: t("firmware.checked"),
|
|
1409
|
+
value: String(formatDateTime(status.fetchedAt))
|
|
1008
1410
|
})
|
|
1009
1411
|
]
|
|
1010
1412
|
});
|
|
1011
1413
|
}
|
|
1012
1414
|
function FirmwareDrawer({ device, onOpenChange, onUpdated }) {
|
|
1013
|
-
const
|
|
1014
|
-
const [currentPassword, setCurrentPassword] = useState$1("");
|
|
1015
|
-
const [loading, setLoading] = useState$1(false);
|
|
1016
|
-
const [error, setError] = useState$1(null);
|
|
1017
|
-
const [installing, setInstalling] = useState$1(null);
|
|
1018
|
-
const [installedVersion, setInstalledVersion] = useState$1(null);
|
|
1019
|
-
const targetVersion = useRef(null);
|
|
1020
|
-
const deadline = useRef(0);
|
|
1021
|
-
const close = useCallback$1(() => onOpenChange(false), [onOpenChange]);
|
|
1022
|
-
const fetchStatus = useCallback$1(async () => {
|
|
1023
|
-
if (!device) return null;
|
|
1024
|
-
return getFirmware(device.id, { currentPassword: currentPassword || void 0 });
|
|
1025
|
-
}, [device, currentPassword]);
|
|
1026
|
-
const load = useCallback$1(async () => {
|
|
1027
|
-
if (!device) return;
|
|
1028
|
-
setLoading(true);
|
|
1029
|
-
setError(null);
|
|
1030
|
-
try {
|
|
1031
|
-
setStatus(await fetchStatus());
|
|
1032
|
-
} catch (err) {
|
|
1033
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
1034
|
-
} finally {
|
|
1035
|
-
setLoading(false);
|
|
1036
|
-
}
|
|
1037
|
-
}, [device, fetchStatus]);
|
|
1038
|
-
useEffect$1(() => {
|
|
1039
|
-
if (!device) return;
|
|
1040
|
-
setStatus(null);
|
|
1041
|
-
setInstalling(null);
|
|
1042
|
-
setInstalledVersion(null);
|
|
1043
|
-
setError(null);
|
|
1044
|
-
load();
|
|
1045
|
-
}, [device]);
|
|
1046
|
-
const install = useCallback$1(async (stage) => {
|
|
1047
|
-
if (!device) return;
|
|
1048
|
-
setError(null);
|
|
1049
|
-
setInstalling(stage);
|
|
1050
|
-
targetVersion.current = status?.available[stage] ?? null;
|
|
1051
|
-
deadline.current = Date.now() + UPDATE_TIMEOUT_MS;
|
|
1052
|
-
try {
|
|
1053
|
-
await startFirmwareUpdate(device.id, {
|
|
1054
|
-
stage,
|
|
1055
|
-
currentPassword: currentPassword || void 0
|
|
1056
|
-
});
|
|
1057
|
-
} catch (err) {
|
|
1058
|
-
setInstalling(null);
|
|
1059
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
1060
|
-
}
|
|
1061
|
-
}, [
|
|
1062
|
-
currentPassword,
|
|
1415
|
+
const { t, tMessage, status, currentPassword, setCurrentPassword, loading, error, installing, installedVersion, targetVersion, close, load, install, stages } = useFirmwareDrawerState({
|
|
1063
1416
|
device,
|
|
1064
|
-
|
|
1065
|
-
]);
|
|
1066
|
-
useEffect$1(() => {
|
|
1067
|
-
if (!installing || !device) return;
|
|
1068
|
-
let cancelled = false;
|
|
1069
|
-
const poll = async () => {
|
|
1070
|
-
if (cancelled) return;
|
|
1071
|
-
if (Date.now() > deadline.current) {
|
|
1072
|
-
setInstalling(null);
|
|
1073
|
-
setError("The device did not report the expected firmware version within 5 minutes. Check it and re-check the firmware manually.");
|
|
1074
|
-
return;
|
|
1075
|
-
}
|
|
1076
|
-
try {
|
|
1077
|
-
const next = await fetchStatus();
|
|
1078
|
-
if (cancelled || !next) return;
|
|
1079
|
-
setStatus(next);
|
|
1080
|
-
if ((targetVersion.current ? next.currentVersion === targetVersion.current : !next.hasUpdate) && next.state !== "updating" && next.state !== "pending") {
|
|
1081
|
-
setInstalling(null);
|
|
1082
|
-
setInstalledVersion(next.currentVersion);
|
|
1083
|
-
onUpdated();
|
|
1084
|
-
}
|
|
1085
|
-
} catch {}
|
|
1086
|
-
};
|
|
1087
|
-
const timer = setInterval(poll, POLL_INTERVAL_MS);
|
|
1088
|
-
return () => {
|
|
1089
|
-
cancelled = true;
|
|
1090
|
-
clearInterval(timer);
|
|
1091
|
-
};
|
|
1092
|
-
}, [
|
|
1093
|
-
installing,
|
|
1094
|
-
device,
|
|
1095
|
-
fetchStatus,
|
|
1417
|
+
onOpenChange,
|
|
1096
1418
|
onUpdated
|
|
1097
|
-
|
|
1419
|
+
});
|
|
1098
1420
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardDrawer, {
|
|
1099
1421
|
isOpen: !!device,
|
|
1100
1422
|
onOpenChange,
|
|
@@ -1105,24 +1427,21 @@ function FirmwareDrawer({ device, onOpenChange, onUpdated }) {
|
|
|
1105
1427
|
className: "sh:flex sh:min-w-0 sh:flex-col sh:gap-1",
|
|
1106
1428
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1107
1429
|
className: "sh:flex sh:items-center sh:gap-2",
|
|
1108
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CpuIcon$1, { className: "sh:h-5 sh:w-5 sh:shrink-0 sh:text-accent-soft-foreground" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1430
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CpuIcon$1, { className: "sh:h-5 sh:w-5 sh:shrink-0 sh:text-accent-soft-foreground" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerHeading, {
|
|
1109
1431
|
className: "sh:text-lg sh:font-semibold",
|
|
1110
|
-
children: "
|
|
1432
|
+
children: t("devices.firmware")
|
|
1111
1433
|
})]
|
|
1112
|
-
}), device && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
1434
|
+
}), device && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
1113
1435
|
className: "sh:text-sm sh:text-muted",
|
|
1114
|
-
children:
|
|
1115
|
-
|
|
1116
|
-
device.
|
|
1117
|
-
|
|
1118
|
-
device.ipAddress,
|
|
1119
|
-
")."
|
|
1120
|
-
]
|
|
1436
|
+
children: t("firmware.description", {
|
|
1437
|
+
name: device.name,
|
|
1438
|
+
address: device.ipAddress
|
|
1439
|
+
})
|
|
1121
1440
|
})]
|
|
1122
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$
|
|
1441
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
|
|
1123
1442
|
isIconOnly: true,
|
|
1124
1443
|
variant: "ghost",
|
|
1125
|
-
"aria-label": "
|
|
1444
|
+
"aria-label": t("common.close"),
|
|
1126
1445
|
onPress: close,
|
|
1127
1446
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XIcon, { size: 16 })
|
|
1128
1447
|
})]
|
|
@@ -1130,80 +1449,77 @@ function FirmwareDrawer({ device, onOpenChange, onUpdated }) {
|
|
|
1130
1449
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DrawerBody, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1131
1450
|
className: "sh:flex sh:flex-col sh:gap-4",
|
|
1132
1451
|
children: [
|
|
1133
|
-
device?.authState === "required" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1134
|
-
label: "
|
|
1452
|
+
device?.authState === "required" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PasswordInput, {
|
|
1453
|
+
label: t("password.current"),
|
|
1135
1454
|
value: currentPassword,
|
|
1136
1455
|
onChange: setCurrentPassword,
|
|
1137
|
-
description: "
|
|
1456
|
+
description: t("password.currentDescription"),
|
|
1138
1457
|
autoComplete: "current-password",
|
|
1139
|
-
|
|
1458
|
+
"data-cy": "shelly-firmware-current-password"
|
|
1140
1459
|
}),
|
|
1141
|
-
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert, {
|
|
1460
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$1, {
|
|
1142
1461
|
status: "danger",
|
|
1143
|
-
title: "
|
|
1144
|
-
|
|
1145
|
-
children: error
|
|
1462
|
+
title: t("firmware.error"),
|
|
1463
|
+
"data-cy": "shelly-firmware-error",
|
|
1464
|
+
children: tMessage(error)
|
|
1146
1465
|
}),
|
|
1147
|
-
installing && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert, {
|
|
1466
|
+
installing && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$1, {
|
|
1148
1467
|
status: "accent",
|
|
1149
|
-
title: "
|
|
1150
|
-
|
|
1468
|
+
title: t("firmware.running"),
|
|
1469
|
+
"data-cy": "shelly-firmware-progress",
|
|
1151
1470
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
1152
1471
|
className: "sh:flex sh:items-center sh:gap-2",
|
|
1153
|
-
children: [
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
}),
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
" firmware",
|
|
1161
|
-
targetVersion.current ? ` (${targetVersion.current})` : "",
|
|
1162
|
-
". The device reboots during the update and is offline for a moment — this page keeps checking."
|
|
1163
|
-
]
|
|
1472
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {
|
|
1473
|
+
size: "sm",
|
|
1474
|
+
color: "accent"
|
|
1475
|
+
}), t("firmware.installing", {
|
|
1476
|
+
stage: t(`firmware.${installing}Stage`),
|
|
1477
|
+
version: targetVersion.current ? ` (${targetVersion.current})` : ""
|
|
1478
|
+
})]
|
|
1164
1479
|
})
|
|
1165
1480
|
}),
|
|
1166
|
-
installedVersion && !installing && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
1481
|
+
installedVersion && !installing && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$1, {
|
|
1167
1482
|
status: "success",
|
|
1168
|
-
title: "
|
|
1169
|
-
|
|
1170
|
-
children:
|
|
1171
|
-
"The device now runs ",
|
|
1172
|
-
installedVersion,
|
|
1173
|
-
"."
|
|
1174
|
-
]
|
|
1483
|
+
title: t("firmware.finished"),
|
|
1484
|
+
"data-cy": "shelly-firmware-success",
|
|
1485
|
+
children: t("firmware.success", { version: installedVersion })
|
|
1175
1486
|
}),
|
|
1176
|
-
loading && !status ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1177
|
-
className: "sh:flex sh:items-center sh:justify-center sh:p-6",
|
|
1178
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner$1, { color: "accent" })
|
|
1179
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FirmwareDetails, { status })
|
|
1487
|
+
loading && !status ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableDataLoadingIndicator$1, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FirmwareDetails, { status })
|
|
1180
1488
|
]
|
|
1181
1489
|
}) }),
|
|
1182
1490
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DrawerFooter, {
|
|
1183
1491
|
className: "sh:flex-wrap",
|
|
1184
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$
|
|
1492
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$2, {
|
|
1185
1493
|
variant: "secondary",
|
|
1186
1494
|
onPress: load,
|
|
1187
1495
|
isPending: loading,
|
|
1188
1496
|
isDisabled: !!installing,
|
|
1189
1497
|
"data-cy": "shelly-firmware-refresh",
|
|
1190
|
-
children: [
|
|
1191
|
-
|
|
1498
|
+
children: [
|
|
1499
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RefreshCwIcon$1, { className: "sh:h-4 sh:w-4" }),
|
|
1500
|
+
" ",
|
|
1501
|
+
t("firmware.recheck")
|
|
1502
|
+
]
|
|
1503
|
+
}), stages.map((stage) => {
|
|
1192
1504
|
const version = status?.available[stage];
|
|
1193
1505
|
if (!version) return null;
|
|
1194
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$
|
|
1506
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$2, {
|
|
1195
1507
|
variant: stage === "stable" ? "primary" : "secondary",
|
|
1196
1508
|
onPress: () => install(stage),
|
|
1197
1509
|
isPending: installing === stage,
|
|
1198
1510
|
isDisabled: !!installing,
|
|
1199
1511
|
"data-cy": `shelly-firmware-install-${stage}`,
|
|
1200
|
-
"aria-label":
|
|
1512
|
+
"aria-label": t("firmware.installLabel", {
|
|
1513
|
+
stage: t(`firmware.${stage}Stage`),
|
|
1514
|
+
version
|
|
1515
|
+
}),
|
|
1201
1516
|
children: [
|
|
1202
1517
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DownloadIcon, { className: "sh:h-4 sh:w-4" }),
|
|
1203
|
-
" Install ",
|
|
1204
|
-
STAGE_LABEL[stage],
|
|
1205
1518
|
" ",
|
|
1206
|
-
|
|
1519
|
+
t("firmware.install", {
|
|
1520
|
+
stage: t(`firmware.${stage}Stage`),
|
|
1521
|
+
version: shortVersion(version)
|
|
1522
|
+
})
|
|
1207
1523
|
]
|
|
1208
1524
|
}, stage);
|
|
1209
1525
|
})]
|
|
@@ -1212,123 +1528,181 @@ function FirmwareDrawer({ device, onOpenChange, onUpdated }) {
|
|
|
1212
1528
|
});
|
|
1213
1529
|
}
|
|
1214
1530
|
//#endregion
|
|
1215
|
-
//#region frontend/src/
|
|
1216
|
-
var { Button
|
|
1217
|
-
var {
|
|
1218
|
-
var {
|
|
1219
|
-
function generationLabel(generation) {
|
|
1220
|
-
if (generation === null) return "Unknown";
|
|
1221
|
-
return generation === 1 ? "Gen 1" : `Gen ${generation}+`;
|
|
1222
|
-
}
|
|
1531
|
+
//#region frontend/src/devices/DeviceRowParts.tsx
|
|
1532
|
+
var { Button: Button$1 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
1533
|
+
var { Chip: Chip$1, Dropdown, DropdownItem, DropdownMenu, DropdownPopover, DropdownTrigger, Tooltip } = await importShared("@heroui/react");
|
|
1534
|
+
var { CpuIcon, InfoIcon, KeyRoundIcon, MoreVerticalIcon, RefreshCwIcon, Trash2Icon, TriangleAlertIcon } = await importShared("lucide-react");
|
|
1223
1535
|
function AuthChip({ state }) {
|
|
1224
|
-
const {
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
}
|
|
1229
|
-
required: {
|
|
1230
|
-
color: "warning",
|
|
1231
|
-
label: "Auth required"
|
|
1232
|
-
},
|
|
1233
|
-
unknown: {
|
|
1234
|
-
color: "default",
|
|
1235
|
-
label: "Unknown"
|
|
1236
|
-
}
|
|
1536
|
+
const { t } = useShellyTranslations();
|
|
1537
|
+
const { color } = {
|
|
1538
|
+
none: { color: "success" },
|
|
1539
|
+
required: { color: "warning" },
|
|
1540
|
+
unknown: { color: "default" }
|
|
1237
1541
|
}[state];
|
|
1238
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip, {
|
|
1542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip$1, {
|
|
1239
1543
|
variant: "soft",
|
|
1240
1544
|
color,
|
|
1241
1545
|
size: "sm",
|
|
1242
1546
|
className: "sh:whitespace-nowrap",
|
|
1243
|
-
children:
|
|
1547
|
+
children: t(`auth.${state}`)
|
|
1244
1548
|
});
|
|
1245
1549
|
}
|
|
1246
1550
|
function ProbeErrorIndicator({ message }) {
|
|
1247
|
-
|
|
1551
|
+
const { t } = useShellyTranslations();
|
|
1552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
|
|
1248
1553
|
variant: "ghost",
|
|
1249
1554
|
size: "sm",
|
|
1250
1555
|
isIconOnly: true,
|
|
1251
|
-
"aria-label":
|
|
1556
|
+
"aria-label": t("devices.probeError", { message }),
|
|
1252
1557
|
className: "sh:h-6 sh:w-6 sh:min-w-6 sh:text-warning",
|
|
1253
1558
|
"data-cy": "shelly-device-probe-error",
|
|
1254
1559
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TriangleAlertIcon, { className: "sh:h-4 sh:w-4" })
|
|
1255
|
-
}) }), /* @__PURE__ */ (0, import_jsx_runtime.
|
|
1560
|
+
}) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip.Content, { children: t("devices.probeError", { message }) })] });
|
|
1256
1561
|
}
|
|
1257
1562
|
function RowActions({ deviceId, isBusy, onInfo, onFirmware, onAuth, onReprobe, onDelete }) {
|
|
1563
|
+
const { t } = useShellyTranslations();
|
|
1258
1564
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1259
1565
|
className: "sh:flex sh:flex-row sh:items-center sh:justify-end sh:gap-1 sh:whitespace-nowrap",
|
|
1260
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
|
|
1566
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
|
|
1261
1567
|
variant: "ghost",
|
|
1262
1568
|
size: "sm",
|
|
1263
1569
|
isIconOnly: true,
|
|
1264
|
-
"aria-label": "
|
|
1570
|
+
"aria-label": t("devices.info"),
|
|
1265
1571
|
isDisabled: isBusy,
|
|
1266
1572
|
onPress: onInfo,
|
|
1267
1573
|
"data-cy": `shelly-device-info-${deviceId}`,
|
|
1268
1574
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InfoIcon, { className: "sh:h-4 sh:w-4" })
|
|
1269
|
-
}) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip.Content, { children: "
|
|
1575
|
+
}) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip.Content, { children: t("devices.info") })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Dropdown, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
|
|
1270
1576
|
variant: "ghost",
|
|
1271
1577
|
size: "sm",
|
|
1272
1578
|
isIconOnly: true,
|
|
1273
|
-
"aria-label": "
|
|
1579
|
+
"aria-label": t("devices.more"),
|
|
1274
1580
|
isPending: isBusy,
|
|
1275
1581
|
"data-cy": `shelly-device-menu-${deviceId}`,
|
|
1276
1582
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MoreVerticalIcon, { className: "sh:h-4 sh:w-4" })
|
|
1277
1583
|
}) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownPopover, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownMenu, {
|
|
1278
|
-
"aria-label": "
|
|
1584
|
+
"aria-label": t("devices.deviceActions"),
|
|
1279
1585
|
children: [
|
|
1280
1586
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownItem, {
|
|
1281
1587
|
id: "firmware",
|
|
1282
1588
|
onPress: onFirmware,
|
|
1283
1589
|
"data-cy": `shelly-device-firmware-${deviceId}`,
|
|
1284
|
-
children: [
|
|
1590
|
+
children: [
|
|
1591
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CpuIcon, { className: "sh:mr-2 sh:inline sh:h-4 sh:w-4" }),
|
|
1592
|
+
" ",
|
|
1593
|
+
t("devices.manageFirmware")
|
|
1594
|
+
]
|
|
1285
1595
|
}),
|
|
1286
1596
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownItem, {
|
|
1287
1597
|
id: "auth",
|
|
1288
1598
|
onPress: onAuth,
|
|
1289
1599
|
"data-cy": `shelly-device-auth-${deviceId}`,
|
|
1290
|
-
children: [
|
|
1600
|
+
children: [
|
|
1601
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(KeyRoundIcon, { className: "sh:mr-2 sh:inline sh:h-4 sh:w-4" }),
|
|
1602
|
+
" ",
|
|
1603
|
+
t("devices.password")
|
|
1604
|
+
]
|
|
1291
1605
|
}),
|
|
1292
1606
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownItem, {
|
|
1293
1607
|
id: "reprobe",
|
|
1294
1608
|
onPress: onReprobe,
|
|
1295
1609
|
"data-cy": `shelly-device-reprobe-${deviceId}`,
|
|
1296
|
-
children: [
|
|
1610
|
+
children: [
|
|
1611
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RefreshCwIcon, { className: "sh:mr-2 sh:inline sh:h-4 sh:w-4" }),
|
|
1612
|
+
" ",
|
|
1613
|
+
t("devices.reprobe")
|
|
1614
|
+
]
|
|
1297
1615
|
}),
|
|
1298
1616
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DropdownItem, {
|
|
1299
1617
|
id: "delete",
|
|
1300
1618
|
onPress: onDelete,
|
|
1301
1619
|
className: "sh:text-danger",
|
|
1302
1620
|
"data-cy": `shelly-device-delete-${deviceId}`,
|
|
1303
|
-
children: [
|
|
1621
|
+
children: [
|
|
1622
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trash2Icon, { className: "sh:mr-2 sh:inline sh:h-4 sh:w-4" }),
|
|
1623
|
+
" ",
|
|
1624
|
+
t("devices.delete")
|
|
1625
|
+
]
|
|
1304
1626
|
})
|
|
1305
1627
|
]
|
|
1306
1628
|
}) })] })]
|
|
1307
1629
|
});
|
|
1308
1630
|
}
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1631
|
+
//#endregion
|
|
1632
|
+
//#region frontend/src/renderDevicesPageDevicesRows.tsx
|
|
1633
|
+
var { Chip, TableCell, TableRow } = await importShared("@heroui/react");
|
|
1634
|
+
function renderDevicesPageDevicesRows(device, { firmware, t, rowBusyId, setInfoDevice, setFirmwareDevice, setAuthDevice, withRowBusy, setDeleteTarget }) {
|
|
1635
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableRow, {
|
|
1636
|
+
id: device.id,
|
|
1637
|
+
"data-cy": `shelly-device-row-${device.id}`,
|
|
1312
1638
|
children: [
|
|
1313
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
1314
|
-
|
|
1315
|
-
|
|
1639
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableCell, {
|
|
1640
|
+
className: "sh:whitespace-nowrap",
|
|
1641
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1642
|
+
className: "sh:flex sh:items-center sh:gap-1",
|
|
1643
|
+
children: [
|
|
1644
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1645
|
+
className: "sh:max-w-36 sh:truncate sh:font-medium sh:text-default-800 sh:sm:max-w-48",
|
|
1646
|
+
title: device.name,
|
|
1647
|
+
children: device.name
|
|
1648
|
+
}),
|
|
1649
|
+
device.lastProbeError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProbeErrorIndicator, { message: device.lastProbeError }),
|
|
1650
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(UpdateAvailableIndicator, { entry: firmware[device.id] })
|
|
1651
|
+
]
|
|
1652
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1653
|
+
className: "sh:text-xs sh:text-default-500 sh:sm:hidden sh:md:block sh:lg:hidden",
|
|
1654
|
+
children: device.ipAddress
|
|
1655
|
+
})]
|
|
1316
1656
|
}),
|
|
1317
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1318
|
-
className: "sh:
|
|
1319
|
-
children:
|
|
1657
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
|
|
1658
|
+
className: "sh:hidden sh:whitespace-nowrap sh:text-default-600 sh:sm:table-cell sh:md:hidden sh:lg:table-cell",
|
|
1659
|
+
children: device.ipAddress
|
|
1320
1660
|
}),
|
|
1321
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1661
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
|
|
1662
|
+
className: "sh:hidden sh:whitespace-nowrap sh:lg:table-cell",
|
|
1663
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1664
|
+
className: "sh:flex sh:items-center sh:gap-1.5",
|
|
1665
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1666
|
+
className: "sh:max-w-36 sh:truncate",
|
|
1667
|
+
title: device.model ?? void 0,
|
|
1668
|
+
children: device.model ?? "—"
|
|
1669
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip, {
|
|
1670
|
+
variant: "soft",
|
|
1671
|
+
size: "sm",
|
|
1672
|
+
className: "sh:whitespace-nowrap",
|
|
1673
|
+
children: device.generation === null ? t("devices.unknown") : t(device.generation === 1 ? "devices.generation" : "devices.generationPlus", { generation: device.generation })
|
|
1674
|
+
})]
|
|
1675
|
+
})
|
|
1676
|
+
}),
|
|
1677
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
|
|
1678
|
+
className: "sh:hidden sh:whitespace-nowrap sh:sm:table-cell",
|
|
1679
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AuthChip, { state: device.authState })
|
|
1680
|
+
}),
|
|
1681
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
|
|
1682
|
+
className: "sh:hidden sh:whitespace-nowrap sh:xl:table-cell",
|
|
1683
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FirmwareCell, { entry: firmware[device.id] })
|
|
1684
|
+
}),
|
|
1685
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
|
|
1686
|
+
className: "sh:whitespace-nowrap",
|
|
1687
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RowActions, {
|
|
1688
|
+
deviceId: device.id,
|
|
1689
|
+
isBusy: rowBusyId === device.id,
|
|
1690
|
+
onInfo: () => setInfoDevice(device),
|
|
1691
|
+
onFirmware: () => setFirmwareDevice(device),
|
|
1692
|
+
onAuth: () => setAuthDevice(device),
|
|
1693
|
+
onReprobe: () => withRowBusy(device.id, () => reprobeDevice(device.id)),
|
|
1694
|
+
onDelete: () => setDeleteTarget(device)
|
|
1695
|
+
})
|
|
1327
1696
|
})
|
|
1328
1697
|
]
|
|
1329
|
-
});
|
|
1698
|
+
}, device.id);
|
|
1330
1699
|
}
|
|
1331
|
-
|
|
1700
|
+
//#endregion
|
|
1701
|
+
//#region frontend/src/useDevicesPageState.tsx
|
|
1702
|
+
var { useOverlayState } = await importShared("@heroui/react");
|
|
1703
|
+
var { useCallback, useEffect, useState } = await importShared("react");
|
|
1704
|
+
function useDevicesPageState() {
|
|
1705
|
+
const { t, language } = useShellyTranslations();
|
|
1332
1706
|
const [devices, setDevices] = useState([]);
|
|
1333
1707
|
const [loading, setLoading] = useState(true);
|
|
1334
1708
|
const [pageError, setPageError] = useState(null);
|
|
@@ -1369,165 +1743,154 @@ function DevicesPage() {
|
|
|
1369
1743
|
useEffect(() => {
|
|
1370
1744
|
refresh();
|
|
1371
1745
|
}, [refresh]);
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1746
|
+
return {
|
|
1747
|
+
t,
|
|
1748
|
+
language,
|
|
1749
|
+
devices,
|
|
1750
|
+
loading,
|
|
1751
|
+
pageError,
|
|
1752
|
+
rowBusyId,
|
|
1753
|
+
infoDevice,
|
|
1754
|
+
setInfoDevice,
|
|
1755
|
+
authDevice,
|
|
1756
|
+
setAuthDevice,
|
|
1757
|
+
firmwareDevice,
|
|
1758
|
+
setFirmwareDevice,
|
|
1759
|
+
firmware,
|
|
1760
|
+
deleteTarget,
|
|
1761
|
+
setDeleteTarget,
|
|
1762
|
+
deleting,
|
|
1763
|
+
addDrawer,
|
|
1764
|
+
discoverDrawer,
|
|
1765
|
+
refreshFirmware,
|
|
1766
|
+
refresh,
|
|
1767
|
+
withRowBusy: useCallback(async (id, action) => {
|
|
1768
|
+
setRowBusyId(id);
|
|
1769
|
+
try {
|
|
1770
|
+
await action();
|
|
1771
|
+
await refresh();
|
|
1772
|
+
} catch (err) {
|
|
1773
|
+
setPageError(err instanceof Error ? err.message : String(err));
|
|
1774
|
+
} finally {
|
|
1775
|
+
setRowBusyId(null);
|
|
1776
|
+
}
|
|
1777
|
+
}, [refresh]),
|
|
1778
|
+
confirmDelete: useCallback(async () => {
|
|
1779
|
+
if (!deleteTarget) return;
|
|
1780
|
+
setDeleting(true);
|
|
1781
|
+
try {
|
|
1782
|
+
await deleteDevice(deleteTarget.id);
|
|
1783
|
+
await refresh();
|
|
1784
|
+
setDeleteTarget(null);
|
|
1785
|
+
} catch (err) {
|
|
1786
|
+
setPageError(err instanceof Error ? err.message : String(err));
|
|
1787
|
+
setDeleteTarget(null);
|
|
1788
|
+
} finally {
|
|
1789
|
+
setDeleting(false);
|
|
1790
|
+
}
|
|
1791
|
+
}, [deleteTarget, refresh])
|
|
1792
|
+
};
|
|
1793
|
+
}
|
|
1794
|
+
//#endregion
|
|
1795
|
+
//#region frontend/src/devices/DevicesPage.tsx
|
|
1796
|
+
var { Button, EmptyState, PageHeader, StatusAlert, StatusDialog, TableDataLoadingIndicator } = await importShared("@attraccess/plugins-frontend-ui");
|
|
1797
|
+
var { Table, TableBody, TableColumn, TableContent, TableHeader, TableScrollContainer } = await importShared("@heroui/react");
|
|
1798
|
+
var { PlusIcon, SearchIcon, WifiIcon: WifiIcon$1 } = await importShared("lucide-react");
|
|
1799
|
+
function EmptyDevices({ onAdd }) {
|
|
1800
|
+
const { t } = useShellyTranslations();
|
|
1801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1802
|
+
className: "sh:flex sh:flex-col sh:items-center sh:justify-center sh:gap-3 sh:pb-6",
|
|
1803
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyState, { message: t("devices.empty") }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
|
|
1804
|
+
variant: "secondary",
|
|
1805
|
+
size: "sm",
|
|
1806
|
+
onPress: onAdd,
|
|
1807
|
+
"data-cy": "shelly-add-open-empty",
|
|
1808
|
+
children: [
|
|
1809
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlusIcon, { className: "sh:h-4 sh:w-4" }),
|
|
1810
|
+
" ",
|
|
1811
|
+
t("devices.add")
|
|
1812
|
+
]
|
|
1813
|
+
})]
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
function DevicesPage() {
|
|
1817
|
+
const { t, language, devices, loading, pageError, rowBusyId, infoDevice, setInfoDevice, authDevice, setAuthDevice, firmwareDevice, setFirmwareDevice, firmware, deleteTarget, setDeleteTarget, deleting, addDrawer, discoverDrawer, refreshFirmware, refresh, withRowBusy, confirmDelete } = useDevicesPageState();
|
|
1397
1818
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1398
1819
|
className: "sh:mx-auto sh:flex sh:w-full sh:max-w-5xl sh:flex-col sh:gap-6 sh:p-4 sh:md:p-6",
|
|
1399
1820
|
children: [
|
|
1400
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
onPress: addDrawer.open,
|
|
1421
|
-
"data-cy": "shelly-add-open",
|
|
1422
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlusIcon, { className: "sh:h-4 sh:w-4" }), " Add device"]
|
|
1423
|
-
})]
|
|
1424
|
-
})]
|
|
1821
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, {
|
|
1822
|
+
noMargin: true,
|
|
1823
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WifiIcon$1, { className: "sh:h-6 sh:w-6 sh:text-accent-soft-foreground" }),
|
|
1824
|
+
title: t("devices.title"),
|
|
1825
|
+
subtitle: t("devices.description"),
|
|
1826
|
+
actions: [{
|
|
1827
|
+
key: "discover",
|
|
1828
|
+
label: t("devices.discover"),
|
|
1829
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SearchIcon, { className: "sh:h-4 sh:w-4" }),
|
|
1830
|
+
variant: "secondary",
|
|
1831
|
+
onPress: discoverDrawer.open,
|
|
1832
|
+
dataCy: "shelly-discover-open"
|
|
1833
|
+
}, {
|
|
1834
|
+
key: "add",
|
|
1835
|
+
label: t("devices.add"),
|
|
1836
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlusIcon, { className: "sh:h-4 sh:w-4" }),
|
|
1837
|
+
variant: "primary",
|
|
1838
|
+
onPress: addDrawer.open,
|
|
1839
|
+
dataCy: "shelly-add-open"
|
|
1840
|
+
}]
|
|
1425
1841
|
}),
|
|
1426
1842
|
pageError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert, {
|
|
1427
1843
|
status: "danger",
|
|
1428
|
-
title: "
|
|
1844
|
+
title: t("devices.loadError"),
|
|
1429
1845
|
children: pageError
|
|
1430
1846
|
}),
|
|
1431
|
-
loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1432
|
-
className: "sh:flex sh:items-center sh:justify-center sh:p-6",
|
|
1433
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, { color: "accent" })
|
|
1434
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Table, {
|
|
1847
|
+
loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableDataLoadingIndicator, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Table, {
|
|
1435
1848
|
"data-cy": "shelly-device-table",
|
|
1436
1849
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableScrollContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableContent, {
|
|
1437
|
-
"aria-label": "
|
|
1850
|
+
"aria-label": t("devices.table"),
|
|
1438
1851
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableHeader, { children: [
|
|
1439
1852
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
|
|
1440
1853
|
isRowHeader: true,
|
|
1441
|
-
children: "
|
|
1854
|
+
children: t("devices.device")
|
|
1442
1855
|
}),
|
|
1443
1856
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
|
|
1444
1857
|
className: "sh:hidden sh:sm:table-cell sh:md:hidden sh:lg:table-cell",
|
|
1445
|
-
children: "
|
|
1858
|
+
children: t("devices.address")
|
|
1446
1859
|
}),
|
|
1447
1860
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
|
|
1448
1861
|
className: "sh:hidden sh:lg:table-cell",
|
|
1449
|
-
children: "
|
|
1862
|
+
children: t("devices.model")
|
|
1450
1863
|
}),
|
|
1451
1864
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
|
|
1452
1865
|
className: "sh:hidden sh:sm:table-cell",
|
|
1453
|
-
children: "
|
|
1866
|
+
children: t("devices.auth")
|
|
1454
1867
|
}),
|
|
1455
1868
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
|
|
1456
1869
|
className: "sh:hidden sh:xl:table-cell",
|
|
1457
|
-
children: "
|
|
1870
|
+
children: t("devices.firmware")
|
|
1458
1871
|
}),
|
|
1459
1872
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
|
|
1460
1873
|
className: "sh:text-end",
|
|
1461
|
-
children: "
|
|
1874
|
+
children: t("devices.actions")
|
|
1462
1875
|
})
|
|
1463
1876
|
] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableBody, {
|
|
1464
1877
|
items: devices,
|
|
1465
|
-
dependencies: [
|
|
1878
|
+
dependencies: [
|
|
1879
|
+
firmware,
|
|
1880
|
+
rowBusyId,
|
|
1881
|
+
language
|
|
1882
|
+
],
|
|
1466
1883
|
renderEmptyState: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyDevices, { onAdd: addDrawer.open }),
|
|
1467
|
-
children: (device) =>
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
className: "sh:max-w-36 sh:truncate sh:font-medium sh:text-default-800 sh:sm:max-w-48",
|
|
1478
|
-
title: device.name,
|
|
1479
|
-
children: device.name
|
|
1480
|
-
}),
|
|
1481
|
-
device.lastProbeError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProbeErrorIndicator, { message: device.lastProbeError }),
|
|
1482
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(UpdateAvailableIndicator, { entry: firmware[device.id] })
|
|
1483
|
-
]
|
|
1484
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1485
|
-
className: "sh:text-xs sh:text-default-500 sh:sm:hidden sh:md:block sh:lg:hidden",
|
|
1486
|
-
children: device.ipAddress
|
|
1487
|
-
})]
|
|
1488
|
-
}),
|
|
1489
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
|
|
1490
|
-
className: "sh:hidden sh:whitespace-nowrap sh:text-default-600 sh:sm:table-cell sh:md:hidden sh:lg:table-cell",
|
|
1491
|
-
children: device.ipAddress
|
|
1492
|
-
}),
|
|
1493
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
|
|
1494
|
-
className: "sh:hidden sh:whitespace-nowrap sh:lg:table-cell",
|
|
1495
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1496
|
-
className: "sh:flex sh:items-center sh:gap-1.5",
|
|
1497
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1498
|
-
className: "sh:max-w-36 sh:truncate",
|
|
1499
|
-
title: device.model ?? void 0,
|
|
1500
|
-
children: device.model ?? "—"
|
|
1501
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip, {
|
|
1502
|
-
variant: "soft",
|
|
1503
|
-
size: "sm",
|
|
1504
|
-
className: "sh:whitespace-nowrap",
|
|
1505
|
-
children: generationLabel(device.generation)
|
|
1506
|
-
})]
|
|
1507
|
-
})
|
|
1508
|
-
}),
|
|
1509
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
|
|
1510
|
-
className: "sh:hidden sh:whitespace-nowrap sh:sm:table-cell",
|
|
1511
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AuthChip, { state: device.authState })
|
|
1512
|
-
}),
|
|
1513
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
|
|
1514
|
-
className: "sh:hidden sh:whitespace-nowrap sh:xl:table-cell",
|
|
1515
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FirmwareCell, { entry: firmware[device.id] })
|
|
1516
|
-
}),
|
|
1517
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
|
|
1518
|
-
className: "sh:whitespace-nowrap",
|
|
1519
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RowActions, {
|
|
1520
|
-
deviceId: device.id,
|
|
1521
|
-
isBusy: rowBusyId === device.id,
|
|
1522
|
-
onInfo: () => setInfoDevice(device),
|
|
1523
|
-
onFirmware: () => setFirmwareDevice(device),
|
|
1524
|
-
onAuth: () => setAuthDevice(device),
|
|
1525
|
-
onReprobe: () => withRowBusy(device.id, () => reprobeDevice(device.id)),
|
|
1526
|
-
onDelete: () => setDeleteTarget(device)
|
|
1527
|
-
})
|
|
1528
|
-
})
|
|
1529
|
-
]
|
|
1530
|
-
}, device.id)
|
|
1884
|
+
children: (device) => renderDevicesPageDevicesRows(device, {
|
|
1885
|
+
firmware,
|
|
1886
|
+
t,
|
|
1887
|
+
rowBusyId,
|
|
1888
|
+
setInfoDevice,
|
|
1889
|
+
setFirmwareDevice,
|
|
1890
|
+
setAuthDevice,
|
|
1891
|
+
withRowBusy,
|
|
1892
|
+
setDeleteTarget
|
|
1893
|
+
})
|
|
1531
1894
|
})]
|
|
1532
1895
|
}) })
|
|
1533
1896
|
}),
|
|
@@ -1555,40 +1918,24 @@ function DevicesPage() {
|
|
|
1555
1918
|
onOpenChange: (open) => !open && setFirmwareDevice(null),
|
|
1556
1919
|
onUpdated: () => void refreshFirmware(devices)
|
|
1557
1920
|
}),
|
|
1558
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1921
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog, {
|
|
1559
1922
|
isOpen: !!deleteTarget,
|
|
1560
|
-
|
|
1561
|
-
|
|
1923
|
+
onClose: () => setDeleteTarget(null),
|
|
1924
|
+
status: "error",
|
|
1925
|
+
title: t("devices.delete"),
|
|
1926
|
+
action: {
|
|
1927
|
+
label: t("common.delete"),
|
|
1928
|
+
onPress: confirmDelete,
|
|
1929
|
+
isPending: deleting,
|
|
1930
|
+
"data-cy": "shelly-delete-confirm"
|
|
1562
1931
|
},
|
|
1932
|
+
closeLabel: t("common.cancel"),
|
|
1933
|
+
closeDataCy: "shelly-delete-cancel",
|
|
1563
1934
|
"data-cy": "shelly-delete-confirmation-modal",
|
|
1564
|
-
children:
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalBody, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
1569
|
-
"Remove ",
|
|
1570
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1571
|
-
className: "sh:font-semibold",
|
|
1572
|
-
children: deleteTarget?.name
|
|
1573
|
-
}),
|
|
1574
|
-
" (",
|
|
1575
|
-
deleteTarget?.ipAddress,
|
|
1576
|
-
") from the registry? The device itself is not changed."
|
|
1577
|
-
] }) }),
|
|
1578
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ModalFooter, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
|
|
1579
|
-
variant: "secondary",
|
|
1580
|
-
onPress: () => setDeleteTarget(null),
|
|
1581
|
-
"data-cy": "shelly-delete-cancel",
|
|
1582
|
-
children: "Cancel"
|
|
1583
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
|
|
1584
|
-
variant: "danger",
|
|
1585
|
-
onPress: confirmDelete,
|
|
1586
|
-
isPending: deleting,
|
|
1587
|
-
"data-cy": "shelly-delete-confirm",
|
|
1588
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trash2Icon, { className: "sh:h-4 sh:w-4" }), " Delete"]
|
|
1589
|
-
})] })
|
|
1590
|
-
] })
|
|
1591
|
-
}) })
|
|
1935
|
+
children: t("devices.deleteDescription", {
|
|
1936
|
+
name: deleteTarget?.name,
|
|
1937
|
+
address: deleteTarget?.ipAddress
|
|
1938
|
+
})
|
|
1592
1939
|
})
|
|
1593
1940
|
]
|
|
1594
1941
|
});
|