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

{% block primary_content_inner %}
  <h2>{{ _('Current Sysadmins') }}</h2>

  <table class="table table-header table-hover table-bordered">
    <thead>
      <tr>
        <th>{{ _('User') }}</th>
        <th>&nbsp;</th>
      </tr>
    </thead>
    <tbody>
      {% for user in sysadmins %}
        <tr>
          <td>{{ h.linked_user(user) }}</td>
          <td>
            <div class="btn-group pull-right">
              <form method="POST" action="{% url_for 'user.sysadmin' %}">
                {{ h.csrf_input() }}
                <input type="hidden" value="{{ user }}" name="username" />
                <input type="hidden" value="0" name="status" />
                <button
                  type="submit"
                  class="btn btn-danger btn-sm"
                  title="{{ _('Revoke Sysadmin permission') }}"
                >
                  <i class="fa fa-times"></i>
                </button>
              </form>
            </div>
          </td>
        </tr>
      {% endfor %}
    </tbody>
  </table>

  <hr />

  <h2>{{ _('Promote user to Sysadmin') }}</h2>

  <form method="POST" action="{% url_for 'user.sysadmin' %}">
    {{ h.csrf_input() }}
    <div class="row">
      <div class="col">

        <div class="form-group">
          <input
            id="promote-username" type="text" name="username" placeholder="Username"
            value="" class="control-medium" data-module="autocomplete"
            data-module-source="/api/2/util/user/autocomplete?ignore_self=true&q=?"
          >
          <input type="hidden" value="1" name="status" />
        </div>

        <div class="form-actions">
          <button
            type="submit"
            class="btn btn-primary"
            title="{{ _('Promote user to Sysadmin') }}"
          >{{ _('Promote') }}</button>
        </div>

      </div>
    </div>
  </form>
{% endblock %}

{% block secondary_content %}
  <div class="module module-narrow module-shallow">
    <h2 class="module-heading">
      <i class="fa fa-info-circle"></i>
      {{ _('Administer CKAN') }}
    </h2>
    <div class="module-content">

      {% set docs_url = "http://docs.ckan.org/en/{0}/sysadmin-guide.html".format(g.ckan_doc_version) %}
      {% trans %}
        <p>As a sysadmin user you have full control over this CKAN instance. Proceed with care!</p>
        <p>For guidance on using sysadmin features, see the CKAN  <a href="{{ docs_url }}" target="_blank" rel="noreferrer">sysadmin guide</a></p>
      {% endtrans %}
    </div>
  </div>
{% endblock %}
