From 330905da5e369118bb2ec0dafb21810295b122cd Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 29 Dec 2008 22:46:18 +0000 Subject: [PATCH] - Added priority actions in Web UI --- src/eventmanager.cpp | 5 +++++ src/httpconnection.cpp | 26 ++++++++++++++------------ src/httpconnection.h | 2 ++ src/httpserver.cpp | 2 ++ src/webui/css/style.css | 4 ++++ src/webui/index.html | 5 +++++ src/webui/scripts/client.js | 8 ++++++++ src/webui/scripts/mocha-init.js | 4 +++- 8 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/eventmanager.cpp b/src/eventmanager.cpp index e8533ee1a..8b4f60088 100644 --- a/src/eventmanager.cpp +++ b/src/eventmanager.cpp @@ -81,6 +81,11 @@ void EventManager::modifiedTorrent(QTorrentHandle h) if(!h.is_seed()) { event["progress"] = QVariant(h.progress()); event["dlspeed"] = QVariant(h.download_payload_rate()); + if(BTSession->isQueueingEnabled()) { + event["priority"] = QVariant(h.queue_position()); + } else { + event["priority"] = -1; + } } event["upspeed"] = QVariant(h.upload_payload_rate()); event["seed"] = QVariant(h.is_seed()); diff --git a/src/httpconnection.cpp b/src/httpconnection.cpp index 165a24ed3..7b889ffb4 100644 --- a/src/httpconnection.cpp +++ b/src/httpconnection.cpp @@ -202,34 +202,36 @@ void HttpConnection::respondCommand(QString command) emit torrentReadyToBeDownloaded(filePath, false, QString(), false); return; } - if(command == "resumeall") - { + if(command == "resumeall") { emit resumeAllTorrents(); return; } - if(command == "pauseall") - { + if(command == "pauseall") { emit pauseAllTorrents(); return; } - if(command == "resume") - { + if(command == "resume") { emit resumeTorrent(parser.post("hash")); return; } - if(command == "pause") - { + if(command == "pause") { emit pauseTorrent(parser.post("hash")); return; } - if(command == "delete") - { + if(command == "delete") { emit deleteTorrent(parser.post("hash"), false); return; } - if(command == "deletePerm") - { + if(command == "deletePerm") { emit deleteTorrent(parser.post("hash"), true); return; } + if(command == "increasePrio") { + emit increasePrioTorrent(parser.post("hash")); + return; + } + if(command == "decreasePrio") { + emit decreasePrioTorrent(parser.post("hash")); + return; + } } diff --git a/src/httpconnection.h b/src/httpconnection.h index 1b4a1466f..9bca2ba37 100644 --- a/src/httpconnection.h +++ b/src/httpconnection.h @@ -62,6 +62,8 @@ class HttpConnection : public QObject void deleteTorrent(QString hash, bool permanently); void resumeTorrent(QString hash); void pauseTorrent(QString hash); + void increasePrioTorrent(QString hash); + void decreasePrioTorrent(QString hash); void resumeAllTorrents(); void pauseAllTorrents(); }; diff --git a/src/httpserver.cpp b/src/httpserver.cpp index fd25b1013..2dc986cf8 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -68,6 +68,8 @@ void HttpServer::newHttpConnection() connect(connection, SIGNAL(resumeTorrent(QString)), BTSession, SLOT(resumeTorrent(QString))); connect(connection, SIGNAL(pauseAllTorrents()), BTSession, SLOT(pauseAllTorrents())); connect(connection, SIGNAL(resumeAllTorrents()), BTSession, SLOT(resumeAllTorrents())); + connect(connection, SIGNAL(increasePrioTorrent(QString)), BTSession, SLOT(increaseDlTorrentPriority(QString))); + connect(connection, SIGNAL(decreasePrioTorrent(QString)), BTSession, SLOT(decreaseDlTorrentPriority(QString))); } } diff --git a/src/webui/css/style.css b/src/webui/css/style.css index f672936c3..e1830fbcf 100644 --- a/src/webui/css/style.css +++ b/src/webui/css/style.css @@ -20,6 +20,10 @@ body { width: 300px; } +.invisible { + display: none; +} + /* Typography */ h2, h3, h4 { diff --git a/src/webui/index.html b/src/webui/index.html index fc2cd4b30..c5b4f65f2 100644 --- a/src/webui/index.html +++ b/src/webui/index.html @@ -64,6 +64,10 @@ + + + +
@@ -82,6 +86,7 @@ Progress DL Speed UP Speed + Priority diff --git a/src/webui/scripts/client.js b/src/webui/scripts/client.js index a7a9941d2..97ab7fde7 100644 --- a/src/webui/scripts/client.js +++ b/src/webui/scripts/client.js @@ -72,6 +72,7 @@ window.addEvent('domready', function(){ return round1(val) + ' TiB'; }; var ajaxfn = function(){ + var queueing_enabled = false; var url = 'json/events'; if (!waiting){ waiting=true; @@ -122,6 +123,9 @@ window.addEvent('domready', function(){ row[3] = round1(event.progress*100) + ' %'; row[4] = fspeed(event.dlspeed); row[5] = fspeed(event.upspeed); + row[6] = event.priority + if(row[6] != -1) + queueing_enabled = true; if(!unfinished_hashes.contains(event.hash)) { // New unfinished torrent unfinished_hashes[unfinished_hashes.length] = event.hash; @@ -149,6 +153,10 @@ window.addEvent('domready', function(){ myTableUP.removeRow(hash); } }); + if(queueing_enabled) + $('queueingButtons').removeClass('invisible'); + else + $('queueingButtons').addClass('invisible'); } waiting=false; ajaxfn.delay(1000); diff --git a/src/webui/scripts/mocha-init.js b/src/webui/scripts/mocha-init.js index 20e2017c4..cfa58bb78 100644 --- a/src/webui/scripts/mocha-init.js +++ b/src/webui/scripts/mocha-init.js @@ -82,12 +82,14 @@ initializeWindows = function(){ } }); - ['pause','resume'].each(function(item) { + ['pause','resume','decreasePrio','increasePrio'].each(function(item) { addClickEvent(item, function(e){ new Event(e).stop(); if($("Tab1").hasClass('active')) { var h = myTable.selectedIds(); } else { + if(item=='decreasePrio' || item=='increasePrio') + return; var h = myTableUP.selectedIds(); } if(h.length){