{% extends "base.html" %}
{% block content %}
<h2 class="sub-header">Pipeline runs</h2>
<div class="table-responsive">
<table id="pipeline_table" data-toggle="table" class="table table-striped" data-pagination="true" data-page-list="[50, 100, 1000, 2000]" data-smart-display=True data-page-size=50 data-search="true">
  <thead>
    <tr>
		<th data-sortable="true">ID</th>
		<th data-sortable="true">Name</th>
		<th>Description</th>
		<th data-sortable="true">Create date</th>
		<th>Executer</th>
		<th data-sortable="true">Status</th>
		<th>Action</th>
    </tr>
  </thead>
  <tbody>
  {% for pipeline in pipelines %}
    <tr>
		<td>{{ pipeline.id }}.</td>
		<td><a href="{{ url_for('pipeline', pipeline_id=pipeline.id)  }}">{{ pipeline.name }}</a></td>
		<td>{{ pipeline.description }}</td>
		<td>{{ pipeline.create_date }}</td>
		<td>{{ pipeline.executer }}</td>
		<td>
		{% if pipeline.status == "FINISHED" %}
			<button class="btn btn-success btn-block">{{ pipeline.status }}</button>
		{% elif pipeline.status == "RUNNING" %}
			<button class="btn btn-warning btn-block">{{ pipeline.status }}</button>
		{% elif pipeline.status == "FAILED" %}
			<button class="btn btn-danger btn-block">{{ pipeline.status }}</button>
		{% elif pipeline.status == "SUSPENDED" %}
			<button class="btn btn-default btn-block">{{ pipeline.status }}</button>
		{% elif pipeline.status == "IDLE" %}
			<button class="btn btn-info btn-block">{{ pipeline.status }}</button>
		{% else %}
		 <button class="btn btn-default btn-block">{{ pipeline.status }}</button>
		{% endif %}
		</td>
		<td>
		<a href="{{ url_for('restart', pipeline_id=pipeline.id, stay_on_page=0)}}" onclick="return confirm('Do you really want ro restart job {{ pipeline.id }}?')"><span class="glyphicon glyphicon-repeat" aria-hidden="false" data-toggle="tooltip" data-placement="top"  title='RESTART. Sets the job status to "IDLE" and stops it if it is running.'></span></a>
		<a href="{{ url_for('restart_recursive', pipeline_id=pipeline.id, stay_on_page=0)}}" onclick="return confirm('Do you really want to recursively restart job {{ pipeline.id }}?')"><span class="glyphicon glyphicon-refresh" aria-hidden="true" data-toggle="tooltip" data-placement="top" title='RESTART RECURSIVE. Sets the job status to "IDLE" and stops it if it is running. Does the same to all jobs that depend directly or indirectly on this job'></span></a>
		<a href="{{ url_for('cancel', pipeline_id=pipeline.id, stay_on_page=0)}}" onclick="return confirm('Do you really want to cancel job {{ pipeline.id }}?')"><span class="glyphicon glyphicon-remove" aria-hidden="true" data-toggle="tooltip" data-placement="top" title='CANCEL. Sets the status of this job to "CANCELLED" and stops the job if it is running'></span></a>
		<a href="{{ url_for('delete', pipeline_id=pipeline.id, stay_on_page=0)}}" onclick="return confirm('Do you really want to finish job {{ pipeline.id }}?')"><span class="glyphicon glyphicon-stop" aria-hidden="true" data-toggle="tooltip" data-placement="top" title='FINISH. Sets the status of this job to "FINISHED". If the job is running, it does nothing.'></span></a>
		<a href="{{ url_for('delete', pipeline_id=pipeline.id, stay_on_page=0)}}" onclick="return confirm('Do you really want to delete job {{ pipeline.id }}?')"><span class="glyphicon glyphicon-trash" aria-hidden="true" data-toggle="tooltip" data-placement="top"  title="DELETE. Deletes the job from the database."></span></a>
		</td>
    </tr>
    {% endfor %}
  </tbody>
</table>
</div>

{% endblock %}
