Browse Source

- Use global maximum transfer rates as maximum values in per-torrent speed limiting dialogs (Web UI)

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
ee9ca1ece7
  1. 14
      src/httpconnection.cpp
  2. 38
      src/webui/scripts/parametrics.js

14
src/httpconnection.cpp

@ -46,7 +46,7 @@
#include <QTemporaryFile> #include <QTemporaryFile>
HttpConnection::HttpConnection(QTcpSocket *socket, Bittorrent *BTSession, HttpServer *parent) HttpConnection::HttpConnection(QTcpSocket *socket, Bittorrent *BTSession, HttpServer *parent)
: QObject(parent), socket(socket), parent(parent), BTSession(BTSession) : QObject(parent), socket(socket), parent(parent), BTSession(BTSession)
{ {
socket->setParent(this); socket->setParent(this);
connect(socket, SIGNAL(readyRead()), this, SLOT(read())); connect(socket, SIGNAL(readyRead()), this, SLOT(read()));
@ -346,6 +346,18 @@ void HttpConnection::respondCommand(QString command)
h.file_priority(file_id, priority); h.file_priority(file_id, priority);
} }
} }
if(command == "getGlobalUpLimit") {
generator.setStatusLine(200, "OK");
generator.setContentTypeByExt("html");
generator.setMessage(QString::number(BTSession->getSession()->upload_rate_limit()));
write();
}
if(command == "getGlobalDlLimit") {
generator.setStatusLine(200, "OK");
generator.setContentTypeByExt("html");
generator.setMessage(QString::number(BTSession->getSession()->download_rate_limit()));
write();
}
if(command == "getTorrentUpLimit") { if(command == "getTorrentUpLimit") {
QString hash = parser.post("hash"); QString hash = parser.post("hash");
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);

38
src/webui/scripts/parametrics.js

@ -19,6 +19,23 @@ MochaUI.extend({
if ($('uplimitSliderarea')) { if ($('uplimitSliderarea')) {
var windowOptions = MochaUI.Windows.windowOptions; var windowOptions = MochaUI.Windows.windowOptions;
var sliderFirst = true; var sliderFirst = true;
// Get global upload limit
var maximum = 500;
var req = new Request({
url: '/command/getGlobalUpLimit',
method: 'post',
data: {},
onSuccess: function(data) {
if(data){
var tmp = data.toInt();
if(tmp > 0) {
maximum = tmp / 1024.
}
}
}
}).send();
// Get torrent upload limit
// And create slider
var req = new Request({ var req = new Request({
url: '/command/getTorrentUpLimit', url: '/command/getTorrentUpLimit',
method: 'post', method: 'post',
@ -28,7 +45,7 @@ MochaUI.extend({
var up_limit = data.toInt(); var up_limit = data.toInt();
if(up_limit < 0) up_limit = 0; if(up_limit < 0) up_limit = 0;
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), { var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
steps: 500, steps: maximum,
offset: 0, offset: 0,
initialStep: (up_limit/1024.).round(), initialStep: (up_limit/1024.).round(),
onChange: function(pos){ onChange: function(pos){
@ -59,6 +76,23 @@ MochaUI.extend({
if ($('dllimitSliderarea')) { if ($('dllimitSliderarea')) {
var windowOptions = MochaUI.Windows.windowOptions; var windowOptions = MochaUI.Windows.windowOptions;
var sliderFirst = true; var sliderFirst = true;
// Get global upload limit
var maximum = 500;
var req = new Request({
url: '/command/getGlobalDlLimit',
method: 'post',
data: {},
onSuccess: function(data) {
if(data){
var tmp = data.toInt();
if(tmp > 0) {
maximum = tmp / 1024.
}
}
}
}).send();
// Get torrent download limit
// And create slider
var req = new Request({ var req = new Request({
url: '/command/getTorrentDlLimit', url: '/command/getTorrentDlLimit',
method: 'post', method: 'post',
@ -68,7 +102,7 @@ MochaUI.extend({
var dl_limit = data.toInt(); var dl_limit = data.toInt();
if(dl_limit < 0) dl_limit = 0; if(dl_limit < 0) dl_limit = 0;
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), { var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
steps: 500, steps: maximum,
offset: 0, offset: 0,
initialStep: (dl_limit/1024.).round(), initialStep: (dl_limit/1024.).round(),
onChange: function(pos){ onChange: function(pos){

Loading…
Cancel
Save