();
+
+ const load = async () => {
+ setList(await DeviceApi.ValidatedList());
+ };
+
+ const reload = () => {
+ loadKey.current += 1;
+ setList(undefined);
+ };
+
+ return (
+
+
+
+
+
+ }
+ >
+ }
+ />
+
+ );
+}
+
+function ValidatedDevicesList(p: {
+ list: Device[];
+ onReload: () => void;
+}): React.ReactElement {
+ const alert = useAlert();
+ const confirm = useConfirm();
+ const snackbar = useSnackbar();
+ const loadingMessage = useLoadingMessage();
+
+ const deleteDevice = async (d: Device) => {
+ try {
+ if (
+ !(await confirm(
+ `Do you really want to delete the device ${d.id}? The operation cannot be reverted!`
+ ))
+ )
+ return;
+
+ loadingMessage.show("Deleting device...");
+ await DeviceApi.Delete(d);
+
+ snackbar("The device has been successfully deleted!");
+ p.onReload();
+ } catch (e) {
+ console.error(`Failed to delete device! ${e})`);
+ alert("Failed to delete device!");
+ } finally {
+ loadingMessage.hide();
+ }
+ };
+
+ if (p.list.length === 0) {
+ return There is no device validated yet.
;
+ }
+
+ return (
+
+
+
+
+ #
+ Model
+ Version
+ Max number of relays
+ Created
+ Updated
+
+
+
+
+ {p.list.map((dev) => (
+
+
+ {dev.id}
+
+ {dev.info.reference}
+ {dev.info.version}
+ {dev.info.max_relays}
+
+
+
+
+
+
+
+
+ deleteDevice(dev)}>
+
+
+
+
+
+ ))}
+
+
+
+ );
+}
diff --git a/central_frontend/src/widgets/SolarEnergyNavList.tsx b/central_frontend/src/widgets/SolarEnergyNavList.tsx
index 5b5a260..784d4d9 100644
--- a/central_frontend/src/widgets/SolarEnergyNavList.tsx
+++ b/central_frontend/src/widgets/SolarEnergyNavList.tsx
@@ -1,4 +1,4 @@
-import { mdiHome, mdiNewBox } from "@mdi/js";
+import { mdiChip, mdiHome, mdiNewBox } from "@mdi/js";
import Icon from "@mdi/react";
import {
List,
@@ -21,6 +21,11 @@ export function SolarEnergyNavList(): React.ReactElement {
}}
>
} />
+ }
+ />