From 4e4db891ec10fb9c1a2aa64fc2d216d1613ce080 Mon Sep 17 00:00:00 2001 From: Knut Anderssen Date: Tue, 11 Jun 2024 16:08:26 +0100 Subject: [PATCH] Small network fixes --- web/src/client/network/index.js | 2 +- web/src/client/network/model.js | 4 ++-- web/src/components/network/NetworkPage.jsx | 16 ++++------------ web/src/components/network/routes.js | 7 ++++--- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/web/src/client/network/index.js b/web/src/client/network/index.js index 4ddb3ce1b1..5ded4036ac 100644 --- a/web/src/client/network/index.js +++ b/web/src/client/network/index.js @@ -123,7 +123,7 @@ class NetworkClient { const { ipConfig = {}, ...dev } = device; const routes4 = (ipConfig.routes4 || []).map((route) => { const [ip, netmask] = route.destination.split("/"); - const destination = { address: ip, prefix: ipPrefixFor(netmask) }; + const destination = (netmask !== undefined) ? { address: ip, prefix: ipPrefixFor(netmask) } : { address: ip }; return { ...route, destination }; }); diff --git a/web/src/client/network/model.js b/web/src/client/network/model.js index 2ad100b080..c8a8a069e1 100644 --- a/web/src/client/network/model.js +++ b/web/src/client/network/model.js @@ -176,8 +176,8 @@ const ApSecurityFlags = Object.freeze({ /** * @typedef {object} NetworkSettings * @property {boolean} connectivity -* @property {boolean} wirelessEnabled -* @property {boolean} networkingEnabled +* @property {boolean} wireless_enabled +* @property {boolean} networking_enabled * @property {string} hostname /** diff --git a/web/src/components/network/NetworkPage.jsx b/web/src/components/network/NetworkPage.jsx index 47ab899748..75c5b81ceb 100644 --- a/web/src/components/network/NetworkPage.jsx +++ b/web/src/components/network/NetworkPage.jsx @@ -85,11 +85,10 @@ const NoWifiConnections = ({ wifiScanSupported, openWifiSelector }) => { */ export default function NetworkPage() { const { network: client } = useInstallerClient(); - const initialConnections = useLoaderData(); + const { connections: initialConnections, settings } = useLoaderData(); const [connections, setConnections] = useState(initialConnections); const [devices, setDevices] = useState(undefined); const [selectedConnection, setSelectedConnection] = useState(null); - const [wifiScanSupported, setWifiScanSupported] = useState(false); const [wifiSelectorOpen, setWifiSelectorOpen] = useState(false); const openWifiSelector = () => setWifiSelectorOpen(true); @@ -124,13 +123,6 @@ export default function NetworkPage() { }); }, [client, devices]); - useEffect(() => { - if (connections !== undefined) return; - - client.settings().then((s) => setWifiScanSupported(s.wireless_enabled)); - // client.connections().then(setConnections); - }, [client, connections]); - useEffect(() => { if (devices !== undefined) return; @@ -158,7 +150,7 @@ export default function NetworkPage() { if (wifiConnections.length === 0) { return ( - + ); } @@ -183,7 +175,7 @@ export default function NetworkPage() {

{_("Network")}