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()
m_ui->tabSelection->setCurrentRow(TAB_WEBUI); m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
return; return;
} }
if (!isAlternativeWebUIPathValid()) {
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
return;
}
m_applyButton->setEnabled(false); m_applyButton->setEnabled(false);
this->hide(); this->hide();
saveOptions(); saveOptions();
@ -1269,6 +1273,10 @@ void OptionsDialog::applySettings(QAbstractButton *button)
m_ui->tabSelection->setCurrentRow(TAB_WEBUI); m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
return; return;
} }
if (!isAlternativeWebUIPathValid()) {
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
return;
}
saveOptions(); saveOptions();
} }
} }
@ -1751,6 +1759,15 @@ bool OptionsDialog::webUIAuthenticationOk()
return true; 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() void OptionsDialog::on_banListButton_clicked()
{ {
// call dialog window // call dialog window

1
src/gui/optionsdialog.h

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

2
src/gui/optionsdialog.ui

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

81
src/webui/api/appcontroller.cpp

@ -52,6 +52,7 @@
#include "base/rss/rss_autodownloader.h" #include "base/rss/rss_autodownloader.h"
#include "base/rss/rss_session.h" #include "base/rss/rss_session.h"
#include "base/scanfoldersmodel.h" #include "base/scanfoldersmodel.h"
#include "base/torrentfileguard.h"
#include "base/utils/fs.h" #include "base/utils/fs.h"
#include "base/utils/net.h" #include "base/utils/net.h"
#include "base/utils/password.h" #include "base/utils/password.h"
@ -84,12 +85,23 @@ void AppController::preferencesAction()
QVariantMap data; QVariantMap data;
// Downloads // 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["save_path"] = Utils::Fs::toNativePath(session->defaultSavePath());
data["temp_path_enabled"] = session->isTempPathEnabled(); data["temp_path_enabled"] = session->isTempPathEnabled();
data["temp_path"] = Utils::Fs::toNativePath(session->tempPath()); data["temp_path"] = Utils::Fs::toNativePath(session->tempPath());
data["preallocate_all"] = session->isPreallocationEnabled(); data["export_dir"] = Utils::Fs::toNativePath(session->torrentExportDirectory());
data["incomplete_files_ext"] = session->isAppendExtensionEnabled(); data["export_dir_fin"] = Utils::Fs::toNativePath(session->finishedTorrentExportDirectory());
// Automatically add torrents from
const QVariantHash dirs = pref->getScanDirs(); const QVariantHash dirs = pref->getScanDirs();
QVariantMap nativeDirs; QVariantMap nativeDirs;
for (QVariantHash::const_iterator i = dirs.cbegin(), e = dirs.cend(); i != e; ++i) { for (QVariantHash::const_iterator i = dirs.cbegin(), e = dirs.cend(); i != e; ++i) {
@ -99,10 +111,9 @@ void AppController::preferencesAction()
nativeDirs.insert(Utils::Fs::toNativePath(i.key()), Utils::Fs::toNativePath(i.value().toString())); nativeDirs.insert(Utils::Fs::toNativePath(i.key()), Utils::Fs::toNativePath(i.value().toString()));
} }
data["scan_dirs"] = nativeDirs; 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 // Email notification upon download completion
data["mail_notification_enabled"] = pref->isMailNotificationEnabled(); data["mail_notification_enabled"] = pref->isMailNotificationEnabled();
data["mail_notification_sender"] = pref->getMailNotificationSender();
data["mail_notification_email"] = pref->getMailNotificationEmail(); data["mail_notification_email"] = pref->getMailNotificationEmail();
data["mail_notification_smtp"] = pref->getMailNotificationSMTP(); data["mail_notification_smtp"] = pref->getMailNotificationSMTP();
data["mail_notification_ssl_enabled"] = pref->getMailNotificationSMTPSSL(); data["mail_notification_ssl_enabled"] = pref->getMailNotificationSMTPSSL();
@ -153,6 +164,7 @@ void AppController::preferencesAction()
data["bittorrent_protocol"] = static_cast<int>(session->btProtocol()); data["bittorrent_protocol"] = static_cast<int>(session->btProtocol());
data["limit_utp_rate"] = session->isUTPRateLimited(); data["limit_utp_rate"] = session->isUTPRateLimited();
data["limit_tcp_overhead"] = session->includeOverheadInLimits(); data["limit_tcp_overhead"] = session->includeOverheadInLimits();
data["limit_lan_peers"] = !session->ignoreLimitsOnLAN();
// Scheduling // Scheduling
data["scheduler_enabled"] = session->isBandwidthSchedulerEnabled(); data["scheduler_enabled"] = session->isBandwidthSchedulerEnabled();
const QTime start_time = pref->getSchedulerStartTime(); const QTime start_time = pref->getSchedulerStartTime();
@ -176,6 +188,9 @@ void AppController::preferencesAction()
data["max_active_torrents"] = session->maxActiveTorrents(); data["max_active_torrents"] = session->maxActiveTorrents();
data["max_active_uploads"] = session->maxActiveUploads(); data["max_active_uploads"] = session->maxActiveUploads();
data["dont_count_slow_torrents"] = session->ignoreSlowTorrentsForQueueing(); 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 // Share Ratio Limiting
data["max_ratio_enabled"] = (session->globalMaxRatio() >= 0.); data["max_ratio_enabled"] = (session->globalMaxRatio() >= 0.);
data["max_ratio"] = session->globalMaxRatio(); data["max_ratio"] = session->globalMaxRatio();
@ -205,6 +220,9 @@ void AppController::preferencesAction()
for (const Utils::Net::Subnet &subnet : asConst(pref->getWebUiAuthSubnetWhitelist())) for (const Utils::Net::Subnet &subnet : asConst(pref->getWebUiAuthSubnetWhitelist()))
authSubnetWhitelistStringList << Utils::Net::subnetToString(subnet); authSubnetWhitelistStringList << Utils::Net::subnetToString(subnet);
data["bypass_auth_subnet_whitelist"] = authSubnetWhitelistStringList.join("\n"); 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 // Security
data["web_ui_clickjacking_protection_enabled"] = pref->isWebUiClickjackingProtectionEnabled(); data["web_ui_clickjacking_protection_enabled"] = pref->isWebUiClickjackingProtectionEnabled();
data["web_ui_csrf_protection_enabled"] = pref->isWebUiCSRFProtectionEnabled(); data["web_ui_csrf_protection_enabled"] = pref->isWebUiCSRFProtectionEnabled();
@ -232,19 +250,42 @@ void AppController::setPreferencesAction()
Preferences *const pref = Preferences::instance(); Preferences *const pref = Preferences::instance();
auto session = BitTorrent::Session::instance(); auto session = BitTorrent::Session::instance();
const QVariantMap m = QJsonDocument::fromJson(params()["json"].toUtf8()).toVariant().toMap(); const QVariantMap m = QJsonDocument::fromJson(params()["json"].toUtf8()).toVariant().toMap();
QVariantMap::ConstIterator it;
// Downloads // 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")) if (m.contains("save_path"))
session->setDefaultSavePath(m["save_path"].toString()); session->setDefaultSavePath(m["save_path"].toString());
if (m.contains("temp_path_enabled")) if (m.contains("temp_path_enabled"))
session->setTempPathEnabled(m["temp_path_enabled"].toBool()); session->setTempPathEnabled(m["temp_path_enabled"].toBool());
if (m.contains("temp_path")) if (m.contains("temp_path"))
session->setTempPath(m["temp_path"].toString()); session->setTempPath(m["temp_path"].toString());
if (m.contains("preallocate_all")) if ((it = m.find(QLatin1String("export_dir"))) != m.constEnd())
session->setPreallocationEnabled(m["preallocate_all"].toBool()); session->setTorrentExportDirectory(it.value().toString());
if (m.contains("incomplete_files_ext")) if ((it = m.find(QLatin1String("export_dir_fin"))) != m.constEnd())
session->setAppendExtensionEnabled(m["incomplete_files_ext"].toBool()); session->setFinishedTorrentExportDirectory(it.value().toString());
// Automatically add torrents from
if (m.contains("scan_dirs")) { if (m.contains("scan_dirs")) {
const QVariantMap nativeDirs = m["scan_dirs"].toMap(); const QVariantMap nativeDirs = m["scan_dirs"].toMap();
QVariantHash oldScanDirs = pref->getScanDirs(); QVariantHash oldScanDirs = pref->getScanDirs();
@ -288,13 +329,11 @@ void AppController::setPreferencesAction()
} }
pref->setScanDirs(scanDirs); 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 // Email notification upon download completion
if (m.contains("mail_notification_enabled")) if (m.contains("mail_notification_enabled"))
pref->setMailNotificationEnabled(m["mail_notification_enabled"].toBool()); 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")) if (m.contains("mail_notification_email"))
pref->setMailNotificationEmail(m["mail_notification_email"].toString()); pref->setMailNotificationEmail(m["mail_notification_email"].toString());
if (m.contains("mail_notification_smtp")) if (m.contains("mail_notification_smtp"))
@ -379,6 +418,8 @@ void AppController::setPreferencesAction()
session->setUTPRateLimited(m["limit_utp_rate"].toBool()); session->setUTPRateLimited(m["limit_utp_rate"].toBool());
if (m.contains("limit_tcp_overhead")) if (m.contains("limit_tcp_overhead"))
session->setIncludeOverheadInLimits(m["limit_tcp_overhead"].toBool()); session->setIncludeOverheadInLimits(m["limit_tcp_overhead"].toBool());
if ((it = m.find(QLatin1String("limit_lan_peers"))) != m.constEnd())
session->setIgnoreLimitsOnLAN(!it.value().toBool());
// Scheduling // Scheduling
if (m.contains("scheduler_enabled")) if (m.contains("scheduler_enabled"))
session->setBandwidthSchedulerEnabled(m["scheduler_enabled"].toBool()); session->setBandwidthSchedulerEnabled(m["scheduler_enabled"].toBool());
@ -412,6 +453,12 @@ void AppController::setPreferencesAction()
session->setMaxActiveUploads(m["max_active_uploads"].toInt()); session->setMaxActiveUploads(m["max_active_uploads"].toInt());
if (m.contains("dont_count_slow_torrents")) if (m.contains("dont_count_slow_torrents"))
session->setIgnoreSlowTorrentsForQueueing(m["dont_count_slow_torrents"].toBool()); 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 // Share Ratio Limiting
if (m.contains("max_ratio_enabled")) { if (m.contains("max_ratio_enabled")) {
if (m["max_ratio_enabled"].toBool()) if (m["max_ratio_enabled"].toBool())
@ -483,6 +530,11 @@ void AppController::setPreferencesAction()
// recognize new lines and commas as delimiters // recognize new lines and commas as delimiters
pref->setWebUiAuthSubnetWhitelist(m["bypass_auth_subnet_whitelist"].toString().split(QRegularExpression("\n|,"), QString::SkipEmptyParts)); 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 // Security
if (m.contains("web_ui_clickjacking_protection_enabled")) if (m.contains("web_ui_clickjacking_protection_enabled"))
pref->setWebUiClickjackingProtectionEnabled(m["web_ui_clickjacking_protection_enabled"].toBool()); pref->setWebUiClickjackingProtectionEnabled(m["web_ui_clickjacking_protection_enabled"].toBool());
@ -505,7 +557,6 @@ void AppController::setPreferencesAction()
// Save preferences // Save preferences
pref->apply(); pref->apply();
QVariantMap::ConstIterator it;
if ((it = m.find(QLatin1String("rss_refresh_interval"))) != m.constEnd()) if ((it = m.find(QLatin1String("rss_refresh_interval"))) != m.constEnd())
RSS::Session::instance()->setRefreshInterval(it.value().toUInt()); RSS::Session::instance()->setRefreshInterval(it.value().toUInt());
if ((it = m.find(QLatin1String("rss_max_articles_per_feed"))) != m.constEnd()) 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()
const QString torrentName = params()["rename"].trimmed(); const QString torrentName = params()["rename"].trimmed();
const int upLimit = params()["upLimit"].toInt(); const int upLimit = params()["upLimit"].toInt();
const int dlLimit = params()["dlLimit"].toInt(); const int dlLimit = params()["dlLimit"].toInt();
const TriStateBool autoTMM = parseTriStateBool(params()["autoTMM"]);
QList<QNetworkCookie> cookies; QList<QNetworkCookie> cookies;
if (!cookie.isEmpty()) { if (!cookie.isEmpty()) {
@ -496,6 +497,7 @@ void TorrentsController::addAction()
params.name = torrentName; params.name = torrentName;
params.uploadLimit = (upLimit > 0) ? upLimit : -1; params.uploadLimit = (upLimit > 0) ? upLimit : -1;
params.downloadLimit = (dlLimit > 0) ? dlLimit : -1; params.downloadLimit = (dlLimit > 0) ? dlLimit : -1;
params.useAutoTMM = autoTMM;
bool partialSuccess = false; bool partialSuccess = false;
for (QString url : asConst(urls.split('\n'))) { for (QString url : asConst(urls.split('\n'))) {

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

@ -375,28 +375,8 @@ fieldset.settings label {
padding: 2px; padding: 2px;
} }
fieldset.settings .leftLabelSmall { fieldset.settings + div.formRow {
width: 5em; margin-top: 10px;
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;
} }
div.formRow { div.formRow {

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

@ -18,52 +18,114 @@
<h2 class="vcenter">QBT_TR(Download Torrents from their URLs or Magnet links)QBT_TR[CONTEXT=HttpServer]</h2> <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> <textarea id="urls" rows="10" name="urls"></textarea>
<p>QBT_TR(Only one link per line)QBT_TR[CONTEXT=HttpServer]</p> <p>QBT_TR(Only one link per line)QBT_TR[CONTEXT=HttpServer]</p>
<fieldset class="settings" style="border: 0; text-align: left;"> <fieldset class="settings" style="border: 0; text-align: left; margin-top: 6px;">
<div class="formRow" style="margin-top: 6px;"> <table style="margin: auto;">
<label for="savepath" class="leftLabelLarge">QBT_TR(Save files to location:)QBT_TR[CONTEXT=HttpServer]</label> <tr>
<input type="text" id="savepath" name="savepath" style="width: 16em;" /> <td>
</div> <label for="autoTMM">QBT_TR(Torrent Management Mode:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
<div class="formRow"> </td>
<label for="cookie" class="leftLabelLarge">QBT_TR(Cookie:)QBT_TR[CONTEXT=HttpServer]</label> <td>
<input type="text" id="cookie" name="cookie" style="width: 16em;" /> <select id="autoTMM" name="autoTMM" onchange="changeTMM(this)">
</div> <option selected value="false">Manual</option>
<div class="formRow"> <option value="true">Automatic</option>
<label for="rename" class="leftLabelLarge">QBT_TR(Rename torrent)QBT_TR[CONTEXT=HttpServer]</label> </select>
<input type="text" id="rename" name="rename" style="width: 16em;" /> </td>
</div> </tr>
<div class="formRow"> <tr>
<label for="category" class="leftLabelLarge">QBT_TR(Category:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label> <td>
<input type="text" id="category" name="category" style="width: 16em;" /> <label for="savepath">QBT_TR(Save files to location:)QBT_TR[CONTEXT=HttpServer]</label>
</div> </td>
<div class="formRow"> <td>
<label for="start_torrent" class="leftLabelLarge">QBT_TR(Start torrent)QBT_TR[CONTEXT=AddNewTorrentDialog]</label> <input type="text" id="savepath" name="savepath" style="width: 16em;" />
<input type="checkbox" id="start_torrent" checked="checked" /> </td>
<input type="hidden" id="add_paused" name="paused" value="false" readonly /> </tr>
</div> <tr>
<div class="formRow"> <td>
<label for="skip_checking" class="leftLabelLarge">QBT_TR(Skip hash check)QBT_TR[CONTEXT=AddNewTorrentDialog]</label> <label for="cookie">QBT_TR(Cookie:)QBT_TR[CONTEXT=HttpServer]</label>
<input type="checkbox" id="skip_checking" name="skip_checking" value="true" /> </td>
</div> <td>
<div class="formRow"> <input type="text" id="cookie" name="cookie" style="width: 16em;" />
<label for="root_folder" class="leftLabelLarge">QBT_TR(Create subfolder)QBT_TR[CONTEXT=AddNewTorrentDialog]</label> </td>
<input type="checkbox" id="root_folder" name="root_folder" value="true" checked="checked" /> </tr>
</div> <tr>
<div class="formRow"> <td>
<label for="sequentialDownload" class="leftLabelLarge">QBT_TR(Download in sequential order)QBT_TR[CONTEXT=TransferListWidget]</label> <label for="rename">QBT_TR(Rename torrent)QBT_TR[CONTEXT=HttpServer]</label>
<input type="checkbox" id="sequentialDownload" name="sequentialDownload" value="true" /> </td>
</div> <td>
<div class="formRow"> <input type="text" id="rename" name="rename" style="width: 16em;" />
<label for="firstLastPiecePrio" class="leftLabelLarge">QBT_TR(Download first and last pieces first)QBT_TR[CONTEXT=TransferListWidget]</label> </td>
<input type="checkbox" id="firstLastPiecePrio" name="firstLastPiecePrio" value="true" /> </tr>
</div> <tr>
<div class="formRow"> <td>
<label for="dlLimit" class="leftLabelLarge">QBT_TR(Limit download rate)QBT_TR[CONTEXT=HttpServer]</label> <label for="category">QBT_TR(Category:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
<input type="text" id="dlLimit" name="dlLimit" style="width: 16em;" placeholder="Bytes/s" /> </td>
</div> <td>
<div class="formRow"> <div class="select-watched-folder-editable">
<label for="upLimit" class="leftLabelLarge">QBT_TR(Limit upload rate)QBT_TR[CONTEXT=HttpServer]</label> <select id="categorySelect" onchange="changeCategorySelect(this)">
<input type="text" id="upLimit" name="upLimit" style="width: 16em;" placeholder="Bytes/s" /> <option selected value="\other"></option>
</div> </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;"> <div id="submitbutton" style="margin-top: 12px; text-align: center;">
<button type="submit" id="submitButton">QBT_TR(Download)QBT_TR[CONTEXT=downloadFromURL]</button> <button type="submit" id="submitButton">QBT_TR(Download)QBT_TR[CONTEXT=downloadFromURL]</button>
</div> </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 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
getSavePath = function() { var categories = {};
new Request({ var defaultSavePath = "";
url: 'api/v2/app/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', method: 'get',
noCache: true, noCache: true,
onFailure: function() { onFailure: function() {
alert("Could not contact qBittorrent"); alert("Could not contact qBittorrent");
}, },
onSuccess: function(data) { onSuccess: function(pref) {
if (data) { if (pref) {
$('savepath').setProperty('value', data); 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(); }).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() { $(window).addEventListener("load", function() {
getSavePath(); getPreferences();
getCategories();
}); });

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

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

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

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

Loading…
Cancel
Save