<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">
        <li class="active">
            <a href="diff_report.html" title="Summary">
                <span>Summary</span>
            </a>
        </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 class="row">
      <div class="span12">
        <div id="sla failure summary" style="overflow-x:auto;">
          <h2 class="content-title">
            <span class="text">SLA Failure Summary</span>
          </h2>
          {%- if sla_failure_list %}
          <table id="table-diff-sla-failure" class="table table-bordered table-striped sortable">
            <caption>Summary of SLA Failures</caption>
            <thead>
              <tr>
                <th>metric</th>
                <th>sub_metric</th>
                <th>sla_rule</th>
                <th>Baseline Value</th>
                <th>Current Value</th>
                <th>Diff</th>
              </tr>
            </thead>
            <tbody>
              {%- for sla_failure in sla_failure_list %}
              {%- if sla_failure.sla.sla_passed == True %}
              <tr class="success">
              {%- elif sla_failure.sla.sla_passed == False %}
              <tr class="danger">
              {%- else %}
              <tr>
              {%- endif %}
                <td>{{sla_failure.sla.metric}}</td>
                <td>{{sla_failure.sla.sub_metric}}</td>
                <td>{{sla_failure.sla.stat_name}} {{sla_failure.sla.sla_type}} {{sla_failure.sla.threshold}}{{sla_failure.sla.display}}</td>
                <td>{{sla_failure.diff_metric[0]}}</td>
                <td>{{sla_failure.diff_metric[1]}}</td>
                {%- if sla_failure.sla.display == '' %}
                  <td>{{sla_failure.diff_metric['absolute_diff']}}{{sla_failure.sla.display}}</td>
                {%- else %}
                  <td>{{sla_failure.diff_metric['percent_diff']}}{{sla_failure.sla.display}}</td>
                {%- endif %}
              </tr>
             {%- endfor %}
            </tbody>
          </table>
          {%- endif %} 
       </div>
      </div>
    </div>

    {%- if diff_data %}
      {%- for metric in diff_data|sort %}
      <div class="row">
        <div class="span12">
         <div id="div-diff-{{ metric }}" style="overflow-x:auto;">
          <h2 class="content-title">
            <span class="text">{{ metric }}</span>
          </h2>
          <form>
            <input type="radio" name="radio-diff-{{ metric }}" id="radio-diff-{{ metric }}" value="%" checked onclick="switch_diff_table('{{ metric }}')">%
            <input type="radio" name="radio-diff-{{ metric }}" value="#" onclick="switch_diff_table('{{ metric }}')">#
          </form>
          <table id="table-diff-percent-{{ metric }}" class="table table-bordered table-striped sortable">
            <caption>{{ metric }} : % diff</caption>
            <thead>
              <th>sub-metric</th>
              {%- for header in diff_data[metric][diff_data[metric].keys()[0]].keys()|sort %}
              <th>{{ header }}</th>
              {%- endfor %}
            </thead>
            <tbody>
              {%- for sub_metric in diff_data[metric]|sort %}
                <tr>
                  <td>{{ sub_metric }}</td>
                  {%- for stats in diff_data[metric][sub_metric]|sort %}
                    {%- if sub_metric in sla_map[metric].keys() %}
                      {%- if stats in sla_map[metric][sub_metric].keys() %}
                        {%- if sla_map[metric][sub_metric][stats].display == '%' %}
                          {%- if sla_map[metric][sub_metric][stats].sla_passed == True %} 
                          <td class="success" type="naarad-diff-td-percentage" title="{{ sub_metric }} , {{ stats }} , Report 1={{ diff_data[metric][sub_metric][stats][0] }} , Report 2={{ diff_data[metric][sub_metric][stats][1] }} , diff={{ diff_data[metric][sub_metric][stats]['absolute_diff'] }}, %diff={{diff_data[metric][sub_metric][stats]['percent_diff'] }}">
                          {%- elif sla_map[metric][sub_metric][stats].sla_passed ==  False %}
                          <td class="danger" type="naarad-diff-td-percentage" title="{{ sub_metric }} , {{ stats }} , Report 1={{ diff_data[metric][sub_metric][stats][0] }} , Report 2={{ diff_data[metric][sub_metric][stats][1] }} , diff={{ diff_data[metric][sub_metric][stats]['absolute_diff'] }}, %diff={{diff_data[metric][sub_metric][stats]['percent_diff'] }}">
                          {%- else %}
                          <td type="naarad-diff-td-percentage" title="{{ sub_metric }} , {{ stats }} , Report 1={{ diff_data[metric][sub_metric][stats][0] }} , Report 2={{ diff_data[metric][sub_metric][stats][1] }} , diff={{ diff_data[metric][sub_metric][stats]['absolute_diff'] }}, %diff={{diff_data[metric][sub_metric][stats]['percent_diff'] }}">
                          {%- endif %}
                        {%- else %}
                        <td type="naarad-diff-td-percentage" title="{{ sub_metric }} , {{ stats }} , Report 1={{ diff_data[metric][sub_metric][stats][0] }} , Report 2={{ diff_data[metric][sub_metric][stats][1] }} , diff={{ diff_data[metric][sub_metric][stats]['absolute_diff'] }}, %diff={{diff_data[metric][sub_metric][stats]['percent_diff'] }}">
                        {%- endif %}
                      {%- else %}
                      <td type="naarad-diff-td-percentage" title="{{ sub_metric }} , {{ stats }} , Report 1={{ diff_data[metric][sub_metric][stats][0] }} , Report 2={{ diff_data[metric][sub_metric][stats][1] }} , diff={{ diff_data[metric][sub_metric][stats]['absolute_diff'] }}, %diff={{diff_data[metric][sub_metric][stats]['percent_diff'] }}">
                      {%- endif %}
                    {%- else %}
                    <td type="naarad-diff-td-percentage" title="{{ sub_metric }} , {{ stats }} , Report 1={{ diff_data[metric][sub_metric][stats][0] }} , Report 2={{ diff_data[metric][sub_metric][stats][1] }} , diff={{ diff_data[metric][sub_metric][stats]['absolute_diff'] }}, %diff={{diff_data[metric][sub_metric][stats]['percent_diff'] }}">
                    {%- endif %}
                    {{ diff_data[metric][sub_metric][stats]['percent_diff'] }}%
                  </td>
                  {%- endfor %}
                </tr>
               {%- endfor %}
            </tbody>
          </table>
          <table id="table-diff-absolute-{{ metric }}" class="table table-bordered table-striped sortable" hidden="true">
            <caption>{{ metric }} : absolute diff</caption>
            <thead>
              <th>sub-metric</th>
              {%- for header in diff_data[metric][diff_data[metric].keys()[0]].keys()|sort %}
              <th>{{ header }}</th>
              {%- endfor %}
            </thead>
            <tbody>
              {%- for sub_metric in diff_data[metric]|sort %}
                <tr>
                  <td>{{ sub_metric }}</td>
                  {%- for stats in diff_data[metric][sub_metric]|sort %}
                    {%- if sub_metric in sla_map[metric].keys() %}
                      {%- if stats in sla_map[metric][sub_metric].keys() %}
                        {%- if sla_map[metric][sub_metric][stats].display == '' %}
                          {%- if sla_map[metric][sub_metric][stats].sla_passed == True %} 
                          <td class="success" type="naarad-diff-td-percentage" title="{{ sub_metric }} , {{ stats }} , Report 1={{ diff_data[metric][sub_metric][stats][0] }} , Report 2={{ diff_data[metric][sub_metric][stats][1] }} , diff={{ diff_data[metric][sub_metric][stats]['absolute_diff'] }}, %diff={{diff_data[metric][sub_metric][stats]['percent_diff'] }}">
                          {%- elif sla_map[metric][sub_metric][stats].sla_passed ==  False %}
                          <td class="danger" type="naarad-diff-td-percentage" title="{{ sub_metric }} , {{ stats }} , Report 1={{ diff_data[metric][sub_metric][stats][0] }} , Report 2={{ diff_data[metric][sub_metric][stats][1] }} , diff={{ diff_data[metric][sub_metric][stats]['absolute_diff'] }}, %diff={{diff_data[metric][sub_metric][stats]['percent_diff'] }}">
                          {%- else %}
                          <td type="naarad-diff-td-percentage" title="{{ sub_metric }} , {{ stats }} , Report 1={{ diff_data[metric][sub_metric][stats][0] }} , Report 2={{ diff_data[metric][sub_metric][stats][1] }} , diff={{ diff_data[metric][sub_metric][stats]['absolute_diff'] }}, %diff={{diff_data[metric][sub_metric][stats]['percent_diff'] }}">
                          {%- endif %}
                        {%- else %}
                        <td type="naarad-diff-td-percentage" title="{{ sub_metric }} , {{ stats }} , Report 1={{ diff_data[metric][sub_metric][stats][0] }} , Report 2={{ diff_data[metric][sub_metric][stats][1] }} , diff={{ diff_data[metric][sub_metric][stats]['absolute_diff'] }}, %diff={{diff_data[metric][sub_metric][stats]['percent_diff'] }}">
                        {%- endif %}
                      {%- else %}
                      <td type="naarad-diff-td-percentage" title="{{ sub_metric }} , {{ stats }} , Report 1={{ diff_data[metric][sub_metric][stats][0] }} , Report 2={{ diff_data[metric][sub_metric][stats][1] }} , diff={{ diff_data[metric][sub_metric][stats]['absolute_diff'] }}, %diff={{diff_data[metric][sub_metric][stats]['percent_diff'] }}">
                      {%- endif %}
                    {%- else %}
                    <td type="naarad-diff-td-percentage" title="{{ sub_metric }} , {{ stats }} , Report 1={{ diff_data[metric][sub_metric][stats][0] }} , Report 2={{ diff_data[metric][sub_metric][stats][1] }} , diff={{ diff_data[metric][sub_metric][stats]['absolute_diff'] }}, %diff={{diff_data[metric][sub_metric][stats]['percent_diff'] }}">
                    {%- endif %}
                    {{ diff_data[metric][sub_metric][stats]['absolute_diff'] }}
                  </td>
                  {%- endfor %}
                </tr>
              {%- endfor %}
            </tbody>
          </table>
         </div>
        </div>
      </div>
      {%- endfor %}
    {%- endif %}

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

    <div class="row">
      <div class="span12">
        <table class="table">
            <h2 class="content-title">
                <span class="text">Source Files Locations</span>
            </h2>
            <tr><td><a href={{ reports[0].location }}>Baseline Report: {{ reports[0].location }}</a></td></tr>
            <tr><td><a href={{ reports[1].location }}>Current Report: {{ reports[1].location }}</a></td></tr>
        </table>
      </div>
    </div>

  </div>
</div>
