rename tab_statistics to tab_status

update status when a torrent is selected in the grid
tweak status css
This commit is contained in:
Damien Churchill 2009-02-20 21:57:31 +00:00
parent 4f9e627131
commit 3cfeb8a2ef
4 changed files with 58 additions and 8 deletions

View File

@ -57,6 +57,10 @@ html, body {
height: 19px; height: 19px;
} }
.deluge-status dd.downloaded, .deluge-status dd.uploaded, .deluge-status dd.share, .deluge-status dd.announce, .deluge-status dd.tracker_status, .deluge-status dd.active_time {
width: 170px;
}
.deluge-status dd.downspeed, .deluge-status dd.upspeed, .deluge-status dd.eta, .deluge-status dd.pieces { .deluge-status dd.downspeed, .deluge-status dd.upspeed, .deluge-status dd.eta, .deluge-status dd.pieces {
margin-left: 75px; margin-left: 75px;
} }

View File

@ -1,11 +1,18 @@
Deluge.Details = {} Deluge.Details = {}
/*Deluge.ProgressBar = Ext.extend(Ext.ProgressBar, {
initComponent: function() {
Deluge.ProgressBar.superClass.initComponent.call(this);
}
});
Ext.reg('deluge-progress', Deluge.ProgressBar);*/
Deluge.Details.Status = { Deluge.Details.Status = {
onRender: function(panel) { onRender: function(panel) {
this.panel = panel; this.panel = panel;
this.progressBar = new Ext.ProgressBar({ this.progressBar = new Ext.ProgressBar({
text: "0% Stopped", text: '0% Stopped',
id: "pbar-status", id: 'pbar-status',
cls: 'deluge-status-progressbar' cls: 'deluge-status-progressbar'
}); });
this.panel.add(this.progressBar); this.panel.add(this.progressBar);
@ -21,20 +28,59 @@ Deluge.Details.Status = {
onStatusRender: function(panel) { onStatusRender: function(panel) {
this.status = panel; this.status = panel;
this.status.load({ this.status.load({
url: "/render/tab_statistics.html", url: '/render/tab_status.html',
text: _("Loading") + "..." text: _('Loading') + '...'
}); });
}, },
onRequestComplete: function(status) {
var fsize = Deluge.Formatters.size, ftime = Deluge.Formatters.timeRemaining, fspeed = Deluge.Formatters.speed;
var data = {
downloaded: fsize(status.total_done) + ' (' + fsize(status.total_payload_download) + ')',
uploaded: fsize(status.total_uploaded) + ' (' + fsize(status.total_payload_upload) + ')',
share: status.ratio.toFixed(3),
announce: ftime(status.next_announce),
tracker_status: status.tracker_status,
downspeed: fspeed(status.download_payload_rate),
upspeed: fspeed(status.upload_payload_rate),
eta: ftime(status.eta),
pieces: status.num_pieces + ' (' + fsize(status.piece_length) + ')',
seeders: status.num_seeds + ' (' + status.total_seeds + ')',
peers: status.num_peers + ' (' + status.total_peers + ')',
avail: status.distributed_copies.toFixed(3),
active_time: ftime(status.active_time),
seeding_time: ftime(status.seeding_time),
seed_rank: status.seed_rank,
auto_managed: 'False'
}
if (status.is_auto_managed) {data.auto_managed = 'True'}
this.fields.each(function(value, key) {
value.set('text', data[key]);
}, this);
var text = status.state + ' ' + status.progress.toFixed(2) + '%';
this.progressBar.updateProgress(status.progress, text);
},
getFields: function() {
var panel = this.panel.items.get('status-details');
this.fields = new Hash();
panel.body.dom.getElements('dd').each(function(item) {
this.fields[item.getProperty('class')] = item;
}, this);
},
update: function(torrentId) { update: function(torrentId) {
alert(torrentId); if (!this.fields) this.getFields();
Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Status, {
onSuccess: this.onRequestComplete.bind(this)
});
} }
} }
Deluge.Details.Details = { Deluge.Details.Details = {
onRender: function(panel) { onRender: function(panel) {
this.panel = panel.load({ this.panel = panel.load({
url: "/render/tab_details.html" url: '/render/tab_details.html'
}); });
} }
} }

View File

@ -97,7 +97,7 @@ Deluge.Keys = {
'upload_payload_rate', 'eta', 'ratio', 'distributed_copies', 'upload_payload_rate', 'eta', 'ratio', 'distributed_copies',
'is_auto_managed' 'is_auto_managed'
], ],
Statistics: [ Status: [
'total_done', 'total_payload_download', 'total_uploaded', 'total_done', 'total_payload_download', 'total_uploaded',
'total_payload_upload', 'next_announce', 'tracker_status', 'num_pieces', 'total_payload_upload', 'next_announce', 'tracker_status', 'num_pieces',
'piece_length', 'is_auto_managed', 'active_time', 'seeding_time', 'piece_length', 'is_auto_managed', 'active_time', 'seeding_time',
@ -119,4 +119,4 @@ Deluge.Keys = {
'remove_at_ratio', 'private', 'prioritize_first_last' 'remove_at_ratio', 'private', 'prioritize_first_last'
] ]
}; };
Deluge.Keys.Statistics.extend(Deluge.Keys.Grid); Deluge.Keys.Status.extend(Deluge.Keys.Grid);