From e4e88638b68ca34cc15ea5551f0e8a1a4c2e03d5 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 14 Apr 2013 14:01:52 -0500 Subject: Turn visualize-mirror into a CSS class --- templates/mirrors/mirror_details.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates/mirrors') diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html index 02d68a3a..ee60157b 100644 --- a/templates/mirrors/mirror_details.html +++ b/templates/mirrors/mirror_details.html @@ -109,7 +109,7 @@

Available URLs

Mirror Status Chart

-
+
{% load cdn %}{% jquery %}{% jquery_tablesorter %} -- cgit v1.2.3-54-g00ecf From 9b07cb1ebdc8c5cc5dff66a7edb02e0ddc9f4733 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 14 Apr 2013 15:08:25 -0500 Subject: Draw one mirror status graph per check location Rather than lump it all together and have odd spikes depending on which side of the Atlantic checked a mirror in a given timeslot, draw a chart per check location. Signed-off-by: Dan McGee --- mirrors/static/mirror_status.js | 68 +++++++++++++++++++++++++---------- mirrors/views.py | 3 +- templates/mirrors/mirror_details.html | 12 +++++-- 3 files changed, 60 insertions(+), 23 deletions(-) (limited to 'templates/mirrors') diff --git a/mirrors/static/mirror_status.js b/mirrors/static/mirror_status.js index 8ec85c40..4a57128a 100644 --- a/mirrors/static/mirror_status.js +++ b/mirrors/static/mirror_status.js @@ -1,7 +1,16 @@ -function mirror_status(chart_id, data_url) { - var jq_div = jQuery(chart_id); +function draw_graphs(location_url, log_url, container_id) { + $.when($.getJSON(location_url), $.getJSON(log_url)) + .then(function(loc_data, log_data) { + $.each(loc_data[0].locations, function(i, val) { + mirror_status(container_id, val, log_data[0]); + }); + }); +} - var draw_graph = function(data) { +function mirror_status(container_id, check_loc, log_data) { + + var draw_graph = function(chart_id, data) { + var jq_div = jQuery(chart_id); var margin = {top: 20, right: 20, bottom: 30, left: 40}, width = jq_div.width() - margin.left - margin.right, height = jq_div.height() - margin.top - margin.bottom; @@ -106,31 +115,52 @@ function mirror_status(chart_id, data_url) { .text(function(d) { return d; }); }; - /* invoke the data-fetch + first draw */ - var cached_data = null; - d3.json(data_url, function(json) { - cached_data = jQuery.map(json.urls, function(url, i) { + var filter_data = function(json, location_id) { + return jQuery.map(json.urls, function(url, i) { + var logs = jQuery.map(url.logs, function(log, j) { + if (!log.is_success) { + return null; + } + /* screen by location ID if we were given one */ + if (location_id && log.location_id !== location_id) { + return null; + } + return { + duration: log.duration, + check_time: new Date(log.check_time) + }; + }); + /* don't return URLs without any log info */ + if (logs.length === 0) { + return null; + } return { url: url.url, - logs: jQuery.map(url.logs, function(log, j) { - if (!log.is_success) { - return null; - } - return { - duration: log.duration, - check_time: new Date(log.check_time) - }; - }) + logs: logs }; }); - draw_graph(cached_data); - }); + }; + + var cached_data = filter_data(log_data, check_loc.id); + /* we had a check location with no log data handed to us, skip graphing */ + if (cached_data.length === 0) { + return; + } + + /* create the containers, defer the actual graph drawing */ + var chart_id = 'status-chart-' + check_loc.id; + $(container_id).append('

' + check_loc.country + ' (' + check_loc.source_ip + '), IPv' + check_loc.ip_version + '

'); + $(container_id).append('
'); + $(container_id).append('
'); + setTimeout(function() { + draw_graph('#' + chart_id, cached_data); + }, 0); /* then hook up a resize handler to redraw if necessary */ var resize_timeout = null; var real_resize = function() { resize_timeout = null; - draw_graph(cached_data); + draw_graph('#' + chart_id, cached_data); }; jQuery(window).resize(function() { if (resize_timeout) { diff --git a/mirrors/views.py b/mirrors/views.py index 30f96b63..9311fb8f 100644 --- a/mirrors/views.py +++ b/mirrors/views.py @@ -304,6 +304,7 @@ def default(self, obj): return list(obj) if isinstance(obj, CheckLocation): return { + 'id': obj.pk, 'hostname': obj.hostname, 'source_ip': obj.source_ip, 'country': unicode(obj.country.name), @@ -316,7 +317,7 @@ def default(self, obj): def locations_json(request): data = {} data['version'] = 1 - data['locations'] = CheckLocation.objects.all() + data['locations'] = CheckLocation.objects.all().order_by('pk') to_json = json.dumps(data, ensure_ascii=False, cls=LocationJSONEncoder) response = HttpResponse(to_json, content_type='application/json') return response diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html index ee60157b..1c9a970e 100644 --- a/templates/mirrors/mirror_details.html +++ b/templates/mirrors/mirror_details.html @@ -106,10 +106,16 @@

Available URLs

{% endfor %} + + +
+

Mirror Status Charts

-

Mirror Status Chart

+

Periodic checks of the mirrors are done from various geographic + locations, IP addresses, and using IPv4 or IPv6. These results are + summarized in graphical form below.

-
+
{% load cdn %}{% jquery %}{% jquery_tablesorter %} @@ -122,7 +128,7 @@

Mirror Status Chart

headers: { 8: { sorter: 'mostlydigit' }, 9: { sorter: 'mostlydigit' }, 10: { sorter: 'mostlydigit' } } }); }); $(document).ready(function() { - mirror_status("#visualize-mirror", "./json/"); + draw_graphs("/mirrors/locations/json/", "./json/", "#charts-container"); }); {% endblock %} -- cgit v1.2.3-54-g00ecf From b519c40e0af5b86ba660cf9d9cfc53a66fd8bef8 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 20 Apr 2013 11:11:04 -0500 Subject: Remove {% spaceless %} tag from a few more places This tag is simply not worth the time it takes to do what it does. Signed-off-by: Dan McGee --- templates/mirrors/status.html | 6 ++---- templates/mirrors/status_table.html | 6 ++---- templates/packages/search.html | 6 ++---- templates/packages/signoffs.html | 8 ++------ 4 files changed, 8 insertions(+), 18 deletions(-) (limited to 'templates/mirrors') diff --git a/templates/mirrors/status.html b/templates/mirrors/status.html index 8d32d3fa..26e81e79 100644 --- a/templates/mirrors/status.html +++ b/templates/mirrors/status.html @@ -87,16 +87,14 @@

Mirror Syncing Error Log

- {% for log in error_logs %} - {% spaceless %} + {% for log in error_logs %} {{ log.url__url }} {{ log.url__protocol__protocol }} {% country_flag log.country %}{{ log.country.name }} {{ log.error|linebreaksbr }} {{ log.last_occurred|date:'Y-m-d H:i' }} {{ log.error_count }} - - {% endspaceless %}{% endfor %} + {% endfor %} diff --git a/templates/mirrors/status_table.html b/templates/mirrors/status_table.html index 2dd7ef49..e848a9c9 100644 --- a/templates/mirrors/status_table.html +++ b/templates/mirrors/status_table.html @@ -14,8 +14,7 @@ - {% for m_url in urls %} - {% spaceless %} + {% for m_url in urls %} {{ m_url.url }} {{ m_url.protocol }} {% country_flag m_url.country %}{{ m_url.country.name }} @@ -24,7 +23,6 @@ {{ m_url.duration_avg|floatformat:2 }} {{ m_url.duration_stddev|floatformat:2 }} {{ m_url.score|floatformat:1|default:'∞' }} - - {% endspaceless %}{% endfor %} + {% endfor %} diff --git a/templates/packages/search.html b/templates/packages/search.html index bf1eecd9..f50bc8be 100644 --- a/templates/packages/search.html +++ b/templates/packages/search.html @@ -69,8 +69,7 @@

Package Search

- {% for pkg in package_list %} - {% spaceless %} + {% for pkg in package_list %} {% if perms.main.change_package %} {% endif %} @@ -85,8 +84,7 @@

Package Search

{{ pkg.pkgdesc }} {{ pkg.last_update|date }} {{ pkg.flag_date|date }} - - {% endspaceless %}{% endfor %} + {% endfor %} {% include "packages/search_paginator.html" %} diff --git a/templates/packages/signoffs.html b/templates/packages/signoffs.html index 20371f95..2879c30b 100644 --- a/templates/packages/signoffs.html +++ b/templates/packages/signoffs.html @@ -50,9 +50,7 @@

Filter Displayed Signoffs

- {% for group in signoff_groups %} - - {% spaceless %} + {% for group in signoff_groups %} {% pkg_details_link group.package %} {{ group.version }} {{ group.arch.name }} {{ group.target_repo }} @@ -75,9 +73,7 @@

Filter Displayed Signoffs

{% endcomment %}{% if spec.known_bad %}Package is known to be bad
{% endif %}{% comment %} {% endcomment %}{{ spec.comments|default:""|linebreaksbr }} {% endwith %}{% endif %} - {% endspaceless %} - - {% endfor %} + {% endfor %} -- cgit v1.2.3-54-g00ecf From 3e085183bf39c59fdcd0b9e67b5a02653a51d30e Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 20 Apr 2013 11:28:12 -0500 Subject: Move all script blocks into {% script_block %} section I added this a while back, but didn't roll it out to all templates. Signed-off-by: Dan McGee --- templates/devel/clock.html | 3 +++ templates/devel/index.html | 2 ++ templates/devel/packages.html | 3 +++ templates/devel/profile.html | 2 ++ templates/mirrors/mirror_details.html | 3 +++ templates/mirrors/status.html | 3 +++ templates/packages/details.html | 2 ++ templates/packages/differences.html | 2 ++ templates/packages/groups.html | 3 +++ templates/packages/packages_list.html | 3 +++ templates/packages/signoffs.html | 3 +++ templates/packages/stale_relations.html | 3 +++ templates/public/keys.html | 2 ++ templates/registration/login.html | 2 ++ templates/releng/iso_overview.html | 3 +++ templates/releng/release_list.html | 2 ++ templates/releng/result_list.html | 3 +++ templates/todolists/list.html | 3 +++ templates/todolists/view.html | 3 +++ templates/visualize/index.html | 2 ++ 20 files changed, 52 insertions(+) (limited to 'templates/mirrors') diff --git a/templates/devel/clock.html b/templates/devel/clock.html index 83fbb70b..2c5bfacf 100644 --- a/templates/devel/clock.html +++ b/templates/devel/clock.html @@ -56,6 +56,9 @@

Developer World Clocks

+{% endblock %} + +{% block script_block %} {% load cdn %}{% jquery %}{% jquery_tablesorter %} diff --git a/templates/mirrors/status.html b/templates/mirrors/status.html index 26e81e79..283ff681 100644 --- a/templates/mirrors/status.html +++ b/templates/mirrors/status.html @@ -99,6 +99,9 @@

Mirror Syncing Error Log

+{% endblock %} + +{% block script_block %} {% load cdn %}{% jquery %}{% jquery_tablesorter %} diff --git a/templates/registration/login.html b/templates/registration/login.html index edbb77ea..82f74f58 100644 --- a/templates/registration/login.html +++ b/templates/registration/login.html @@ -21,7 +21,9 @@

Developer Login

+{% endblock %} +{% block script_block %} {% load cdn %}{% jquery %} -- cgit v1.2.3-54-g00ecf