diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-03-04 20:27:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-04 20:27:18 +0100 |
commit | 6c167ea880bd29c69730d802c48ebc2c0253b905 (patch) | |
tree | 5de85f0e644d678d6a9cf1a208ee2d78d9e56d67 | |
parent | fc94ff1881dc50539fc03a734ada264590121883 (diff) | |
parent | c949d116b09c93c6c8076a69fa260c96818a761a (diff) |
Merge pull request #3713 from TDT-AG/pr/20200303-luci-mod-network
luci-mod-network: extended interfaces.js for check if new interface i…
-rw-r--r-- | modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js index 80acd7c77..5cc452c9f 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js @@ -760,24 +760,35 @@ return L.view.extend({ 'class': 'cbi-button cbi-button-positive important', 'click': ui.createHandlerFn(this, function(ev) { var nameval = name.isValid('_new_') ? name.formvalue('_new_') : null, - protoval = proto.isValid('_new_') ? proto.formvalue('_new_') : null; + protoval = proto.isValid('_new_') ? proto.formvalue('_new_') : null, + protoclass = protoval ? network.getProtocol(protoval) : null; if (nameval == null || protoval == null || nameval == '' || protoval == '') return; - return m.save(function() { - var section_id = uci.add('network', 'interface', nameval); + return protoclass.isCreateable(nameval).then(function(checkval) { + if (checkval != null) { + ui.addNotification(null, + E('p', _('New interface for "%s" can not be created: %s').format(protoclass.getI18n(), checkval))); + ui.hideModal(); + return; + } - uci.set('network', section_id, 'proto', protoval); + return m.save(function() { + var section_id = uci.add('network', 'interface', nameval); - if (ifname_single.isActive('_new_')) { - uci.set('network', section_id, 'ifname', ifname_single.formvalue('_new_')); - } - else if (ifname_multi.isActive('_new_')) { - uci.set('network', section_id, 'type', 'bridge'); - uci.set('network', section_id, 'ifname', L.toArray(ifname_multi.formvalue('_new_')).join(' ')); - } - }).then(L.bind(m.children[0].renderMoreOptionsModal, m.children[0], nameval)); + uci.set('network', section_id, 'proto', protoval); + + if (ifname_single.isActive('_new_')) { + uci.set('network', section_id, 'ifname', ifname_single.formvalue('_new_')); + } + else if (ifname_multi.isActive('_new_')) { + uci.set('network', section_id, 'type', 'bridge'); + uci.set('network', section_id, 'ifname', L.toArray(ifname_multi.formvalue('_new_')).join(' ')); + } + }).then(L.bind(m.children[0].renderMoreOptionsModal, m.children[0], nameval)); + + }); }) }, _('Create interface')) ]) |