{% 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 href="{% url 'admin:mini_buildd_remote_changelist' %}"><img class="mbd-icon" src="{% static 'icons/categories/preferences-other.svg' %}" alt="Configure" title="Remotes"></a></li>
{% endblock %}

{% block content %}
	<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 class="{% mbd_cssmap 'model_status' builder.remote.get_status_display %}" title="{{ builder.remote.mbd_get_status_display }}">
						{% if builder.ourselves %}
							{% mbd_get mbd.mdls.chroot.Chroot.mbd_attention as attention %}
							<span class="{{ attention|yesno:"mbd-attention," }}" title="{{ attention|join:"&#10;" }}">Ourselves (chroots)</span>
						{% else %}
							<a class="{{ builder.remote.mbd_needs_attention|yesno:"mbd-attention," }}" href="{{ builder.remote.mbd_url }}/mini_buildd/builders/">{{ builder.remote }}➚</a>
						{% endif %}
					</td>
					<td>
						<code>{{ builder.status.incoming_url }}</code>
					</td>
					<td>
						{% if builder.status is None %}
							<strong class="mbd-warning">Service not available</strong>: {{ builder.exception }}
						{% elif builder.status.load < 0 %}
							<strong class="mbd-notice">Powered Off</strong>
						{% else %}
							<strong class="mbd-success" title="Chroots: {{ builder.status.chroots|join:', ' }}">Accepting (load {{ builder.status.load }})</strong>
						{% endif %}
					</td>
					<td>
						<nav>
							<ul>
								{% if builder.ourselves %}
									<li>{% mbd_api_popup "status" %}</li>
									<li>{% mbd_api_popup "remake_chroots" %}</li>
									<li><a href="{% url 'admin:mini_buildd_chroot_changelist' %}"><img class="mbd-icon" src="{% static 'icons/categories/preferences-other.svg' %}" alt="Configure chroots" title="Configure chroots"></a></li>
								{% else %}
									<li><a href="{{ builder.remote.mbd_url }}{{ mbd.config.URIS.api.view }}status/?output=page">status➚</a></li>
									<li>{% mbd_api_popup "wake" value_remote=builder.remote.http %}</li>
									<li><a href="{% url 'admin:mini_buildd_remote_change' builder.remote.pk %}"><img class="mbd-icon" src="{% static 'icons/categories/preferences-other.svg' %}" alt="Configure remote" title="Configure remote"></a></li>
								{% endif %}
							</ul>
						</nav>
					</td>
				</tr>
			{% endfor %}
		</tbody>
	</table>
{% endblock %}
