{% extends "admin/change_list.html" %}
{% load i18n admin_urls admin_static admin_list %}

{% block extrastyle %}
  {{ block.super }}
  <link rel="stylesheet" type="text/css" href="{% static "admin/css/d3-tip.css" %}" />
  <link rel="stylesheet" type="text/css" href="{% static "admin/css/main.css" %}" />
{% endblock %}

{% block pretitle %}
  <div style="overflow: hidden; width: 100%">
    <div id="world-map" class="stats-widget" style="width: 700px; height: 475px;"></div>
    <div id="devices-stats" class="stats-widget"></div>
    <div id="requests-graph" class="graph-widget"></div>
  </div>
{% endblock %}

{% block result_list %}
  {# Countries statistics #}
  {% if countries_count %}
    <script>
      var countries = {{ countries_count|safe }};
    </script>
    <script src="{% static 'admin/js/world_map.js' %}"></script>
  {% endif %}

  {# Devices statistics #}
  {% if devices_count %}
    <script>
      var devices = '{{ devices_count|safe }}';
    </script>
    <script src="{% static 'admin/js/devices_stats.js' %}"></script>
  {% endif %}

  <script>
    var requests = '{{ requests_count|safe }}';
  </script>
  <script src="{% static 'admin/js/requests_graph.js' %}"></script>

  {{ block.super }}
{% endblock %}