From 035344e47c19699e201dfd71abb6b3dba24aca6a Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 4 Sep 2024 15:21:37 +0200 Subject: [PATCH] UI/iwd: wifi machine module --- pkgs/clan-cli/clan_cli/api/iwd.py | 13 +- .../app/src/components/TextInput.tsx | 4 - pkgs/webview-ui/app/src/hooks/index.ts | 24 ++ pkgs/webview-ui/app/src/index.tsx | 8 +- .../app/src/routes/clans/details.tsx | 4 +- pkgs/webview-ui/app/src/routes/disk/view.tsx | 4 - .../machines/{[name]/view.tsx => details.tsx} | 366 ++++++++++++------ .../app/src/routes/machines/index.ts | 3 + .../routes/machines/{view.tsx => list.tsx} | 0 9 files changed, 293 insertions(+), 133 deletions(-) rename pkgs/webview-ui/app/src/routes/machines/{[name]/view.tsx => details.tsx} (70%) create mode 100644 pkgs/webview-ui/app/src/routes/machines/index.ts rename pkgs/webview-ui/app/src/routes/machines/{view.tsx => list.tsx} (100%) diff --git a/pkgs/clan-cli/clan_cli/api/iwd.py b/pkgs/clan-cli/clan_cli/api/iwd.py index 63501608e..387a337f2 100644 --- a/pkgs/clan-cli/clan_cli/api/iwd.py +++ b/pkgs/clan-cli/clan_cli/api/iwd.py @@ -28,14 +28,23 @@ def instance_name(machine_name: str) -> str: @API.register -def get_iwd_service(base_url: str, machine_name: str) -> ServiceIwd | None: +def get_iwd_service(base_url: str, machine_name: str) -> ServiceIwd: """ Return the admin service of a clan. There is only one admin service. This might be changed in the future """ inventory = load_inventory_eval(base_url) - return inventory.services.iwd.get(instance_name(machine_name)) + service_config = inventory.services.iwd.get(instance_name(machine_name)) + if service_config: + return service_config + + # Empty service + return ServiceIwd( + meta=ServiceMeta(name="wifi_0"), + roles=ServiceIwdRole(default=ServiceIwdRoleDefault(machines=[machine_name])), + config=IwdConfig(networks={}), + ) @dataclass diff --git a/pkgs/webview-ui/app/src/components/TextInput.tsx b/pkgs/webview-ui/app/src/components/TextInput.tsx index 8c735edf0..a73ef02c9 100644 --- a/pkgs/webview-ui/app/src/components/TextInput.tsx +++ b/pkgs/webview-ui/app/src/components/TextInput.tsx @@ -25,10 +25,6 @@ export function TextInput( ) { const value = () => props.value; - createEffect(() => { - console.log("rendering text input", props.value); - }); - return (