<body data-spy="scroll" data-target=".topbar" data-offset="90">
<div class="topbar navbar navbar-fixed-top navbar-inverse">
  <div class="navbar-inner">
   <div class="container">
    <div class="topbar-content">

    <a class="brand" href="https://github.com/linkedin/naarad">naarad</a>

    <ul class="nav">
        {% if summary_enabled %}
        <li>
            <a href="summary_report.html" title="Summary">
                <span>Summary</span>
            </a>
        </li>
        {% endif %}
        <li class="active dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                <span>Metrics</span>
                <b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
                {%- for metric_name in metric_list %}
                <li>
                    <a href="{{ metric_name.label }}_report.html">
                        <span>{{ metric_name.label }}</span>
                    </a>
                </li>
                {%- endfor %}
            </ul>
        </li>
        <li><a href="report.html"><span>Chart</span></a></li>
    </ul>
    </div><!-- /topbar-content -->
   </div><!-- /container -->
 </div><!-- /topbar-inner -->
</div><!-- /topbar -->
<div class="container">
  <div class="content">
    <div id="{{ metric.label }}-header" class="row">
        <div id="{{ metric.label }}-header-span" class="span12">
            <h2 class="content-title">
                <span class="text">{{ metric.label }}</span>
            </h2>
        </div>
    </div>
    {%- if metric.sla_list|length > 0 %}
    <div id="{{ metric.label }}-sla-table" class="row">
        <div id="{{ metric.label }}-sla-table-span" class="span12">
            <h3>SLA Summary</h3>
            <div style="overflow-x:auto;">
                <table class="table table-hover table-striped table-bordered sortable">
                    <thead>
                        <tr>
                            <th>metric</th>
                            <th>sub_metric</th>
                            <th>sla rule</th>
                            <th>value</th>
                        </tr>
                    </thead>
                    <tbody>
                        {%- for sla in metric.sla_list %}
                        {%- if sla.sla_passed == True %}
                        <tr class="success">
                        {%- elif sla.sla_passed == False %}
                        <tr class="danger">
                        {%- else %}
                        <tr>
                        {%- endif %}
                            <td>{{ sla.metric }}</td>
                            <td>{{ sla.sub_metric }}</td>
                            <td>{{ sla.stat_name }} {{ sla.sla_type }} {{ sla.threshold}}</td>
                            <td>{{ sla.stat_value }}</td>
                        </tr>
                        {%- endfor %}
                    </tbody>
                    <tfoot></tfoot>
                </table>
            </div>
        </div>
    </div>
    {%- endif %}

    {%- if metric.summary_stats|length %}
    <div id="{{ metric.label }}-summary-table" class="row">
        <div id="{{ metric.label }}-summary-table-span" class="span12">
        <h3>Metric Summary</h3>
        <div style="overflow-x:auto;">
        <table class="table table-hover table-striped table-bordered sortable">
            <thead>
                <tr>
                    <th>sub_metric</th>
                    {%- for header in metric.summary_stats[metric.summary_stats.keys()[0]].keys()|sort %}
                    <th>{{ header }}</th>
                    {%- endfor %}
                </tr>
            </thead>
            <tbody>
                {%- for sub_metric in metric.summary_stats.keys() %}
                    <tr>
                        <td>{{ sub_metric }}</td>
                    {%- for stat in metric.summary_stats[sub_metric]|sort %}
                        {%- if sub_metric in metric.sla_map.keys() %}
                            {%- if stat in metric.sla_map[sub_metric].keys() %}
                                {%- if metric.sla_map[sub_metric][stat].sla_passed == True %}
                                    <td class="success" title="{{ metric.sla_map[sub_metric][stat].stat_name }} {{ metric.sla_map[sub_metric][stat].sla_type }} {{ metric.sla_map[sub_metric][stat].threshold}}">{{ metric.summary_stats[sub_metric][stat] }}</td>
                                {%- elif metric.sla_map[sub_metric][stat].sla_passed == False %}
                                    <td class="danger" title="{{ metric.sla_map[sub_metric][stat].stat_name }} {{ metric.sla_map[sub_metric][stat].sla_type }} {{ metric.sla_map[sub_metric][stat].threshold}}">{{ metric.summary_stats[sub_metric][stat] }}</td>
                                {%- else %}
                                    <td>{{ metric.summary_stats[sub_metric][stat] }}</td>
                                {%- endif %}
                            {%- else %}
                                <td>{{ metric.summary_stats[sub_metric][stat] }}</td>
                            {%- endif %}
                        {%- else %}
                            <td>{{ metric.summary_stats[sub_metric][stat] }}</td>
                        {%- endif %}
                    {%- endfor %}
                    </tr>
                {%- endfor %}
            </tbody>
            <tfoot></tfoot>
        </table>
        </div>
      </div>
    </div>
    {%- endif %}

    {%- if plot_div_content %}
    <div id="{{ metric }}-metric-plots" class="row">
      <div id="{{ metric }}-metric-plots-span" class="span12">
    <h3>Metric Plots</h3>
    <p>
        {{ plot_div_content }}
    </p>
    </div>
    </div>
    {%- endif %}

    </div>
</div>
