{% extends "master.html" %}

{% block title %}Settings · Anitya{% endblock %}


{% block body %}
  <div class="intro">
      <h3>
        User ID
      </h3>
      <p>
        Your user ID is {{ user.id }}
      </p>
  </div>

  <div class="intro">
      <h3>
        API Tokens
      </h3>
      <p>
        API keys are tokens used to authenticate you when using the REST API.
        These keys are like passwords; make sure to store them safely.
      </p>
  </div>

  <div class="col-md-8 col-md-offset-2">
    {% if user.api_tokens %}
    <ul class="list-group list-group-flush">
    {% for api_token in user.api_tokens %}
        <li class="list-group-item">
          <div>
            <strong>{{ api_token.description or '' }}</strong>
          </div>
          <form class="pull-right" style="margin-left: 14px" method="POST"
	      action="{{ url_for('.delete_token', token=api_token.token) }}">
            <button class="btn btn-danger" type="submit"
                onclick="return confirm('Are you sure to delete this token?');"
                title="Remove API Token">
	      Remove API Token
            </button>
            {{ form.csrf_token }}
          </form>
          <div class="form-group">
            <div class="input-group">
              <div class="input-group-addon">
                <span class="oi" data-glyph="key"></span>
              </div>
              <input class="form-control" type="text" value="{{ api_token.token }}" readonly>
            </div>
          </div>
        </li>
    {% endfor %}
    </ul>
    {% endif %}
    <div class="card-block">
      <form action="{{ url_for('.new_token') }}" method="POST">
        {{ form.description.label }}: {{ form.description(size=30) }}
        <button class="btn btn-primary" type="submit" title="Create API Token">
          Create API Token
        </button>
        {{ form.csrf_token }}
      </form>
    </div>
  </div>
{% endblock %}
