Changeset View
Changeset View
Standalone View
Standalone View
swh/web/templates/coverage.html
Show All 12 Lines | |||||
<html lang="en"> | <html lang="en"> | ||||
<head> | <head> | ||||
<meta charset="utf-8"> | <meta charset="utf-8"> | ||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||||
<title>Software Heritage archive coverage</title> | <title>Software Heritage archive coverage</title> | ||||
{% render_bundle 'vendors' %} | {% render_bundle 'vendors' %} | ||||
{% render_bundle 'webapp' %} | {% render_bundle 'webapp' %} | ||||
<script src="{% url 'js_reverse' %}" type="text/javascript"></script> | |||||
<base target="_parent"> | <base target="_parent"> | ||||
</head> | </head> | ||||
<body style="padding-bottom: 0;"> | <body style="padding-bottom: 0;"> | ||||
<div class="content-wrapper" style="margin-left: 0;" data-iframe-height> | <div class="content-wrapper" style="margin-left: 0;" data-iframe-height> | ||||
<div class="content"> | <div class="content"> | ||||
<div class="container-fluid"> | <div class="container-fluid"> | ||||
<div class="row"> | <div class="row"> | ||||
{% for provider in providers %} | {% for provider in providers %} | ||||
<div class="col-md-2"> | <div class="col-md-2 swh-coverage-col"> | ||||
<div class="card swh-coverage" title="{{ provider.provider_info }}"> | <div class="card swh-coverage" id="{{ provider.provider_id }}" title="{{ provider.provider_info }}"> | ||||
<a href="{{ provider.provider_url }}"> | <a href="{{ provider.provider_url }}"> | ||||
<img class="card-img-top swh-coverage-logo" src="{% static provider.provider_logo %}"> | <img class="card-img-top swh-coverage-logo" src="{% static provider.provider_logo %}"> | ||||
</a> | </a> | ||||
<div class="text-center swh-coverage-origin-count"></div> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
{% endfor %} | {% endfor %} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</body> | </body> | ||||
{% if count_origins %} | |||||
<script> | |||||
$.ajax({ | |||||
url: Urls.browse_origin_coverage_count(), | |||||
dataType: 'json', | |||||
success: function (data) { | |||||
for (var i = 0 ; i < data.length; ++i) { | |||||
var origin_count = data[i].origin_count; | |||||
var provider_id = data[i].provider_id; | |||||
var origin_types = data[i].origin_types; | |||||
if (origin_count < 0) { | |||||
$('.swh-coverage-origin-count').text(''); | |||||
break; | |||||
} else { | |||||
vlorentz: Why use Javascript to retrieve these counters instead of doing it while rendering the page? | |||||
Done Inline ActionsBecause when count results are not in cache or when the cache expires, the count queries need to be executed again and this can take a couple of minutes. So to avoid having to wait until the queries get executed, display the coverage page and update the count labels anlambert: Because when count results are not in cache or when the cache expires, the count queries need… | |||||
Done Inline Actionsok vlorentz: ok | |||||
var text = origin_count.toLocaleString() + ' ' + origin_types; | |||||
$('#'+provider_id + ' .swh-coverage-origin-count').text(text); | |||||
} | |||||
} | |||||
} | |||||
}); | |||||
</script> | |||||
{% endif %} | |||||
</html> | </html> |
Why use Javascript to retrieve these counters instead of doing it while rendering the page?