Browse Source

- Added priority actions in Web UI

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
330905da5e
  1. 5
      src/eventmanager.cpp
  2. 26
      src/httpconnection.cpp
  3. 2
      src/httpconnection.h
  4. 2
      src/httpserver.cpp
  5. 4
      src/webui/css/style.css
  6. 5
      src/webui/index.html
  7. 8
      src/webui/scripts/client.js
  8. 4
      src/webui/scripts/mocha-init.js

5
src/eventmanager.cpp

@ -81,6 +81,11 @@ void EventManager::modifiedTorrent(QTorrentHandle h) @@ -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());

26
src/httpconnection.cpp

@ -202,34 +202,36 @@ void HttpConnection::respondCommand(QString command) @@ -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;
}
}

2
src/httpconnection.h

@ -62,6 +62,8 @@ class HttpConnection : public QObject @@ -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();
};

2
src/httpserver.cpp

@ -68,6 +68,8 @@ void HttpServer::newHttpConnection() @@ -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)));
}
}

4
src/webui/css/style.css

@ -20,6 +20,10 @@ body { @@ -20,6 +20,10 @@ body {
width: 300px;
}
.invisible {
display: none;
}
/* Typography */
h2, h3, h4 {

5
src/webui/index.html

@ -64,6 +64,10 @@ @@ -64,6 +64,10 @@
<a id="pauseButton"><img class="mochaToolButton" title="Pause" src="images/skin/pause.png"/></a>
<a id="resumeAllButton"><img class="mochaToolButton" title="Resume all" src="images/skin/play_all.png"/></a>
<a id="pauseAllButton"><img class="mochaToolButton" title="Pause All" src="images/skin/pause_all.png"/></a>
<span id="queueingButtons">
<a id="decreasePrioButton"><img class="mochaToolButton" title="Decrease priority" src="images/skin/decrease.png"/></a>
<a id="increasePrioButton"><img class="mochaToolButton" title="Increase priority" src="images/skin/increase.png"/></a>
</span>
</div>
</div>
<div id="pageWrapper"> <span id="error_div"></span>
@ -82,6 +86,7 @@ @@ -82,6 +86,7 @@
<th>Progress</th>
<th>DL Speed</th>
<th>UP Speed</th>
<th>Priority</th>
</tr>
</thead>
<tbody id="myTable"></tbody>

8
src/webui/scripts/client.js

@ -72,6 +72,7 @@ window.addEvent('domready', function(){ @@ -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(){ @@ -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(){ @@ -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);

4
src/webui/scripts/mocha-init.js

@ -82,12 +82,14 @@ initializeWindows = function(){ @@ -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){

Loading…
Cancel
Save