{% extends "mini_buildd/base.html" %}
{% block title %}{% block titledup %}{{ route|title }}{% endblock %}{% endblock %}
{% block tooltip %}{{ mbd.daemon.crontab.jobs|length }} jobs in {{ route }}{% endblock %}

{% block content %}
	<table id="mbd-crontab-table" style="width: 100%;">
		{% mbd_datatable "mbd-crontab-table" order='[0, "asc"]' %}
		<thead>
			<tr>
				<th>Next Run</th>
				<th>Identity</th>
				<th>Description</th>
				<th>Log</th>
				<th>Menu</th>
			</tr>
		</thead>
		<tbody>
			{% for job in mbd.daemon.crontab.jobs %}
				<tr>
					<td class="mbd-localize-date" title="{{ job.next_run_utc|date:"r" }}" data-order="{{ job.next_run_utc|date:"U" }}">{{ job.next_run_utc|date:"r" }}</td>
					<td>{{ job.id }}</td>
					<td>{{ job.desc }}</td>
					<td>
						<details>
							{% with job.log|first as msg %}
								<summary class="mbd-{% if msg.0 == 'E' %}error{% else %}info{% endif %}">{{ job.log|length }} runs</summary>
							{% endwith %}
							<ol>
								{% for msg in job.log %}
									<li class="mbd-{% if msg.0 == 'E' %}error{% else %}info{% endif %}">{{ msg }}</li>
								{% endfor %}
							</ol>
						</details>
					</td>
					<td>
						<nav>
							<ul>
								<li>{% mbd_api "cronjob" value_id=job.id %}</li>
							</ul>
						</nav>
					</td>
				</tr>
			{% endfor %}
		</tbody>
	</table>
{% endblock %}
