{% extends "layout.html" %}

{% block content %}
<ol class="breadcrumb">
  <li class="active"><strong>Playbook</strong>{% if playbook.path %}: "{{playbook.path}}"{% endif %}</li>
</ol>

<h2>Playbook information</h2>
<table class="summary table table-striped table-bordered table-hover table-condensed">
  <thead>
    <tr>
      <th>Start</th>
      <th>End</th>
      <th>Duration</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{ playbook.time_start }}</td>
      <td>{{ playbook.time_end }}</td>
      <td>{{ playbook.duration }}</td>
    </tr>
  </tbody>
</table>

<h2>Statistics</h2>
<table class="stats table table-striped table-bordered table-hover table-condensed">
  <thead>
    <tr>
      <th>Host</th>
      <th>Ok</th>
      <th>Changed</th>
      <th>Failed</th>
      <th>Skipped</th>
      <th>Unreachable</th>
    </tr>
  </thead>
  <tbody>
    {% for stat in playbook.stats %}
    <tr>
      <td>{{ macros.make_link('playbook_host', stat.host.name, playbook=playbook.id, host=stat.host.name) }}</td>
        {{ macros.statslink(stat, 'ok', playbook, stat.host) }}
        {{ macros.statslink(stat, 'changed', playbook, stat.host) }}
        {{ macros.statslink(stat, 'failed', playbook, stat.host) }}
        {{ macros.statslink(stat, 'skipped', playbook, stat.host) }}
        {{ macros.statslink(stat, 'unreachable', playbook, stat.host) }}
    </tr>
    {% endfor %}
  </tbody>
</table>

<h2>Plays</h2>
<table class="plays table table-striped table-bordered table-hover table-condensed">
  <thead>
    <tr>
      <th>Start</th>
      <th>End</th>
      <th>Duration</th>
      <th></th>
    </tr>
  </thead>

  <tbody>
    {% for play in playbook.plays.order_by('time_start') %}
    <tr>
      <td>{{ playbook.time_start |datetime }}</td>
      <td>{{ playbook.time_end |datetime }}</td>
      <td>{{ playbook.duration }}</td>
      <td>{{ macros.make_link('play', 'details', play=play.id) }}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>

<h2>Tasks</h2>
<table class="tasks table table-striped table-bordered table-hover table-condensed">
  <thead>
    <tr>
      <th>Start</th>
      <th>End</th>
      <th>Duration</th>
      <th>Action</th>
      <th>File</th>
      <th>Line</th>
      <th></th>
    </tr>
  </thead>

  <tbody>
    {% for task in playbook.tasks.order_by('time_start') %}
    <tr>
      <td>{{ task.time_start |datetime }}</td>
      <td>{{ task.time_end |datetime }}</td>
      <td>{{ task.duration }}</td>
      <td>{{ task.action }}</td>
      <td>{{ task.path }}</td>
      <td>{{ task.lineno }}</td>
      <td>{{ macros.make_link('task', 'details', task=task.id) }}
      </td>
    </tr>
    {% endfor %}
  </tbody>
</table>
{% endblock %}
