From 3cfeb8a2ef706920db3c999788c9fa4fc786f0e5 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Fri, 20 Feb 2009 21:57:31 +0000 Subject: [PATCH] rename tab_statistics to tab_status update status when a torrent is selected in the grid tweak status css --- deluge/ui/web/css/deluge.css | 4 ++ deluge/ui/web/js/deluge-details.js | 58 +++++++++++++++++-- deluge/ui/web/js/deluge.js | 4 +- .../{tab_statistics.html => tab_status.html} | 0 4 files changed, 58 insertions(+), 8 deletions(-) rename deluge/ui/web/render/{tab_statistics.html => tab_status.html} (100%) diff --git a/deluge/ui/web/css/deluge.css b/deluge/ui/web/css/deluge.css index dad5b6b90..7b1bea492 100644 --- a/deluge/ui/web/css/deluge.css +++ b/deluge/ui/web/css/deluge.css @@ -57,6 +57,10 @@ html, body { 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 { margin-left: 75px; } diff --git a/deluge/ui/web/js/deluge-details.js b/deluge/ui/web/js/deluge-details.js index aa7c775e4..b6aebaa51 100644 --- a/deluge/ui/web/js/deluge-details.js +++ b/deluge/ui/web/js/deluge-details.js @@ -1,11 +1,18 @@ 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 = { onRender: function(panel) { this.panel = panel; this.progressBar = new Ext.ProgressBar({ - text: "0% Stopped", - id: "pbar-status", + text: '0% Stopped', + id: 'pbar-status', cls: 'deluge-status-progressbar' }); this.panel.add(this.progressBar); @@ -21,20 +28,59 @@ Deluge.Details.Status = { onStatusRender: function(panel) { this.status = panel; this.status.load({ - url: "/render/tab_statistics.html", - text: _("Loading") + "..." + url: '/render/tab_status.html', + 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) { - 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 = { onRender: function(panel) { this.panel = panel.load({ - url: "/render/tab_details.html" + url: '/render/tab_details.html' }); } } diff --git a/deluge/ui/web/js/deluge.js b/deluge/ui/web/js/deluge.js index fbf772aa1..c96ebd344 100644 --- a/deluge/ui/web/js/deluge.js +++ b/deluge/ui/web/js/deluge.js @@ -97,7 +97,7 @@ Deluge.Keys = { 'upload_payload_rate', 'eta', 'ratio', 'distributed_copies', 'is_auto_managed' ], - Statistics: [ + Status: [ 'total_done', 'total_payload_download', 'total_uploaded', 'total_payload_upload', 'next_announce', 'tracker_status', 'num_pieces', 'piece_length', 'is_auto_managed', 'active_time', 'seeding_time', @@ -119,4 +119,4 @@ Deluge.Keys = { 'remove_at_ratio', 'private', 'prioritize_first_last' ] }; -Deluge.Keys.Statistics.extend(Deluge.Keys.Grid); \ No newline at end of file +Deluge.Keys.Status.extend(Deluge.Keys.Grid); \ No newline at end of file diff --git a/deluge/ui/web/render/tab_statistics.html b/deluge/ui/web/render/tab_status.html similarity index 100% rename from deluge/ui/web/render/tab_statistics.html rename to deluge/ui/web/render/tab_status.html