prepare support for section names

This commit is contained in:
Johannes Kimmel 2023-04-24 11:13:57 +02:00
parent bb52a90c22
commit 9f9067f11e
1 changed files with 18 additions and 10 deletions

View File

@ -23,13 +23,17 @@ function makeText(text) {
}
class L3Section {
constructor(legend, ...inputs) {
constructor(legend, presetname, ...inputs) {
this.legend = legend;
this.presetname = presetname;
this.inputs = inputs;
}
node() {
let fieldset = makeFieldset();
fieldset.append(makeLegend(makeText(this.legend)));
fieldset.append(makeLegend(
makeText(this.legend),
(typeof this.presetname === 'string')?"":this.presetname)
);
let sep = undefined;
for (const input of this.inputs) {
fieldset.append(input.node());
@ -64,7 +68,11 @@ class L3Section {
}
}
}
return `config ${this.legend}\n\t` + optstrs.join('\n\t')
let sectionname = "";
if (this.presetname) {
sectionname = ` '${this.presetname}'`
}
return `config ${this.legend}${sectionname}\n\t` + optstrs.join('\n\t')
}
}
@ -276,7 +284,7 @@ function initForm() {
l3configinput.appendChild(form);
const l3cfg = new L3Config();
l3cfg.addSection(new L3Section('gateway',
l3cfg.addSection(new L3Section('gateway', 'meta',
new L3Input('Router Name','gatewayName', 'name', {type: 'search', placeholder: 'Router Name'}),
new L3MultiInput('Router IPv4 Address', function(idsuffix) {
return new L3Input(undefined,'gatewayRouterIP4'+idsuffix, 'router_ip', {type: 'search', maxlength: 15, placeholder: 'Router IPv4 Address'});
@ -286,7 +294,7 @@ function initForm() {
}),
new L3Input('Config Version', 'gatewayConfigVersion', 'config_version', {type: 'text', value: 2, disabled: ''}),
));
l3cfg.addSection(new L3Section('dns',
l3cfg.addSection(new L3Section('dns', '',
new L3Select('Preset','dnsAnycastSelect', 'server', {name: 'anycast'}, [
['Anycast DNS', 'fd43:5602:29bd:ffff:1:1:1:1'],
['Anycast DNS64', 'fd43:5602:29bd:ffff:1:1:1:64'],
@ -296,11 +304,11 @@ function initForm() {
return new L3Input(undefined,'dnsOther'+idsuffix, 'server', {type: 'text', maxlength: 39, placeholder: 'Custom DNS Server'});
}),
));
l3cfg.addSection(new L3Section('wan',
l3cfg.addSection(new L3Section('wan', '',
new L3Input('Use VLAN','babelpeerVLAN', 'vlan', {type: 'number', min: 1, max: 4094}),
new L3Input('Use Interface directly','babelpeerIFACE', 'iface', {type: 'text', placeholder: 'eth0, eth0.4, ...'}),
));
l3cfg.addSection(new L3Section('client',
l3cfg.addSection(new L3Section('client', '',
new L3Input('Use VLAN','clientVLAN', 'vlan', {type: 'number', min: 1, max: 4094}),
new L3Input('Use Interface directly','clientIFACE', 'iface', {type: 'text', placeholder: 'eth0, eth0.4, ...'}),
new L3MultiInput('Client IPv6 Subnet', function(idsuffix) {
@ -317,13 +325,13 @@ function initForm() {
new L3Input('Wifi 5 GHz Channel','client5GHZ', 'chan5ghz', {type: 'number', min: 36, max: 140}),
));
l3cfg.addSection(new L3MultiSection('VLAN', function(idsuffix) {
return new L3Section('vlan',
return new L3Section('vlan', '',
new L3Input('Comment','vlanComment', 'comment', {type: 'text'}, ['client', 'wan']),
new L3Input('Ports','vlanPorts', 'ports', {type: 'text', placeholder: 'eth0:*, eth1.4:u, ...'}),
);
}));
l3cfg.addSection(new L3MultiSection('Direct Babel Peering', function(idsuffix) {
return new L3Section('babelpeer',
return new L3Section('babelpeer', '',
new L3Input('Use VLAN','babelpeerVLAN', 'vlan', {type: 'number', min: 1, max: 4094}),
new L3Input('Use Interface directly','babelpeerIFACE', 'iface', {type: 'text', placeholder: 'eth0, eth0.4, ...'}),
new L3Select('Babel Interface Type','babelpeerType', 'type', {name: 'type'}, [
@ -335,7 +343,7 @@ function initForm() {
);
}));
l3cfg.addSection(new L3MultiSection('WireGuard Peering', function(idsuffix) {
return new L3Section('wireguardpeer',
return new L3Section('wireguardpeer', '',
new L3Input('Endpoint Host', 'wireguardpeerEPHost'+idsuffix, 'endpoint_host', {type: 'text', required: ''}, ['peering.nue3.fff.community','ff1.zbau.f3netze.de','nsvm.f3netze.de','2a0b:f4c0:400::']),
new L3Input('Endpoint Port','wireguardpeerEPPort'+idsuffix, 'endpoint_port', {type: 'number', required: '', min:1, max: 65535}),
new L3Input('Persistent Keepalive','wireguardpeerPersistentKeepalive', 'persistent_keepalive', {type: 'number', min: 0, max: 65535, placeholder: '1 - 65535 Seconds...'}),