diff --git a/src/httpconnection.cpp b/src/httpconnection.cpp index 0e04b7f4b..dd95fccb2 100644 --- a/src/httpconnection.cpp +++ b/src/httpconnection.cpp @@ -46,7 +46,7 @@ #include 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); connect(socket, SIGNAL(readyRead()), this, SLOT(read())); @@ -346,6 +346,18 @@ void HttpConnection::respondCommand(QString command) 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") { QString hash = parser.post("hash"); QTorrentHandle h = BTSession->getTorrentHandle(hash); diff --git a/src/webui/scripts/parametrics.js b/src/webui/scripts/parametrics.js index eef3f4641..3cbb148bf 100644 --- a/src/webui/scripts/parametrics.js +++ b/src/webui/scripts/parametrics.js @@ -19,6 +19,23 @@ MochaUI.extend({ if ($('uplimitSliderarea')) { var windowOptions = MochaUI.Windows.windowOptions; 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({ url: '/command/getTorrentUpLimit', method: 'post', @@ -28,7 +45,7 @@ MochaUI.extend({ var up_limit = data.toInt(); if(up_limit < 0) up_limit = 0; var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), { - steps: 500, + steps: maximum, offset: 0, initialStep: (up_limit/1024.).round(), onChange: function(pos){ @@ -59,6 +76,23 @@ MochaUI.extend({ if ($('dllimitSliderarea')) { var windowOptions = MochaUI.Windows.windowOptions; 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({ url: '/command/getTorrentDlLimit', method: 'post', @@ -68,7 +102,7 @@ MochaUI.extend({ var dl_limit = data.toInt(); if(dl_limit < 0) dl_limit = 0; var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), { - steps: 500, + steps: maximum, offset: 0, initialStep: (dl_limit/1024.).round(), onChange: function(pos){