Skip to content

Commit c779b83

Browse files
committed
Removed SSID update feature
Changing SSID is now only possible if the `change_ssid` capability is enabled
1 parent 154c0ff commit c779b83

5 files changed

Lines changed: 37 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
- WiFi config change (Profile, SSID – if capability enabled, Passphrase)
13+
- SSH service
14+
- Links to known admin services

src/adminui/context.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class Context:
2020
# contentfilter_prefix: str = "contentfilter"
2121
# filemanager_prefix: str = "resources"
2222

23+
# capabilities are restrictions on an hotspot
24+
# regarding edit features of the adminUI
25+
can_change_ssid: bool = False
26+
2327
wifi_ssid: str = "Kiwix Hotspot"
2428
wifi_passphrase: str | None = None
2529
wifi_profile: str = "perf"

src/adminui/setup.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class MissingType:
1818
Missing = MissingType() # single value used to check if its missing
1919

2020

21+
@dataclass
22+
class Capabilities:
23+
change_ssid: bool = False
24+
25+
2126
@dataclass
2227
class ComposeData:
2328
"""useful information read from compose.yaml"""
@@ -60,6 +65,13 @@ def get_from_compose() -> ComposeData:
6065
return ComposeData(tld=tld, domain=domain, kiwix_prefix=kiwix_prefix)
6166

6267

68+
def get_capabilities_from_config() -> Capabilities:
69+
yaml_config = read_offspot_conf()
70+
cap = yaml_config.get("capabilities", {})
71+
# only SSID change ATM
72+
return Capabilities(change_ssid=cap.get("change_ssid"))
73+
74+
6375
def get_wifi_conf_from_offspot_yaml() -> WifiConf:
6476
"""read offspot.yaml for updated-not-applied changes to WiFi conf"""
6577
conf = WifiConf()
@@ -104,6 +116,9 @@ def prepare_context():
104116
# read tld, domain, prefixes from compose
105117
compose_data = get_from_compose()
106118

119+
# read capabilities
120+
capabilities = get_capabilities_from_config()
121+
107122
# read wifi conf from offspot.yaml if present
108123
wifi_conf = get_wifi_conf_from_offspot_yaml()
109124
if not wifi_conf.is_complete:
@@ -120,6 +135,7 @@ def prepare_context():
120135
tld=compose_data.tld,
121136
domain=compose_data.domain,
122137
kiwix_prefix=compose_data.kiwix_prefix,
138+
can_change_ssid=capabilities.change_ssid,
123139
wifi_profile=wifi_conf.profile,
124140
wifi_ssid=wifi_conf.ssid,
125141
wifi_passphrase=wifi_conf.passphrase,

src/adminui/templates/wifi/config.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</div>
3535
</div>
3636

37-
<div class="row mb-3">
37+
<div class="row mb-3 {% if not ctx.can_change_ssid %}d-none{% endif %}">
3838
<div class="col-12 col-md-2">
3939
<label for="ssid">SSID</label>
4040
</div>

src/adminui/wifi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ def config_update(
9090
update_wifi_config(data=data)
9191
# update context
9292
context.wifi_profile = data.profile
93-
context.wifi_ssid = data.ssid
93+
if context.can_change_ssid:
94+
context.wifi_ssid = data.ssid
9495
context.wifi_passphrase = None if data.open else data.passphrase
9596
except Exception as exc:
9697
logger.error(f"failed to record WiFi conf: {exc}")

0 commit comments

Comments
 (0)