{% extends "template.html" %}
{% block content %}

<h1> Setup </h1>
<p>Here you can setup the luniebox or restart services when having issues.</p>

<div class="row">
  {% if model['setup']: %}
  <div class="col col-xs-12 col-md-6 col-lg-6 col-xl-6 mt-3">
    <div class="card">
      <div class="card-body">
        <a href="{{ url_for('api.restart_spotifyd') }}" class="btn btn-primary">Restart spotifyd</a>
        <a href="{{ url_for('api.daemon_start') }}" class="btn btn-secondary">Start daemon</a>
        <a href="{{ url_for('api.daemon_stop') }}" class="btn btn-warning">Stop daemon</a>
      </div>
    </div>
  </div>
  {% endif %}
  <div class="col col-xs-12 col-md-6 col-lg-6 col-xl-6 mt-3">
    {% if model['setup']: %}
    <div class="my-3 alert alert-warning">
      Already set-up! On changes you may need to restart spotifyd service.
    </div>
    {% endif %}
    <form method="POST" action="{{ url_for('api.setup') }}">
      <div class="mb-3">
        <label for="spotify-device-name" class="form-label">Spotify Device Name</label>
        <input type="text" class="form-control" id="spotify-device-name" name="spotify-device-name" required
          value="{{'' if not model['device-name'] else '' + model['device-name'] }}">
      </div>
      <div class="mb-3">
        <label for="spotify-username" class="form-label">Spotify Username</label>
        <input type="text" class="form-control" id="spotify-username" name="spotify-username" required
          value="{{'' if not model['username'] else '' + model['username'] }}">
      </div>
      <div class="mb-3">
        <label for="spotify-password" class="form-label">Spotify Password</label>
        <input type="password" class="form-control" id="spotify-password" name="spotify-password" required
          value="{{'' if not model['password'] else '' + model['password'] }}">
      </div>
      <div class="mb-3">
        <label for="spotify-client-id" class="form-label">Spotify Client Id</label>
        <input type="text" class="form-control" id="spotify-client-id" name="spotify-client-id" required
          value="{{'' if not model['client-id'] else '' + model['client-id'] }}">
      </div>
      <div class="mb-3">
        <label for="spotify-client-secret" class="form-label">Spotify Client Secret</label>
        <input type="text" class="form-control" id="spotify-client-secret" name="spotify-client-secret" required
          value="{{'' if not model['client-secret'] else '' + model['client-secret'] }}">
      </div>
      <div class="mb-3">
        <label for="spotify-redirect-uri" class="form-label">Spotify Redirect Uri</label>
        <input type="text" class="form-control" id="spotify-redirect-uri" name="spotify-redirect-uri"
          value="{{'' if not model['redirect-uri'] else '' + model['redirect-uri'] }}">
      </div>
      <button type="submit" class="btn btn-primary">Setup</button>
    </form>
  </div>
</div>
{% endblock %}