{% extends "mini_buildd/base.html" %}
{% load static %}
{% load mini_buildd_tags %}

{% block title %}mini-buildd{% endblock %}
{% block page_title %}{% mbd_title %}{% endblock %}
{% block page_sub_title %}
	{% if not daemon.is_busy %}
		{% if daemon.is_running %}
			{% mbd_api "stop" output="referer" %}
		{% else %}
			{% mbd_api "start" output="referer" %}
		{% endif %}
	{% endif %}
	<span class="status {% if daemon.is_busy %}busy{% elif daemon.is_running %}running{% else %}stopped{% endif %}">
		{% if daemon.is_busy %}Busy...{% elif daemon.is_running %}Running{% else %}Stopped{% endif %}: {{ daemon.model }}
	</span>
	<br />
{% endblock %}

{% block content %}
	<div>

		{% if not daemon.is_running %}
			{% mbd_api "autosetup" %}
		{% endif %}

		<details>
			<summary class="header">Events ({{ daemon.events|length }})</summary>
			{% include "includes/mbd_events.html" with events=daemon.events %}
		</details>

		<details>
			<summary class="header">Toolbox</summary>
			<div class="box">
				{% mbd_api "getkey" %}
				{% mbd_api "getdputconf" %}
				{% mbd_api "logcat" %}
				{% mbd_api "portext" %}
				{% mbd_api "keyringpackages" %}
				{% mbd_api "testpackages" %}
			</div>
		</details>

		<details>
			<summary class="header">Repositories ({{ repositories|length }})</summary>
			<div class="box">
				<ul>
					{% for r in repositories %}
						<li>
							<span class="status {{ r.get_status_display }}" title="{{ r.mbd_get_status_display }}">{{ r }}</span>
							(<a title="Go to repository overview page" href="/mini_buildd/repositories/{{ r.identity }}/">Overview</a>)
							{% if r.external_home_url %}
								(<a href="{{ r.external_home_url }}" title="Link to the repository's external documentation">ExtHome</a>)
							{% endif %}
						</li>
						{% empty %}
						<li>No repositories.</li>
					{% endfor %}
				</ul>
			</div>
		</details>

		<details>
			<summary class="header">Chroots ({{ chroots|length }})</summary>
			<div class="box">
				<ul>
					{% for c in chroots %}
						<li><span class="status {{ c.get_status_display }}" title="{{ c.mbd_get_status_display }}">{{ c }}</span></li>
						{% empty %}
						<li>No chroots.</li>
					{% endfor %}
				</ul>
			</div>
		</details>

		<details>
			<summary class="header">Remotes ({{ remotes|length }})</summary>
			<div class="box">
				<ul>
					{% for r in remotes %}
						<li>
							<span class="status {{ r.get_status_display }}" title="{{ r.mbd_get_status_display }}">{{ r }}</span>
							(<a title="Visit remote" href="{{ r.mbd_url }}">Visit</a>)
						</li>
						{% empty %}
						<li>No remotes.</li>
					{% endfor %}
				</ul>
			</div>
		</details>

		{% if daemon.packages.items %}
			<div class="box">
				<h1 class="box-caption">
					<img class="rotate" src="{% static "img/debian_swirl.svg" %}" alt="Packaging..." title="Packaging..." />
					Packaging ({{ daemon.packages|length }})</h1>
					{% include "includes/mbd_packaging.html" with packages=daemon.packages.values %}
			</div>
		{% endif %}

		{% if daemon.builds.items %}
			<div class="box">
				<h1 class="box-caption">
					<img class="rotate" src="{% static "img/debian_swirl.svg" %}" alt="Building..." title="Building..." />
					Building ({{ daemon.build_queue }})
				</h1>
				{% include "includes/mbd_building.html" with builds=daemon.builds.values %}
			</div>
		{% endif %}
	</div>
{% endblock %}
