Skip to content

Commit

Permalink
Issue #13 - remove torrent
Browse files Browse the repository at this point in the history
  • Loading branch information
styxit committed Aug 14, 2013
1 parent 1e59bb9 commit 5524d1d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
16 changes: 14 additions & 2 deletions interfaces/default/js/transmission.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,20 @@ function getTorrents(){
// Round to 2 decimals
ratio = Math.round(torrent.uploadRatio*100) / 100;

// Action button
// Button group
buttons = $('<div>').addClass('btn-group');

// Action button (pause or resume)
actionButton = generateTorrentActionButton(torrent);
buttons.append(actionButton);

// Remove button
removeButton = $('<a>').
addClass('btn btn-mini').
html('<i class="icon-remove"></i>').
attr('href', WEBDIR + 'transmission/remove/' + torrent.id).
attr('title', 'Remove torrent');
buttons.append(removeButton);

tr.append(
$('<td>').html(torrent.name
Expand All @@ -63,7 +75,7 @@ function getTorrents(){
$('<td>').text(getReadableTime(torrent.eta)),
$('<td>').text(torrentStatus(torrent.status)),
$('<td>').addClass('span3').html(progress),
$('<td>').addClass('torrent-action').append(actionButton)
$('<td>').addClass('torrent-action').append(buttons)
);
$('#torrent-queue').append(tr);
});
Expand Down
9 changes: 9 additions & 0 deletions modules/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ def stop(self, torrentId):
return False
return self.fetch('torrent-stop', {'ids': torrentId})

@cherrypy.expose()
@cherrypy.tools.json_out()
def remove(self, torrentId):
try:
torrentId = int(torrentId)
except ValueError:
return False
return self.fetch('torrent-remove', {'ids': torrentId})

# Wrapper to access the Transmission Api
# If the first call fails, there probably is no valid Session ID so we try it again
def fetch(self, method, arguments=''):
Expand Down

0 comments on commit 5524d1d

Please sign in to comment.