{% extends 'base.twig' %}

{% block content %}
<ul class="nav nav-tabs" role="tablist">
  <li role="presentation" class="nav-item"><button class="nav-link active" data-bs-target="#tab-containers" aria-controls="tab-containers" role="tab" data-bs-toggle="tab">{{ lang.debug.system_containers }}</button></li>
  <li class="nav-item dropdown">
    <a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#">{{ lang.debug.logs }}</a>
    <ul class="dropdown-menu">
      <li role="presentation"><span class="dropdown-header fs-6">{{ lang.debug.in_memory_logs }}</span></li>
      <li role="presentation"><button class="dropdown-item" data-bs-target="#tab-postfix-logs" aria-selected="false" aria-controls="tab-postfix-logs" role="tab" data-bs-toggle="tab">Postfix</button></li>
      <li role="presentation"><button class="dropdown-item" data-bs-target="#tab-dovecot-logs" aria-selected="false" aria-controls="tab-dovecot-logs" role="tab" data-bs-toggle="tab">Dovecot</button></li>
      <li role="presentation"><button class="dropdown-item" data-bs-target="#tab-sogo-logs" aria-selected="false" aria-controls="tab-sogo-logs" role="tab" data-bs-toggle="tab">SOGo</button></li>
      <li role="presentation"><button class="dropdown-item" data-bs-target="#tab-netfilter-logs" aria-selected="false" aria-controls="tab-netfilter-logs" role="tab" data-bs-toggle="tab">Netfilter</button></li>
      <li role="presentation"><button class="dropdown-item" data-bs-target="#tab-autodiscover-logs" aria-selected="false" aria-controls="tab-autodiscover-logs" role="tab" data-bs-toggle="tab">Autodiscover</button></li>
      <li role="presentation"><button class="dropdown-item" data-bs-target="#tab-watchdog-logs" aria-selected="false" aria-controls="tab-watchdog-logs" role="tab" data-bs-toggle="tab">Watchdog</button></li>
      <li role="presentation"><button class="dropdown-item" data-bs-target="#tab-acme-logs" aria-selected="false" aria-controls="tab-acme-logs" role="tab" data-bs-toggle="tab">ACME</button></li>
      <li role="presentation"><button class="dropdown-item" data-bs-target="#tab-api-logs" aria-selected="false" aria-controls="tab-api-logs" role="tab" data-bs-toggle="tab">API</button></li>
      <li role="presentation"><button class="dropdown-item" data-bs-target="#tab-api-rl" aria-selected="false" aria-controls="tab-api-rl" role="tab" data-bs-toggle="tab">Ratelimits</button></li>
      <li role="presentation"><span class="dropdown-header fs-6">{{ lang.debug.external_logs }}</span></li>
      <li role="presentation"><button class="dropdown-item" data-bs-target="#tab-rspamd-history" aria-selected="false" aria-controls="tab-rspamd-history" role="tab" data-bs-toggle="tab">Rspamd</button></li>
      <li role="presentation"><span class="dropdown-header fs-6">{{ lang.debug.static_logs }}</span></li>
      <li role="presentation"><button class="dropdown-item" data-bs-target="#tab-ui" aria-selected="false" aria-controls="tab-ui" role="tab" data-bs-toggle="tab">Mailcow UI</button></li>
      <li role="presentation"><button class="dropdown-item" data-bs-target="#tab-sasl" aria-selected="false" aria-controls="tab-sasl" role="tab" data-bs-toggle="tab">SASL</button></li>
    </ul>
  </li>
</ul>

<div class="row">
  <div class="col-md-12">
    <div class="tab-content" style="padding-top:20px">
      <div role="tabpanel" class="tab-pane active" id="tab-containers">

        <div class="card mb-4">
          <div class="card-header fs-5">
            <span>{{ ui_texts.title_name|raw }}</span>
          </div>
          <div class="card-body">
            <div class="row">
              <div class="col-sm-12 col-md-4 d-flex flex-column">
                <img class="img-responsive my-auto m-auto" alt="mailcow-logo" style="max-width: 85%; max-height: 85%;" src="{{ logo|default('/img/cow_mailcow.svg') }}">
              </div>
              <div class="col-sm-12 col-md-8">
                <div class="table-responsive" style="margin-top: 10px;">
                  <table class="table table-striped table-condensed">
                    <tbody>
                      <tr>
                        <td>Hostname</td>
                        <td class="text-break"><div>
                          <p><b>{{ hostname }}</b></p>
                        </div></td>
                      </tr>
                      <tr>
                        <td>IPs</td>
                        <td class="text-break">
                          {% if ip_check == 1 %}
                            <span class="d-none" id="host_ipv4">-</span>
                            <span class="d-none mb-2" id="host_ipv6">-</span>
                            <button class="d-block btn btn-primary btn-sm" id="host_show_ip">
                              <span class="text">{{ lang.debug.show_ip }}</span>
                              <div class="spinner-border spinner-border-sm d-none" role="status">
                                <span class="visually-hidden">Loading...</span>
                              </div>  
                            </button>
                          {% else %}
                            <span class="d-block">{{ lang.admin.ip_check_disabled|raw }}</span>
                          {% endif %}
                        </td>
                      </tr>
                      <tr>
                        <td>Version</td>
                        <td class="text-break">
                          <div class="fw-bolder">
                            <p ><a href="#" id="maiclow_version">{{ mailcow_info.version_tag }}</a></p>
                            <p id="mailcow_update"></p> 
                          </div>
                        </td>
                      </tr>
                      <tr>
                        <td>{{ lang.debug.current_time }}</td>
                        <td id="host_date" class="text-break">-</td>
                      </tr>
                      <tr>
                        <td>{{ lang.debug.timezone }}</td>
                        <td class="text-break">{{ timezone }}</td>
                      </tr>
                      <tr>
                        <td>{{ lang.debug.uptime }}</td>
                        <td id="host_uptime" class="text-break">-</td>
                      </tr>
                      <tr>
                        <td>{{ lang.debug.disk_usage }}</td>
                        <td class="text-break">
                          <div>
                            <span class="d-block"><i class="bi bi-hdd-fill"></i> {{ vmail_df[0] }}</span>
                            <span class="d-block">{{ vmail_df[2] }} / {{ vmail_df[1] }} ({{ vmail_df[4] }})</span>
                          </div>
                          <div class="mt-2 mb-4">
                            <div class="progress">
                              <div class="progress-bar bg-info" role="progressbar" style="width:{{ vmail_df[4] }}"></div>
                            </div>
                          </div>
                        </td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </div>

              <div class="col-sm-6 mt-4">
                <h3>CPU</h3>
                <h5><span id="host_cpu_cores">-</span> {{ lang.debug.cores }} @ <span id="host_cpu_usage"></span></h5>
                <canvas id="host_cpu_chart" width="400" height="200"></canvas>
              </div>
              <div class="col-sm-6 mt-4">
                <h3>{{ lang.debug.memory|upper}}</h3>
                <h5><span id="host_memory_total">-</span> @ <span id="host_memory_usage"></span></h5>
                <canvas id="host_mem_chart" width="400" height="200"></canvas>
              </div>

              <div class="col-sm-12">
                <legend class="mt-4">
                  {{ lang.admin.guid_and_license }}
                </legend>
                <hr />
                <div id="license">
                  <form class="form-horizontal" autocapitalize="none" autocorrect="off" role="form" method="post">
                    <div class="row">
                      <label class="control-label col-sm-3" for="guid">{{ lang.admin.guid }}:</label>
                      <div class="col-sm-9">
                        <div class="input-group">
                          <span class="input-group-text">
                            <i class="bi bi-suit-heart{% if gal.valid == true %}-fill text-danger{% endif %}"></i>
                          </span>
                          <input type="text" id="guid" class="form-control" value="{{ license_guid }}" readonly>
                        </div>
                        <p class="text-muted">
                          {{ lang.admin.customer_id }}: {{ gal.c|default('?')|raw }} -
                          {{ lang.admin.service_id }}: {{ gal.s|default('?')|raw }} -
                          {{ lang.admin.sal_level }}: {{ gal.m|default('?')|raw }}
                        </p>
                      </div>
                    </div>
                    <div class="row">
                      <div class="offset-sm-3 col-sm-9">
                        <p class="text-muted">{{ lang.admin.license_info|raw }}</p>
                        <div class="btn-group">
                          <button class="btn btn-sm d-block d-sm-inline btn-success" name="license_validate_now" type="submit" href="#">{{ lang.admin.validate_license_now }}</button>
                        </div>
                      </div>
                    </div>
                  </form>
                </div>
              </div>
            </div>
          </div>
        </div>



        <!-- container info -->
        <div class="card mb-4">
          <div class="card-header fs-5">
            <span>{{ lang.debug.containers_info }}</span>
          </div>
          <div class="card-body p-0">
            <div class="row mx-0">
              <!-- solr info -->
              <div class="col-md-6 col-sm-12 p-2">
                <div class="list-group-item p-0">
                  <div class="d-flex p-2 list-group-header">
                    <div>
                      <span class="fw-bold">solr-mailcow</span>
                      {% if containers["solr-mailcow"].State.Running == 1 %}
                      <span class="d-block d-md-inline">({{ containers["solr-mailcow"].Config.Image }})</span>
                      {% endif %}
                      {% if containers["solr-mailcow"].State.Running == 1 %}
                      <small class="d-block">({{ lang.debug.started_on }} <span class="parse_date">{{ containers["solr-mailcow"].State.StartedAtHR }}</span>)</small>
                      {% elseif containers["solr-mailcow"].State.Running != 1 %}
                      <small class="d-block">{{ lang.debug.container_disabled }}</small>
                      {% endif %}
                      {% if containers["solr-mailcow"].State.Running == 1 %}
                        <span class="badge fs-7 bg-success loader" style="min-width:100px">
                          {{ lang.debug.container_running }}
                          <span class="loader-dot">.</span>
                          <span class="loader-dot">.</span>
                          <span class="loader-dot">.</span>
                        </span>
                      {% elseif containers["solr-mailcow"].State.Running != 1 %}
                        <span class="badge fs-7 bg-danger" style="min-width:100px">
                          {{ lang.debug.container_stopped }}
                          <i class="bi-x ms-1"></i>
                        </span>
                      {% endif %}
                    </div>
                  {% if containers["solr-mailcow"].State.Running == 1 %}
                    <div class="mt-auto ms-auto">
                      <button class="btn btn-light" type="button" data-bs-toggle="collapse" data-bs-target="#solr-mailcowCollapse" aria-expanded="false" aria-controls="solr-mailcowCollapse">
                        <i class="bi bi-caret-down-fill caret"></i>
                      </button>
                    </div>
                  {% endif %}  
                  </div>
                  {% if containers["solr-mailcow"].State.Running == 1 %}
                  <div class="collapse p-0 list-group-details container-details-collapse" id="solr-mailcowCollapse" data-id="{{ containers["solr-mailcow"].Id }}">    
                    <div class="row p-2 pt-4">
                      <div class="col-sm-3">
                        <p><img class="img-responsive" alt="Solr Logo" width="128px" src="data:image/png;base64, " /></p>
                      </div>
                      <div class="col-sm-9">
                        {% if solr_status != false %}
                        <div class="progress">
                          <div class="progress-bar bg-info" role="progressbar" style="width:{{ solr_status.jvm.memory.raw['used%']|round }}%"></div>
                        </div>
                        <p>{{ lang.debug.jvm_memory_solr }}: {{ (solr_status.jvm.memory.total - solr_status.jvm.memory.free) }} / {{ solr_status.jvm.memory.total }}
                          ({{ solr_status.jvm.memory.raw['used%']|round }}%)</p>
                        <hr>
                        <span class="d-block">{{ lang.debug.uptime }}: {{ solr_uptime }}h</span>
                        <span class="d-block">{{ lang.debug.started_at }}: <span class="parse_date">{{ solr_status.status['dovecot-fts'].startTime }}</span></span>
                        <span class="d-block">{{ lang.debug.last_modified }}: <span class="parse_date">{{ solr_status.status['dovecot-fts'].index.lastModified }}</span></span>
                        <span class="d-block">{{ lang.debug.size }}: {{ solr_status.status['dovecot-fts'].index.size }}</span>
                        <span class="d-block"><i class="bi bi-file-text"></i> {{ lang.debug.docs }}: {{ solr_status.status['dovecot-fts'].index.numDocs }}</span>
                        {% else %}
                        <span class="d-block">{{ lang.debug.solr_dead }}</span>
                        {% endif %}
                      </div>
                      <div class="mt-4 col-sm-12 col-md-6 d-flex flex-column">
                        <h6>Disk I/O</h6>
                        <div class="spinner-border my-4 mx-auto" role="status">
                          <span class="visually-hidden">Loading...</span>
                        </div>
                        <canvas class="d-none" id="solr-mailcow_DiskIOChart" width="400" height="200"></canvas>
                      </div>
                      <div class="mt-4 col-sm-12 col-md-6 d-flex flex-column">
                        <h6>Net I/O</h6>
                        <div class="spinner-border my-4 mx-auto" role="status">
                          <span class="visually-hidden">Loading...</span>
                        </div>
                        <canvas class="d-none" id="solr-mailcow_NetIOChart" width="400" height="200"></canvas>
                      </div>
                      <div class="col-sm-12 d-flex" style="height: 40px">
                        <a href data-bs-toggle="modal" 
                          data-container="solr-mailcow" 
                          data-bs-target="#RestartContainer" 
                          class="btn btn-sm btn-secondary d-flex align-items-center justify-content-center mb-2 ms-auto" 
                          style="height: 30px;">{{ lang.debug.restart_container }}
                            <i class="ms-1 bi
                            {% if containers["solr-mailcow"].State.Running == 1 %}
                            bi-record-fill text-success
                            {% elseif containers["solr-mailcow"].State %}
                            bi-record-fill text-danger
                            {% else %}
                            default
                            {% endif %}
                            "
                          ></i>
                        </a>
                      </div>
                    </div>                  
                  </div>
                  {% endif %}
                </div>
              </div>

              <!-- rest of the containers -->
              {% for container, container_info in containers %}
                {% if container != "solr-mailcow" %}
                  <div class="col-md-6 col-sm-12 p-2">
                    <div class="list-group-item p-0">
                      <div class="d-flex p-2 list-group-header">
                        <div>
                          <span class="fw-bold">{{ container }}</span>
                          <span class="d-block d-md-inline">({{ container_info.Config.Image }})</span>
                          <small class="d-block">({{ lang.debug.started_on }} <span class="parse_date">{{ container_info.State.StartedAtHR }}</span>)</small>
                          {% if container_info.State.Running == 1 %}
                            <span class="badge fs-7 bg-success loader" style="min-width:100px">
                              {{ lang.debug.container_running }}
                              <span class="loader-dot">.</span>
                              <span class="loader-dot">.</span>
                              <span class="loader-dot">.</span>
                            </span>
                          {% elseif container_info.State %}
                            <span class="badge fs-7 bg-danger" style="min-width:100px">
                              {{ lang.debug.container_stopped }}
                              <i class="bi-x ms-1"></i>
                            </span>
                          {% endif %}
                        </div>
                        <div class="mt-auto ms-auto">
                          <button class="btn btn-light" type="button" data-bs-toggle="collapse" data-bs-target="#{{ container }}Collapse" aria-expanded="false" aria-controls="{{ container }}Collapse">
                            <i class="bi bi-caret-down-fill caret"></i>
                          </button>
                        </div>
                      </div>
                      <div class="collapse p-0 list-group-details container-details-collapse" id="{{ container }}Collapse" data-id="{{ container_info.Id }}">   
                        <div class="row p-2 pt-4">   
                          <div class="mt-4 col-sm-12 col-md-6 d-flex flex-column">
                            <h6>Disk I/O</h6>
                            <div class="spinner-border my-4 mx-auto" role="status">
                              <span class="visually-hidden">Loading...</span>
                            </div>
                            <canvas class="d-none" id="{{ container }}_DiskIOChart" width="400" height="200"></canvas>
                          </div>
                          <div class="mt-4 col-sm-12 col-md-6 d-flex flex-column">
                            <h6>Net I/O</h6>
                            <div class="spinner-border my-4 mx-auto" role="status">
                              <span class="visually-hidden">Loading...</span>
                            </div>
                            <canvas class="d-none" id="{{ container }}_NetIOChart" width="400" height="200"></canvas>
                          </div>   
                          <div class="col-12 d-flex" style="height: 40px">             
                            <a href data-bs-toggle="modal" 
                              data-container="{{ container }}" 
                              data-bs-target="#RestartContainer" 
                              class="btn btn-sm btn-secondary d-flex align-items-center justify-content-center mb-2 ms-auto" 
                              style="height: 30px;">{{ lang.debug.restart_container }}
                                <i class="ms-1 bi
                                {% if container_info.State.Running == 1 %}
                                bi-record-fill text-success
                                {% elseif container_info.State %}
                                bi-record-fill text-danger
                                {% else %}
                                default
                                {% endif %}
                                "
                              ></i>
                            </a>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                {% endif %}
              {% endfor %}
            </div>
          </div>
        </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab-postfix-logs">
        <div class="debug-log-info">{{ lang.debug.log_info|format(log_lines+1)|raw }}</div>
        <div class="card">
          <div class="card-header d-flex align-items-center fs-5">
            <span class="mt-2 ms-2">Postfix</span>      
            <div class="btn-group ms-auto">
              <button class="btn btn-sm btn-secondary refresh_table" data-draw="draw_postfix_logs" data-table="postfix_log">{{ lang.admin.refresh }}</button>
            </div>
          </div>
          <div class="card-body">
            <a class="btn btn-sm btn-secondary dropdown-toggle mb-4" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.quick_actions }}</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item add_log_lines" data-post-process="general_syslog" data-table="postfix_log" data-log-url="postfix" data-nrows="100" href="#">+ 100</a></li>
              <li><a class="dropdown-item add_log_lines" data-post-process="general_syslog" data-table="postfix_log" data-log-url="postfix" data-nrows="1000" href="#">+ 1000</a></li>
              <li class="table_collapse_option"><hr class="dropdown-divider"></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-expand="postfix_log" data-table="postfix_log" href="#">{{ lang.datatables.expand_all }}</a></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-collapse="postfix_log" data-table="postfix_log" href="#">{{ lang.datatables.collapse_all }}</a></li>
            </ul>
            <table id="postfix_log" class="table table-striped dt-responsive w-100"></table>
          </div>
        </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab-ui">
        <div class="debug-log-info">{{ lang.debug.log_info|format(log_lines+1)|raw }}</div>
        <div class="card">
          <div class="card-header d-flex align-items-center fs-5">
            <span class="mt-2 ms-2">Mailcow UI</span>
            <div class="btn-group ms-auto">
              <button class="btn btn-sm btn-secondary refresh_table" data-draw="draw_ui_logs" data-table="ui_logs">{{ lang.admin.refresh }}</button>
            </div>
          </div>
          <div class="card-body">
            <a class="btn btn-sm btn-secondary dropdown-toggle mb-4" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.quick_actions }}</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item add_log_lines" data-post-process="mailcow_ui" data-table="ui_logs" data-log-url="ui" data-nrows="100" href="#">+ 100</a></li>
              <li><a class="dropdown-item add_log_lines" data-post-process="mailcow_ui" data-table="ui_logs" data-log-url="ui" data-nrows="1000" href="#">+ 1000</a></li>
              <li class="table_collapse_option"><hr class="dropdown-divider"></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-expand="ui_logs" data-table="ui_logs" href="#">{{ lang.datatables.expand_all }}</a></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-collapse="ui_logs" data-table="ui_logs" href="#">{{ lang.datatables.collapse_all }}</a></li>
            </ul>
            <table id="ui_logs" class="table table-striped dt-responsive w-100"></table>
          </div>
        </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab-sasl">
        <div class="debug-log-info">{{ lang.debug.log_info|format(log_lines+1)|raw }}</div>
        <div class="card">
          <div class="card-header d-flex align-items-center fs-5">
            <span class="mt-2 ms-2">SASL</span>
            <div class="btn-group ms-auto">
              <button class="btn btn-sm btn-secondary refresh_table" data-draw="draw_sasl_logs" data-table="sasl_logs">{{ lang.admin.refresh }}</button>
            </div>
          </div>
          <div class="card-body">
            <a class="btn btn-sm btn-secondary dropdown-toggle mb-4" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.quick_actions }}</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item add_log_lines" data-post-process="sasl_log_table" data-table="sasl_logs" data-log-url="ui" data-nrows="100" href="#">+ 100</a></li>
              <li><a class="dropdown-item add_log_lines" data-post-process="sasl_log_table" data-table="sasl_logs" data-log-url="ui" data-nrows="1000" href="#">+ 1000</a></li>
              <li class="table_collapse_option"><hr class="dropdown-divider"></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-expand="sasl_logs" data-table="sasl_logs" href="#">{{ lang.datatables.expand_all }}</a></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-collapse="sasl_logs" data-table="sasl_logs" href="#">{{ lang.datatables.collapse_all }}</a></li>
            </ul>
            <table id="sasl_logs" class="table table-striped dt-responsive w-100"></table>
          </div>
        </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab-dovecot-logs">
        <div class="debug-log-info">{{ lang.debug.log_info|format(log_lines+1)|raw }}</div>
        <div class="card">
          <div class="card-header d-flex align-items-center fs-5">
            <span class="mt-2 ms-2">Dovecot</span>
            <div class="btn-group ms-auto">
              <button class="btn btn-sm btn-secondary refresh_table" data-draw="draw_dovecot_logs" data-table="dovecot_log">{{ lang.admin.refresh }}</button>
            </div>
          </div>
          <div class="card-body">
            <a class="btn btn-sm btn-secondary dropdown-toggle mb-4" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.quick_actions }}</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item add_log_lines" data-post-process="general_syslog" data-table="dovecot_log" data-log-url="dovecot" data-nrows="100" href="#">+ 100</a></li>
              <li><a class="dropdown-item add_log_lines" data-post-process="general_syslog" data-table="dovecot_log" data-log-url="dovecot" data-nrows="1000" href="#">+ 1000</a></li>
              <li class="table_collapse_option"><hr class="dropdown-divider"></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-expand="dovecot_log" data-table="dovecot_log" href="#">{{ lang.datatables.expand_all }}</a></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-collapse="dovecot_log" data-table="dovecot_log" href="#">{{ lang.datatables.collapse_all }}</a></li>
            </ul>
            <table id="dovecot_log" class="table table-striped dt-responsive w-100"></table>
          </div>
        </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab-sogo-logs">
        <div class="debug-log-info">{{ lang.debug.log_info|format(log_lines+1)|raw }}</div>
        <div class="card">
          <div class="card-header d-flex align-items-center fs-5">
            <span class="mt-2 ms-2">SOGo</span>
            <div class="btn-group ms-auto">
              <button class="btn btn-sm btn-secondary refresh_table" data-draw="draw_sogo_logs" data-table="sogo_log">{{ lang.admin.refresh }}</button>
            </div>
          </div>
          <div class="card-body">
            <a class="btn btn-sm btn-secondary dropdown-toggle mb-4" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.quick_actions }}</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item add_log_lines" data-post-process="general_syslog" data-table="sogo_log" data-log-url="sogo" data-nrows="100" href="#">+ 100</a></li>
              <li><a class="dropdown-item add_log_lines" data-post-process="general_syslog" data-table="sogo_log" data-log-url="sogo" data-nrows="1000" href="#">+ 1000</a></li>
              <li class="table_collapse_option"><hr class="dropdown-divider"></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-expand="sogo_log" data-table="sogo_log" href="#">{{ lang.datatables.expand_all }}</a></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-collapse="sogo_log" data-table="sogo_log" href="#">{{ lang.datatables.collapse_all }}</a></li>
            </ul>
            <table id="sogo_log" class="table table-striped dt-responsive w-100"></table>
          </div>
        </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab-netfilter-logs">
        <div class="debug-log-info">{{ lang.debug.log_info|format(log_lines+1)|raw }}</div>
        <div class="card">
          <div class="card-header d-flex align-items-center fs-5">
            <span class="mt-2 ms-2">Netfilter</span>
            <div class="btn-group ms-auto">
              <button class="btn btn-sm btn-secondary refresh_table" data-draw="draw_netfilter_logs" data-table="netfilter_log">{{ lang.admin.refresh }}</button>
            </div>
          </div>
          <div class="card-body">
            <a class="btn btn-sm btn-secondary dropdown-toggle mb-4" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.quick_actions }}</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item add_log_lines" data-post-process="general_syslog" data-table="netfilter_log" data-log-url="netfilter" data-nrows="100" href="#">+ 100</a></li>
              <li><a class="dropdown-item add_log_lines" data-post-process="general_syslog" data-table="netfilter_log" data-log-url="netfilter" data-nrows="1000" href="#">+ 1000</a></li>
              <li class="table_collapse_option"><hr class="dropdown-divider"></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-expand="netfilter_log" data-table="netfilter_log" href="#">{{ lang.datatables.expand_all }}</a></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-collapse="netfilter_log" data-table="netfilter_log" href="#">{{ lang.datatables.collapse_all }}</a></li>
            </ul>
            <table id="netfilter_log" class="table table-striped dt-responsive w-100"></table>
          </div>
        </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab-rspamd-history">
        <div class="debug-log-info">{{ lang.debug.log_info|format(log_lines+1)|raw }}</div>
        <div class="card">
          <div class="card-header d-flex align-items-center fs-5">
            <span class="mt-2 ms-2">Rspamd history</span>
            <div class="btn-group ms-auto">
              <button class="btn btn-sm btn-secondary refresh_table" data-draw="draw_rspamd_history" data-table="rspamd_history">{{ lang.admin.refresh }}</button>
            </div>
          </div>
          <div class="card-body">
            <legend>{{ lang.debug.chart_this_server }}</legend><hr />
            <div id="chart-container">
              <canvas id="rspamd_donut" style="width:100%;height:400px"></canvas>
            </div>
            <legend>{{ lang.debug.history_all_servers }}</legend><hr />
            <a class="btn btn-sm btn-secondary dropdown-toggle mb-4" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.quick_actions }}</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item add_log_lines" data-post-process="rspamd_history" data-table="rspamd_history" data-log-url="rspamd_history" data-nrows="100" href="#">+ 100</a></li>
              <li><a class="dropdown-item add_log_lines" data-post-process="rspamd_history" data-table="rspamd_history" data-log-url="rspamd_history" data-nrows="1000" href="#">+ 1000</a></li>
              <li class="table_collapse_option"><hr class="dropdown-divider"></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-expand="rspamd_history" data-table="rspamd_history" href="#">{{ lang.datatables.expand_all }}</a></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-collapse="rspamd_history" data-table="rspamd_history" href="#">{{ lang.datatables.collapse_all }}</a></li>
            </ul>
            <table id="rspamd_history" class="table table-striped dt-responsive w-100"></table>
          </div>
        </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab-autodiscover-logs">
        <div class="debug-log-info">{{ lang.debug.log_info|format(log_lines+1)|raw }}</div>
        <div class="card">
          <div class="card-header d-flex align-items-center fs-5">
            <span class="mt-2 ms-2">Autodiscover</span>
            <div class="btn-group ms-auto">
              <button class="btn btn-sm btn-secondary refresh_table" data-draw="draw_autodiscover_logs" data-table="autodiscover_log">{{ lang.admin.refresh }}</button>
            </div>
          </div>
          <div class="card-body">
            <a class="btn btn-sm btn-secondary dropdown-toggle mb-4" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.quick_actions }}</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item add_log_lines" data-post-process="autodiscover_log" data-table="autodiscover_log" data-log-url="autodiscover" data-nrows="100" href="#">+ 100</a></li>
              <li><a class="dropdown-item add_log_lines" data-post-process="autodiscover_log" data-table="autodiscover_log" data-log-url="autodiscover" data-nrows="1000" href="#">+ 1000</a></li>
              <li class="table_collapse_option"><hr class="dropdown-divider"></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-expand="autodiscover_log" data-table="autodiscover_log" href="#">{{ lang.datatables.expand_all }}</a></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-collapse="autodiscover_log" data-table="autodiscover_log" href="#">{{ lang.datatables.collapse_all }}</a></li>
            </ul>
            <table id="autodiscover_log" class="table table-striped dt-responsive w-100"></table>
          </div>
        </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab-watchdog-logs">
        <div class="debug-log-info">{{ lang.debug.log_info|format(log_lines+1)|raw }}</div>
        <div class="card">
          <div class="card-header d-flex align-items-center fs-5">
            <span class="mt-2 ms-2">Watchdog</span>
            <div class="btn-group ms-auto">
              <button class="btn btn-sm btn-secondary refresh_table" data-draw="draw_watchdog_logs" data-table="watchdog_log">{{ lang.admin.refresh }}</button>
            </div>
          </div>
          <div class="card-body">
            <a class="btn btn-sm btn-secondary dropdown-toggle mb-4" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.quick_actions }}</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item add_log_lines" data-post-process="watchdog" data-table="watchdog_log" data-log-url="watchdog" data-nrows="100" href="#">+ 100</a></li>
              <li><a class="dropdown-item add_log_lines" data-post-process="watchdog" data-table="watchdog_log" data-log-url="watchdog" data-nrows="1000" href="#">+ 1000</a></li>
              <li class="table_collapse_option"><hr class="dropdown-divider"></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-expand="watchdog_log" data-table="watchdog_log" href="#">{{ lang.datatables.expand_all }}</a></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-collapse="watchdog_log" data-table="watchdog_log" href="#">{{ lang.datatables.collapse_all }}</a></li>
            </ul>
            <table id="watchdog_log" class="table table-striped dt-responsive w-100"></table>
          </div>
        </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab-acme-logs">
        <div class="debug-log-info">{{ lang.debug.log_info|format(log_lines+1)|raw }}</div>
        <div class="card">
          <div class="card-header d-flex align-items-center fs-5">
            <span class="mt-2 ms-2">ACME</span>
            <div class="btn-group ms-auto">
              <button class="btn btn-sm btn-secondary refresh_table" data-draw="draw_acme_logs" data-table="acme_log">{{ lang.admin.refresh }}</button>
            </div>
          </div>
          <div class="card-body">
            <a class="btn btn-sm btn-secondary dropdown-toggle mb-4" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.quick_actions }}</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item add_log_lines" data-post-process="general_syslog" data-table="acme_log" data-log-url="acme" data-nrows="100" href="#">+ 100</a></li>
              <li><a class="dropdown-item add_log_lines" data-post-process="general_syslog" data-table="acme_log" data-log-url="acme" data-nrows="1000" href="#">+ 1000</a></li>
              <li class="table_collapse_option"><hr class="dropdown-divider"></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-expand="acme_log" data-table="acme_log" href="#">{{ lang.datatables.expand_all }}</a></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-collapse="acme_log" data-table="acme_log" href="#">{{ lang.datatables.collapse_all }}</a></li>
            </ul>
            <table id="acme_log" class="table table-striped dt-responsive w-100"></table>
          </div>
        </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab-api-logs">
        <div class="debug-log-info">{{ lang.debug.log_info|format(log_lines+1)|raw }}</div>
        <div class="card">
          <div class="card-header d-flex align-items-center fs-5">
            <span class="mt-2 ms-2">API</span>
            <div class="btn-group ms-auto">
              <button class="btn btn-sm btn-secondary refresh_table" data-draw="draw_api_logs" data-table="api_log">{{ lang.admin.refresh }}</button>
            </div>
          </div>
          <div class="card-body">
            <a class="btn btn-sm btn-secondary dropdown-toggle mb-4" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.quick_actions }}</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item add_log_lines" data-post-process="apilog" data-table="api_log" data-log-url="api" data-nrows="100" href="#">+ 100</a></li>
              <li><a class="dropdown-item add_log_lines" data-post-process="apilog" data-table="api_log" data-log-url="api" data-nrows="1000" href="#">+ 1000</a></li>
              <li class="table_collapse_option"><hr class="dropdown-divider"></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-expand="api_log" data-table="api_log" href="#">{{ lang.datatables.expand_all }}</a></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-collapse="api_log" data-table="api_log" href="#">{{ lang.datatables.collapse_all }}</a></li>
            </ul>
            <table id="api_log" class="table table-striped dt-responsive w-100"></table>
          </div>
        </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab-api-rl">
        <div class="debug-log-info">{{ lang.debug.log_info|format(log_lines+1)|raw }}</div>
        <div class="card">
          <div class="card-header d-flex align-items-center fs-5">
            <span class="mt-2 ms-2">Ratelimits</span>
            <div class="btn-group ms-auto">
              <button class="btn btn-sm btn-secondary refresh_table" data-draw="draw_rl_logs" data-table="rl_log">{{ lang.admin.refresh }}</button>
            </div>
          </div>
          <div class="card-body">
            <a class="btn btn-sm btn-secondary dropdown-toggle mb-4" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.quick_actions }}</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item add_log_lines" data-post-process="rllog" data-table="rl_log" data-log-url="ratelimited" data-nrows="100" href="#">+ 100</a></li>
              <li><a class="dropdown-item add_log_lines" data-post-process="rllog" data-table="rl_log" data-log-url="ratelimited" data-nrows="1000" href="#">+ 1000</a></li>
              <li class="table_collapse_option"><hr class="dropdown-divider"></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-expand="rl_log" data-table="rl_log" href="#">{{ lang.datatables.expand_all }}</a></li>
              <li class="table_collapse_option"><a class="dropdown-item" data-datatables-collapse="rl_log" data-table="rl_log" href="#">{{ lang.datatables.collapse_all }}</a></li>
            </ul>
            <p class="text-muted">{{ lang.admin.hash_remove_info }}</p>
            <table id="rl_log" class="table table-striped dt-responsive w-100"></table>
          </div>
        </div>
      </div>

    </div> <!-- /tab-content -->
  </div> <!-- /col-md-12 -->
</div> <!-- /row -->

<script type='text/javascript'>
  var lang = {{ lang_admin|raw }};
  var lang_debug = {{ lang_debug|raw }};
  var lang_datatables = {{ lang_datatables|raw }};
  var csrf_token = '{{ csrf_token }}';
  var log_pagination_size = '{{ log_pagination_size }}';
</script>
{% endblock %}
