+ */
+ Trackers: ['trackers', 'trackers_status', 'trackers_peers'],
+
+ /**
+ * Keys used in the trackers tab of the statistics panel for Deluge version <2.1.1.
+ *
['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 f7edc84b19..1b3c10a527 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',
@@ -223,6 +224,11 @@ deluge.ui = {
this.running = setTimeout(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,
@@ -234,6 +240,7 @@ deluge.ui = {
* @private
*/
onDisconnect: function () {
+ deluge.server_version = '';
this.stop();
},
diff --git a/deluge/ui/web/js/deluge-all/data/TrackerRecord.js b/deluge/ui/web/js/deluge-all/data/TrackerRecord.js
new file mode 100644
index 0000000000..f8d65b97d5
--- /dev/null
+++ b/deluge/ui/web/js/deluge-all/data/TrackerRecord.js
@@ -0,0 +1,40 @@
+/**
+ * Deluge.data.TrackerRecord.js
+ *
+ * Copyright (c) Damien Churchill 2009-2010
+ *
+ * This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
+ * the additional special exception to link portions of this program with the OpenSSL library.
+ * See LICENSE for more details.
+ */
+Ext.namespace('Deluge.data');
+
+/**
+ * Deluge.data.Tracker record
+ *
+ * @author Damien Churchill
+ * @version 1.3
+ *
+ * @class Deluge.data.Tracker
+ * @extends Ext.data.Record
+ * @constructor
+ * @param {Object} data The tracker data
+ */
+Deluge.data.Tracker = Ext.data.Record.create([
+ {
+ name: 'tracker',
+ type: 'string',
+ },
+ {
+ name: 'status',
+ type: 'string',
+ },
+ {
+ name: 'peers',
+ type: 'int',
+ },
+ {
+ name: 'message',
+ type: 'string',
+ },
+]);
diff --git a/deluge/ui/web/js/deluge-all/details/DetailsPanel.js b/deluge/ui/web/js/deluge-all/details/DetailsPanel.js
index 3f28b2576c..9a32e32fcc 100644
--- a/deluge/ui/web/js/deluge-all/details/DetailsPanel.js
+++ b/deluge/ui/web/js/deluge-all/details/DetailsPanel.js
@@ -21,6 +21,7 @@ Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
this.add(new Deluge.details.StatusTab());
this.add(new Deluge.details.DetailsTab());
this.add(new Deluge.details.FilesTab());
+ this.add(new Deluge.details.TrackersTab());
this.add(new Deluge.details.PeersTab());
this.add(new Deluge.details.OptionsTab());
},
diff --git a/deluge/ui/web/js/deluge-all/details/TrackersTab.js b/deluge/ui/web/js/deluge-all/details/TrackersTab.js
new file mode 100644
index 0000000000..0f137574d8
--- /dev/null
+++ b/deluge/ui/web/js/deluge-all/details/TrackersTab.js
@@ -0,0 +1,174 @@
+/**
+ * Deluge.details.TrackersTab.js
+ *
+ * Copyright (c) Damien Churchill 2009-2010
+ *
+ * This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
+ * the additional special exception to link portions of this program with the OpenSSL library.
+ * See LICENSE for more details.
+ */
+
+(function () {
+ Deluge.details.TrackersTab = Ext.extend(Ext.grid.GridPanel, {
+ // fast way to figure out if we have a tracker already.
+ trackers: {},
+ can_get_trackers_info: false,
+
+ constructor: function (config) {
+ config = Ext.apply(
+ {
+ title: _('Trackers'),
+ cls: 'x-deluge-trackers',
+ store: new Ext.data.Store({
+ reader: new Ext.data.JsonReader(
+ {
+ idProperty: 'ip',
+ root: 'peers',
+ },
+ Deluge.data.Tracker
+ ),
+ }),
+ columns: [
+ {
+ header: _('Tracker'),
+ width: 300,
+ sortable: true,
+ renderer: 'htmlEncode',
+ dataIndex: 'tracker',
+ },
+ {
+ header: _('Status'),
+ width: 150,
+ sortable: true,
+ renderer: 'htmlEncode',
+ dataIndex: 'status',
+ },
+ {
+ header: _('Peers'),
+ width: 100,
+ sortable: true,
+ renderer: 'htmlEncode',
+ dataIndex: 'peers',
+ },
+ {
+ header: _('Message'),
+ width: 100,
+ renderer: 'htmlEncode',
+ dataIndex: 'message',
+ },
+ ],
+ stripeRows: true,
+ deferredRender: false,
+ autoScroll: true,
+ },
+ config
+ );
+ Deluge.details.TrackersTab.superclass.constructor.call(
+ this,
+ config
+ );
+ },
+
+ clear: function () {
+ this.getStore().removeAll();
+ 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, trackers_keys, {
+ success: this.onTrackersRequestComplete,
+ scope: this,
+ });
+ },
+
+ onTrackersRequestComplete: function (status, options) {
+ if (!status) return;
+
+ var store = this.getStore();
+ 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: status['tracker_status'],
+ message: '',
+ },
+ };
+ status['trackers_peers'] = {};
+ }
+
+ // Go through the trackers updating and creating tracker records
+ Ext.each(
+ status.trackers,
+ function (tracker) {
+ var url = tracker.url;
+ var tracker_status =
+ url in status.trackers_status
+ ? status.trackers_status[url]
+ : {};
+ var message = tracker.message ? tracker.message : '';
+ if (!message && 'message' in tracker_status) {
+ message = tracker_status['message'];
+ }
+ var tracker_data = {
+ tracker: url,
+ status:
+ 'status' in tracker_status
+ ? tracker_status['status']
+ : '',
+ peers:
+ url in status.trackers_peers
+ ? status.trackers_peers[url]
+ : 0,
+ message: message,
+ };
+ if (this.trackers[tracker.url]) {
+ var record = store.getById(tracker.url);
+ record.beginEdit();
+ for (var k in tracker_data) {
+ if (record.get(k) != tracker_data[k]) {
+ record.set(k, tracker_data[k]);
+ }
+ }
+ record.endEdit();
+ } else {
+ this.trackers[tracker.url] = 1;
+ newTrackers.push(
+ new Deluge.data.Tracker(tracker_data, tracker.url)
+ );
+ }
+ addresses[tracker.url] = 1;
+ },
+ this
+ );
+ store.add(newTrackers);
+
+ // Remove any trackers that should not be left in the store.
+ store.each(function (record) {
+ if (!addresses[record.id] && !this.constantRows[record.id]) {
+ store.remove(record);
+ delete this.trackers[record.id];
+ }
+ }, this);
+ store.commitChanges();
+
+ var sortState = store.getSortState();
+ if (!sortState) return;
+ store.sort(sortState.field, sortState.direction);
+ },
+ });
+})();