{% extends "layout.html.j2" %}
{% block content %}
	{% include "basic_header.html.j2" %}
	<!-- Datasets -->
	<div class="row mt-4">
		<div class="col">
			<h3>
			Datasets
			<a href="/dataset/0"><button type="button" class="btn btn-sm btn-info">view all</button></a>
			</h3>
			<table id="table_datasets" class="table table-striped container-fluid">
				<thead class="thead-light">
					<tr>
						<th rowspan="2">name</th>
						<th rowspan="2" class="text-right">#genomes</th>
						<th colspan="2" class="text-center">#BGCs</th>
						<th rowspan="2">description</th>
					</tr>
					<tr>
						<th class="text-right">total</th>
						<th class="text-right">with taxonomy</th>
					</tr>
				</thead>
				<tbody class="tbody">
					{% for ds in datasets %}
						<tr>
							<td><a href="/dataset/{{ ds['id'] }}"><button type="button" class="btn btn-sm btn-info">{{ ds["name"] }}</button></a></td>
							<td class="text-right">{{ ds["count_genomes"] }}</td>
							<td class="text-right">{{ ds["count_bgcs"] }}</td>
							<td class="text-right">{{ ds["count_bgcs_with_taxonomy"] }}</td>
							<td>{{ ds["desc"] }}</td>
						</tr>
					{% endfor %}
				</tbody>
			</table>
		</div>
	</div>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#table_datasets").DataTable({
				searching: false,
				ordering:  false
			});
		});
	</script>
	<!-------------->
	<!-- Runs -->
	<div class="row mt-5">
		<div class="col">
			<h3>Runs</h3>
			<table id="table_runs" class="table table-striped container-fluid">
				<thead class="thead-light">
					<tr>
						<th>name</th>
						<th>started</th>
						<th>finished</th>
						<th>status</th>
						<th class="text-right">threshold</th>
						<th class="text-right">#BGCs</th>
						<th class="text-right">#GCFs</th>
					</tr>
				</thead>
				<tbody class="tbody">
					{% for rn in runs %}
						<tr>
							<td><a href="/run/{{ rn['id'] }}"><button type="button" class="btn btn-sm btn-info">{{ rn["name"] }}</button></a></td>
							<td>{{ rn["start"] }}</td>
							<td>
								{{ rn["finished"] }}
								{% if rn["resumes"]|length > 0 and rn["finished"] != "n/a" %}
									<a tabindex="0" href="javascript:void(0);" data-toggle="popover" data-trigger="hover" data-html="true" class="badge badge-info badge-pill ml-2" title="Note" data-content="
										This run was resumed {{ rn['resumes']|length }} time(s): <br/>
										<ul>
											{% for resumed in rn['resumes'] %}
												<li>{{ resumed }}</li>
											{% endfor %}
										</ul>
										">
										note
									</a>
								{% endif %}
							</td>
							<td>{{ rn["status"] }}</td>
							<td class="text-right">{{ rn["threshold"] }}</td>
							<td class="text-right">{{ rn["count_bgcs"] }}</td>
							<td class="text-right">{{ rn["count_gcfs"] }}</td>
						</tr>
					{% endfor %}
				</tbody>
			</table>
		</div>
	</div>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#table_runs").DataTable({
				searching: false,
				ordering:  false
			});
		});
	</script>
	<!-------------->
{% endblock %}