From a0afcac4b0e7137e4f32c3bf0e1e31359ec6c7c4 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 10 Mar 2011 01:37:58 +0000 Subject: [PATCH] #4093 Peer and network settings accessible through the Web Client --- web/index.html | 78 ++++++++++++++++++++++++--- web/javascript/transmission.js | 56 ++++++++++++++++++- web/javascript/transmission.remote.js | 30 ++++++++++- web/stylesheets/common.css | 4 ++ 4 files changed, 157 insertions(+), 11 deletions(-) diff --git a/web/index.html b/web/index.html index fbc2c0730..828ea0896 100755 --- a/web/index.html +++ b/web/index.html @@ -229,6 +229,8 @@
@@ -242,13 +244,6 @@
-
- -
- - -
-
@@ -321,6 +316,75 @@
+ + Save diff --git a/web/javascript/transmission.js b/web/javascript/transmission.js index daedf555c..6cf85d0ea 100644 --- a/web/javascript/transmission.js +++ b/web/javascript/transmission.js @@ -1,5 +1,5 @@ /* - * Copyright © Dave Perrett and Malcolm Jarvis + * Copyright © Dave Perrett, Malcolm Jarvis and Bruno Bierbaumer * This code is licensed under the GPL version 2. * For details, see http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @@ -48,6 +48,7 @@ Transmission.prototype = $('#filter_finished_link').parent().bind('click', function(e){ tr.showFinishedClicked(e); }); $('#prefs_save_button').bind('click', function(e) { tr.savePrefsClicked(e); return false;}); $('#prefs_cancel_button').bind('click', function(e){ tr.cancelPrefsClicked(e); return false; }); + $('#block_update_button').bind('click', function(e){ tr.blocklistUpdateClicked(e); return false; }); $('#stats_close_button').bind('click', function(e){ tr.closeStatsClicked(e); return false; }); $('.inspector_tab').bind('click', function(e){ tr.inspectorTabClicked(e, this); }); $('.file_wanted_control').live('click', function(e){ tr.fileWantedClicked(e, this); }); @@ -60,7 +61,10 @@ Transmission.prototype = $('#turtle_button').bind('click', function(e){ tr.toggleTurtleClicked(e); return false; }); $('#prefs_tab_general_tab').click(function(e){ changeTab(this, 'prefs_tab_general') }); $('#prefs_tab_speed_tab').click(function(e){ changeTab(this, 'prefs_tab_speed') }); + $('#prefs_tab_peers_tab').click(function(e){ changeTab(this, 'prefs_tab_peers') }); + $('#prefs_tab_network_tab').click(function(e){ changeTab(this, 'prefs_tab_network');}); $('#torrent_upload_form').submit(function(){ $('#upload_confirm_button').click(); return false; }); + $('#torrent_upload_form').submit(function(){ $('#upload_confirm_button').click(); return false; }); if (iPhone) { $('#inspector_close').bind('click', function(e){ tr.hideInspector(); }); @@ -149,6 +153,14 @@ Transmission.prototype = tr.updateStats( o ); }, async ); }, + checkPort: function( async ){ + $('#port_test').text('checking ...') + var tr = this; + this.remote.checkPort( function(data){ + var o = data.arguments; + tr.updatePortStatus( o ); + }, async ); + }, preloadImages: function() { if (iPhone) { @@ -189,7 +201,7 @@ Transmission.prototype = */ setupPrefConstraints: function() { // only allow integers for speed limit & port options - $('div.preference input[@type=text]:not(#download_location)').blur( function() { + $('div.preference input[@type=text]:not(#download_location,#block_url)').blur( function() { this.value = this.value.replace(/[^0-9]/gi, ''); if (this.value == '') { if ($(this).is('#refresh_rate')) { @@ -636,6 +648,7 @@ Transmission.prototype = savePrefsClicked: function(event) { + // handle the clutch prefs locally var tr = this; var rate = parseInt( $('#prefs_form #refresh_rate')[0].value ); @@ -669,10 +682,28 @@ Transmission.prototype = o[RPC._TurtleTimeEnd] = parseInt( $('#prefs_form #turtle_end_time').val() ); o[RPC._TurtleTimeDay] = parseInt( $('#prefs_form #turtle_days').val() ); + + o[RPC._PeerLimitGlobal] = parseInt( $('#prefs_form #conn_global').val() ); + o[RPC._PeerLimitPerTorrent] = parseInt( $('#prefs_form #conn_torrent').val() ); + o[RPC._PexEnabled] = $('#prefs_form #conn_pex')[0].checked; + o[RPC._DhtEnabled] = $('#prefs_form #conn_dht')[0].checked; + o[RPC._LpdEnabled] = $('#prefs_form #conn_lpd')[0].checked; + o[RPC._BlocklistEnabled] = $('#prefs_form #block_enable')[0].checked; + o[RPC._BlocklistURL] = $('#prefs_form #block_url').val(); + o[RPC._UtpEnabled] = $('#prefs_form #network_utp')[0].checked; + o[RPC._PeerPortRandom] = $('#prefs_form #port_rand')[0].checked; + o[RPC._PortForwardingEnabled]= $('#prefs_form #port_forward')[0].checked; + + + tr.remote.savePrefs( o ); tr.hidePrefsDialog( ); }, + blocklistUpdateClicked: function(event){ + var tr = this; + tr.remote.updateBlocklist(); + }, closeStatsClicked: function(event) { this.hideStatsDialog( ); @@ -948,6 +979,7 @@ Transmission.prototype = *--------------------------------------------*/ showPrefsDialog: function( ) { + this.checkPort(true); $('body').addClass('prefs_showing'); $('#prefs_container').show(); this.hideiPhoneAddressbar(); @@ -1008,6 +1040,19 @@ Transmission.prototype = $('select#turtle_days').val( prefs[RPC._TurtleTimeDay] ); $('#transmission_version').text( prefs[RPC._DaemonVersion] ); + $('#conn_global').val( prefs[RPC._PeerLimitGlobal] ); + $('#conn_torrent').val( prefs[RPC._PeerLimitPerTorrent] ); + $('#conn_pex')[0].checked = prefs[RPC._PexEnabled]; + $('#conn_dht')[0].checked = prefs[RPC._DhtEnabled]; + $('#conn_lpd')[0].checked = prefs[RPC._LpdEnabled]; + $('#block_enable')[0].checked = prefs[RPC._BlocklistEnabled]; + $('#block_url').val( prefs[RPC._BlocklistURL]); + $('#block_size').text( prefs[RPC._BlocklistSize] + ' IP rules in the list' ); + $('#network_utp')[0].checked = prefs[RPC._UtpEnabled]; + $('#port_rand')[0].checked = prefs[RPC._PeerPortRandom]; + $('#port_forward')[0].checked = prefs[RPC._PortForwardingEnabled]; + + if (!iPhone) { setInnerHTML( $('#limited_download_rate')[0], [ 'Limit (', Transmission.fmt.speed(dn_limit_k), ')' ].join('') ); @@ -1025,6 +1070,13 @@ Transmission.prototype = this.updateTurtleButton(); }, + updatePortStatus: function( status ){ + if(status['port-is-open']) + $('#port_test').text('Port is open'); + else + $('#port_test').text('Port is closed'); + }, + showStatsDialog: function( ) { this.loadDaemonStats(); $('body').addClass('stats_showing'); diff --git a/web/javascript/transmission.remote.js b/web/javascript/transmission.remote.js index 9f51ffe9b..b62ed0c76 100644 --- a/web/javascript/transmission.remote.js +++ b/web/javascript/transmission.remote.js @@ -1,5 +1,5 @@ /* - * Copyright © Dave Perrett and Malcolm Jarvis + * Copyright © Dave Perrett, Malcolm Jarvis and Bruno Bierbaumer * This code is licensed under the GPL version 2. * For details, see http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @@ -28,6 +28,17 @@ RPC._TurtleTimeEnabled = 'alt-speed-time-enabled'; RPC._TurtleTimeBegin = 'alt-speed-time-begin'; RPC._TurtleTimeEnd = 'alt-speed-time-end'; RPC._TurtleTimeDay = 'alt-speed-time-day'; +RPC._PeerLimitGlobal = 'peer-limit-global'; +RPC._PeerLimitPerTorrent = 'peer-limit-per-torrent'; +RPC._PexEnabled = 'pex-enabled'; +RPC._DhtEnabled = 'dht-enabled'; +RPC._LpdEnabled = 'lpd-enabled'; +RPC._BlocklistEnabled = 'blocklist-enabled'; +RPC._BlocklistURL = 'blocklist-url'; +RPC._BlocklistSize = 'blocklist-size'; +RPC._UtpEnabled = 'utp-enabled'; +RPC._PeerPortRandom = 'peer-port-random-on-start'; +RPC._PortForwardingEnabled = 'port-forwarding-enabled'; RPC._StartAddedTorrent = 'start-added-torrents'; function TransmissionRemote( controller ) @@ -108,7 +119,13 @@ TransmissionRemote.prototype = var o = { method: 'session-get' }; this.sendRequest( o, callback, async ); }, - + + checkPort: function( callback, async ) { + var tr = this._controller; + var o = { method: 'port-test' }; + this.sendRequest( o, callback, async ); + }, + loadDaemonStats: function( callback, async ) { var tr = this._controller; var o = { method: 'session-stats' }; @@ -250,6 +267,15 @@ TransmissionRemote.prototype = remote._controller.loadDaemonPrefs(); } ); }, + updateBlocklist: function() { + var remote = this; + var o = { + method: 'blocklist-update', + }; + this.sendRequest( o, function() { + remote._controller.loadDaemonPrefs(); + } ); + }, filesSelectAll: function( torrent_ids, files, callback ) { this.sendTorrentSetRequests( 'torrent-set', torrent_ids, { 'files-wanted': files }, callback ); }, diff --git a/web/stylesheets/common.css b/web/stylesheets/common.css index 20bd9be26..1e00b62cb 100644 --- a/web/stylesheets/common.css +++ b/web/stylesheets/common.css @@ -1220,6 +1220,10 @@ div#prefs_container div.preference input { float: left; } +div#prefs_container div.block_url input { + width: 256px !important; +} + div#prefs_container div.download_location input { width: 256px !important; }