diff options
Diffstat (limited to 'applications')
4 files changed, 102 insertions, 6 deletions
diff --git a/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/interface.js b/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/interface.js index 74c1718322..c9ec5209c7 100644 --- a/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/interface.js +++ b/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/interface.js @@ -3,6 +3,7 @@ 'require fs'; 'require view'; 'require uci'; +'require ui'; return view.extend({ load: function() { @@ -28,6 +29,29 @@ return view.extend({ s.anonymous = false; s.nodescriptions = true; + /* This name length error check can likely be removed when mwan3 migrates to nftables */ + s.renderSectionAdd = function(extra_class) { + var el = form.GridSection.prototype.renderSectionAdd.apply(this, arguments), + nameEl = el.querySelector('.cbi-section-create-name'); + ui.addValidator(nameEl, 'uciname', true, function(v) { + let sections = [ + ...uci.sections('mwan3', 'interface'), + ...uci.sections('mwan3', 'member'), + ...uci.sections('mwan3', 'policy'), + ...uci.sections('mwan3', 'rule') + ]; + + for (let j = 0; j < sections.length; j++) { + if (sections[j]['.name'] == v) { + return _('Interfaces may not share the same name as configured members, policies or rules.'); + } + } + if (v.length > 15) return _('Name length shall not exceed 15 characters'); + return true; + }, 'blur', 'keyup'); + return el; + }; + o = s.option(form.Flag, 'enabled', _('Enabled')); o.default = false; diff --git a/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/member.js b/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/member.js index c49cc6e1ef..17946da2c8 100644 --- a/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/member.js +++ b/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/member.js @@ -2,6 +2,7 @@ 'require form'; 'require view'; 'require uci'; +'require ui'; return view.extend({ load: function() { @@ -23,6 +24,29 @@ return view.extend({ s.anonymous = false; s.nodescriptions = true; + /* This name length error check can likely be removed when mwan3 migrates to nftables */ + s.renderSectionAdd = function(extra_class) { + var el = form.GridSection.prototype.renderSectionAdd.apply(this, arguments), + nameEl = el.querySelector('.cbi-section-create-name'); + ui.addValidator(nameEl, 'uciname', true, function(v) { + let sections = [ + ...uci.sections('mwan3', 'interface'), + ...uci.sections('mwan3', 'member'), + ...uci.sections('mwan3', 'policy'), + ...uci.sections('mwan3', 'rule') + ]; + + for (let j = 0; j < sections.length; j++) { + if (sections[j]['.name'] == v) { + return _('Members may not share the same name as configured interfaces, policies or rules.'); + } + } + if (v.length > 15) return _('Name length shall not exceed 15 characters'); + return true; + }, 'blur', 'keyup'); + return el; + }; + o = s.option(form.ListValue, 'interface', _('Interface')); var options = uci.sections('mwan3', 'interface') for (var i = 0; i < options.length; i++) { diff --git a/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/policy.js b/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/policy.js index d39eb3bfba..3963185f6a 100644 --- a/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/policy.js +++ b/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/policy.js @@ -2,6 +2,7 @@ 'require form'; 'require view'; 'require uci'; +'require ui'; return view.extend({ load: function() { @@ -14,12 +15,12 @@ return view.extend({ var m, s, o; m = new form.Map('mwan3', _('MultiWAN Manager - Policies'), - _('Policies are profiles grouping one or more members controlling how Mwan3 distributes traffic.') + - _('Member interfaces with lower metrics are used first.') + - _('Member interfaces with the same metric will be load-balanced.') + - _('Load-balanced member interfaces distribute more traffic out those with higher weights.') + - _('Names may contain characters A-Z, a-z, 0-9, _ and no spaces.') + - _('Names must be 15 characters or less.') + + _('Policies are profiles grouping one or more members controlling how Mwan3 distributes traffic.') + '<br />' + + _('Member interfaces with lower metrics are used first.') + '<br />' + + _('Member interfaces with the same metric will be load-balanced.') + '<br />' + + _('Load-balanced member interfaces distribute more traffic out those with higher weights.') + '<br />' + + _('Names may contain characters A-Z, a-z, 0-9, _ and no spaces.') + '<br />' + + _('Names must be 15 characters or less.') + '<br />' + _('Policies may not share the same name as configured interfaces, members or rules')); s = m.section(form.GridSection, 'policy'); @@ -27,6 +28,29 @@ return view.extend({ s.anonymous = false; s.nodescriptions = true; + /* This name length error check can likely be removed when mwan3 migrates to nftables */ + s.renderSectionAdd = function(extra_class) { + var el = form.GridSection.prototype.renderSectionAdd.apply(this, arguments), + nameEl = el.querySelector('.cbi-section-create-name'); + ui.addValidator(nameEl, 'uciname', true, function(v) { + let sections = [ + ...uci.sections('mwan3', 'interface'), + ...uci.sections('mwan3', 'member'), + ...uci.sections('mwan3', 'policy'), + ...uci.sections('mwan3', 'rule') + ]; + + for (let j = 0; j < sections.length; j++) { + if (sections[j]['.name'] == v) { + return _('Policies may not share the same name as configured interfaces, members or rules'); + } + } + if (v.length > 15) return _('Name length shall not exceed 15 characters'); + return true; + }, 'blur', 'keyup'); + return el; + }; + o = s.option(form.DynamicList, 'use_member', _('Member used')); var options = uci.sections('mwan3', 'member') for (var i = 0; i < options.length; i++) { diff --git a/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/rule.js b/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/rule.js index 6452caf58a..2e90e5dd26 100644 --- a/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/rule.js +++ b/applications/luci-app-mwan3/htdocs/luci-static/resources/view/mwan3/network/rule.js @@ -3,6 +3,7 @@ 'require fs'; 'require view'; 'require uci'; +'require ui'; return view.extend({ load: function() { @@ -32,6 +33,29 @@ return view.extend({ s.nodescriptions = true; s.sortable = true; + /* This name length error check can likely be removed when mwan3 migrates to nftables */ + s.renderSectionAdd = function(extra_class) { + var el = form.GridSection.prototype.renderSectionAdd.apply(this, arguments), + nameEl = el.querySelector('.cbi-section-create-name'); + ui.addValidator(nameEl, 'uciname', true, function(v) { + let sections = [ + ...uci.sections('mwan3', 'interface'), + ...uci.sections('mwan3', 'member'), + ...uci.sections('mwan3', 'policy'), + ...uci.sections('mwan3', 'rule') + ]; + + for (let j = 0; j < sections.length; j++) { + if (sections[j]['.name'] == v) { + return _('Rules may not share the same name as configured interfaces, members or policies.'); + } + } + if (v.length > 15) return _('Name length shall not exceed 15 characters'); + return true; + }, 'blur', 'keyup'); + return el; + }; + o = s.option(form.ListValue, 'family', _('Internet Protocol')); o.default = ''; o.value('', _('IPv4 and IPv6')); |