{% extends "base.html" %}

{% set active_page = "Database" %}



{% block head %}
	{# jstree import #}
    <script src="{{ url_for('static', filename='web_js/jstree/dist/jstree.min.js') }}"></script>
    <link rel="stylesheet" href="{{ url_for('static', filename='web_js/jstree/dist/themes/default/style.min.css') }}" />
{% endblock %}


{% block body %}

<table class="table table-bordered mt-4">
	<thead>
		<tr>
			<th>Firmware</th>
			{% for uid in uid_list %}
				<th>{{ result['general']['hid'][uid] }}</th>
			{% endfor %}
		</tr>
	</thead>
	<tbody>
	
	{# --- general information --- #}
		<tr>
			<th colspan="{{ uid_list | length + 1 }}" class="table-head-light" style="text-align:center;">General information</th>
		</tr>
		{% for feature in result['general'] | sort %}
            {% if feature != 'hid' %}
                <tr>
                    <td width="150px"> {{ feature | replace_underscore }} </td>
                    {% if result['general'][feature] | all_items_equal %}
                        <td colspan="{{ uid_list | length }}" class="text-center text-success">
                            {% if feature == "size"%}
                                {{ result['general'][feature][uid_list[0]] | number_format }}
                            {% else %}
                                {{ result['general'][feature][uid_list[0]] | list_group | replace_uid_with_hid | safe }}
                            {% endif %}
                        </td>
                    {% else %}
                        {% for uid in uid_list %}
                            <td>
                                {% if feature == "size"%}
                                    {{ result['general'][feature][uid] | number_format }}
                                {% else %}
                                    {{ result['general'][feature][uid] | list_group | replace_uid_with_hid | safe }}
                                {% endif %}
                                </td>
                        {% endfor %}
                    {% endif %}
                </tr>
            {% endif %}
		{% endfor %}
		
		{# --- plugin results --- #}
		
		{% for plugin in result['plugins'] | sort %}
		<tr>
			<th colspan="{{ uid_list | length  + 1 }}" class="table-head-light" style="text-align:center;">{{ plugin | replace_underscore }}</th>
		</tr>
            {% if plugin in plugins_without_view %}

                {# plugins without separate view #}
                {% for feature in result['plugins'][plugin] | sort %}
                    <tr>
                        <td>{{ feature | replace_underscore }}</td>

                        {# --- all case --- #}
                        {% if 'all' in result['plugins'][plugin][feature] %}
                            {% if result['plugins'][plugin][feature]['collapse'] %}
                                <td colspan="{{ uid_list | length }}">
                                    {{ result['plugins'][plugin][feature]['all'] | list_group_collapse('success') | uids_to_link | replace_uid_with_file_name | safe  }}
                                </td>
                            {% else %}
                                {{ result['plugins'][plugin][feature]['all'] | list_group | uids_to_link | replace_uid_with_file_name | safe  }}
                            {% endif %}

                        {# --- individual results --- #}
                        {% else %}
                            {% for uid in uid_list %}
                                <td>
                                {% if result['plugins'][plugin][feature]['collapse'] %}
                                    {{ result['plugins'][plugin][feature][uid] | list_group_collapse('warning') | uids_to_link(root_uid=uid) | replace_uid_with_file_name | safe }}
                                {% else %}
                                    {{ result['plugins'][plugin][feature][uid] | list_group | uids_to_link(root_uid=uid) | replace_uid_with_file_name | safe }}
                                {% endif %}
                                </td>
                            {% endfor %}
                        {% endif %}
                    </tr>
                {% endfor %}


            {# individual plugin views #}

            {% endif %}
		{% endfor %}
		
	</tbody>
</table>


{% endblock %}
