From 38929ab13f342cf546882cd9877c5307de9ca588 Mon Sep 17 00:00:00 2001 From: DjLegolas Date: Fri, 29 Apr 2022 14:44:45 +0300 Subject: [PATCH] no more Peers Source info ** This commit dropped Peers Source info ** ** Will be added in later MR ** New commit for later use: [UI] Add and improve trackers tab First, added trackers tab to the WebUI. Second, now we can view all the trackers and view each: * status * number of peers * additional message Third, moved the private torrent info to the details tab (GTK). closes: https://dev.deluge-torrent.org/ticket/1015 --- deluge/ui/gtk3/trackers_tab.py | 49 +----------- deluge/ui/web/js/deluge-all/Keys.js | 8 +- deluge/ui/web/js/deluge-all/UI.js | 7 ++ .../web/js/deluge-all/details/TrackersTab.js | 76 ++++++------------- 4 files changed, 40 insertions(+), 100 deletions(-) diff --git a/deluge/ui/gtk3/trackers_tab.py b/deluge/ui/gtk3/trackers_tab.py index 48db862df0..65af9366d2 100644 --- a/deluge/ui/gtk3/trackers_tab.py +++ b/deluge/ui/gtk3/trackers_tab.py @@ -38,7 +38,6 @@ def __init__(self): # key is url, item is row iter self.trackers = {} - self.constant_rows = {} self._can_get_trackers_info = False @@ -94,28 +93,13 @@ def __init__(self): self.torrent_id = None - self._fill_constant_rows() - - def _fill_constant_rows(self): - for item in ['DHT', 'PeX', 'LSD']: - row = self.liststore.append( - [ - f'*** {item} ***', - '', - 0, - '', - ] - ) - - self.constant_rows[item.lower()] = row - def update(self): if client.is_standalone(): self._can_get_trackers_info = True else: - self._can_get_trackers_info = ( - VersionSplit(client.connection_version()) > VersionSplit('2.0.5') - ) + self._can_get_trackers_info = VersionSplit( + client.connection_version() + ) > VersionSplit('2.0.5') self.do_update() @maybe_coroutine @@ -128,14 +112,12 @@ async def do_update(self): torrent_id = torrent_id[0] else: self.liststore.clear() - self._fill_constant_rows() return if torrent_id != self.torrent_id: # We only want to do this if the torrent_id has changed self.liststore.clear() self.trackers = {} - self._fill_constant_rows() self.torrent_id = torrent_id session = component.get('SessionProxy') @@ -152,9 +134,6 @@ async def do_update(self): 'trackers_peers', ] - peers_sources = await session.get_torrent_status(torrent_id, ['peers_source']) - self._on_get_peers_source_status(peers_sources) - status = await session.get_torrent_status(torrent_id, tracker_keys) self._on_get_torrent_tracker_status(status) @@ -164,12 +143,7 @@ def _on_get_torrent_tracker_status(self, status): return if not self._can_get_trackers_info: - status['trackers'] = [ - { - 'url': status['tracker_host'], - 'message': '' - } - ] + status['trackers'] = [{'url': status['tracker_host'], 'message': ''}] status['trackers_status'] = { status['tracker_host']: status['tracker_status'] } @@ -212,23 +186,8 @@ def _on_get_torrent_tracker_status(self, status): self.liststore.remove(self.trackers[tracker]) del self.trackers[tracker] - def _on_get_peers_source_status(self, status): - # Check to see if we got valid data from the core - if not status: - return - - for const_values in status['peers_source']: - row = self.constant_rows[const_values['name']] - old_peers_value = self.liststore.get(row, 2)[0] - status = 'Working' if const_values['enabled'] else 'Disabled' - peers_count = const_values['count'] - self.liststore.set_value(row, 1, status) - if peers_count != old_peers_value: - self.liststore.set_value(row, 2, peers_count) - def clear(self): self.liststore.clear() - self._fill_constant_rows() def _on_button_press_event(self, widget, event): """This is a callback for showing the right-click context menu.""" diff --git a/deluge/ui/web/js/deluge-all/Keys.js b/deluge/ui/web/js/deluge-all/Keys.js index 8c01273e9b..c8bb804ba5 100644 --- a/deluge/ui/web/js/deluge-all/Keys.js +++ b/deluge/ui/web/js/deluge-all/Keys.js @@ -96,10 +96,16 @@ Deluge.Keys = { /** * Keys used in the trackers tab of the statistics panel. - *
['trackers']
+ *
['trackers', 'trackers_status', 'trackers_peers']
*/ Trackers: ['trackers', 'trackers_status', 'trackers_peers'], + /** + * Keys used in the trackers tab of the statistics panel for Deluge version <2.0.5. + *
['tracker_host', 'tracker_status']
+ */ + TrackersRedundant: ['tracker_host', 'tracker_status'], + /** * Keys used in the details tab of the statistics panel. */ diff --git a/deluge/ui/web/js/deluge-all/UI.js b/deluge/ui/web/js/deluge-all/UI.js index cc877d597a..b7badf96d3 100644 --- a/deluge/ui/web/js/deluge-all/UI.js +++ b/deluge/ui/web/js/deluge-all/UI.js @@ -52,6 +52,7 @@ deluge.ui = { deluge.sidebar = new Deluge.Sidebar(); deluge.statusbar = new Deluge.Statusbar(); deluge.toolbar = new Deluge.Toolbar(); + deluge.server_version = ''; this.detailsPanel = new Ext.Panel({ id: 'detailsPanel', @@ -204,6 +205,11 @@ deluge.ui = { this.running = setInterval(this.update, 2000); this.update(); } + deluge.client.daemon.get_version({ + success: function (server_version) { + deluge.server_version = server_version; + }, + }); deluge.client.web.get_plugins({ success: this.onGotPlugins, scope: this, @@ -215,6 +221,7 @@ deluge.ui = { * @private */ onDisconnect: function () { + deluge.server_version = ''; this.stop(); }, diff --git a/deluge/ui/web/js/deluge-all/details/TrackersTab.js b/deluge/ui/web/js/deluge-all/details/TrackersTab.js index 51d0a727b4..f6ed1ceefa 100644 --- a/deluge/ui/web/js/deluge-all/details/TrackersTab.js +++ b/deluge/ui/web/js/deluge-all/details/TrackersTab.js @@ -12,7 +12,7 @@ Deluge.details.TrackersTab = Ext.extend(Ext.grid.GridPanel, { // fast way to figure out if we have a tracker already. trackers: {}, - constantRows: {}, + can_get_trackers_info: false, constructor: function (config) { config = Ext.apply( @@ -67,54 +67,28 @@ this, config ); - // this.constantRows = {}; - this._fillConstantRows(); - }, - - _fillConstantRows: function () { - var constRows = []; - var tmpConstantRows = {}; - - Ext.each(['DHT', 'PeX', 'LSD'], function (constRowName) { - constRows.push( - new Deluge.data.Tracker( - { - tracker: '*** ' + constRowName + ' ***', - status: '', - peers: 0, - message: '', - }, - constRowName.toLowerCase() - ) - ); - tmpConstantRows[constRowName.toLowerCase()] = true; - }); - - this.constantRows = tmpConstantRows; - var store = this.getStore(); - store.add(constRows); - store.commitChanges(); }, clear: function () { this.getStore().removeAll(); - this._fillConstantRows(); this.trackers = {}; }, update: function (torrentId) { + this.can_get_trackers_info = deluge.server_version > '2.0.5'; + + var trackers_keys = this.can_get_trackers_info + ? Deluge.Keys.Trackers + : Deluge.Keys.TrackersRedundant; + deluge.client.web.get_torrent_status( torrentId, - Deluge.Keys.Trackers, + trackers_keys, { success: this.onTrackersRequestComplete, scope: this, } ); - deluge.client.web.get_torrent_status(torrentId, ['peers_source'], { - success: this.onPeersSourceRequestComplete, - scope: this, - }); }, onTrackersRequestComplete: function (status, options) { @@ -124,6 +98,20 @@ var newTrackers = []; var addresses = {}; + if (!this.can_get_trackers_info) { + status['trackers'] = [ + { + 'url': status['tracker_host'], + 'message': '' + } + ]; + var tracker_host = status['tracker_host']; + status['trackers_status'] = { + tracker_host: status['tracker_status'] + }; + status['trackers_peers'] = {}; + }; + // Go through the trackers updating and creating tracker records Ext.each( status.trackers, @@ -175,25 +163,5 @@ if (!sortState) return; store.sort(sortState.field, sortState.direction); }, - - onPeersSourceRequestComplete: function (status, options) { - if (!status) return; - - var store = this.getStore(); - Ext.each(status.peers_source, function (source) { - var record = store.getById(source.name); - var source_data = { - status: source.enabled ? 'Working' : 'Disabled', - peers: source.count, - }; - record.beginEdit(); - for (var k in source_data) { - if (record.get(k) != source_data[k]) { - record.set(k, source_data[k]); - } - } - record.endEdit(); - }); - }, }); })();