(trunk, web) #5510 'add file renaming to transmission web interface' -- added with patch from mark ablov
This commit is contained in:
parent
cd00ad4f55
commit
258b6cf029
|
@ -105,7 +105,16 @@ TransmissionRemote.prototype =
|
|||
var o = { method: 'port-test' };
|
||||
this.sendRequest(o, callback, context, async);
|
||||
},
|
||||
|
||||
|
||||
renameTorrent: function(torrentIds, oldpath, newname, callback, context) {
|
||||
var o = { method: 'torrent-rename-path',
|
||||
arguments: { 'ids': torrentIds,
|
||||
'path': oldpath,
|
||||
'name': newname }
|
||||
};
|
||||
this.sendRequest(o, callback, context);
|
||||
},
|
||||
|
||||
loadDaemonStats: function(callback, context, async) {
|
||||
var o = { method: 'session-stats' };
|
||||
this.sendRequest(o, callback, context, async);
|
||||
|
|
|
@ -53,6 +53,10 @@ Transmission.prototype =
|
|||
$('#upload_confirm_button').click($.proxy(this.confirmUploadClicked,this));
|
||||
$('#upload_cancel_button').click($.proxy(this.hideUploadDialog,this));
|
||||
|
||||
$('#rename_confirm_button').click($.proxy(this.confirmRenameClicked,this));
|
||||
$('#rename_cancel_button').click($.proxy(this.hideRenameDialog,this));
|
||||
|
||||
|
||||
$('#move_confirm_button').click($.proxy(this.confirmMoveClicked,this));
|
||||
$('#move_cancel_button').click($.proxy(this.hideMoveDialog,this));
|
||||
|
||||
|
@ -183,6 +187,7 @@ Transmission.prototype =
|
|||
context_remove: function() { tr.removeSelectedTorrents(); },
|
||||
context_removedata: function() { tr.removeSelectedTorrentsAndData(); },
|
||||
context_verify: function() { tr.verifySelectedTorrents(); },
|
||||
context_rename: function() { tr.renameSelectedTorrents(); },
|
||||
context_reannounce: function() { tr.reannounceSelectedTorrents(); },
|
||||
context_move_top: function() { tr.moveTop(); },
|
||||
context_move_up: function() { tr.moveUp(); },
|
||||
|
@ -572,6 +577,17 @@ Transmission.prototype =
|
|||
this.hideUploadDialog();
|
||||
},
|
||||
|
||||
hideRenameDialog: function() {
|
||||
$('body.open_showing').removeClass('open_showing');
|
||||
$('#rename_container').hide();
|
||||
},
|
||||
|
||||
confirmRenameClicked: function() {
|
||||
var torrents = this.getSelectedTorrents();
|
||||
this.renameTorrent(torrents[0], $('input#torrent_rename_name').attr('value'));
|
||||
this.hideRenameDialog();
|
||||
},
|
||||
|
||||
removeClicked: function(ev) {
|
||||
if (this.isButtonEnabled(ev)) {
|
||||
this.removeSelectedTorrents();
|
||||
|
@ -1054,6 +1070,36 @@ Transmission.prototype =
|
|||
this.remote.removeTorrentsAndData(torrents);
|
||||
},
|
||||
|
||||
promptToRenameTorrent: function(torrent) {
|
||||
$('body').addClass('open_showing');
|
||||
$('input#torrent_rename_name').attr('value', torrent.getName());
|
||||
$('#rename_container').show();
|
||||
$('#torrent_rename_name').focus();
|
||||
},
|
||||
|
||||
renameSelectedTorrents: function() {
|
||||
var torrents = this.getSelectedTorrents();
|
||||
if (torrents.length != 1)
|
||||
dialog.alert("Renaming", "You can rename only one torrent at a time.", "Ok");
|
||||
else
|
||||
this.promptToRenameTorrent(torrents[0]);
|
||||
},
|
||||
|
||||
onTorrentRenamed: function(response) {
|
||||
var torrent;
|
||||
if ((response.result === 'success') &&
|
||||
(response.arguments) &&
|
||||
((torrent = this._torrents[response.arguments.id])))
|
||||
{
|
||||
torrent.refresh(response.arguments);
|
||||
}
|
||||
},
|
||||
|
||||
renameTorrent: function (torrent, newname) {
|
||||
var oldpath = torrent.getName();
|
||||
this.remote.renameTorrent([torrent.getId()], oldpath, newname, this.onTorrentRenamed, this);
|
||||
},
|
||||
|
||||
verifySelectedTorrents: function() {
|
||||
this.verifyTorrents(this.getSelectedTorrents());
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue