{% extends "mini_buildd/includes/api/base.html" %}
{% block results %}
	<table id="mbd-setup-results-table" style="width: 100%;">
		{% mbd_datatable "mbd-setup-results-table" columns='[null, null, null, null, null, null, {"searchable": false, "orderable": false}]' %}
		<thead>
			<tr>
				<th>Instance</th>
				<th>Status</th>
				<th title="Deviations here most likely should be fixed (run ``setup`` with ``update`` option to auto-fix)">Diff from Setup (subject for update)</th>
				<th title="Deviations here are most likely harmless or intended -- for information only (if needed/wanted, please fixup manually)">Diff from Model (informational)</th>
				<th>Updated</th>
				<th>Created</th>
				<th>Menu</th>
			</tr>
		</thead>
		<tbody>
			{% for info in view.mbd_call.result %}
				<tr>
					<td><strong>{{ info.identity_str }}</strong></td>
					<td class="{% mbd_cssmap 'model_status' info.status %}"><strong>{{ info.status }}</strong></td>
					{% with msg=info.diff.setup.diff|yesno:'Setup differs,Setup matches' data=info.diff.setup %}
						<td data-search="{{ msg }}" class="{{ data.diff|yesno:'mbd-warning,mbd-success' }}" title="Fields compared: {{ data.fields }}">
							<details>
								<summary>{{ msg }}</summary>
								<pre>{{ data.diff|mbd_jsonpp }}</pre>
							</details>
						</td>
					{% endwith %}
					{% with msg=info.diff.model.diff|yesno:'Model differs,Model matches' data=info.diff.model %}
						<td data-search="{{ msg }}" class="{{ data.diff|yesno:'mbd-notice,mbd-success' }}" title="Fields compared: {{ data.fields }}">
							<details>
								<summary>{{ msg }}</summary>
								<pre>{{ data.diff|mbd_jsonpp }}</pre>
							</details>
						</td>
					{% endwith %}
					<td>{{ info.updated }}</td>
					<td>{{ info.created }}</td>
					<td>
						<nav>
							<ul>
								<li>{% mbd_api view.mbd_call name="update" value_update=info.identity_hash value_pca="" %}</li>
								<li>{% mbd_api view.mbd_call name="pca" value_update="" value_pca=info.identity_hash %}</li>
								<li>{% mbd_api view.mbd_call name="update+pca" value_update=info.identity_hash value_pca=info.identity_hash %}</li>
								{% if info.change_instance_url %}
									<li><a href="{% url info.change_instance_url info.change_instance_pk %}"><img class="mbd-icon" src="{% static 'icons/categories/preferences-other.svg' %}" alt="Configure instance" title="Configure instance"></a></li>
								{% endif %}
							</ul>
						</nav>
				</tr>
			{% endfor %}
		</tbody>
		<tfoot>
			<tr>
				<th colspan="4">
					<nav>
						<ul>
							<li>{% mbd_api view.mbd_call name="update all" value_update="all" value_pca="" %}</li>
							<li>{% mbd_api view.mbd_call name="pca all" value_update="" value_pca="all" %}</li>
							<li>{% mbd_api view.mbd_call name="update+pca all" value_update="all" value_pca="all" %}</li>
						</ul>
					</nav>
			</tr>
		</tfoot>
	</table>
{% endblock %}
