mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-19 22:58:30 +00:00
improve the torrents grid, updating existing entries rather than just
reloading the whole grid
This commit is contained in:
parent
7b72d79d32
commit
78b5c06776
@ -72,7 +72,8 @@ Copyright:
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @param {Object} config Configuration options
|
* @param {Object} config Configuration options
|
||||||
*/
|
*/
|
||||||
Ext.deluge.TorrentGrid = function(config) {
|
Ext.deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, {
|
||||||
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
id: 'torrentGrid',
|
id: 'torrentGrid',
|
||||||
store: new Ext.data.SimpleStore({
|
store: new Ext.data.SimpleStore({
|
||||||
@ -186,9 +187,8 @@ Copyright:
|
|||||||
margins: '5 5 0 0'
|
margins: '5 5 0 0'
|
||||||
}, config);
|
}, config);
|
||||||
Ext.deluge.TorrentGrid.superclass.constructor.call(this, config);
|
Ext.deluge.TorrentGrid.superclass.constructor.call(this, config);
|
||||||
}
|
},
|
||||||
|
|
||||||
Ext.extend(Ext.deluge.TorrentGrid, Ext.grid.GridPanel, {
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Ext.deluge.TorrentGrid.superclass.initComponent.call(this);
|
Ext.deluge.TorrentGrid.superclass.initComponent.call(this);
|
||||||
Deluge.Events.on('torrentRemoved', this.onTorrentRemoved, this);
|
Deluge.Events.on('torrentRemoved', this.onTorrentRemoved, this);
|
||||||
@ -220,6 +220,56 @@ Copyright:
|
|||||||
return this.getSelectionModel().getSelections();
|
return this.getSelectionModel().getSelections();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
update: function(torrents) {
|
||||||
|
//var torrents = [];
|
||||||
|
var store = this.getStore();
|
||||||
|
for (var torrentId in torrents) {
|
||||||
|
var record = store.getById(torrentId);
|
||||||
|
var torrent = torrents[torrentId];
|
||||||
|
if (!record) {
|
||||||
|
// We need to create a new record
|
||||||
|
var data = [
|
||||||
|
torrent.queue,
|
||||||
|
torrent.name,
|
||||||
|
torrent.total_size,
|
||||||
|
torrent.state,
|
||||||
|
torrent.progress,
|
||||||
|
torrent.num_seeds,
|
||||||
|
torrent.total_seeds,
|
||||||
|
torrent.num_peers,
|
||||||
|
torrent.total_peers,
|
||||||
|
torrent.download_payload_rate,
|
||||||
|
torrent.upload_payload_rate,
|
||||||
|
torrent.eta,
|
||||||
|
torrent.ratio,
|
||||||
|
torrent.distributed_copies,
|
||||||
|
torrent.time_added,
|
||||||
|
torrent.tracker_host,
|
||||||
|
torrentId
|
||||||
|
];
|
||||||
|
store.loadData([data], true);
|
||||||
|
} else {
|
||||||
|
// We just need to do an update
|
||||||
|
record.set('queue', torrent.queue);
|
||||||
|
record.set('name', torrent.name);
|
||||||
|
record.set('size', torrent.total_size);
|
||||||
|
record.set('state', torrent.state);
|
||||||
|
record.set('progress', torrent.progress);
|
||||||
|
record.set('seeds', torrent.num_seeds);
|
||||||
|
record.set('total_seeds', torrent.total_seeds);
|
||||||
|
record.set('peers', torrent.num_peers);
|
||||||
|
record.set('total_peers', torrent.total_peers);
|
||||||
|
record.set('downspeed', torrent.download_payload_rate);
|
||||||
|
record.set('upspeed', torrent.upload_payload_rate);
|
||||||
|
record.set('eta', torrent.eta);
|
||||||
|
record.set('ratio', torrent.ratio);
|
||||||
|
record.set('avail', torrent.distributed_copies);
|
||||||
|
record.set('added', torrent.time_added);
|
||||||
|
record.set('tracker', torrent.tracker_host);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onTorrentRemoved: function(torrentIds) {
|
onTorrentRemoved: function(torrentIds) {
|
||||||
var selModel = this.getSelectionModel();
|
var selModel = this.getSelectionModel();
|
||||||
|
@ -93,29 +93,7 @@ Deluge.UI = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onUpdate: function(data) {
|
onUpdate: function(data) {
|
||||||
var torrents = [];
|
Deluge.Torrents.update(data['torrents']);
|
||||||
for (var torrentId in data['torrents']) {
|
|
||||||
var torrent = data['torrents'][torrentId];
|
|
||||||
torrents.push([torrent.queue,
|
|
||||||
torrent.name,
|
|
||||||
torrent.total_size,
|
|
||||||
torrent.state,
|
|
||||||
torrent.progress,
|
|
||||||
torrent.num_seeds,
|
|
||||||
torrent.total_seeds,
|
|
||||||
torrent.num_peers,
|
|
||||||
torrent.total_peers,
|
|
||||||
torrent.download_payload_rate,
|
|
||||||
torrent.upload_payload_rate,
|
|
||||||
torrent.eta,
|
|
||||||
torrent.ratio,
|
|
||||||
torrent.distributed_copies,
|
|
||||||
torrent.time_added,
|
|
||||||
torrent.tracker_host,
|
|
||||||
torrentId
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
Deluge.Torrents.getStore().loadData(torrents);
|
|
||||||
Deluge.Statusbar.update(data['stats']);
|
Deluge.Statusbar.update(data['stats']);
|
||||||
Deluge.Sidebar.update(data['filters']);
|
Deluge.Sidebar.update(data['filters']);
|
||||||
this.errorCount = 0;
|
this.errorCount = 0;
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user