{% extends "./layout.html" %}
{% block content %}
  <h1><div class="text-shadow">Settings</div></h1>
  {% if username != "zoffline" %}
    <h4 class="text-shadow">Logged in as {{ username }}</h4>
  {% endif %}
  <div class="row">
    <div class="col-md-12">
      <a href="{{ url_for('user_home', username=username) }}" class="btn btn-sm btn-secondary">Back</a>
      {% if username != "zoffline" %}
        <a href="{{ url_for('reset', username=username) }}" class="btn btn-sm btn-secondary">Change password</a>
      {% endif %}
      <a href="{{ url_for('power_curves', username=username) }}" class="btn btn-sm btn-secondary">Power curves</a>
      <a href="{{ url_for('profile', username=username) }}" class="btn btn-sm btn-secondary">Zwift</a>
      {% if not token %}
        <a href="{{ url_for('strava') }}" class="btn btn-sm btn-secondary">Strava</a>
      {% else %}
        <a href="/delete/strava_token.txt" class="btn btn-sm btn-danger">Remove Strava token</a>
      {% endif %}
      <a href="{{ url_for('garmin', username=username) }}" class="btn btn-sm btn-secondary">Garmin</a>
      <a href="{{ url_for('intervals', username=username) }}" class="btn btn-sm btn-secondary">Intervals</a>
    </div>
  </div>
  <div class="row">
    <div class="col-sm-8 col-md-8 top-buffer">
      <ul class="list-group">
        {% if profile %}
          <li class="list-group-item">
            <div class="row">
              <div class="col-md-12">
                <table width="480px"><td><label class="text-shadow">profile.bin - {{ profile }}</label></td>
                <td align="right"><a href="/download/profile.bin"><div class="btn btn-sm btn-light">Download</div></a>
                <a href="/delete/profile.bin"><div class="btn btn-sm btn-danger">Delete</div></a></td></table>
              </div>
            </div>
          </li>
        {% endif %}
        {% if achievements %}
          <li class="list-group-item">
            <div class="row">
              <div class="col-md-12">
                <table width="480px"><td><label class="text-shadow">achievements.bin - {{ achievements }}</label></td>
                <td align="right"><a href="/download/achievements.bin"><div class="btn btn-sm btn-light">Download</div></a>
                <a href="/delete/achievements.bin"><div class="btn btn-sm btn-danger">Delete</div></a></td></table>
              </div>
            </div>
          </li>
        {% endif %}
      </ul>
    </div>
  </div>
  <div class="row">
    <div class="col-sm-8 col-md-6">
      <form method="POST" action="/settings/{{ username }}/" enctype="multipart/form-data" class="top-buffer">
        <h5 class="text-shadow">Upload profile / achievements</h5>
        <div class="row">
          <div class="col-md-12">
            <input type="file" name="file" class="form-control-file text-shadow" />
          </div>
        </div>
        <div class="row">
          <div class="col-md-12 top-buffer">
            <input type="submit" value="Upload" class="btn btn-sm btn-light"/>
          </div>
        </div>
      </form>
      {% with messages = get_flashed_messages() %}
        {% if messages %}
          <ul class="list-group top-buffer">
          {% for message in messages %}
            <li class="list-group-item">
              <div class="text-shadow">{{ message }}</div>
            </li>
          {% endfor %}
          </ul>
        {% endif %}
      {% endwith %}
    </div>
  </div>
{% endblock %}
