luci-app-mtwifi-cfg: add sanity check for vif remove

This commit is contained in:
hanwckf 2024-01-08 13:02:12 +08:00
parent 41208baa4d
commit 1519eb5d13
2 changed files with 32 additions and 2 deletions

View File

@ -33,3 +33,9 @@ msgstr "弱信号接入阈值"
msgid "Wireless HWNAT"
msgstr "无线硬件加速"
msgid "Wireless configuration error"
msgstr "无线网络设置错误"
msgid "At least one MBSSID needs to be reserved"
msgstr "至少需要保留1个MBSSID"

View File

@ -924,7 +924,7 @@ return view.extend({
E('button', {
'class': 'cbi-button cbi-button-negative remove',
'title': _('Delete this network'),
'click': ui.createHandlerFn(this, 'handleRemove', section_id)
'click': ui.createHandlerFn(this, 'handleRemove', section_id, inst)
}, _('Remove'))
];
}
@ -1985,7 +1985,31 @@ return view.extend({
});
};
s.handleRemove = function(section_id, ev) {
s.handleRemove = function(section_id, radioNet, ev) {
var radioName = radioNet.getWifiDeviceName();
var hwtype = uci.get('wireless', radioName, 'type');
if (hwtype == 'mtwifi')
{
var wifi_sections = uci.sections('wireless', 'wifi-iface');
var mbssid_num = 0;
for (var i = 0; i < wifi_sections.length; i++) {
if (wifi_sections[i].device == radioName && wifi_sections[i].mode == "ap")
mbssid_num++;
}
if (mbssid_num <= 1)
return ui.showModal(_('Wireless configuration error'), [
E('p', _('At least one MBSSID needs to be reserved')),
E('div', { 'class': 'right' },
E('button', {
'class': 'btn',
'click': ui.hideModal
}, _('Close')))
]);
}
document.querySelector('.cbi-section-table-row[data-sid="%s"]'.format(section_id)).style.opacity = 0.5;
return form.TypedSection.prototype.handleRemove.apply(this, [section_id, ev]);
};