{% extends 'generic/_base.html' %}
{% load buttons %}
{% load helpers %}
{% load i18n %}
{% load render_table from django_tables2 %}

{% block title %}{% trans "System" %}{% endblock %}

{% block controls %}
  <a href="?export=true" class="btn btn-purple">
    <i class="mdi mdi-download"></i> {% trans "Export" %}
  </a>
{% endblock controls %}

{% block tabs %}
  <ul class="nav nav-tabs px-3">
    <li class="nav-item" role="presentation">
      <a class="nav-link active" role="tab">{% trans "Status" %}</a>
    </li>
  </ul>
{% endblock tabs %}

{% block content %}
  {# System status #}
  <div class="row mb-3">
    <div class="col">
      <div class="card">
        <h2 class="card-header">{% trans "System Status" %}</h2>
        <table class="table table-hover attr-table">
          <tr>
            <th scope="row">{% trans "NetBox release" %}</th>
            <td>
              {{ stats.netbox_release.name }}
              {% if stats.netbox_release.published %}
               ({{ stats.netbox_release.published|isodate }})
              {% endif %}
            </td>
          </tr>
          <tr>
            <th scope="row">{% trans "Python version" %}</th>
            <td>{{ stats.python_version }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Django version" %}</th>
            <td>{{ stats.django_version }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "PostgreSQL version" %}</th>
            <td>{{ stats.postgresql_version }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Database name" %}</th>
            <td>{{ stats.database_name }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Database size" %}</th>
            <td>
              {% if stats.database_size %}
                {{ stats.database_size }}
              {% else %}
                <span class="text-muted">{% trans "Unavailable" %}</span>
              {% endif %}
            </td>
          </tr>
          <tr>
            <th scope="row">{% trans "RQ workers" %}</th>
            <td>
              <a href="{% url 'core:background_queue_list' %}">{{ stats.rq_worker_count }}</a>
              ({% trans "default queue" %})
            </td>
          </tr>
          <tr>
            <th scope="row">{% trans "System time" %}</th>
            <td>{% now 'Y-m-d H:i:s T' %}</td>
          </tr>
        </table>
      </div>
    </div>
  </div>

  {# Configuration #}
  <div class="row mb-3">
    <div class="col col-md-12">
      <div class="card">
        <h2 class="card-header">{% trans "Current Configuration" %}</h2>
        {% include 'core/inc/config_data.html' %}
      </div>
    </div>
  </div>
{% endblock content %}
