mirror of
https://github.com/transmission/transmission.git
synced 2026-04-19 00:12:26 +01:00
(trunk web) Add option to remove data when removing torrent from web interface
This commit is contained in:
@@ -11,7 +11,7 @@ Menu = {
|
||||
context: {
|
||||
|
||||
menu_style: {
|
||||
width: '210px',
|
||||
width: '310px',
|
||||
backgroundColor: '#fff',
|
||||
border: 'none',
|
||||
padding: '5px 0',
|
||||
|
||||
@@ -46,6 +46,7 @@ Transmission.prototype =
|
||||
$('#pause_selected_link').bind('click', this.stopSelectedClicked );
|
||||
$('#resume_selected_link').bind('click', this.startSelectedClicked);
|
||||
$('#remove_link').bind('click', this.removeClicked);
|
||||
$('#removedata_link').bind('click', this.removeDataClicked);
|
||||
$('#filter_all_link').parent().bind('click', this.showAllClicked);
|
||||
$('#filter_downloading_link').parent().bind('click', this.showDownloadingClicked);
|
||||
$('#filter_seeding_link').parent().bind('click', this.showSeedingClicked);
|
||||
@@ -197,6 +198,9 @@ Transmission.prototype =
|
||||
contextRemoveSelected: function( ) {
|
||||
transmission.removeSelectedTorrents( );
|
||||
},
|
||||
contextRemoveDataSelected: function( ) {
|
||||
transmission.removeSelectedTorrentsAndData( );
|
||||
},
|
||||
contextToggleInspector: function( ) {
|
||||
transmission.toggleInspector( );
|
||||
},
|
||||
@@ -216,6 +220,7 @@ Transmission.prototype =
|
||||
context_pause_selected: this.contextStopSelected,
|
||||
context_resume_selected: this.contextStartSelected,
|
||||
context_remove: this.contextRemoveSelected,
|
||||
context_removedata: this.contextRemoveDataSelected,
|
||||
context_toggle_inspector: this.contextToggleInspector,
|
||||
context_select_all: this.contextSelectAll,
|
||||
context_deselect_all: this.contextDeselectAll
|
||||
@@ -547,6 +552,14 @@ Transmission.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
removeDataClicked: function( event ) {
|
||||
var tr = transmission;
|
||||
if( tr.isButtonEnabled( event ) ) {
|
||||
tr.removeSelectedTorrentsAndData( );
|
||||
tr.hideiPhoneAddressbar( );
|
||||
}
|
||||
},
|
||||
|
||||
toggleInspectorClicked: function( event ) {
|
||||
var tr = transmission;
|
||||
if( tr.isButtonEnabled( event ) )
|
||||
@@ -1187,6 +1200,12 @@ Transmission.prototype =
|
||||
this.promptToRemoveTorrents( torrents );
|
||||
},
|
||||
|
||||
removeSelectedTorrentsAndData: function() {
|
||||
var torrents = this.getSelectedTorrents( );
|
||||
if( torrents.length )
|
||||
this.promptToRemoveTorrentsAndData( torrents );
|
||||
},
|
||||
|
||||
promptToRemoveTorrents:function( torrents )
|
||||
{
|
||||
if( torrents.length == 1 )
|
||||
@@ -1204,10 +1223,31 @@ Transmission.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
promptToRemoveTorrentsAndData:function( torrents )
|
||||
{
|
||||
if( torrents.length == 1 )
|
||||
{
|
||||
var torrent = torrents[0],
|
||||
header = 'Remove ' + torrent.name() + ' and delete data?',
|
||||
message = 'All data downloaded for this torrent will be deleted. Are you sure you want to remove it?';
|
||||
dialog.confirm( header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents );
|
||||
}
|
||||
else
|
||||
{
|
||||
var header = 'Remove ' + torrents.length + ' transfers and delete data?',
|
||||
message = 'All data downloaded for these torrents will be deleted. Are you sure you want to remove them?';
|
||||
dialog.confirm( header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents );
|
||||
}
|
||||
},
|
||||
|
||||
removeTorrents: function( torrents ) {
|
||||
this.remote.removeTorrents( torrents );
|
||||
},
|
||||
|
||||
removeTorrentsAndData: function( torrents ) {
|
||||
this.remote.removeTorrentsAndData( torrents );
|
||||
},
|
||||
|
||||
startSelectedTorrents: function( ) {
|
||||
this.startTorrents( this.getSelectedTorrents( ) );
|
||||
},
|
||||
@@ -1336,6 +1376,7 @@ Transmission.prototype =
|
||||
this.setEnabled( 'li#resume_selected', havePausedSelection );
|
||||
this.setEnabled( 'li.context_resume_selected', havePausedSelection );
|
||||
this.setEnabled( 'li#remove', haveSelection );
|
||||
this.setEnabled( 'li#removedata', haveSelection );
|
||||
this.setEnabled( 'li#pause_all', haveActive );
|
||||
this.setEnabled( 'li#resume_all', havePaused );
|
||||
}
|
||||
|
||||
@@ -121,6 +121,20 @@ TransmissionRemote.prototype =
|
||||
removeTorrents: function( torrents ) {
|
||||
this.sendTorrentCommand( 'torrent-remove', torrents );
|
||||
},
|
||||
removeTorrentsAndData: function( torrents ) {
|
||||
var remote = this,
|
||||
o = { };
|
||||
o.method = 'torrent-remove';
|
||||
o.arguments = { };
|
||||
o.arguments['delete-local-data'] = true;
|
||||
o.arguments.ids = [ ];
|
||||
if( torrents != null )
|
||||
for( var i=0, len=torrents.length; i<len; ++i )
|
||||
o.arguments.ids.push( torrents[i].id() );
|
||||
this.sendRequest( RPC._Root, $.toJSON(o), function( ) {
|
||||
remote.loadTorrents();
|
||||
}, "json" );
|
||||
},
|
||||
addTorrentByUrl: function( url, options ) {
|
||||
this.sendRequest( RPC._Root, $.toJSON({
|
||||
method: 'torrent-add',
|
||||
|
||||
Reference in New Issue
Block a user