Permalink
Browse files

Added move torrent functionality to web interface.

1 parent 86f083d commit c1c16c5a1e70efc26a39985ec896c28107d69702 @joehillen committed Feb 27, 2012
Showing with 71 additions and 3 deletions.
  1. +18 −0 web/index.html
  2. +1 −0 web/javascript/dialog.js
  3. +7 −0 web/javascript/remote.js
  4. +45 −3 web/javascript/transmission.js
View
@@ -303,6 +303,23 @@ <h2 class="dialog_heading">Upload Torrent Files</h2>
</div>
</div>
+ <div class="dialog_container" id="move_container" style="display:none;">
+ <div class="dialog_top_bar"></div>
+ <div class="dialog_window">
+ <div class="dialog_logo" id="move_dialog_logo"></div>
+ <h2 class="dialog_heading">Set Location</h2>
+ <form action="#" method="post" id="torrent_move_form"
+ enctype="multipart/form-data" target="torrent_move_frame">
+ <div class="dialog_message">
+ <label for="torrent_path">Location:</label>
+ <input type="text" id="torrent_path"/>
+ </div>
+ <a href="#move" id="move_confirm_button">Apply</a>
+ <a href="#cancel" id="move_cancel_button">Cancel</a>
+ </form>
+ </div>
+ </div>
+
<div class="torrent_footer">
<ul id="settings_menu" title="Settings Menu">
<li id="button">&nbsp;
@@ -392,6 +409,7 @@ <h2 class="dialog_heading">Upload Torrent Files</h2>
<li id="context_removedata">Trash Data & Remove From List...</li>
<li class="separator"></li>
<li id="context_verify">Verify Local Data</li>
+ <li id="context_move">Set Location...</li>
<li class="separator"></li>
<li id="context_reannounce">Ask tracker for more peers</li>
</ul>
@@ -103,6 +103,7 @@ Dialog.prototype = {
setInnerHTML(this._cancel_button[0], cancel_button_label);
// Just in case
$('#upload_container').hide();
+ $('#move_container').hide();
$('body').addClass('dialog_showing');
transmission.updateButtonStates();
if (isMobileDevice)
@@ -157,6 +157,13 @@ TransmissionRemote.prototype =
stopTorrents: function(torrent_ids, callback, context) {
this.sendTorrentActionRequests('torrent-stop', torrent_ids, callback, context);
},
+
+ moveTorrents: function(torrent_ids, new_location, callback, context) {
+ var remote = this;
+ this.sendTorrentSetRequests( 'torrent-set-location', torrent_ids,
+ {"move": true, "location": new_location}, callback, context);
+ },
+
removeTorrents: function(torrent_ids, callback, context) {
this.sendTorrentActionRequests('torrent-remove', torrent_ids, callback, context);
},
@@ -53,6 +53,10 @@ Transmission.prototype =
$('#upload_confirm_button').click($.proxy(this.confirmUploadClicked,this));
$('#upload_cancel_button').click($.proxy(this.hideUploadDialog,this));
+
+ $('#move_confirm_button').click($.proxy(this.confirmMoveClicked,this));
+ $('#move_cancel_button').click($.proxy(this.hideMoveDialog,this));
+
$('#turtle-button').click($.proxy(this.toggleTurtleClicked,this));
$('#compact-button').click($.proxy(this.toggleCompactClicked,this));
@@ -175,6 +179,7 @@ Transmission.prototype =
context_pause_selected: function() { tr.stopSelectedTorrents(); },
context_resume_selected: function() { tr.startSelectedTorrents(false); },
context_resume_now_selected: function() { tr.startSelectedTorrents(true); },
+ context_move: function() { tr.moveSelectedTorrents(false); },
context_remove: function() { tr.removeSelectedTorrents(); },
context_removedata: function() { tr.removeSelectedTorrentsAndData(); },
context_verify: function() { tr.verifySelectedTorrents(); },
@@ -497,7 +502,7 @@ Transmission.prototype =
drop: function(ev)
{
var i, uri, uris=null,
- types = ["text/uri-list", "text/plain"];
+ types = ["text/uri-list", "text/plain"],
paused = this.shouldAddedTorrentsStart();
if (!ev.dataTransfer || !ev.dataTransfer.types)
@@ -529,6 +534,16 @@ Transmission.prototype =
this.hideUploadDialog();
},
+ hideMoveDialog: function() {
+ $('#move_container').hide();
+ this.updateButtonStates();
+ },
+
+ confirmMoveClicked: function() {
+ this.moveSelectedTorrents(true);
+ this.hideUploadDialog();
+ },
+
removeClicked: function(ev) {
if (this.isButtonEnabled(ev)) {
this.removeSelectedTorrents();
@@ -870,6 +885,34 @@ Transmission.prototype =
}
},
+ promptSetLocation: function(confirmed, torrents) {
+ if (! confirmed) {
+ var path;
+ if (torrents.length === 1) {
+ path = torrents[0].getDownloadDir();
+ } else {
+ path = $("#download-dir").val();
+ }
+ $('input#torrent_path').attr('value', path);
+ $('#move_container').show();
+ $('#torrent_path').focus();
+ } else {
+ var ids = this.getTorrentIds(torrents);
+ this.remote.moveTorrents(
+ ids,
+ $("input#torrent_path").val(),
+ this.refreshTorrents,
+ this);
+ $('#move_container').hide();
+ }
+ },
+
+ moveSelectedTorrents: function(confirmed) {
+ var torrents = this.getSelectedTorrents();
+ if (torrents.length)
+ this.promptSetLocation(confirmed, torrents);
+ },
+
removeSelectedTorrents: function() {
var torrents = this.getSelectedTorrents();
if (torrents.length)
@@ -882,8 +925,7 @@ Transmission.prototype =
this.promptToRemoveTorrentsAndData(torrents);
},
- promptToRemoveTorrents:function(torrents)
- {
+ promptToRemoveTorrents: function(torrents) {
if (torrents.length === 1)
{
var torrent = torrents[0],

0 comments on commit c1c16c5

Please sign in to comment.