Skip to content

Commit ce683af

Browse files
committed
Migrate the viewer track settings and hub config sections, accepting track_memory without applying it
1 parent e7e2851 commit ce683af

8 files changed

Lines changed: 313 additions & 114 deletions

File tree

Source/Application/WebViewer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,10 @@ Setting &WebViewer::SetKey(AIS::Keys key, const std::string &arg)
10901090
case AIS::KEY_SETTING_CUTOFF:
10911091
settings.tracking.cutoff = Util::Parse::Integer(arg, 0, 10000);
10921092
break;
1093+
case AIS::KEY_SETTING_TRACK_MEMORY:
1094+
// accepted and range checked, but the track store is not yet sized from it
1095+
Util::Parse::Integer(arg, 16, 256 * 1024);
1096+
break;
10931097
case AIS::KEY_SETTING_EXPIRE:
10941098
settings.tracking.expire_fields = Util::Parse::Switch(arg);
10951099
break;

Source/JSON/KeyDefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ X(KEY_SETTING_CONTEXT, "", "", "", "", "context", "", "", "", nullptr)
7878
X(KEY_SETTING_CONN_STR, "", "", "", "", "conn_str", "", "", "", nullptr)
7979
X(KEY_SETTING_CRC_CHECK, "", "", "", "", "crc_check", "", "", "", nullptr)
8080
X(KEY_SETTING_CUTOFF, "", "", "", "", "cutoff", "", "", "", nullptr)
81+
X(KEY_SETTING_TRACK_MEMORY, "", "", "", "", "track_memory", "", "KB", "Memory budget for ship tracks", nullptr)
8182
X(KEY_SETTING_DECODER, "", "", "", "", "decoder", "", "", "", nullptr)
8283
X(KEY_SETTING_DESCRIPTION, "", "", "", "", "description", "", "", "", nullptr)
8384
X(KEY_SETTING_DESC, "", "", "", "", "desc", "", "", "", nullptr)

frontend/control/js/app.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -978,19 +978,20 @@
978978

979979
function loadViewerConfig() {
980980
// every viewer setting except the port, which follows the control port
981-
const keys = ['station', 'station_link', 'lat', 'lon', 'webcontrol_http',
982-
'plugin_dir', 'file', 'backup', 'history',
983-
'share_loc', 'realtime', 'msg', 'decoder', 'log', 'use_gps', 'expire', 'zones'];
984-
const halves = ['station', 'station_link'];
981+
const keys = ['station', 'station_link', 'webcontrol_http',
982+
'lat', 'lon', 'share_loc', 'use_gps',
983+
'history', 'track_memory', 'expire',
984+
'file', 'backup',
985+
'plugin_dir', 'context',
986+
'realtime', 'msg', 'decoder', 'log', 'geojson', 'prome',
987+
'zones'];
985988
const schema = {};
986-
keys.forEach(k => {
987-
schema[k] = Object.assign({}, webviewerSchema[k]);
988-
if (halves.indexOf(k) !== -1) schema[k].width = 50;
989-
if (k === 'history') schema[k].width = 100; // so the toggles start on a new row
990-
});
989+
keys.forEach(k => { schema[k] = Object.assign({}, webviewerSchema[k]); });
991990
schema.use_gps.label = 'GPS';
992991
createSimpleConfigManager({
993992
schema: schema,
993+
sectionOrder: ['Connection', 'Station', 'Location', 'Retention', 'Service',
994+
'Backup', 'Storage', 'Features', 'Zones'],
994995
containerId: 'viewer-config-container',
995996
nestedPath: ['control', 'viewer'],
996997
title: 'Map'

frontend/control/js/config-manager.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,9 @@
556556
}
557557
};
558558

559+
const SECTION_ORDER = ['Label', 'Connection', 'Station', 'Location', 'Format',
560+
'Options', 'Retention', 'Service', 'Backup', 'Storage', 'Features', 'Filter', 'Zones'];
561+
559562
const Styles = {
560563
input: 'input',
561564
select: 'select',
@@ -565,6 +568,7 @@
565568
sliderDisplay: 'slider-value',
566569
label: 'field-label',
567570
description: 'field-desc',
571+
section: 'field-section',
568572
button: 'btn',
569573
buttonPrimary: 'btn btn-icon',
570574
card: 'card',
@@ -1018,8 +1022,9 @@
10181022
container._field = field;
10191023
container._dataContext = dataContext;
10201024
}
1021-
if (field.tooltip) container.title = field.tooltip;
1022-
if (field.description) container.appendChild(el('p', Styles.description, {}, field.description));
1025+
const desc = field.description || field.tooltip;
1026+
if (desc) container.appendChild(el('p', Styles.description, {}, desc));
1027+
else if (field.tooltip) container.title = field.tooltip;
10231028

10241029
return container;
10251030
},
@@ -1167,8 +1172,27 @@
11671172
let syncAdvanced = () => syncs.forEach(f => f());
11681173
const refresh = () => { Renderer.updateVisibility(innerFields, item); syncAdvanced(); };
11691174

1170-
this.fields.forEach(field => {
1175+
// Section all fields of a schema or none: an unsectioned one trailing a block reads as part of it.
1176+
const ordered = [];
1177+
const bySection = new Map();
1178+
this.fields.forEach(f => {
1179+
const key = (!f.advanced && f.section) || null;
1180+
if (key === null) return ordered.push(f);
1181+
if (!bySection.has(key)) bySection.set(key, []);
1182+
bySection.get(key).push(f);
1183+
});
1184+
const order = this.config.sectionOrder || SECTION_ORDER;
1185+
const rank = k => { const i = order.indexOf(k); return i === -1 ? order.length : i; };
1186+
[...bySection.keys()].sort((a, b) => rank(a) - rank(b))
1187+
.forEach(k => ordered.push(bySection.get(k)));
1188+
1189+
let currentSection = null;
1190+
ordered.flat().forEach(field => {
11711191
if (activeField && field.name === 'active') return;
1192+
if (field.section && field.section !== currentSection && !field.advanced) {
1193+
currentSection = field.section;
1194+
innerFields.appendChild(el('h5', Styles.section, {}, field.section));
1195+
}
11721196
const fieldEl = Renderer.renderField(field, index, item,
11731197
(fld, val) => this.updateValue(index, fld, val),
11741198
refresh,

0 commit comments

Comments
 (0)