{% extends "layout.html" %}

{% block content %}
<!-- Header container -->
<div class="container-fluid container-pf-nav-pf-vertical container-pf-nav-pf-vertical-with-secondary">
  <div class="row">
    <div class="col-xs-12 col-sm-6 col-md-10 col-md-offset-1">
      <h1><strong>Task</strong>{% if task.name %}: {{ task.name }}{% endif %}</h1>
      <h2>{{ task.time_start |datefmt }} <span class="fa fa-angle-double-right"></span> {{ task.time_end |datefmt }}</h2>
    </div>
  </div>
</div>
<!-- Dashboard container -->
<div class="container-fluid container-cards-pf container-pf-nav-pf-vertical container-pf-nav-pf-vertical-with-secondary">
  <div class="row row-cards-pf">
    <div class="col-xs-12 col-sm-6 col-md-2 col-md-offset-1">
      <div class="card-pf card-pf-accented card-pf-aggregate-status card-pf-aggregate-status-mini" style="height: 59px;">
        <h2 class="card-pf-title" style="height: 42px;">
          <span class="pficon pficon-server"></span>
          <span class="card-pf-aggregate-status-count">{{ playbook.hosts.count() }}</span> <strong>Hosts</strong>
        </h2>
      </div>
    </div>

    {% if task.file %}
    <div class="col-xs-12 col-sm-6 col-md-2">
      <div class="card-pf card-pf-accented card-pf-aggregate-status card-pf-aggregate-status-mini" style="height: 59px;">
        <h2 class="card-pf-title" style="height: 42px;">
          <span class="pficon pficon-folder-open"></span>
          <span class="card-pf-aggregate-status-count">
              {{ macros.make_link('file.show_file', task.file.path |pathtruncate(15), file_=task.file.id) }}
          </span> <strong>File</strong>
        </h2>
      </div>
    </div>

    <div class="col-xs-12 col-sm-6 col-md-2">
      <div class="card-pf card-pf-accented card-pf-aggregate-status card-pf-aggregate-status-mini" style="height: 59px;">
        <h2 class="card-pf-title" style="height: 42px;">
          <span class="fa fa-search"></span>
          <span class="card-pf-aggregate-status-count">
              {{ macros.make_link('file.show_file', task.lineno, file_=task.file.id, _anchor="line-" ~ task.lineno) }}
          </span> <strong>File line</strong>
        </h2>
      </div>
    </div>
    {% endif %}

    <div class="col-xs-12 col-sm-6 col-md-2">
      <div class="card-pf card-pf-accented card-pf-aggregate-status card-pf-aggregate-status-mini" style="height: 59px;">
        <h2 class="card-pf-title" style="height: 42px;">
          <span class="fa pficon-info"></span>
          <span class="card-pf-aggregate-status-count">{{ task.action }}</span> <strong>Action</strong>
        </h2>
      </div>
    </div>

    <div class="col-xs-12 col-sm-6 col-md-2">
      <div class="card-pf card-pf-accented card-pf-aggregate-status card-pf-aggregate-status-mini" style="height: 59px;">
        <h2 class="card-pf-title" style="height: 42px;">
          <span class="fa fa-clock-o"></span>
          <span class="card-pf-aggregate-status-count">{{ task.duration |timefmt }}</span> <strong>Duration</strong>
        </h2>
      </div>
    </div>
  </div>
</div>
<!-- Detail container -->
<div class="container-fluid container-pf-nav-pf-vertical container-pf-nav-pf-vertical-with-secondary">
  <div class="row">
    <div class="col-xs-12 col-sm-6 col-md-10 col-md-offset-1">
      <h2><strong>Task Results</strong></h2>
      <table class="results table table-striped table-bordered table-hover table-condensed">
        <thead>
          <tr>
            <th>Start</th>
            <th>End</th>
            <th>Duration</th>
            <th>Host</th>
            <th>Status</th>
            <th></th>
          </tr>
        </thead>

        <tbody>
          {% for result in task_results %}
          {% set status = result.derived_status %}
          <tr>
            <td>{{ result.time_start |datefmt }}</td>
            <td>{{ result.time_end |datefmt }}</td>
            <td>{{ result.duration |timefmt }}</td>
            <td>{{ macros.make_link('host.show_host', result.host.name,
              id=result.host.id) }}</td>
            <td><span class="{{ status }} label status-label">{{ status |upper }}</span></td>
            <td>{{ macros.make_link('result.show_result', 'details', task_result=result.id) }}</td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
</div>
{% endblock %}