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:
@@ -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"""
|
||||
|
||||
Reference in New Issue
Block a user