{% extends "mini_buildd/base.html" %}
{% block title %}{% block titledup %}{{ route|title }}{% endblock %}{% endblock %}
{% block tooltip %}{{ view.mbd_builders|length }} builders{% endblock %}
{% block menu %}
	<li><a class="mbd-icon" href="{% url 'admin:mini_buildd_chroot_changelist' %}"><img class="mbd-icon" src="{% static 'icons/configure-chroots.svg' %}" alt="Configure chroots" title="Configure chroots"></a></li>
	<li><a class="mbd-icon" href="{% url 'admin:mini_buildd_remote_changelist' %}"><img class="mbd-icon" src="{% static 'icons/configure-remotes.svg' %}" alt="Configure remotes" title="Configure remotes"></a></li>
{% endblock %}

{% block content %}
	{% if view.mbd_check %}<section class="mbd-notice"><strong>Remotes re-checked</strong> (logged-in as <em>staff</em> user).</section>{% endif %}

	<table id="mbd-builders-table" style="width: 100%;">
		{% mbd_datatable "mbd-builders-table" %}
		<thead>
			<tr>
				<th>Remote</th>
				<th>Incoming</th>
				<th>Status</th>
				<th>Actions</th>
			</tr>
		</thead>
		<tbody>
			{% for builder in view.mbd_builders %}
				<tr>
					<td>
						{% if builder.ourselves %}
							<span class="mbd-table-remote">Ourselves (chroots)</span>
						{% else %}
							<a href="{{ builder.remote.mbd_url }}/mini_buildd/builders/"><span class="mbd-table-remote">{{ builder.remote }}➚</span></a>
						{% endif %}
					</td>
					<td>
						<code>{{ builder.status.incoming_url }}</code>
					</td>
					<td>
						{% if builder.status is None %}
							<strong class="mbd-warning" title="{{ builder.exception }}" >Service not available</strong>
						{% elif builder.status.load < 0 %}
							<strong class="mbd-notice">Stopped</strong>
						{% else %}
							<strong class="mbd-model-status-{{ builder.remote.get_status_display }}" title="Chroots: {{ builder.status.chroots|join:', ' }}">{{ builder.remote.get_status_display }} (load {{ builder.status.load }})</strong>
						{% endif %}
					</td>
					<td>
						<nav>
							<ul>
								{% if builder.ourselves %}
									<li>{% mbd_api "remake_chroots" %}</li>
								{% else %}
									<li>{% mbd_api "wake" value_remote=builder.remote.http %}</li>
								{% endif %}
							</ul>
						</nav>
					</td>
				</tr>
			{% endfor %}
		</tbody>
	</table>
{% endblock %}
