Improve Samba Global Configuration display in WebUI

Backend:
- Parse global config into structured key-value pairs
- Return parameters array instead of raw text
- Better handling of comments and empty lines

Frontend:
- Add 'Samba Config' tab to shares page
- Display config parameters in readable table format
- Color-code parameter names for clarity
- Add getSambaConfig() method to API client

Co-Authored-By: Patrick <patrick@perlbach24.de>
This commit is contained in:
2026-04-22 01:01:40 +02:00
parent 8402053dd8
commit eec74626d0
3 changed files with 69 additions and 9 deletions
+14 -7
View File
@@ -180,16 +180,15 @@ class SharesManager:
return False
def get_samba_global_config(self) -> Dict[str, Any]:
"""Read Samba global configuration section"""
"""Read Samba global configuration section as structured key-value pairs"""
if not SAMBA_CONFIG.exists():
return {"raw": ""}
return {"parameters": []}
try:
with open(SAMBA_CONFIG, 'r') as f:
content = f.read()
# Extract global section
global_section = ""
parameters = []
lines = content.split('\n')
in_global = False
for line in lines:
@@ -199,12 +198,20 @@ class SharesManager:
if in_global:
if line.strip().startswith('['):
break
global_section += line + '\n'
line = line.strip()
if not line or line.startswith(';') or line.startswith('#'):
continue
if '=' in line:
key, value = line.split('=', 1)
parameters.append({
"key": key.strip(),
"value": value.strip()
})
return {"raw": global_section.strip()}
return {"parameters": parameters}
except Exception as e:
logger.error(f"Error reading Samba global config: {e}")
return {"raw": ""}
return {"parameters": []}
def set_samba_global_config(self, config_text: str) -> bool:
"""Write Samba global configuration section"""