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