{% extends "./layout.html" %}
{% block content %}
  <h1><div class="text-shadow">Zwift Launcher</div></h1>
  {% if username != "zoffline" %}
    <h4 class="text-shadow">Logged in as {{ username }}</h4>
  {% endif %}
  {% if restarting %}
    <div class="row">
      <div class="col-sm-6 col-md-5">
        <p class="alert alert-info">Server is restarting in {{ restarting_in_minutes }} minutes</p>
      </div>
    </div>
  {% endif %}
  <div class="row">
    <div class="col-md-12">
      <a href="{{ url_for('settings', username=username) }}" class="btn btn-sm btn-secondary">Settings</a>
      {% if is_admin %}
        {% if not restarting %}
          <a href="/restart" class="btn btn-sm btn-danger">Restart server</a>
        {% else %}
          <a href="/cancelrestart" class="btn btn-sm btn-danger">Cancel restart</a>
        {% endif %}
        <a href="/reloadbots" class="btn btn-sm btn-warning">Reload bots</a>
      {% endif %}
      {% if username != "zoffline" %}
        <a href="{{ url_for('logout', username=username) }}" class="btn btn-sm btn-secondary">Logout</a>
      {% endif %}
    </div>
  </div>
  <div class="row">
    <div class="col-sm-6 col-md-5">
      <form method="POST" action="/start-zwift" class="top-buffer">
        <div class="row">
          <div class="col-md-12">
            <label class="text-shadow">Map</label>
            <select name="map" class="form-control form-control-sm">
              <option value="CALENDAR">Calendar{% if online.total > 0 %} ({{online.total}} online total){% endif %}</option>
              <option value="LONDON">London / Yorkshire{% if online.london + online.yorkshire > 0 %} ({{online.london + online.yorkshire}} online){% endif %}</option>
              <option value="MAKURIISLANDS">Makuri Islands / NYC{% if online.makuriislands + online.newyork > 0 %} ({{online.makuriislands + online.newyork}} online){% endif %}</option>
              <option value="FRANCE">France / Paris{% if online.france + online.paris > 0 %} ({{online.france + online.paris}} online){% endif %}</option>
              <option value="RICHMOND">Richmond / London{% if online.richmond + online.london > 0 %} ({{online.richmond + online.london}} online){% endif %}</option>
              <option value="INNSBRUCK">Innsbruck / Richmond{% if online.innsbruck + online.richmond > 0 %} ({{online.innsbruck + online.richmond}} online){% endif %}</option>
              <option value="SCOTLAND">Scotland / Makuri Islands{% if online.scotland + online.makuriislands > 0 %} ({{online.scotland + online.makuriislands}} online){% endif %}</option>
            </select>
          </div>
        </div>
        <div class="row">
          <div class="col-md-12 top-buffer">
            <label class="text-shadow">Climb</label>
            <select name="climb" class="form-control form-control-sm">
              <option value="CALENDAR">Calendar</option>
              {% for climb in climbs %}
                <option value="{{ climb['road'] }}">{{ climb['name'] }}</option>
              {% endfor %}
            </select>
          </div>
        </div>
        <div class="row">
          <div class="col-md-12 top-buffer">
            <div class="form-check">
              <input class="form-check-input" type="checkbox" {{'checked' if enable_ghosts else ''}} id="enableghosts" name="enableghosts">
              <label class="form-check-label text-shadow" for="enableghosts">
                Enable ghosts
              </label>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-md-12 top-buffer">
            <input type="submit" value="Start Zwift" 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 %}
