luci-mod-network: wifi join: allow reclaiming empty wwan networks
Fixes: #3660
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 48e18fb8ac
)
This commit is contained in:
parent
4c8f0cdcc8
commit
62be6eff08
1 changed files with 11 additions and 2 deletions
|
@ -1893,6 +1893,15 @@ return L.view.extend({
|
||||||
is_psk = (enc && Array.isArray(enc.wpa) && L.toArray(enc.authentication).filter(function(a) { return a == 'psk' || a == 'sae' })),
|
is_psk = (enc && Array.isArray(enc.wpa) && L.toArray(enc.authentication).filter(function(a) { return a == 'psk' || a == 'sae' })),
|
||||||
replace, passphrase, name, bssid, zone;
|
replace, passphrase, name, bssid, zone;
|
||||||
|
|
||||||
|
var nameUsed = function(name) {
|
||||||
|
var s = uci.get('network', name);
|
||||||
|
if (s != null && s['.type'] != 'interface')
|
||||||
|
return true;
|
||||||
|
|
||||||
|
var net = (s != null) ? network.instantiateNetwork(name) : null;
|
||||||
|
return (net != null && !net.isEmpty());
|
||||||
|
};
|
||||||
|
|
||||||
s2.render = function() {
|
s2.render = function() {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
{},
|
{},
|
||||||
|
@ -1907,13 +1916,13 @@ return L.view.extend({
|
||||||
name.default = 'wwan';
|
name.default = 'wwan';
|
||||||
name.rmempty = false;
|
name.rmempty = false;
|
||||||
name.validate = function(section_id, value) {
|
name.validate = function(section_id, value) {
|
||||||
if (uci.get('network', value))
|
if (nameUsed(value))
|
||||||
return _('The network name is already used');
|
return _('The network name is already used');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var i = 2; uci.get('network', name.default); i++)
|
for (var i = 2; nameUsed(name.default); i++)
|
||||||
name.default = 'wwan%d'.format(i);
|
name.default = 'wwan%d'.format(i);
|
||||||
|
|
||||||
if (is_wep || is_psk) {
|
if (is_wep || is_psk) {
|
||||||
|
|
Loading…
Reference in a new issue