{% extends "aggregator/base.html" %}

{% load humanize %}

{% block content %}

<div class="page-header">
  <h1>Domains</h1>
</div>

<p>We track health of {{ services_count|intcomma }} remote map services, containing a total of {{ layers_count|intcomma }} layers.</p>

<div class="row">
  <div class="col-md-12">
    <table class="table table-striped" id="report">
      <thead>
        <tr>
          <th>Domain</th>
          <th>Layers Count</th>
          <th>Services Count</th>
        </tr>
      <tbody>
      </tbody>
    </table>
  </div>
</div>


<script>

var json_data = '{{ data|safe }}';
var obj = JSON.parse(json_data)['facet_counts']['facet_pivot']['domain_name,service_id'];
for(var i=0, l1=obj.length; i<l1; i++){
  var domain = obj[i]
  console.log(domain);
  tr = $('<tr/>');
  tr.append("<td>" + domain.value + "</td>");
  tr.append("<td><a href='/?q=" + domain.value + "'>" + domain.count + "</a></td>");
  tr.append("<td><a href='/?q=" + domain.value + "'>" + domain.pivot.length + "</td>");
  $('#report').append(tr);
}

</script>

{% endblock %}
