luci-app-firewall: fix creating multiple networks from zone network selector
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 5d528da29f
)
This commit is contained in:
parent
6870d9e908
commit
b7f150ca5c
1 changed files with 11 additions and 6 deletions
|
@ -178,19 +178,24 @@ return view.extend({
|
|||
};
|
||||
o.write = function(section_id, formvalue) {
|
||||
var name = uci.get('firewall', section_id, 'name'),
|
||||
cfgvalue = this.cfgvalue(section_id);
|
||||
cfgvalue = this.cfgvalue(section_id),
|
||||
oldNetworks = L.toArray(cfgvalue),
|
||||
newNetworks = L.toArray(formvalue);
|
||||
|
||||
if (typeof(cfgvalue) == 'string' && Array.isArray(formvalue) && (cfgvalue == formvalue.join(' ')))
|
||||
oldNetworks.sort();
|
||||
newNetworks.sort();
|
||||
|
||||
if (oldNetworks.join(' ') == newNetworks.join(' '))
|
||||
return;
|
||||
|
||||
var tasks = [ firewall.getZone(name) ];
|
||||
|
||||
if (Array.isArray(formvalue))
|
||||
for (var i = 0; i < formvalue.length; i++) {
|
||||
var netname = formvalue[i];
|
||||
tasks.push(network.getNetwork(netname).then(function(net) {
|
||||
for (var i = 0; i < newNetworks.length; i++) {
|
||||
var netname = newNetworks[i];
|
||||
tasks.push(network.getNetwork(netname).then(L.bind(function(netname, net) {
|
||||
return net || network.addNetwork(netname, { 'proto': 'none' });
|
||||
}));
|
||||
}, this, netname)));
|
||||
}
|
||||
|
||||
return Promise.all(tasks).then(function(zone_networks) {
|
||||
|
|
Loading…
Reference in a new issue