diff options
Diffstat (limited to 'applications')
-rw-r--r-- | applications/luci-app-libreswan/htdocs/luci-static/resources/view/libreswan/proposals.js | 20 | ||||
-rw-r--r-- | applications/luci-app-libreswan/htdocs/luci-static/resources/view/libreswan/tunnels.js | 20 |
2 files changed, 40 insertions, 0 deletions
diff --git a/applications/luci-app-libreswan/htdocs/luci-static/resources/view/libreswan/proposals.js b/applications/luci-app-libreswan/htdocs/luci-static/resources/view/libreswan/proposals.js index 8569e05caa..e1b14a8e32 100644 --- a/applications/luci-app-libreswan/htdocs/luci-static/resources/view/libreswan/proposals.js +++ b/applications/luci-app-libreswan/htdocs/luci-static/resources/view/libreswan/proposals.js @@ -2,6 +2,7 @@ 'require view'; 'require ui'; 'require form'; +'require uci'; return view.extend({ render: function() { @@ -15,6 +16,25 @@ return view.extend({ s.nodescriptions = true; s.addbtntitle = _('Add Proposal'); + 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('libreswan', 'crypto_proposal'), + ...uci.sections('libreswan', 'tunnel'), + ]; + if (sections.find(function(s) { + return s['.name'] == v; + })) { + return _('This may not share the same name as other proposals or configured tunnels.'); + } + if (v.length > 15) return _('Name length shall not exceed 15 characters'); + return true; + }, 'blur', 'keyup'); + return el; + }; + o = s.tab('general', _('General')); o = s.taboption('general', form.MultiValue, 'hash_algorithm', _('Hash Algorithm'), ('* = %s').format(_('Unsafe'))); diff --git a/applications/luci-app-libreswan/htdocs/luci-static/resources/view/libreswan/tunnels.js b/applications/luci-app-libreswan/htdocs/luci-static/resources/view/libreswan/tunnels.js index f7cb439458..762e17cee7 100644 --- a/applications/luci-app-libreswan/htdocs/luci-static/resources/view/libreswan/tunnels.js +++ b/applications/luci-app-libreswan/htdocs/luci-static/resources/view/libreswan/tunnels.js @@ -54,6 +54,26 @@ return view.extend({ s.nodedescription = false; s.addbtntitle = _('Add Tunnel'); + 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('libreswan', 'crypto_proposal'), + ...uci.sections('libreswan', 'tunnel'), + ]; + + if (sections.find(function(s) { + return s['.name'] == v; + })) { + return _('This may not share the same name as other proposals or configured tunnels.'); + } + if (v.length > 15) return _('Name length shall not exceed 15 characters'); + return true; + }, 'blur', 'keyup'); + return el; + }; + o = s.tab('general', _('General')); o = s.tab('authentication', _('Authentication')); o = s.tab('interface', _('Interface')); |