<!DOCTYPE html>
<html>
<head>
    <title>Ocelot Run {{ uuid }} Report</title>
    <link rel="stylesheet" href="assets/css/font-awesome.min.css">
    <link rel="stylesheet" href="assets/css/footable.standalone.min.css">
    <link rel="stylesheet" href="assets/css/pure-min.css">
    <link rel="stylesheet" href="assets/css/grids-responsive-min.css">
    <link rel="stylesheet" href="assets/css/report.css">
    <script src="assets/js/jquery-1.12.3.min.js"></script>
    <script src="assets/js/footable.min.js"></script>
    <link rel="stylesheet"
          href="assets/css/chartist.min.css">
    <script src="assets/js/chartist.min.js"></script>
    <script src="assets/js/chartist-plugin-axistitle.min.js"></script>
</head>
<body>
<div id="layout" class="pure-g">
  <div class="sidebar pure-u-1 pure-u-md-1-4">
    <div class="header">
      <h1 class="brand-title">Ocelot Report</h1>
      <h2 class="brand-tagline">{{ uuid }}</h2>
      <h2 class="brand-tagline">Input datasets: {{ counts.0.1 }}</h2>
      <h2 class="brand-tagline">Time: {{ elapsed }} seconds</h2>
      <nav class="nav">
          <ul class="nav-list">
              <li class="nav-item">
                  <a class="pure-button" href="https://github.com/OcelotProject/Ocelot">Source code</a>
                  <a class="pure-button" href="https://blog.ocelot.space/">Development blog</a>
                  <a class="pure-button" href="https://osf.io/apg8j/">Open Science</a>
              </li>
          </ul>
      </nav>
      <h2 class="brand-title" style="margin-top: 1em;">Functions</h2>
      {% for func in functions %}<p><a class="sidebar-link" href="#{{ func.id }}">{{ func.name }}</a></p>{% endfor %}
    </div>
  </div>
  <div class="content pure-u-1 pure-u-md-3-4">
    <h1>Timing chart</h1>
    <div id="timingChart"></div>
    <h1>Dataset count chart</h1>
    <div id="countChart"></div>
    <h1>Transform functions</h1>
    {% for func in functions %}
      <h2 id="{{ func.id }}">{{ func.name }} <span class="pure-button toggle-button">toggle</span></h2>
      <div id="{{ func.id }}-container">
        <ul>
            <li>Total time: {{ func.time|int }} seconds</li>
            <li>Number of datasets after application: {{ func.count }}</li>
        </ul>
        <h3>Description</h3>
        <p>{{ func.description }}</p>
        {% if func.table %}
        <h3>{{ func.table.title }}</h3>
        <table class="table" data-paging="true" data-filtering="true" data-sorting="true">
            <thead>
                <tr>
                    {% for col in func.table.columns %}
                    <th data-breakpoints="xs">{{ col }}</th>
                    {% endfor %}
                </tr>
            </thead>
            <tbody>
                {% for row in func.tabledata %}
                <tr>
                    {% for elem in row %}<td>{{ elem }}</td>
                    {% endfor %}
                </tr>
                {% endfor %}
            </tbody>
        </table>
        {% endif %}
      </div>
    {% endfor %}
  </div>
</div>
<script type="text/javascript">
$(".toggle-button").click(function() {
  var parent_id = $(this).parent().attr("id");
  var container_id = "#" + parent_id + "-container";
  $(container_id).toggle();
  console.log( parent_id, container_id );
});

new Chartist.Line('#timingChart', {
  labels: {{ time_labels }},
  series: [
    {{ time_data}}
  ]
}, {
  low: 0,
  showArea: true,
  lineSmooth: Chartist.Interpolation.none(),
  plugins: [
    Chartist.plugins.ctAxisTitle({
      axisY: {
        axisTitle: 'Time (seconds)',
        axisClass: 'ct-axis-title',
        offset: {
          x: 0,
          y: 0
        },
        textAnchor: 'middle'
      },
      axisX: {
        axisTitle: 'Transform functions',
        axisClass: 'ct-axis-title',
        offset: {
          x: 0,
          y: 0
        },
        textAnchor: 'middle',
      }
    })
  ]
});

new Chartist.Line('#countChart', {
  labels: {{ count_labels }},
  series: [
    {{ count_data}}
  ]
}, {
  low: 0,
  showArea: true,
  lineSmooth: Chartist.Interpolation.none(),
  plugins: [
    Chartist.plugins.ctAxisTitle({
      axisY: {
        axisTitle: 'Number of datasets',
        axisClass: 'ct-axis-title',
        offset: {
          x: 0,
          y: 0
        },
        textAnchor: 'middle'
      },
      axisX: {
        axisTitle: 'Transform functions',
        axisClass: 'ct-axis-title',
        offset: {
          x: 0,
          y: 0
        },
        textAnchor: 'middle',
      }
    })
  ]
});

jQuery(function($){
    $('.table').footable();
});
</script>
</body>
</html>
