работающая генерация базовых полей (числа, select, checkbox) + законченные настройки для TDMA

This commit is contained in:
2025-01-13 18:34:19 +03:00
parent a7242c186d
commit bf2d374705
11 changed files with 588 additions and 545 deletions

View File

@@ -5,7 +5,34 @@ import os
def extract_param_names(mc):
result = {}
result = []
def helper_extract(widget):
if 'childs' in widget:
r = []
for child in widget['childs']:
r += helper_extract(child)
return r
elif 'name' in widget:
match widget['widget']:
case 'select': return [{"name": widget['name'], "initValue": widget['values'][0]['value']}]
case 'checkbox': return [{"name": widget['name'], "initValue": 'false'}]
case 'number': return [{"name": widget['name'], "initValue": widget['min'] if widget['min'] else '0'}]
return [{"name": widget['name'], "initValue": 'null'}]
return []
for cat in mc['params']:
ws = []
for w in mc['params'][cat]:
ws += helper_extract(w)
ws.sort(key=lambda k: k['name'])
result.append({
"group": cat,
"params": ws
})
return result
@@ -27,7 +54,8 @@ def build_modem_env(modem):
"header_tabs": mc['tabs'],
"tab_names_array": [t['name'] for t in mc['tabs']],
"params": mc["params"],
"paramGroupsWithNames": extract_param_names(mc),
"dangerousParamGroups": mc["dangerousParamGroups"] if 'dangerousParamGroups' in mc else {},
"paramGroups": extract_param_names(mc),
"paramGroupsList": extract_param_groups(mc),
}