{% 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 %}
							{% mbd_token as cronlog_table_id %}
							<table id="{{ cronlog_table_id }}">
								{% mbd_datatable cronlog_table_id info='false' %}
								<thead>
									<tr>
										<th>Log</th>
									</tr>
								</thead>
								<tbody>
									{% for msg in job.log %}
										<tr>
											<td class="mbd-{% if msg.0 == 'E' %}error{% else %}info{% endif %}">{{ msg }}</td>
										</tr>
									{% endfor %}
								</tbody>
							</table>
						</details>
					</td>
					<td>
						<nav>
							<ul>
								<li>{% mbd_api_popup "cronjob" value_id=job.id %}</li>
							</ul>
						</nav>
					</td>
				</tr>
			{% endfor %}
		</tbody>
	</table>
{% endblock %}
