From d6e18f7729d2fe71afe765e17ca1fdf5cbef18a1 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Tue, 27 Oct 2009 11:39:53 +0000 Subject: [PATCH] fix displaying the protocol speed in the webui also update the update_ui method in json_api so it gets the status more like how the gtkui does --- deluge/ui/web/js/Deluge.Statusbar.js | 4 ++-- deluge/ui/web/json_api.py | 27 +++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/deluge/ui/web/js/Deluge.Statusbar.js b/deluge/ui/web/js/Deluge.Statusbar.js index 81befe81a..642c875e5 100644 --- a/deluge/ui/web/js/Deluge.Statusbar.js +++ b/deluge/ui/web/js/Deluge.Statusbar.js @@ -120,11 +120,11 @@ updateStat('traffic', { value: { - value: stats.download_rate - stats.payload_download_rate, + value: stats.download_protocol_rate, formatter: Deluge.Formatters.speed }, limit: { - value: stats.upload_rate - stats.payload_upload_rate, + value: stats.upload_protocol_rate, formatter: Deluge.Formatters.speed }, format: '{0}/{1}' diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index af619afd5..20c4bdef5 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -473,11 +473,20 @@ class WebApi(JSONComponent): def got_connections(connections): ui_info["stats"]["num_connections"] = connections + def got_dht_nodes(nodes): + ui_info["stats"]["dht_nodes"] = nodes + def got_stats(stats): - ui_info["stats"].update(stats) + ui_info["stats"]["upload_rate"] = stats["payload_upload_rate"] + ui_info["stats"]["download_rate"] = stats["payload_download_rate"] + ui_info["stats"]["download_protocol_rate"] = stats["download_rate"] - stats["payload_download_rate"] + ui_info["stats"]["upload_protocol_rate"] = stats["upload_rate"] - stats["payload_upload_rate"] def got_filters(filters): ui_info["filters"] = filters + + def got_health(health): + ui_info["stats"]["has_incoming_connections"] = health def got_torrents(torrents): ui_info["torrents"] = torrents @@ -491,14 +500,24 @@ class WebApi(JSONComponent): d2 = client.core.get_filter_tree() d2.addCallback(got_filters) - d3 = client.core.get_session_status(["payload_download_rate", "payload_upload_rate", - "dht_nodes", "has_incoming_connections", "download_rate", "upload_rate"]) + d3 = client.core.get_session_status([ + "payload_download_rate", + "payload_upload_rate", + "download_rate", + "upload_rate" + ]) d3.addCallback(got_stats) d4 = client.core.get_num_connections() d4.addCallback(got_connections) + + d5 = client.core.get_dht_nodes() + d5.addCallback(got_dht_nodes) + + d6 = client.core.get_health() + d6.addCallback(got_health) - dl = DeferredList([d1, d2, d3, d4], consumeErrors=True) + dl = DeferredList([d1, d2, d3, d4, d5, d6], consumeErrors=True) dl.addCallback(on_complete) return d