{% extends "master.html" %}

{% set active_page = "listMetrics" %}
{% set run = runlist.get_run(runId) %}


{% block moresidebar %}
</br>
<form name="MetricSelect" action="metricResults" method="get" >
<input type="hidden" name="runId" value="{{runId}}">
<center><input id='mybutton' type='submit' value='Plot Metrics'></center>
</br>
<ul>
{% for g in run.groups.keys() %}
  <li>
  <a href="#{{g|escape}}"> {{g|escape}}</a> </br>
  {% for sg in run.groups[g] %}
    <div id='smallindent'><a href="#{{g|escape}}_{{sg|escape}}">{{sg|escape}}</a></div>
 {% endfor %}
 </li>
{% endfor %}
</ul>
</br>
<center><input id='mybutton' type='submit' value='Plot Metrics'></center>
</br>
{% endblock %}


{% block content %}

<table>

{% set metricInfo = run.metric_info(with_data_link=False) %}
{% set mInfoLen = metricInfo|length  %}

<tr>
<th> </th>
{% for key in metricInfo %}
  <th> {{ key }} </th>
{% endfor %}

<tr>

{% for group in run.groups %}
  {% set groupstart = True %}
  {% for subgroup in run.groups[group] %}
      <tr class="lightestgray">
	<td>
	  <input type='checkbox' name="Group_subgroup"
  value="{{ group|escape }}__{{ subgroup|escape }}">
	</td>
	<td colspan={{mInfoLen}}>
	{% if groupstart == True %}
	  <a name="{{group}}"></a>
	  {% set groupstart = False %}
	{% endif %}
	  <a name="{{group|escape}}_{{subgroup|escape}}">All  Group: <em>{{group|escape
    }}</em>;   Subgroup: <em>{{ subgroup|escape }}</em></a>
	 </td>
        </tr>
       {% set metrics = run.metrics_in_subgroup(group, subgroup) %}
        {% for metric in metrics %}
          {% set metricInfo = run.metric_info(metric, with_data_link=False) %}
          <tr>
	  <td>
          <input type='checkbox' name="metric_id" value="{{metric['metric_id']}}">
	  </td>
	  {% for key in metricInfo %}
           <td>
	   {% if key == 'Data' %}
	       <a href="getData?datatype=npz&runId={{runId}}&metricId={{metric['metric_id']}}">npz</a>
	       <a href="getData?datatype=json&runId={{runId}}&metricId={{metric['metric_id']}}">JSON</a>
	   {% else %}
            {{ metricInfo[key]|escape }}
           {% endif %}
	   </td>
	  {% endfor %} {# end of for key in metricInfo #}
	  </tr>
	{% endfor %} {# End of metrics #}
    {% endfor %}  {# End of subgroup #}
 {% endfor %}  {# End of group #}
<tr>
<td> </td>
</td>
</tr>

</table>

</form>

{% endblock %}
