{% extends "base.html" %}

{% set active_page = "admin_console" %}

{% block title %}
  <title>
    Admin Console - {{ SITE_NAME }}
  </title>
{% endblock %}

{% block dashboard_stat %}
  <div class="content-header">
    <div class="container-fluid">
      <div class="row mb-2">
        <div class="col-sm-6">
          <h1 class="m-0 text-dark">
            PowerDNS
            <small>Server Statistics & Configuration</small>
          </h1>
        </div>
        <div class="col-sm-6">
          <ol class="breadcrumb float-sm-right">
            <li class="breadcrumb-item"><a href="{{ url_for('dashboard.dashboard') }}">Dashboard</a></li>
            <li class="breadcrumb-item active">PowerDNS Server Statistics & Configuration</li>
          </ol>
        </div>
      </div>
    </div>
  </div>
{% endblock %}

{% block content %}
  <section class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-12">
          <div class="card shadow">
            <div class="card-header">
              <h3 class="card-title">PowerDNS Server Statistics</h3>
            </div>
            <div class="card-body">
              <table id="tbl_statistics" class="table table-bordered table-striped">
                <thead>
                  <tr>
                    <th width="30%">Statistic</th>
                    <th>Value</th>
                  </tr>
                </thead>
                <tbody>
                  {% for statistic in statistics %}
                    <tr class="odd gradeX">
                      <td>
                        <a href="https://doc.powerdns.com/authoritative/search.html?q={{ statistic['name'] }}"
                        target="_blank" class="btn btn-primary">
                          <i class="fa fa-search"></i>&nbsp;{{ statistic['name'] }}
                        </a>
                      </td>
                      <td>{{ statistic['value'] }}</td>
                    </tr>
                  {% endfor %}
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-12">
          <div class="card shadow">
            <div class="card-header">
              <h3 class="card-title">PowerDNS Server Configuration</h3>
            </div>
            <div class="card-body">
              <table id="tbl_configuration" class="table table-bordered table-striped">
                <thead>
                  <tr>
                    <th width="30%">Configuration</th>
                    <th>Value</th>
                  </tr>
                </thead>
                <tbody>
                  {% for config in configs %}
                    <tr class="odd gradeX">
                      <td>
                        <a href="https://doc.powerdns.com/authoritative/search.html?q={{ config['name'] }}"
                        target="_blank" class="btn btn-primary">
                          <i class="fa-solid fa-search"></i>&nbsp;{{ config['name'] }}
                        </a>
                      </td>
                      <td>
                        {{ config['value'] }}
                      </td>
                    </tr>
                  {% endfor %}
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
{% endblock %}

{% block extrascripts %}
<script>
  // set up statistics data table
  $("#tbl_statistics").DataTable({
    "paging": true,
    "lengthChange": true,
    "searching": true,
    "ordering": true,
    "info": true,
    "autoWidth": false
  });

  // set up configuration data table
  $("#tbl_configuration").DataTable({
    "paging": true,
    "lengthChange": true,
    "searching": true,
    "ordering": true,
    "info": true,
    "autoWidth": false
  });
</script>
{% endblock %}