summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2015-11-24 00:19:18 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2015-11-24 00:19:21 +0100
commit0e1582702a6b3d8fd4fbe4cd6d8c2f76353b8657 (patch)
tree01005f5bfeb83a2041f0672e6da937b4aab18d47
parent[GTKUI] Fix for flake8 (diff)
downloaddeluge-0e1582702a6b3d8fd4fbe4cd6d8c2f76353b8657.tar.xz
deluge-0e1582702a6b3d8fd4fbe4cd6d8c2f76353b8657.zip
[#2485] [WebUI] Fix unconnected Options in context menu
-rw-r--r--deluge/ui/web/js/deluge-all/Menus.js226
1 files changed, 148 insertions, 78 deletions
diff --git a/deluge/ui/web/js/deluge-all/Menus.js b/deluge/ui/web/js/deluge-all/Menus.js
index f875df8f1..2f56c81f7 100644
--- a/deluge/ui/web/js/deluge-all/Menus.js
+++ b/deluge/ui/web/js/deluge-all/Menus.js
@@ -31,69 +31,54 @@
*/
deluge.menus = {
- onTorrentAction: function(item, e) {
+ onTorrentActionSetOpt: function(item, e) {
var ids = deluge.torrents.getSelectedIds();
var action = item.initialConfig.torrentAction;
+ var opts = {};
+ opts[action[0]] = action[1];
+ deluge.client.core.set_torrent_options(ids, opts);
+ },
+ onTorrentActionMethod: function(item, e) {
+ var ids = deluge.torrents.getSelectedIds();
+ var action = item.initialConfig.torrentAction;
+ deluge.client.core[action](ids, {
+ success: function() {
+ deluge.ui.update();
+ }
+ });
+ },
+
+ onTorrentActionShow: function(item, e) {
+ var ids = deluge.torrents.getSelectedIds();
+ var action = item.initialConfig.torrentAction;
switch (action) {
- case 'pause':
- case 'resume':
- deluge.client.core[action + '_torrent'](ids, {
- success: function() {
- deluge.ui.update();
- }
- });
- break;
- case 'top':
- case 'up':
- case 'down':
- case 'bottom':
- deluge.client.core['queue_' + action](ids, {
- success: function() {
- deluge.ui.update();
- }
- });
- break;
case 'edit_trackers':
deluge.editTrackers.show();
break;
- case 'update':
- deluge.client.core.force_reannounce(ids, {
- success: function() {
- deluge.ui.update();
- }
- });
- break;
case 'remove':
deluge.removeWindow.show(ids);
break;
- case 'recheck':
- deluge.client.core.force_recheck(ids, {
- success: function() {
- deluge.ui.update();
- }
- });
- break;
case 'move':
deluge.moveStorage.show(ids);
break;
}
- }
+ },
}
deluge.menus.torrent = new Ext.menu.Menu({
id: 'torrentMenu',
items: [{
- torrentAction: 'pause',
+ torrentAction: 'pause_torrent',
text: _('Pause'),
iconCls: 'icon-pause',
- handler: deluge.menus.onTorrentAction,
+ handler: deluge.menus.onTorrentActionMethod,
scope: deluge.menus
}, {
- torrentAction: 'resume',
+ torrentAction: 'resume_torrent',
text: _('Resume'),
iconCls: 'icon-resume',
- handler: deluge.menus.onTorrentAction,
+ handler: deluge.menus.onTorrentActionMethod,
scope: deluge.menus
}, '-', {
text: _('Options'),
@@ -106,17 +91,35 @@ deluge.menus.torrent = new Ext.menu.Menu({
hideOnClick: false,
menu: new Ext.menu.Menu({
items: [{
- text: _('5 KiB/s')
+ torrentAction: ['max_download_speed', 5],
+ text: _('5 KiB/s'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: _('10 KiB/s')
+ torrentAction: ['max_download_speed', 10],
+ text: _('10 KiB/s'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: _('30 KiB/s')
+ torrentAction: ['max_download_speed', 30],
+ text: _('30 KiB/s'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: _('80 KiB/s')
+ torrentAction: ['max_download_speed', 80],
+ text: _('80 KiB/s'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: _('300 KiB/s')
+ torrentAction: ['max_download_speed', 300],
+ text: _('300 KiB/s'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
},{
- text: _('Unlimited')
+ torrentAction: ['max_download_speed', -1],
+ text: _('Unlimited'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}]
})
}, {
@@ -125,17 +128,35 @@ deluge.menus.torrent = new Ext.menu.Menu({
hideOnClick: false,
menu: new Ext.menu.Menu({
items: [{
- text: _('5 KiB/s')
+ torrentAction: ['max_upload_speed', 5],
+ text: _('5 KiB/s'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: _('10 KiB/s')
+ torrentAction: ['max_upload_speed', 10],
+ text: _('10 KiB/s'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: _('30 KiB/s')
+ torrentAction: ['max_upload_speed', 30],
+ text: _('30 KiB/s'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: _('80 KiB/s')
+ torrentAction: ['max_upload_speed', 80],
+ text: _('80 KiB/s'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: _('300 KiB/s')
+ torrentAction: ['max_upload_speed', 300],
+ text: _('300 KiB/s'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
},{
- text: _('Unlimited')
+ torrentAction: ['max_upload_speed', -1],
+ text: _('Unlimited'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}]
})
}, {
@@ -144,17 +165,35 @@ deluge.menus.torrent = new Ext.menu.Menu({
hideOnClick: false,
menu: new Ext.menu.Menu({
items: [{
- text: '50'
+ torrentAction: ['max_connections', 50],
+ text: _('50'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: '100'
+ torrentAction: ['max_connections', 100],
+ text: _('100'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: '200'
+ torrentAction: ['max_connections', 200],
+ text: _('200'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: '300'
+ torrentAction: ['max_connections', 300],
+ text: _('300'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: '500'
+ torrentAction: ['max_connections', 500],
+ text: _('500'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
},{
- text: _('Unlimited')
+ torrentAction: ['max_connections', -1],
+ text: _('Unlimited'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}]
})
}, {
@@ -163,23 +202,54 @@ deluge.menus.torrent = new Ext.menu.Menu({
hideOnClick: false,
menu: new Ext.menu.Menu({
items: [{
- text: '0'
+ torrentAction: ['max_upload_slots', 0],
+ text: _('0'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: '1'
+ torrentAction: ['max_upload_slots', 1],
+ text: _('1'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: '2'
+ torrentAction: ['max_upload_slots', 2],
+ text: _('2'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: '3'
+ torrentAction: ['max_upload_slots', 3],
+ text: _('3'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}, {
- text: '5'
+ torrentAction: ['max_upload_slots', 5],
+ text: _('5'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
},{
- text: _('Unlimited')
+ torrentAction: ['max_upload_slots', -1],
+ text: _('Unlimited'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
}]
})
}, {
id: 'auto_managed',
text: _('Auto Managed'),
- checked: false
+ hideOnClick: false,
+ menu: new Ext.menu.Menu({
+ items: [{
+ torrentAction: ['auto_managed', true],
+ text: _('On'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
+ }, {
+ torrentAction: ['auto_managed', false],
+ text: _('Off'),
+ handler: deluge.menus.onTorrentActionSetOpt,
+ scope: deluge.menus
+ }]
+ })
}]
})
}, '-', {
@@ -188,60 +258,60 @@ deluge.menus.torrent = new Ext.menu.Menu({
hideOnClick: false,
menu: new Ext.menu.Menu({
items: [{
- torrentAction: 'top',
+ torrentAction: 'queue_top',
text: _('Top'),
iconCls: 'icon-top',
- handler: deluge.menus.onTorrentAction,
+ handler: deluge.menus.onTorrentActionMethod,
scope: deluge.menus
},{
- torrentAction: 'up',
+ torrentAction: 'queue_up',
text: _('Up'),
iconCls: 'icon-up',
- handler: deluge.menus.onTorrentAction,
+ handler: deluge.menus.onTorrentActionMethod,
scope: deluge.menus
},{
- torrentAction: 'down',
+ torrentAction: 'queue_down',
text: _('Down'),
iconCls: 'icon-down',
- handler: deluge.menus.onTorrentAction,
+ handler: deluge.menus.onTorrentActionMethod,
scope: deluge.menus
},{
- torrentAction: 'bottom',
+ torrentAction: 'queue_bottom',
text: _('Bottom'),
iconCls: 'icon-bottom',
- handler: deluge.menus.onTorrentAction,
+ handler: deluge.menus.onTorrentActionMethod,
scope: deluge.menus
}]
})
}, '-', {
- torrentAction: 'update',
+ torrentAction: 'force_reannounce',
text: _('Update Tracker'),
iconCls: 'icon-update-tracker',
- handler: deluge.menus.onTorrentAction,
+ handler: deluge.menus.onTorrentActionMethod,
scope: deluge.menus
}, {
torrentAction: 'edit_trackers',
text: _('Edit Trackers'),
iconCls: 'icon-edit-trackers',
- handler: deluge.menus.onTorrentAction,
+ handler: deluge.menus.onTorrentActionShow,
scope: deluge.menus
}, '-', {
torrentAction: 'remove',
text: _('Remove Torrent'),
iconCls: 'icon-remove',
- handler: deluge.menus.onTorrentAction,
+ handler: deluge.menus.onTorrentActionShow,
scope: deluge.menus
}, '-', {
- torrentAction: 'recheck',
+ torrentAction: 'force_recheck',
text: _('Force Recheck'),
iconCls: 'icon-recheck',
- handler: deluge.menus.onTorrentAction,
+ handler: deluge.menus.onTorrentActionMethod,
scope: deluge.menus
}, {
torrentAction: 'move',
text: _('Move Download Folder'),
iconCls: 'icon-move',
- handler: deluge.menus.onTorrentAction,
+ handler: deluge.menus.onTorrentActionShow,
scope: deluge.menus
}]
});