Browse Source

WebUI: Preserve the network interfaces when down

PR #19286.
adaptive-webui-19844
Fabricio Silva 1 year ago committed by GitHub
parent
commit
f08556be30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/webui/api/appcontroller.cpp
  2. 10
      src/webui/www/private/views/preferences.html

7
src/webui/api/appcontroller.cpp

@ -320,8 +320,10 @@ void AppController::preferencesAction() @@ -320,8 +320,10 @@ void AppController::preferencesAction()
data[u"memory_working_set_limit"_s] = app()->memoryWorkingSetLimit();
// Current network interface
data[u"current_network_interface"_s] = session->networkInterface();
// Current network interface name
data[u"current_interface_name"_s] = session->networkInterfaceName();
// Current network interface address
data[u"current_interface_address"_s] = BitTorrent::Session::instance()->networkInterfaceAddress();
data[u"current_interface_address"_s] = session->networkInterfaceAddress();
// Save resume data interval
data[u"save_resume_data_interval"_s] = session->saveResumeDataInterval();
// Recheck completed torrents
@ -845,7 +847,8 @@ void AppController::setPreferencesAction() @@ -845,7 +847,8 @@ void AppController::setPreferencesAction()
const QString ifaceName = (ifacesIter != ifaces.cend()) ? ifacesIter->humanReadableName() : QString {};
session->setNetworkInterface(ifaceValue);
session->setNetworkInterfaceName(ifaceName);
if (!ifaceName.isEmpty() || ifaceValue.isEmpty())
session->setNetworkInterfaceName(ifaceName);
}
// Current network interface address
if (hasKey(u"current_interface_address"_s))

10
src/webui/www/private/views/preferences.html

@ -1749,7 +1749,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -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 @@ -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 @@ -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);

Loading…
Cancel
Save