{% extends "base_objectbrowser.html" %}

{% load i18n %}

{% block title %}{% trans "Configuration Health" %}{% endblock %}
{% block smallheader %}{% trans "config" %}{% endblock %}
{% block largeheader %}{% trans "Health" %}{% endblock %}
{% block content %}

<h4>Sanity checks</h4>
{% if booleans %}
<table class="table table-condensed">
	<tr>
		<th>{% trans "Check" %}</th>
		<th>{% trans "Status" %}</th>
	</tr>
{% for k,v in booleans.items %}
	<tr>
		<td>{{ k }}</td>
		<td class="{% if v %}{% trans "ok" %}{% else %}{% trans "warning" %}{% endif %}">{{ v }}</td>
	</tr>
{% endfor %}
{% endif %}
</table>

{% if object_health %}
<div>
    <hr>
	<h4>{% trans "Object Health" %}</h4>
	<table class="table table-condensed">
	<tr>
		<th>{% trans "Description" %}</th>
		<th>{% trans "Count" %}</th>
	</tr>
	{% for k,v in object_health.items %}
		<tr>
			<td><a href="?show={{ k }}">{{ k }}</a></td>
			<td>{{ v|length }}</td>
		</tr>
	{% endfor %}
    </table>
</div>
{% endif %}

{% if parser_errors %}
<!-- Display a list of config errors -->
<div>
    <hr>
       <h4>{% trans "Parser Errors" %}</h4>
<table class="table table-condensed">
	<tr>
        <th>{% trans "Error" %}</th>
        <th>{% trans "Item" %}</th>
		<th>{% trans "Filename" %}</th>
		<th colspan=3>{% trans "Actions" %}</th>

	</tr>
{% for i in parser_errors %}
	<tr>
        <td>{{ i.message }}</td>
        <td>
            {% if i.model %}
                <a title="{{ i.model }}" href="{% url "adagios.objectbrowser.views.edit_object" i.model.id %}">{{ i.item.meta.object_type }} {{ i.model.description }}</a>
            {% else %}
                n/a
            {% endif %}
        </td>
		<td><a href="{% url "adagios.objectbrowser.views.search_objects" %}?filename={{ i.filename }}">{{ i.filename }}</a></td>
		<td><a href="{% url "adagios.objectbrowser.views.delete_object" i.item %}">{% trans "Delete Object" %}</a> </td>
        <td> <a href="#">{% trans "Create Reference" %}</a></td>
        <td> <a href="#">{% trans "Manually Edit" %}</a> </td>
	</tr>
{% endfor %}
</table>
</div>
{% endif %}

{% endblock %}
