diff --git a/front-generator/render-params.json b/front-generator/render-params.json index bec1081..83dd6bf 100644 --- a/front-generator/render-params.json +++ b/front-generator/render-params.json @@ -1,32 +1,73 @@ { "monitoring-params": {}, - "params": { - "rxtx": { - "rx.en": { - "model": "w:switch", - "label": "Включить передатчик" - }, - "rx.isTestInputData": { - "model": "w:select", - "label": "Включить передатчик", - "items": [ - {"value": "false", "label": "Ethernet"}, - {"value": "true", "label": "Тест (CW)"} - ] - }, - "rx.freqKhz": { - "model": "w:number", - "number.type": "int", - "number.step": 1, - "number.min": 500000, - "number.max": 15000000 - } - } - }, "modem_types": { "tdma": { "modem_name": "RCSM-101 TDMA", - "groupsList": ["rxtx", "buclnb"], + "params": { + "rxtx": [ + { + "widget": "h2", + "label": "Настройки приема/передачи" + }, + { + "widget": "flex-container", + "childs": [ + { + "widget": "settings-container", + "childs": [ + { "widget": "h3", "label": "Настройки передатчика" }, + { + "widget": "checkbox", + "label": "Включить передатчик", + "name": "txEn" + }, + { + "widget": "select", + "label": "Входные данные", + "name": "txIsTestInput", + "values": [ + { + "label": "Тест", + "value": "true" + }, + { + "label": "SCPC", + "value": "false" + } + ] + } + ] + }, + { + "widget": "settings-container", + "childs": [ + { "widget": "h3", "label": "Настройки приемника" }, + { + "widget": "select", + "label": "Режим управления усилением", + "name": "rxAgcEn", + "values": [ + { + "label": "АРУ", + "value": "true" + }, + { + "label": "РРУ", + "value": "false" + } + ] + }, + { + "widget": "checkbox", + "label": "Инверсия спектра", + "name": "rxSpectrumInversion" + } + ] + } + ] + } + ] + }, "tabs": [ { "name": "monitoring", @@ -44,7 +85,60 @@ }, "scpc": { "modem_name": "RCSM-101", - "groupsList": ["rxtx", "cinc", "buclnb", "qos", "tcpaccel"], + "params": { + "rxtx": [ + { + "widget": "h2", + "label": "Настройки приема/передачи" + }, + { + "widget": "settings-container", + "childs": [ + { + "widget": "select", + "label": "Режим работы", + "name": "isCinC", + "values": [ + { + "label": "CinC", + "value": "true" + }, + { + "label": "SCPC", + "value": "false" + } + ] + } + ] + }, + { + "widget": "flex-container", + "childs": [ + { + "widget": "settings-container", + "childs": [ + { "widget": "h3", "label": "Настройки приема/передачи" }, + { + "widget": "select", + "label": "Режим работы", + "name": "isCinC", + "values": [ + { + "label": "CinC", + "value": "true" + }, + { + "label": "SCPC", + "value": "false" + } + ] + } + ] + } + ] + } + ] + }, "tabs": [ { "name": "monitoring", diff --git a/front-generator/render.py b/front-generator/render.py index acf4018..d1f3881 100644 --- a/front-generator/render.py +++ b/front-generator/render.py @@ -4,6 +4,15 @@ import sys import os +def extract_param_names(mc): + result = {} + + + +def extract_param_groups(mc): + return [k for k in mc['params']] + + def build_modem_env(modem): with open('render-params.json') as f: config = json.load(f) @@ -17,8 +26,9 @@ def build_modem_env(modem): "modem_name": mc['modem_name'], "header_tabs": mc['tabs'], "tab_names_array": [t['name'] for t in mc['tabs']], - "params": {"groupsList": mc["groupsList"]} | config["params"], - "all_settings_group_names": [] + "params": mc["params"], + "paramGroupsWithNames": extract_param_names(mc), + "paramGroupsList": extract_param_groups(mc), } diff --git a/front-generator/template/common/qos-data.js.j2 b/front-generator/template/common/qos-data.js.j2 index e253188..ee1f477 100644 --- a/front-generator/template/common/qos-data.js.j2 +++ b/front-generator/template/common/qos-data.js.j2 @@ -5,7 +5,7 @@ rt3: [], cd: [], }, - {% if 'tcpaccel' in params.groupsList %} + {% if 'tcpaccel' in params.paramGroupsList %} paramsTcpAccel: { en: false, maxConnections: 128 diff --git a/front-generator/template/common/qos-methods.js.j2 b/front-generator/template/common/qos-methods.js.j2 index a2feefc..45db200 100644 --- a/front-generator/template/common/qos-methods.js.j2 +++ b/front-generator/template/common/qos-methods.js.j2 @@ -1,3 +1,26 @@ + {% if 'tcpaccel' in params.paramGroupsList %} + submitTcpaccelSettings() { + if (this.submitStatus.tcpAccel) { return } + this.submitStatus.tcpAccel = true + fetch('/api/set/tcpAccel', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + "tcpAccel.en": this.param.tcpAccel.en, + "tcpAccel.maxConnections": this.param.tcpAccel.maxConnections + }) + }).then(async (resp) => { + this.submitStatus.tcpAccel = false + this.updateNetworkSettings(await resp.json()) + }).catch((reason) => { + this.submitStatus.tcpAccel = false + alert(`Ошибка при применении настроек: ${reason}`) + }) + }, + updateTcpaccelSettings(vals) { console.log('tcp accel setting update function has no impl! update backend and write this function') } + {% endif %} settingsSubmitQoS() { if (this.submitStatus.qos) { return } this.submitStatus.qos = true @@ -70,29 +93,6 @@ }) }, - {% if 'tcpaccel' in params.groupsList %} - settingsSubmitTcpAccel() { - if (this.submitStatus.tcpAccel) { return } - this.submitStatus.tcpAccel = true - fetch('/api/set/tcpAccel', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - "tcpAccel.en": this.param.tcpAccel.en, - "tcpAccel.maxConnections": this.param.tcpAccel.maxConnections - }) - }).then(async (resp) => { - this.submitStatus.tcpAccel = false - this.updateNetworkSettings(await resp.json()) - }).catch((reason) => { - this.submitStatus.tcpAccel = false - alert(`Ошибка при применении настроек: ${reason}`) - }) - }, - {% endif %} - updateQosSettings(vals) { this.submitStatus.qos = false this.paramsQos.en = vals["settings"]["qos.enabled"] @@ -240,4 +240,5 @@ } return result - }, \ No newline at end of file + }, + diff --git a/front-generator/template/common/qos.html.j2 b/front-generator/template/common/qos.html.j2 index c23bcb1..8a6949a 100644 --- a/front-generator/template/common/qos.html.j2 +++ b/front-generator/template/common/qos.html.j2 @@ -100,7 +100,7 @@ - {% endraw %}{% if 'tcpaccel' in params.groupsList %}{% raw %} + {% endraw %}{% if 'tcpaccel' in params.paramGroupsList %}{% raw %}

Настройки TCP-акселерации

{% endmacro %} + +{% macro build_widget_number(param_group, widget) %} +{% endmacro %} + +{% macro build_widget_select(param_group, widget) %} + {{ widget.label }} + +{% endmacro %} + +{% macro build_widget_flex_container(param_group, widget) %}
+{% for w in widget.childs %}{{ build_widget(param_group, w) }}{% endfor %} +
+{% endmacro %} + +{% macro build_widget_settings_container(param_group, widget) %}
+{% for w in widget.childs %}{{ build_widget(param_group, w) }}{% endfor %} +
+{% endmacro %} + + +{% macro build_widget(param_group, widget) %}{% if widget.widget == 'flex-container' %}{{ build_widget_flex_container(param_group, widget) }} +{% elif widget.widget == 'settings-container' %}{{ build_widget_settings_container(param_group, widget) }} +{% elif widget.widget == 'h2' %}{{ widget.label }} +{% elif widget.widget == 'h3' %}{{ widget.label }} +{% elif widget.widget == 'checkbox' %}{{ build_widget_checkbox(param_group, widget) }} +{% elif widget.widget == 'number' %}{{ build_widget_number(param_group, widget) }} +{% elif widget.widget == 'select' %}{{ build_widget_select(param_group, widget) }} +{% else %}

Widget '{{ widget.widget }}' not defined!

{{ widget }}

+{% endif %} +{% endmacro %} diff --git a/front-generator/template/main.html b/front-generator/template/main.html index 27ec312..a149fd0 100644 --- a/front-generator/template/main.html +++ b/front-generator/template/main.html @@ -74,7 +74,7 @@ // false - означает что статистика не отправляется, true - отправляется submitStatus: { - {% for pg in params.groupsList %} + {% for pg in params.paramGroupsList %} {{ pg }}: false, {% endfor %} firmwareUpload: false, @@ -141,7 +141,7 @@ let d = await fetch("/api/get/settings") let vals = await d.json() this.settingFetchComplete = true - {% for pg in params.groupsList %} + {% for pg in params.paramGroupsList %} this.update{{ pg | capitalize }}Settings(vals) {% endfor %} } diff --git a/static/main-scpc.html b/static/main-scpc.html index 4f3a0e0..7e3048c 100644 --- a/static/main-scpc.html +++ b/static/main-scpc.html @@ -45,6 +45,7 @@ @@ -121,7 +122,34 @@
+
+

Настройки приема/передачи

+
+ +
+
+
+

Настройки приема/передачи

+ +
+ +
+ + +

Настройки QoS

@@ -224,26 +252,12 @@ -

Настройки TCP-акселерации

-
- - -
- -
-

Последнее обновление статистики: {{ lastUpdateTime }}