Browse Source

[Web UI] Fix alternative global rate limits.

adaptive-webui-19844
ngosang 10 years ago
parent
commit
357334fb46
  1. 6
      src/webui/extra_translations.h
  2. 146
      src/webui/www/public/preferences_content.html

6
src/webui/extra_translations.h

@ -42,8 +42,10 @@ static const char *__TRANSLATIONS__[] = {
QT_TRANSLATE_NOOP("HttpServer", "Download local torrent"), QT_TRANSLATE_NOOP("HttpServer", "Download local torrent"),
QT_TRANSLATE_NOOP("HttpServer", "Download"), QT_TRANSLATE_NOOP("HttpServer", "Download"),
QT_TRANSLATE_NOOP("HttpServer", "Are you sure you want to delete the selected torrents from the transfer list?"), QT_TRANSLATE_NOOP("HttpServer", "Are you sure you want to delete the selected torrents from the transfer list?"),
QT_TRANSLATE_NOOP("HttpServer", "Download rate limit must be greater than 0 or disabled."), QT_TRANSLATE_NOOP("HttpServer", "Global upload rate limit must be greater than 0 or disabled."),
QT_TRANSLATE_NOOP("HttpServer", "Upload rate limit must be greater than 0 or disabled."), QT_TRANSLATE_NOOP("HttpServer", "Global download rate limit must be greater than 0 or disabled."),
QT_TRANSLATE_NOOP("HttpServer", "Alternative upload rate limit must be greater than 0 or disabled."),
QT_TRANSLATE_NOOP("HttpServer", "Alternative download rate limit must be greater than 0 or disabled."),
QT_TRANSLATE_NOOP("HttpServer", "Maximum number of connections limit must be greater than 0 or disabled."), QT_TRANSLATE_NOOP("HttpServer", "Maximum number of connections limit must be greater than 0 or disabled."),
QT_TRANSLATE_NOOP("HttpServer", "Maximum number of connections per torrent limit must be greater than 0 or disabled."), QT_TRANSLATE_NOOP("HttpServer", "Maximum number of connections per torrent limit must be greater than 0 or disabled."),
QT_TRANSLATE_NOOP("HttpServer", "Maximum number of upload slots per torrent limit must be greater than 0 or disabled."), QT_TRANSLATE_NOOP("HttpServer", "Maximum number of upload slots per torrent limit must be greater than 0 or disabled."),

146
src/webui/www/public/preferences_content.html

@ -196,13 +196,15 @@
<table> <table>
<tr> <tr>
<td> <td>
QBT_TR(Upload:)QBT_TR <input type="checkbox" id="alt_up_limit_checkbox" onClick="updateAltUpLimitEnabled();"/>
<label for ="alt_up_limit_checkbox">QBT_TR(Upload:)QBT_TR</label>
</td> </td>
<td><input type="text" id="alt_up_limit_value" style="width: 4em;"/>&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR</td> <td><input type="text" id="alt_up_limit_value" style="width: 4em;"/>&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR</td>
</tr> </tr>
<tr> <tr>
<td> <td>
QBT_TR(Download:)QBT_TR <input type="checkbox" id="alt_dl_limit_checkbox" onClick="updateAltDlLimitEnabled();"/>
<label for="alt_dl_limit_checkbox">QBT_TR(Download:)QBT_TR</label>
</td> </td>
<td><input type="text" id="alt_dl_limit_value" style="width: 4em;"/>&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR</td> <td><input type="text" id="alt_dl_limit_value" style="width: 4em;"/>&nbsp;&nbsp;QBT_TR(KiB/s)QBT_TR</td>
</tr> </tr>
@ -394,6 +396,14 @@
<script type="text/javascript"> <script type="text/javascript">
var WatchedFoldersTable = new HtmlTable($("watched_folders_tab")); var WatchedFoldersTable = new HtmlTable($("watched_folders_tab"));
updateUpLimitEnabled = function() {
if($('up_limit_checkbox').getProperty('checked')) {
$('up_limit_value').setProperty('disabled', false);
} else {
$('up_limit_value').setProperty('disabled', true);
}
}
updateDlLimitEnabled = function() { updateDlLimitEnabled = function() {
if($('dl_limit_checkbox').getProperty('checked')) { if($('dl_limit_checkbox').getProperty('checked')) {
$('dl_limit_value').setProperty('disabled', false); $('dl_limit_value').setProperty('disabled', false);
@ -402,6 +412,22 @@ updateDlLimitEnabled = function() {
} }
} }
updateAltUpLimitEnabled = function() {
if($('alt_up_limit_checkbox').getProperty('checked')) {
$('alt_up_limit_value').setProperty('disabled', false);
} else {
$('alt_up_limit_value').setProperty('disabled', true);
}
}
updateAltDlLimitEnabled = function() {
if($('alt_dl_limit_checkbox').getProperty('checked')) {
$('alt_dl_limit_value').setProperty('disabled', false);
} else {
$('alt_dl_limit_value').setProperty('disabled', true);
}
}
updateSchedulingEnabled = function() { updateSchedulingEnabled = function() {
if($('limit_sheduling_checkbox').getProperty('checked')) { if($('limit_sheduling_checkbox').getProperty('checked')) {
$('schedule_from_hour').setProperty('disabled', false); $('schedule_from_hour').setProperty('disabled', false);
@ -418,14 +444,6 @@ updateSchedulingEnabled = function() {
} }
} }
updateUpLimitEnabled = function() {
if($('up_limit_checkbox').getProperty('checked')) {
$('up_limit_value').setProperty('disabled', false);
} else {
$('up_limit_value').setProperty('disabled', true);
}
}
setuTPSettingsVisible = function(visible) { setuTPSettingsVisible = function(visible) {
if(visible) { if(visible) {
$('enable_utp_checkbox').removeClass('invisible'); $('enable_utp_checkbox').removeClass('invisible');
@ -684,7 +702,15 @@ loadPreferences = function() {
$('port_value').setProperty('value', pref.listen_port.toInt()); $('port_value').setProperty('value', pref.listen_port.toInt());
$('upnp_checkbox').setProperty('checked', pref.upnp); $('upnp_checkbox').setProperty('checked', pref.upnp);
$('random_port_checkbox').setProperty('checked', pref.random_port); $('random_port_checkbox').setProperty('checked', pref.random_port);
// Global rate limits
var up_limit = pref.up_limit.toInt();
if(up_limit <= 0) {
$('up_limit_checkbox').setProperty('checked', false);
} else {
$('up_limit_checkbox').setProperty('checked', true);
$('up_limit_value').setProperty('value', up_limit);
}
updateUpLimitEnabled();
var dl_limit = pref.dl_limit.toInt(); var dl_limit = pref.dl_limit.toInt();
if(dl_limit <= 0) { if(dl_limit <= 0) {
$('dl_limit_checkbox').setProperty('checked', false); $('dl_limit_checkbox').setProperty('checked', false);
@ -693,17 +719,23 @@ loadPreferences = function() {
$('dl_limit_value').setProperty('value', dl_limit); $('dl_limit_value').setProperty('value', dl_limit);
} }
updateDlLimitEnabled(); updateDlLimitEnabled();
var up_limit = pref.up_limit.toInt(); // Alternative limits
if(up_limit <= 0) { var alt_up_limit = pref.alt_up_limit.toInt();
$('up_limit_checkbox').setProperty('checked', false); if(alt_up_limit <= 0) {
$('alt_up_limit_checkbox').setProperty('checked', false);
} else { } else {
$('up_limit_checkbox').setProperty('checked', true); $('alt_up_limit_checkbox').setProperty('checked', true);
$('up_limit_value').setProperty('value', up_limit); $('alt_up_limit_value').setProperty('value', alt_up_limit);
} }
updateUpLimitEnabled(); updateAltUpLimitEnabled();
// Alternative limits var alt_dl_limit = pref.alt_dl_limit.toInt();
$('alt_dl_limit_value').setProperty('value', pref.alt_dl_limit.toInt()); if(alt_dl_limit <= 0) {
$('alt_up_limit_value').setProperty('value', pref.alt_up_limit.toInt()); $('alt_dl_limit_checkbox').setProperty('checked', false);
} else {
$('alt_dl_limit_checkbox').setProperty('checked', true);
$('alt_dl_limit_value').setProperty('value', alt_dl_limit);
}
updateAltDlLimitEnabled();
// Scheduling // Scheduling
$('limit_sheduling_checkbox').setProperty('checked', pref.scheduler_enabled); $('limit_sheduling_checkbox').setProperty('checked', pref.scheduler_enabled);
$('schedule_from_hour').setProperty('value', time_padding(pref.schedule_from_hour)); $('schedule_from_hour').setProperty('value', time_padding(pref.schedule_from_hour));
@ -712,15 +744,14 @@ loadPreferences = function() {
$('schedule_to_min').setProperty('value', time_padding(pref.schedule_to_min)); $('schedule_to_min').setProperty('value', time_padding(pref.schedule_to_min));
$('schedule_freq_select').setProperty('value', pref.scheduler_days); $('schedule_freq_select').setProperty('value', pref.scheduler_days);
updateSchedulingEnabled(); updateSchedulingEnabled();
// uTP
// uTP utp_supported = $defined(pref.enable_utp);
utp_supported = $defined(pref.enable_utp); setuTPSettingsVisible(utp_supported);
setuTPSettingsVisible(utp_supported); if(utp_supported) {
if(utp_supported) { $('enable_utp_checkbox').setProperty('checked', pref.enable_utp);
$('enable_utp_checkbox').setProperty('checked', pref.enable_utp); $('limit_utp_rate_checkbox').setProperty('checked', pref.limit_utp_rate);
$('limit_utp_rate_checkbox').setProperty('checked', pref.limit_utp_rate); }
} $('limit_tcp_overhead_checkbox').setProperty('checked', pref.limit_tcp_overhead);
$('limit_tcp_overhead_checkbox').setProperty('checked', pref.limit_tcp_overhead);
var max_connec = pref.max_connec.toInt(); var max_connec = pref.max_connec.toInt();
if(max_connec <= 0) { if(max_connec <= 0) {
$('max_connec_checkbox').setProperty('checked', false); $('max_connec_checkbox').setProperty('checked', false);
@ -891,27 +922,47 @@ applyPreferences = function() {
settings.set('listen_port', listen_port); settings.set('listen_port', listen_port);
settings.set('upnp', $('upnp_checkbox').getProperty('checked')); settings.set('upnp', $('upnp_checkbox').getProperty('checked'));
settings.set('random_port', $('random_port_checkbox').getProperty('checked')); settings.set('random_port', $('random_port_checkbox').getProperty('checked'));
// Global rate limits
var up_limit = -1;
if($('up_limit_checkbox').getProperty('checked')) {
up_limit = $('up_limit_value').getProperty('value').toInt();
if(isNaN(up_limit) || up_limit <= 0) {
alert("QBT_TR(Global upload rate limit must be greater than 0 or disabled.)QBT_TR");
return;
}
}
settings.set('up_limit', up_limit);
var dl_limit = -1; var dl_limit = -1;
if($('dl_limit_checkbox').getProperty('checked')) { if($('dl_limit_checkbox').getProperty('checked')) {
dl_limit = $('dl_limit_value').getProperty('value').toInt(); dl_limit = $('dl_limit_value').getProperty('value').toInt();
if(dl_limit <= 0) { if(isNaN(dl_limit) || dl_limit <= 0) {
alert("QBT_TR(Download rate limit must be greater than 0 or disabled.)QBT_TR"); alert("QBT_TR(Global download rate limit must be greater than 0 or disabled.)QBT_TR");
return; return;
} }
} }
settings.set('dl_limit', dl_limit); settings.set('dl_limit', dl_limit);
var up_limit = -1; // Alternative limits
if($('up_limit_checkbox').getProperty('checked')) { var alt_up_limit = -1;
up_limit = $('up_limit_value').getProperty('value').toInt(); if($('alt_up_limit_checkbox').getProperty('checked')) {
if(up_limit <= 0) { alt_up_limit = $('alt_up_limit_value').getProperty('value').toInt();
alert("QBT_TR(Upload rate limit must be greater than 0 or disabled.)QBT_TR"); if(isNaN(alt_up_limit) || alt_up_limit <= 0) {
alert("QBT_TR(Alternative upload rate limit must be greater than 0 or disabled.)QBT_TR");
return; return;
} }
} }
settings.set('up_limit', up_limit); settings.set('alt_up_limit', alt_up_limit);
var alt_dl_limit = -1;
if($('alt_dl_limit_checkbox').getProperty('checked')) {
alt_dl_limit = $('alt_dl_limit_value').getProperty('value').toInt();
if(isNaN(alt_dl_limit) || alt_dl_limit <= 0) {
alert("QBT_TR(Alternative download rate limit must be greater than 0 or disabled.)QBT_TR");
return;
}
}
settings.set('alt_dl_limit', alt_dl_limit);
if(!$('enable_utp_checkbox').hasClass('invisible')) { if(!$('enable_utp_checkbox').hasClass('invisible')) {
settings.set('enable_utp', $('enable_utp_checkbox').getProperty('checked')); settings.set('enable_utp', $('enable_utp_checkbox').getProperty('checked'));
settings.set('limit_utp_rate', $('limit_utp_rate_checkbox').getProperty('checked')); settings.set('limit_utp_rate', $('limit_utp_rate_checkbox').getProperty('checked'));
@ -959,21 +1010,6 @@ applyPreferences = function() {
} }
settings.set('max_uploads_per_torrent', max_uploads_per_torrent); settings.set('max_uploads_per_torrent', max_uploads_per_torrent);
// Alternative speed limits
var alt_dl_limit = $('alt_dl_limit_value').getProperty('value').toInt();
if(alt_dl_limit <= 0) {
alert("QBT_TR(Download rate limit must be greater than 0 or disabled.)QBT_TR");
return;
}
settings.set('alt_dl_limit', alt_dl_limit);
var alt_up_limit = $('alt_up_limit_value').getProperty('value').toInt();
if(alt_up_limit <= 0) {
alert("QBT_TR(Upload rate limit must be greater than 0 or disabled.)QBT_TR");
return;
}
settings.set('alt_up_limit', alt_up_limit);
// Scheduler // Scheduler
var scheduling_enabled = $('limit_sheduling_checkbox').getProperty('checked'); var scheduling_enabled = $('limit_sheduling_checkbox').getProperty('checked');
settings.set('scheduler_enabled', scheduling_enabled); settings.set('scheduler_enabled', scheduling_enabled);

Loading…
Cancel
Save