From d86befcfd4c0141a3bc52f298bd20694fb30cc85 Mon Sep 17 00:00:00 2001 From: Ethan Li Date: Tue, 6 Jan 2026 15:33:19 +0100 Subject: [PATCH] Simplify UX & UI for configuring external Wi-Fi network connection --- .../routes/internet/conn-profiles.go | 3 + .../app/deviceadmin/routes/internet/routes.go | 10 +- .../internet/conn-profiles/index.page.tmpl | 1 + .../external-network-form.partial.tmpl | 55 +++++++---- web/templates/internet/index.page.tmpl | 96 +------------------ 5 files changed, 48 insertions(+), 117 deletions(-) diff --git a/internal/app/deviceadmin/routes/internet/conn-profiles.go b/internal/app/deviceadmin/routes/internet/conn-profiles.go index c23b2dc..73f15b6 100644 --- a/internal/app/deviceadmin/routes/internet/conn-profiles.go +++ b/internal/app/deviceadmin/routes/internet/conn-profiles.go @@ -170,6 +170,9 @@ func (h *Handlers) HandleConnProfilePostByUUID() echo.HandlerFunc { ); err != nil { return errors.Wrapf(err, "couldn't update connection profile %s", rawUUID) } + if err := h.nmc.ActivateConnProfile(c.Request().Context(), uid); err != nil { + return err + } // Redirect user return c.Redirect(http.StatusSeeOther, redirectTarget) case "updated": diff --git a/internal/app/deviceadmin/routes/internet/routes.go b/internal/app/deviceadmin/routes/internet/routes.go index a722e98..3071fe1 100644 --- a/internal/app/deviceadmin/routes/internet/routes.go +++ b/internal/app/deviceadmin/routes/internet/routes.go @@ -82,8 +82,8 @@ type InternetViewData struct { NM nm.NetworkManager AvailableSSIDs []string - Wlan0InternetConnProfile nm.ConnProfile Wlan0HotspotConnProfile nm.ConnProfile + Wlan1InternetConnProfile nm.ConnProfile WifiDevices []nm.Device EthernetDevices []nm.Device @@ -101,11 +101,11 @@ func getInternetViewData(ctx context.Context, nmc *nm.Client) (vd InternetViewDa return vd, errors.Wrap(err, "couldn't get overall information about NetworkManager") } - const iface = "wlan0" + const internetIface = "wlan1" // Note(ethanjli): the list of APs is just for autocompletion in the simplified wifi management // view, and it can be missing just after activating wlan0-hotspot; so it's fine if we don't // provide any data about available APs on this page: - availableAPs, _ := nmc.ScanNetworks(ctx, iface) + availableAPs, _ := nmc.ScanNetworks(ctx, internetIface) for ssid, aps := range availableAPs { if len(aps) == 0 { continue @@ -138,10 +138,10 @@ func getInternetViewData(ctx context.Context, nmc *nm.Client) (vd InternetViewDa case "wifi": vd.WifiConnProfiles = append(vd.WifiConnProfiles, connProfile.Settings.Conn) switch conn := connProfile.Settings.Conn; conn.ID { - case "wlan0-internet": - vd.Wlan0InternetConnProfile = connProfile case "wlan0-hotspot": vd.Wlan0HotspotConnProfile = connProfile + case "wlan1-internet": + vd.Wlan1InternetConnProfile = connProfile } case "ethernet": vd.EthernetConnProfiles = append(vd.EthernetConnProfiles, connProfile.Settings.Conn) diff --git a/web/templates/internet/conn-profiles/index.page.tmpl b/web/templates/internet/conn-profiles/index.page.tmpl index c4055b9..14d2f99 100644 --- a/web/templates/internet/conn-profiles/index.page.tmpl +++ b/web/templates/internet/conn-profiles/index.page.tmpl @@ -117,6 +117,7 @@ data-form-submission-target="submit" > + diff --git a/web/templates/internet/external-network-form.partial.tmpl b/web/templates/internet/external-network-form.partial.tmpl index 7a17c5f..5c2e00d 100644 --- a/web/templates/internet/external-network-form.partial.tmpl +++ b/web/templates/internet/external-network-form.partial.tmpl @@ -13,13 +13,16 @@ >
{{range $ssid := $availableSSIDs}} @@ -99,7 +102,7 @@ (you can view details about all detected external networks here)

@@ -129,7 +132,10 @@ class="is-inline-block is-vertical-align-top mt-1" {{if not (eq $wifiSec.KeyMgmt "")}}checked{{end}} data-checkable-textbox-target="checkable" - data-action="change->checkable-textbox#toggle change->checkable-textbox#setPlaceholder" + data-action=" + change->checkable-textbox#toggle + change->checkable-textbox#setPlaceholder + " data-checkable-textbox-placeholder-param="not shown here, for security reasons" />
@@ -148,7 +154,11 @@ size=30 data-password-input-target="input" data-checkable-textbox-target="textbox" - data-action="focus->checkable-textbox#edit focus->checkable-textbox#setPlaceholder input->password-input#edit" + data-action=" + focus->checkable-textbox#edit + focus->checkable-textbox#setPlaceholder + input->password-input#edit + " data-checkable-textbox-placeholder-param="not shown here, for security reasons" >
@@ -177,7 +187,10 @@ required autocomplete="off" {{if eq $wifiSec.KeyMgmt ""}}checked{{end}} - data-action="change->checkable-textbox#toggle change->checkable-textbox#setPlaceholder" + data-action=" + change->checkable-textbox#toggle + change->checkable-textbox#setPlaceholder + " data-checkable-textbox-placeholder-param="none" /> No @@ -186,7 +199,7 @@
- +
-
- +
+
+ +
diff --git a/web/templates/internet/index.page.tmpl b/web/templates/internet/index.page.tmpl index 08ad0d5..1836425 100644 --- a/web/templates/internet/index.page.tmpl +++ b/web/templates/internet/index.page.tmpl @@ -51,7 +51,7 @@

Wi-Fi

- {{if not .Data.Wlan0InternetConnProfile.HasData}} + {{if not .Data.Wlan1InternetConnProfile.HasData}}
The basic configuration file for internet access could not be found! Was it removed? @@ -60,110 +60,22 @@ "path" .Meta.Path "query" (.Meta.Form.WithInstead "mode" "advanced").Encode )}}">advanced view of this page to check whether - the "wlan0-internet" connection profile is listed, and if so, what its contents are. - It should have ID "wlan0-internet" and be of type "wifi". + the "wlan1-internet" connection profile is listed, and if so, what its contents are. + It should have ID "wlan1-internet" and be of type "wifi".
{{else}} -

- This machine's internal Wi-Fi module (wlan0) can either connect to an - external Wi-Fi network created by a Wi-Fi router (to give this machine - internet access) or create its own Wi-Fi hotspot (as a way for your - computer to connect directly to this machine). Whenever a connection to an external Wi-Fi - network fails or is lost, this machine will automatically switch to creating its own Wi-Fi - hotspot instead. -

-
-
- Once this machine has started making its own Wi-Fi hotspot, it will not automatically - try to connect to the external Wi-Fi network before the next boot. However, you can - manually make the machine try to connect to the external Wi-Fi network by clicking the - "Use external network now" button further down this page. -
-
-

External Wi-Fi network

{{ template "internet/external-network-form.partial.tmpl" dict - "ConnProfile" .Data.Wlan0InternetConnProfile + "ConnProfile" .Data.Wlan1InternetConnProfile "AvailableSSIDs" .Data.AvailableSSIDs "Meta" .Meta }}
- - {{$wlan0Internet := .Data.Wlan0InternetConnProfile}} - {{$wlan0Hotspot := .Data.Wlan0HotspotConnProfile}} - {{if and $wlan0Hotspot.HasData}} -

- This machine can try to temporarily switch between connecting to the external network - and making the hotspot, before the next boot: -

- {{else}} -

- This machine can try to temporarily connect to the external network, before the next - boot: -

- {{end}} -
-
-
- - - -
-
- {{if $wlan0Hotspot.HasData}} -
-
- - - -
-
- {{end}} -
{{end}}

All modules