{% extends "./_base.html" %}

{% block block %}
<h3>Builder</h3>
<ul class="list-group">
  {% for i in range(free_slots) %}
    <li class="list-group-item">
      Empty slot
    </li>
  {% end %}

  {% for now, build in current_builds %}
    <li class="list-group-item">
      {{ build.project.name }}
      <a class="xhr pull-right" href="{{ reverse_url('ProjectBuildStop', build.project_id, build.build_id) }}"><i class="glyphicon glyphicon-remove"></i></a>
      <a class="badge" href="{{ reverse_url('ProjectLog', build.project.project_id, build.build_id) }}">{{ build.build_id }}</a>

        <div class="progress">
          <div class="progress-bar build-progress progress-bar-striped active" data-now="{{ now }}" data-end="{{ build.project.average_build_duration }}" style="width: {{ (100 * now / build.project.average_build_duration) if now else 0 }}%;">
          </div>
        </div>
    </li>
  {% end %}

  {% for task in server.builder.queue %}
    <li class="list-group-item">
      <a href="{{ reverse_url('ProjectView', task.project_id) }}">{{ task.name }}</a>
      <a class="xhr pull-right" href="{{ reverse_url('ProjectBuildStop', task.project_id, task.build_id) }}"><i class="glyphicon glyphicon-remove"></i></a>
      <span class="badge">{{ task.build_id }}</span>
    </li>
  {% end %}
</ul>
{% end %}
