{% extends "report_base.html" %}
{% block content %}

{% macro indiv_wl_report(item, id) -%}
{% set indiv_id = id | replace(".", "_")%}
{{macros.merging_statistics(item['scaling_tables'], item['xtriage_output'], indiv_id)}}
<div>
    <h2>Analysis plots</h2>
    <div class="panel-group">
        {{ macros.panel('Analysis by resolution', 'resolution_plots_'+ indiv_id, item['resolution_plots']) }}
        {{ macros.panel('Unit cell plots', 'unit_cell_plots_'+ indiv_id, item['unit_cell_plots']) }}
        {{ macros.panel('Miscellaneous plots', 'misc_plots_'+ indiv_id, item['misc_plots']) }}
    </div>
</div>

{%- endmacro %}


<div class="container-fluid">

    <div class="page-header">
        <h1>{{ page_title }}</h1>
    </div>

    {% if multi_data %}

        <ul class="nav nav-tabs">
            <li class="active"><a data-toggle="tab" data-target="#home">Summary</a></li>

            {% for wl, item in individual_reports.items() %}
                <li><a data-toggle="tab" data-target="#dataset_{{ wl | replace(".", "_")}}">Wavelength {{ wl }} &#8491 </a></li>
            {% endfor %}

        </ul>

        <div class="tab-content">

            <div id="home" class="tab-pane in active">
                <h2>Merging statistics</h2>
                <div id="multi" class="panel-group" >
                    <div class="panel panel-default">
                        <div class="panel-heading" data-toggle="collapse" data-target="#collapse_overall_summary">
                            <h4 class="panel-title">
                                <a>Overall</a>
                            </h4>
                        </div>
                        <div id="collapse_overall_summary" class="panel-collapse collapse in">
                            <div class="panel-body">
                                <div style="width: 800px">
                                    {{ macros.table(multi_data["overall_summary"],
                                                    has_column_header=true,
                                                    has_row_header=true) }}
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>


            {% for wl, item in individual_reports.items() %}
            <div id="dataset_{{ wl | replace(".", "_")}}" class="tab-pane">
                {{indiv_wl_report(item, wl)}}
            </div>
            {% endfor %}

        </div>

    {% else %}
        <div id="home">
            {% for wl, item in individual_reports.items() %} {# note just one item in the dict #}
            {{indiv_wl_report(item, wl)}}
            {% endfor %}
        </div>

    {% endif %}

</div>

{% endblock %}
