Browse Source

Merge pull request #9752 from Piccirello/webui-autotmm

Add missing Preferences to WebUI
adaptive-webui-19844
Mike Tzou 6 years ago committed by GitHub
parent
commit
f32865b0c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      src/gui/optionsdialog.cpp
  2. 1
      src/gui/optionsdialog.h
  3. 2
      src/gui/optionsdialog.ui
  4. 81
      src/webui/api/appcontroller.cpp
  5. 2
      src/webui/api/torrentscontroller.cpp
  6. 24
      src/webui/www/private/css/style.css
  7. 154
      src/webui/www/private/download.html
  8. 790
      src/webui/www/private/preferences_content.html
  9. 89
      src/webui/www/private/scripts/download.js
  10. 4
      src/webui/www/private/shareratio.html
  11. 142
      src/webui/www/private/upload.html

17
src/gui/optionsdialog.cpp

@ -1250,6 +1250,10 @@ void OptionsDialog::on_buttonBox_accepted() @@ -1250,6 +1250,10 @@ void OptionsDialog::on_buttonBox_accepted()
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
return;
}
if (!isAlternativeWebUIPathValid()) {
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
return;
}
m_applyButton->setEnabled(false);
this->hide();
saveOptions();
@ -1269,6 +1273,10 @@ void OptionsDialog::applySettings(QAbstractButton *button) @@ -1269,6 +1273,10 @@ void OptionsDialog::applySettings(QAbstractButton *button)
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
return;
}
if (!isAlternativeWebUIPathValid()) {
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
return;
}
saveOptions();
}
}
@ -1751,6 +1759,15 @@ bool OptionsDialog::webUIAuthenticationOk() @@ -1751,6 +1759,15 @@ bool OptionsDialog::webUIAuthenticationOk()
return true;
}
bool OptionsDialog::isAlternativeWebUIPathValid()
{
if (m_ui->groupAltWebUI->isChecked() && m_ui->textWebUIRootFolder->selectedPath().trimmed().isEmpty()) {
QMessageBox::warning(this, tr("Location Error"), tr("The alternative Web UI files location cannot be blank."));
return false;
}
return true;
}
void OptionsDialog::on_banListButton_clicked()
{
// call dialog window

1
src/gui/optionsdialog.h

@ -172,6 +172,7 @@ private: @@ -172,6 +172,7 @@ private:
bool setSslCertificate(const QByteArray &cert);
bool schedTimesOk();
bool webUIAuthenticationOk();
bool isAlternativeWebUIPathValid();
QByteArray m_sslCert, m_sslKey;

2
src/gui/optionsdialog.ui

@ -941,7 +941,7 @@ @@ -941,7 +941,7 @@
<item row="3" column="0">
<widget class="QLabel" name="labelCategoryChanged">
<property name="text">
<string>When Category changed:</string>
<string>When Category Save Path changed:</string>
</property>
</widget>
</item>

81
src/webui/api/appcontroller.cpp

@ -52,6 +52,7 @@ @@ -52,6 +52,7 @@
#include "base/rss/rss_autodownloader.h"
#include "base/rss/rss_session.h"
#include "base/scanfoldersmodel.h"
#include "base/torrentfileguard.h"
#include "base/utils/fs.h"
#include "base/utils/net.h"
#include "base/utils/password.h"
@ -84,12 +85,23 @@ void AppController::preferencesAction() @@ -84,12 +85,23 @@ void AppController::preferencesAction()
QVariantMap data;
// Downloads
// Hard Disk
// When adding a torrent
data["create_subfolder_enabled"] = session->isCreateTorrentSubfolder();
data["start_paused_enabled"] = session->isAddTorrentPaused();
data["auto_delete_mode"] = static_cast<int>(TorrentFileGuard::autoDeleteMode());
data["preallocate_all"] = session->isPreallocationEnabled();
data["incomplete_files_ext"] = session->isAppendExtensionEnabled();
// Saving Management
data["auto_tmm_enabled"] = !session->isAutoTMMDisabledByDefault();
data["torrent_changed_tmm_enabled"] = !session->isDisableAutoTMMWhenCategoryChanged();
data["save_path_changed_tmm_enabled"] = !session->isDisableAutoTMMWhenDefaultSavePathChanged();
data["category_changed_tmm_enabled"] = !session->isDisableAutoTMMWhenCategorySavePathChanged();
data["save_path"] = Utils::Fs::toNativePath(session->defaultSavePath());
data["temp_path_enabled"] = session->isTempPathEnabled();
data["temp_path"] = Utils::Fs::toNativePath(session->tempPath());
data["preallocate_all"] = session->isPreallocationEnabled();
data["incomplete_files_ext"] = session->isAppendExtensionEnabled();
data["export_dir"] = Utils::Fs::toNativePath(session->torrentExportDirectory());
data["export_dir_fin"] = Utils::Fs::toNativePath(session->finishedTorrentExportDirectory());
// Automatically add torrents from
const QVariantHash dirs = pref->getScanDirs();
QVariantMap nativeDirs;
for (QVariantHash::const_iterator i = dirs.cbegin(), e = dirs.cend(); i != e; ++i) {
@ -99,10 +111,9 @@ void AppController::preferencesAction() @@ -99,10 +111,9 @@ void AppController::preferencesAction()
nativeDirs.insert(Utils::Fs::toNativePath(i.key()), Utils::Fs::toNativePath(i.value().toString()));
}
data["scan_dirs"] = nativeDirs;
data["export_dir"] = Utils::Fs::toNativePath(session->torrentExportDirectory());
data["export_dir_fin"] = Utils::Fs::toNativePath(session->finishedTorrentExportDirectory());
// Email notification upon download completion
data["mail_notification_enabled"] = pref->isMailNotificationEnabled();
data["mail_notification_sender"] = pref->getMailNotificationSender();
data["mail_notification_email"] = pref->getMailNotificationEmail();
data["mail_notification_smtp"] = pref->getMailNotificationSMTP();
data["mail_notification_ssl_enabled"] = pref->getMailNotificationSMTPSSL();
@ -153,6 +164,7 @@ void AppController::preferencesAction() @@ -153,6 +164,7 @@ void AppController::preferencesAction()
data["bittorrent_protocol"] = static_cast<int>(session->btProtocol());
data["limit_utp_rate"] = session->isUTPRateLimited();
data["limit_tcp_overhead"] = session->includeOverheadInLimits();
data["limit_lan_peers"] = !session->ignoreLimitsOnLAN();
// Scheduling
data["scheduler_enabled"] = session->isBandwidthSchedulerEnabled();
const QTime start_time = pref->getSchedulerStartTime();
@ -176,6 +188,9 @@ void AppController::preferencesAction() @@ -176,6 +188,9 @@ void AppController::preferencesAction()
data["max_active_torrents"] = session->maxActiveTorrents();
data["max_active_uploads"] = session->maxActiveUploads();
data["dont_count_slow_torrents"] = session->ignoreSlowTorrentsForQueueing();
data["slow_torrent_dl_rate_threshold"] = session->downloadRateForSlowTorrents();
data["slow_torrent_ul_rate_threshold"] = session->uploadRateForSlowTorrents();
data["slow_torrent_inactive_timer"] = session->slowTorrentsInactivityTimer();
// Share Ratio Limiting
data["max_ratio_enabled"] = (session->globalMaxRatio() >= 0.);
data["max_ratio"] = session->globalMaxRatio();
@ -205,6 +220,9 @@ void AppController::preferencesAction() @@ -205,6 +220,9 @@ void AppController::preferencesAction()
for (const Utils::Net::Subnet &subnet : asConst(pref->getWebUiAuthSubnetWhitelist()))
authSubnetWhitelistStringList << Utils::Net::subnetToString(subnet);
data["bypass_auth_subnet_whitelist"] = authSubnetWhitelistStringList.join("\n");
// Use alternative Web UI
data["alternative_webui_enabled"] = pref->isAltWebUiEnabled();
data["alternative_webui_path"] = pref->getWebUiRootFolder();
// Security
data["web_ui_clickjacking_protection_enabled"] = pref->isWebUiClickjackingProtectionEnabled();
data["web_ui_csrf_protection_enabled"] = pref->isWebUiCSRFProtectionEnabled();
@ -232,19 +250,42 @@ void AppController::setPreferencesAction() @@ -232,19 +250,42 @@ void AppController::setPreferencesAction()
Preferences *const pref = Preferences::instance();
auto session = BitTorrent::Session::instance();
const QVariantMap m = QJsonDocument::fromJson(params()["json"].toUtf8()).toVariant().toMap();
QVariantMap::ConstIterator it;
// Downloads
// Hard Disk
// When adding a torrent
if ((it = m.find(QLatin1String("create_subfolder_enabled"))) != m.constEnd())
session->setCreateTorrentSubfolder(it.value().toBool());
if ((it = m.find(QLatin1String("start_paused_enabled"))) != m.constEnd())
session->setAddTorrentPaused(it.value().toBool());
if ((it = m.find(QLatin1String("auto_delete_mode"))) != m.constEnd())
TorrentFileGuard::setAutoDeleteMode(static_cast<TorrentFileGuard::AutoDeleteMode>(it.value().toInt()));
if ((it = m.find(QLatin1String("preallocate_all"))) != m.constEnd())
session->setPreallocationEnabled(it.value().toBool());
if ((it = m.find(QLatin1String("incomplete_files_ext"))) != m.constEnd())
session->setAppendExtensionEnabled(it.value().toBool());
// Saving Management
if ((it = m.find(QLatin1String("auto_tmm_enabled"))) != m.constEnd())
session->setAutoTMMDisabledByDefault(!it.value().toBool());
if ((it = m.find(QLatin1String("torrent_changed_tmm_enabled"))) != m.constEnd())
session->setDisableAutoTMMWhenCategoryChanged(!it.value().toBool());
if ((it = m.find(QLatin1String("save_path_changed_tmm_enabled"))) != m.constEnd())
session->setDisableAutoTMMWhenDefaultSavePathChanged(!it.value().toBool());
if ((it = m.find(QLatin1String("category_changed_tmm_enabled"))) != m.constEnd())
session->setDisableAutoTMMWhenCategorySavePathChanged(!it.value().toBool());
if (m.contains("save_path"))
session->setDefaultSavePath(m["save_path"].toString());
if (m.contains("temp_path_enabled"))
session->setTempPathEnabled(m["temp_path_enabled"].toBool());
if (m.contains("temp_path"))
session->setTempPath(m["temp_path"].toString());
if (m.contains("preallocate_all"))
session->setPreallocationEnabled(m["preallocate_all"].toBool());
if (m.contains("incomplete_files_ext"))
session->setAppendExtensionEnabled(m["incomplete_files_ext"].toBool());
if ((it = m.find(QLatin1String("export_dir"))) != m.constEnd())
session->setTorrentExportDirectory(it.value().toString());
if ((it = m.find(QLatin1String("export_dir_fin"))) != m.constEnd())
session->setFinishedTorrentExportDirectory(it.value().toString());
// Automatically add torrents from
if (m.contains("scan_dirs")) {
const QVariantMap nativeDirs = m["scan_dirs"].toMap();
QVariantHash oldScanDirs = pref->getScanDirs();
@ -288,13 +329,11 @@ void AppController::setPreferencesAction() @@ -288,13 +329,11 @@ void AppController::setPreferencesAction()
}
pref->setScanDirs(scanDirs);
}
if (m.contains("export_dir"))
session->setTorrentExportDirectory(m["export_dir"].toString());
if (m.contains("export_dir_fin"))
session->setFinishedTorrentExportDirectory(m["export_dir_fin"].toString());
// Email notification upon download completion
if (m.contains("mail_notification_enabled"))
pref->setMailNotificationEnabled(m["mail_notification_enabled"].toBool());
if ((it = m.find(QLatin1String("mail_notification_sender"))) != m.constEnd())
pref->setMailNotificationSender(it.value().toString());
if (m.contains("mail_notification_email"))
pref->setMailNotificationEmail(m["mail_notification_email"].toString());
if (m.contains("mail_notification_smtp"))
@ -379,6 +418,8 @@ void AppController::setPreferencesAction() @@ -379,6 +418,8 @@ void AppController::setPreferencesAction()
session->setUTPRateLimited(m["limit_utp_rate"].toBool());
if (m.contains("limit_tcp_overhead"))
session->setIncludeOverheadInLimits(m["limit_tcp_overhead"].toBool());
if ((it = m.find(QLatin1String("limit_lan_peers"))) != m.constEnd())
session->setIgnoreLimitsOnLAN(!it.value().toBool());
// Scheduling
if (m.contains("scheduler_enabled"))
session->setBandwidthSchedulerEnabled(m["scheduler_enabled"].toBool());
@ -412,6 +453,12 @@ void AppController::setPreferencesAction() @@ -412,6 +453,12 @@ void AppController::setPreferencesAction()
session->setMaxActiveUploads(m["max_active_uploads"].toInt());
if (m.contains("dont_count_slow_torrents"))
session->setIgnoreSlowTorrentsForQueueing(m["dont_count_slow_torrents"].toBool());
if ((it = m.find(QLatin1String("slow_torrent_dl_rate_threshold"))) != m.constEnd())
session->setDownloadRateForSlowTorrents(it.value().toInt());
if ((it = m.find(QLatin1String("slow_torrent_ul_rate_threshold"))) != m.constEnd())
session->setUploadRateForSlowTorrents(it.value().toInt());
if ((it = m.find(QLatin1String("slow_torrent_inactive_timer"))) != m.constEnd())
session->setSlowTorrentsInactivityTimer(it.value().toInt());
// Share Ratio Limiting
if (m.contains("max_ratio_enabled")) {
if (m["max_ratio_enabled"].toBool())
@ -483,6 +530,11 @@ void AppController::setPreferencesAction() @@ -483,6 +530,11 @@ void AppController::setPreferencesAction()
// recognize new lines and commas as delimiters
pref->setWebUiAuthSubnetWhitelist(m["bypass_auth_subnet_whitelist"].toString().split(QRegularExpression("\n|,"), QString::SkipEmptyParts));
}
// Use alternative Web UI
if ((it = m.find(QLatin1String("alternative_webui_enabled"))) != m.constEnd())
pref->setAltWebUiEnabled(it.value().toBool());
if ((it = m.find(QLatin1String("alternative_webui_path"))) != m.constEnd())
pref->setWebUiRootFolder(it.value().toString());
// Security
if (m.contains("web_ui_clickjacking_protection_enabled"))
pref->setWebUiClickjackingProtectionEnabled(m["web_ui_clickjacking_protection_enabled"].toBool());
@ -505,7 +557,6 @@ void AppController::setPreferencesAction() @@ -505,7 +557,6 @@ void AppController::setPreferencesAction()
// Save preferences
pref->apply();
QVariantMap::ConstIterator it;
if ((it = m.find(QLatin1String("rss_refresh_interval"))) != m.constEnd())
RSS::Session::instance()->setRefreshInterval(it.value().toUInt());
if ((it = m.find(QLatin1String("rss_max_articles_per_feed"))) != m.constEnd())

2
src/webui/api/torrentscontroller.cpp

@ -469,6 +469,7 @@ void TorrentsController::addAction() @@ -469,6 +469,7 @@ void TorrentsController::addAction()
const QString torrentName = params()["rename"].trimmed();
const int upLimit = params()["upLimit"].toInt();
const int dlLimit = params()["dlLimit"].toInt();
const TriStateBool autoTMM = parseTriStateBool(params()["autoTMM"]);
QList<QNetworkCookie> cookies;
if (!cookie.isEmpty()) {
@ -496,6 +497,7 @@ void TorrentsController::addAction() @@ -496,6 +497,7 @@ void TorrentsController::addAction()
params.name = torrentName;
params.uploadLimit = (upLimit > 0) ? upLimit : -1;
params.downloadLimit = (dlLimit > 0) ? dlLimit : -1;
params.useAutoTMM = autoTMM;
bool partialSuccess = false;
for (QString url : asConst(urls.split('\n'))) {

24
src/webui/www/private/css/style.css

@ -375,28 +375,8 @@ fieldset.settings label { @@ -375,28 +375,8 @@ fieldset.settings label {
padding: 2px;
}
fieldset.settings .leftLabelSmall {
width: 5em;
float: left;
text-align: right;
margin-right: 0.5em;
display: block;
}
fieldset.settings .leftLabelMedium {
width: 9em;
float: left;
text-align: right;
margin-right: 0.5em;
display: block;
}
fieldset.settings .leftLabelLarge {
width: 14em;
float: left;
text-align: right;
margin-right: 0.5em;
display: block;
fieldset.settings + div.formRow {
margin-top: 10px;
}
div.formRow {

154
src/webui/www/private/download.html

@ -18,52 +18,114 @@ @@ -18,52 +18,114 @@
<h2 class="vcenter">QBT_TR(Download Torrents from their URLs or Magnet links)QBT_TR[CONTEXT=HttpServer]</h2>
<textarea id="urls" rows="10" name="urls"></textarea>
<p>QBT_TR(Only one link per line)QBT_TR[CONTEXT=HttpServer]</p>
<fieldset class="settings" style="border: 0; text-align: left;">
<div class="formRow" style="margin-top: 6px;">
<label for="savepath" class="leftLabelLarge">QBT_TR(Save files to location:)QBT_TR[CONTEXT=HttpServer]</label>
<input type="text" id="savepath" name="savepath" style="width: 16em;" />
</div>
<div class="formRow">
<label for="cookie" class="leftLabelLarge">QBT_TR(Cookie:)QBT_TR[CONTEXT=HttpServer]</label>
<input type="text" id="cookie" name="cookie" style="width: 16em;" />
</div>
<div class="formRow">
<label for="rename" class="leftLabelLarge">QBT_TR(Rename torrent)QBT_TR[CONTEXT=HttpServer]</label>
<input type="text" id="rename" name="rename" style="width: 16em;" />
</div>
<div class="formRow">
<label for="category" class="leftLabelLarge">QBT_TR(Category:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
<input type="text" id="category" name="category" style="width: 16em;" />
</div>
<div class="formRow">
<label for="start_torrent" class="leftLabelLarge">QBT_TR(Start torrent)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
<input type="checkbox" id="start_torrent" checked="checked" />
<input type="hidden" id="add_paused" name="paused" value="false" readonly />
</div>
<div class="formRow">
<label for="skip_checking" class="leftLabelLarge">QBT_TR(Skip hash check)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
<input type="checkbox" id="skip_checking" name="skip_checking" value="true" />
</div>
<div class="formRow">
<label for="root_folder" class="leftLabelLarge">QBT_TR(Create subfolder)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
<input type="checkbox" id="root_folder" name="root_folder" value="true" checked="checked" />
</div>
<div class="formRow">
<label for="sequentialDownload" class="leftLabelLarge">QBT_TR(Download in sequential order)QBT_TR[CONTEXT=TransferListWidget]</label>
<input type="checkbox" id="sequentialDownload" name="sequentialDownload" value="true" />
</div>
<div class="formRow">
<label for="firstLastPiecePrio" class="leftLabelLarge">QBT_TR(Download first and last pieces first)QBT_TR[CONTEXT=TransferListWidget]</label>
<input type="checkbox" id="firstLastPiecePrio" name="firstLastPiecePrio" value="true" />
</div>
<div class="formRow">
<label for="dlLimit" class="leftLabelLarge">QBT_TR(Limit download rate)QBT_TR[CONTEXT=HttpServer]</label>
<input type="text" id="dlLimit" name="dlLimit" style="width: 16em;" placeholder="Bytes/s" />
</div>
<div class="formRow">
<label for="upLimit" class="leftLabelLarge">QBT_TR(Limit upload rate)QBT_TR[CONTEXT=HttpServer]</label>
<input type="text" id="upLimit" name="upLimit" style="width: 16em;" placeholder="Bytes/s" />
</div>
<fieldset class="settings" style="border: 0; text-align: left; margin-top: 6px;">
<table style="margin: auto;">
<tr>
<td>
<label for="autoTMM">QBT_TR(Torrent Management Mode:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<select id="autoTMM" name="autoTMM" onchange="changeTMM(this)">
<option selected value="false">Manual</option>
<option value="true">Automatic</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="savepath">QBT_TR(Save files to location:)QBT_TR[CONTEXT=HttpServer]</label>
</td>
<td>
<input type="text" id="savepath" name="savepath" style="width: 16em;" />
</td>
</tr>
<tr>
<td>
<label for="cookie">QBT_TR(Cookie:)QBT_TR[CONTEXT=HttpServer]</label>
</td>
<td>
<input type="text" id="cookie" name="cookie" style="width: 16em;" />
</td>
</tr>
<tr>
<td>
<label for="rename">QBT_TR(Rename torrent)QBT_TR[CONTEXT=HttpServer]</label>
</td>
<td>
<input type="text" id="rename" name="rename" style="width: 16em;" />
</td>
</tr>
<tr>
<td>
<label for="category">QBT_TR(Category:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<div class="select-watched-folder-editable">
<select id="categorySelect" onchange="changeCategorySelect(this)">
<option selected value="\other"></option>
</select>
<input name="category" type="text" value="" />
</div>
</td>
</tr>
<tr>
<td>
<label for="start_torrent">QBT_TR(Start torrent)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<input type="checkbox" id="start_torrent" checked="checked" />
<input type="hidden" id="add_paused" name="paused" value="false" readonly />
</td>
</tr>
<tr>
<td>
<label for="skip_checking">QBT_TR(Skip hash check)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<input type="checkbox" id="skip_checking" name="skip_checking" value="true" />
</td>
</tr>
<tr>
<td>
<label for="root_folder">QBT_TR(Create subfolder)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<input type="checkbox" id="root_folder" name="root_folder" value="true" checked="checked" />
</td>
</tr>
<tr>
<td>
<label for="sequentialDownload">QBT_TR(Download in sequential order)QBT_TR[CONTEXT=TransferListWidget]</label>
</td>
<td>
<input type="checkbox" id="sequentialDownload" name="sequentialDownload" value="true" />
</td>
</tr>
<tr>
<td>
<label for="firstLastPiecePrio">QBT_TR(Download first and last pieces first)QBT_TR[CONTEXT=TransferListWidget]</label>
</td>
<td>
<input type="checkbox" id="firstLastPiecePrio" name="firstLastPiecePrio" value="true" />
</td>
</tr>
<tr>
<td>
<label for="dlLimit">QBT_TR(Limit download rate)QBT_TR[CONTEXT=HttpServer]</label>
</td>
<td>
<input type="text" id="dlLimit" name="dlLimit" style="width: 16em;" placeholder="Bytes/s" />
</td>
</tr>
<tr>
<td>
<label for="upLimit">QBT_TR(Limit upload rate)QBT_TR[CONTEXT=HttpServer]</label>
</td>
<td>
<input type="text" id="upLimit" name="upLimit" style="width: 16em;" placeholder="Bytes/s" />
</td>
</tr>
</table>
<div id="submitbutton" style="margin-top: 12px; text-align: center;">
<button type="submit" id="submitButton">QBT_TR(Download)QBT_TR[CONTEXT=downloadFromURL]</button>
</div>

790
src/webui/www/private/preferences_content.html

File diff suppressed because it is too large Load Diff

89
src/webui/www/private/scripts/download.js

@ -21,22 +21,97 @@ @@ -21,22 +21,97 @@
* THE SOFTWARE.
*/
getSavePath = function() {
new Request({
url: 'api/v2/app/defaultSavePath',
var categories = {};
var defaultSavePath = "";
getCategories = function() {
new Request.JSON({
url: 'api/v2/torrents/categories',
noCache: true,
method: 'get',
onSuccess: function(data) {
if (data) {
categories = data;
for (var i in data) {
var category = data[i];
var option = new Element("option");
option.set('value', category.name);
option.set('html', category.name);
$('categorySelect').appendChild(option);
}
}
}
}).send();
};
getPreferences = function() {
new Request.JSON({
url: 'api/v2/app/preferences',
method: 'get',
noCache: true,
onFailure: function() {
alert("Could not contact qBittorrent");
},
onSuccess: function(data) {
if (data) {
$('savepath').setProperty('value', data);
onSuccess: function(pref) {
if (pref) {
defaultSavePath = pref.save_path;
$('savepath').setProperty('value', defaultSavePath);
$('root_folder').checked = pref.create_subfolder_enabled;
$('start_torrent').checked = !pref.start_paused_enabled;
if (pref.auto_tmm_enabled == 1) {
$('autoTMM').selectedIndex = 1;
$('savepath').disabled = true;
}
else {
$('autoTMM').selectedIndex = 0;
}
}
}
}).send();
};
changeCategorySelect = function(item) {
if (item.value == "\\other") {
item.nextElementSibling.hidden = false;
item.nextElementSibling.value = "";
item.nextElementSibling.select();
if ($('autotmm').selectedIndex == 1)
$('savepath').value = defaultSavePath;
}
else {
item.nextElementSibling.hidden = true;
var text = item.options[item.selectedIndex].innerHTML;
item.nextElementSibling.value = text;
if ($('autotmm').selectedIndex == 1) {
var categoryName = item.value;
var category = categories[categoryName];
var savePath = defaultSavePath;
if (category !== undefined)
savePath = (category['savePath'] !== "") ? category['savePath'] : (defaultSavePath + categoryName);
$('savepath').value = savePath;
}
}
};
changeTMM = function(item) {
if (item.selectedIndex == 1) {
$('savepath').disabled = true;
var categorySelect = $('categorySelect');
var categoryName = categorySelect.options[categorySelect.selectedIndex].value;
var category = categories[categoryName];
$('savepath').value = (category === undefined) ? "" : category['savePath'];
}
else {
$('savepath').disabled = false;
$('savepath').value = defaultSavePath;
}
};
$(window).addEventListener("load", function() {
getSavePath();
getPreferences();
getCategories();
});

4
src/webui/www/private/shareratio.html

@ -150,12 +150,12 @@ @@ -150,12 +150,12 @@
<div style="margin-left: 40px; margin-bottom: 5px;">
<input type="checkbox" id="setRatio" class="shareLimitInput" onclick="enableInputBoxes()" />
<label for="setRatio" class="leftLabelLarge">QBT_TR(ratio)QBT_TR[CONTEXT=UpDownRatioDialog]</label>
<label for="setRatio">QBT_TR(ratio)QBT_TR[CONTEXT=UpDownRatioDialog]</label>
<input type="number" id="ratio" value="0.00" step=".01" min="0" max="9999" class="shareLimitInput" />
</div>
<div style="margin-left: 40px; margin-bottom: 5px;">
<input type="checkbox" id="setMinutes" class="shareLimitInput" onclick="enableInputBoxes()" />
<label for="setMinutes" class="leftLabelLarge">QBT_TR(minutes)QBT_TR[CONTEXT=UpDownRatioDialog]</label>
<label for="setMinutes">QBT_TR(minutes)QBT_TR[CONTEXT=UpDownRatioDialog]</label>
<input type="number" id="minutes" value="0" step="1" min="0" max="525600" class="shareLimitInput" />
</div>
<div style="text-align: center; padding-top: 10px;">

142
src/webui/www/private/upload.html

@ -16,48 +16,106 @@ @@ -16,48 +16,106 @@
<div style="margin-top: 25px; display: inline-block; border: 1px solid lightgrey; border-radius: 4px;">
<input type="file" id="fileselect" name="fileselect[]" multiple="multiple" />
</div>
<fieldset class="settings" style="border: 0; text-align: left;">
<div class="formRow" style="margin-top: 12px;">
<label for="savepath" class="leftLabelLarge">QBT_TR(Save files to location:)QBT_TR[CONTEXT=HttpServer]</label>
<input type="text" id="savepath" name="savepath" style="width: 16em;" />
</div>
<div class="formRow">
<label for="rename" class="leftLabelLarge">QBT_TR(Rename torrent)QBT_TR[CONTEXT=HttpServer]</label>
<input type="text" id="rename" name="rename" style="width: 16em;" />
</div>
<div class="formRow">
<label for="category" class="leftLabelLarge">QBT_TR(Category:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
<input type="text" id="category" name="category" style="width: 16em;" />
</div>
<div class="formRow">
<label for="start_torrent" class="leftLabelLarge">QBT_TR(Start torrent)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
<input type="checkbox" id="start_torrent" checked="checked" />
<input type="hidden" id="add_paused" name="paused" value="false" readonly />
</div>
<div class="formRow">
<label for="skip_checking" class="leftLabelLarge">QBT_TR(Skip hash check)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
<input type="checkbox" id="skip_checking" name="skip_checking" value="true" />
</div>
<div class="formRow">
<label for="root_folder" class="leftLabelLarge">QBT_TR(Create subfolder)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
<input type="checkbox" id="root_folder" name="root_folder" value="true" checked="checked" />
</div>
<div class="formRow">
<label for="sequentialDownload" class="leftLabelLarge">QBT_TR(Download in sequential order)QBT_TR[CONTEXT=TransferListWidget]</label>
<input type="checkbox" id="sequentialDownload" name="sequentialDownload" value="true" />
</div>
<div class="formRow">
<label for="firstLastPiecePrio" class="leftLabelLarge">QBT_TR(Download first and last pieces first)QBT_TR[CONTEXT=TransferListWidget]</label>
<input type="checkbox" id="firstLastPiecePrio" name="firstLastPiecePrio" value="true" />
</div>
<div class="formRow">
<label for="dlLimit" class="leftLabelLarge">QBT_TR(Limit download rate)QBT_TR[CONTEXT=HttpServer]</label>
<input type="text" id="dlLimit" name="dlLimit" style="width: 16em;" placeholder="Bytes/s" />
</div>
<div class="formRow">
<label for="upLimit" class="leftLabelLarge">QBT_TR(Limit upload rate)QBT_TR[CONTEXT=HttpServer]</label>
<input type="text" id="upLimit" name="upLimit" style="width: 16em;" placeholder="Bytes/s" />
</div>
<fieldset class="settings" style="border: 0; text-align: left; margin-top: 12px;">
<table style="margin: auto;">
<tr>
<td>
<label for="autoTMM">QBT_TR(Torrent Management Mode:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<select id="autoTMM" name="autoTMM" onchange="changeTMM(this)">
<option selected value="false">Manual</option>
<option value="true">Automatic</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="savepath">QBT_TR(Save files to location:)QBT_TR[CONTEXT=HttpServer]</label>
</td>
<td>
<input type="text" id="savepath" name="savepath" style="width: 16em;" />
</td>
</tr>
<tr>
<td>
<label for="rename">QBT_TR(Rename torrent)QBT_TR[CONTEXT=HttpServer]</label>
</td>
<td>
<input type="text" id="rename" name="rename" style="width: 16em;" />
</td>
</tr>
<tr>
<td>
<label for="category">QBT_TR(Category:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<div class="select-watched-folder-editable">
<select id="categorySelect" onchange="changeCategorySelect(this)">
<option selected value="\other"></option>
</select>
<input name="category" type="text" value="" />
</div>
</td>
</tr>
<tr>
<td>
<label for="start_torrent">QBT_TR(Start torrent)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<input type="checkbox" id="start_torrent" checked="checked" />
<input type="hidden" id="add_paused" name="paused" value="false" readonly />
</td>
</tr>
<tr>
<td>
<label for="skip_checking">QBT_TR(Skip hash check)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<input type="checkbox" id="skip_checking" name="skip_checking" value="true" />
</td>
</tr>
<tr>
<td>
<label for="root_folder">QBT_TR(Create subfolder)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<input type="checkbox" id="root_folder" name="root_folder" value="true" checked="checked" />
</td>
</tr>
<tr>
<td>
<label for="sequentialDownload">QBT_TR(Download in sequential order)QBT_TR[CONTEXT=TransferListWidget]</label>
</td>
<td>
<input type="checkbox" id="sequentialDownload" name="sequentialDownload" value="true" />
</td>
</tr>
<tr>
<td>
<label for="firstLastPiecePrio">QBT_TR(Download first and last pieces first)QBT_TR[CONTEXT=TransferListWidget]</label>
</td>
<td>
<input type="checkbox" id="firstLastPiecePrio" name="firstLastPiecePrio" value="true" />
</td>
</tr>
<tr>
<td>
<label for="dlLimit">QBT_TR(Limit download rate)QBT_TR[CONTEXT=HttpServer]</label>
</td>
<td>
<input type="text" id="dlLimit" name="dlLimit" style="width: 16em;" placeholder="Bytes/s" />
</td>
</tr>
<tr>
<td>
<label for="upLimit">QBT_TR(Limit upload rate)QBT_TR[CONTEXT=HttpServer]</label>
</td>
<td>
<input type="text" id="upLimit" name="upLimit" style="width: 16em;" placeholder="Bytes/s" />
</td>
</tr>
</table>
<div id="submitbutton" style="margin-top: 30px; text-align: center;">
<button type="submit" style="font-size: 1em;">QBT_TR(Upload Torrents)QBT_TR[CONTEXT=HttpServer]</button>
</div>

Loading…
Cancel
Save