WebUI: Preserve the network interfaces when down

PR #19286.
This commit is contained in:
Fabricio Silva
2023-07-11 04:23:37 +01:00
committed by GitHub
parent 488464731d
commit f08556be30
2 changed files with 12 additions and 5 deletions

View File

@@ -1749,7 +1749,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
};
// Advanced Tab
const updateNetworkInterfaces = function(default_iface) {
const updateNetworkInterfaces = function(default_iface, default_iface_name) {
const url = 'api/v2/app/networkInterfaceList';
$('networkInterface').empty();
new Request.JSON({
@@ -1760,9 +1760,13 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
alert("Could not contact qBittorrent");
},
onSuccess: function(ifaces) {
if (!ifaces)
if (!Array.isArray(ifaces))
return;
// add the current network interface to the options if needed
if (default_iface && !ifaces.some((item) => item.value === default_iface))
ifaces.push({ name: default_iface_name || default_iface, value: default_iface });
$('networkInterface').options.add(new Option('QBT_TR(Any interface)QBT_TR[CONTEXT=OptionsDialog]', ''));
ifaces.forEach(function(item, index) {
$('networkInterface').options.add(new Option(item.name, item.value));
@@ -2144,7 +2148,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
// qBittorrent section
$('resumeDataStorageType').setProperty('value', pref.resume_data_storage_type);
$('memoryWorkingSetLimit').setProperty('value', pref.memory_working_set_limit);
updateNetworkInterfaces(pref.current_network_interface);
updateNetworkInterfaces(pref.current_network_interface, pref.current_interface_name);
updateInterfaceAddresses(pref.current_network_interface, pref.current_interface_address);
$('saveResumeDataInterval').setProperty('value', pref.save_resume_data_interval);
$('recheckTorrentsOnCompletion').setProperty('checked', pref.recheck_completed_torrents);