<!DOCTYPE html>
<html lang="en">
  {% set facet='view' %}
  <head>
    <title>
      {% if recipe.name %}
      {{ recipe.name }} @ HXL Proxy
      {% else %}
      View data @ HXL Proxy
      {% endif %}
    </title>
    {% include "includes/headers.html" %}
  </head>
  <body class="container-fluid">
    {% set page_help='View-page' %}
    {% include "includes/navbar.html" %}
    <header class="row">
      {% include "includes/data-tabs.html" %}
      <h1 class="col-md-9">
        {% if recipe.name %}
        {{ recipe.name }}
        {% else %}
        View data
        {% endif %}
      </h1>
      <p class="col-md-3 small">
        <b>Download as:</b>
        <a href="{{ data_url_for('data_view', recipe, format='csv') }}">CSV</a>&nbsp;|
        <a href="{{ data_url_for('data_view', recipe, format='json') }}">JSON&nbsp;lists</a>&nbsp;|
        <a href="{{ data_url_for('data_view', recipe, flavour='objects', format='json') }}">JSON&nbsp;objects</a>
      </p>
    </header>
    <main class="row">
      <div id="metadata" class="col-xs-12">
        {% include "includes/source.html" %}
        {% if recipe.description %}
        <p>{{ recipe.description }}</p>
        {% endif %}
      </div>
      <section id="data" class="col-xs-12">
        <div id="preview-table">
          {% include 'includes/hxltable.html' %}
        </div>
        {% if source.has_more_rows %}
        <div id="preview-warning" class="alert alert-warning">
          <strong>Note:</strong> Showing only the first {{
          "{:,}".format(source.max_rows) }} data rows. Download the
          CSV or JSON for the full dataset.
          {% if recipe.args['max-rows'] %}
          (Limited to maximum {{ recipe.args['max-rows'] }} row(s) by the
          <i>max-rows</i> parameter.)
          {% endif %}
        </div>
        <div id="post-preview-warning" class="alert alert-warning">
          <strong>Note:</strong> Showing only the first {{
          "{:,}".format(source.max_rows) }} data rows. Download the
          CSV or JSON for the full dataset.
          {% if recipe.args['max-rows'] %}
          (Limited to maximum {{ recipe.args['max-rows'] }} row(s) by the
          <i>max-rows</i> parameter.)
          {% endif %}
        </div>
        {% endif %}
      </section>
    </main>
    {% include "includes/scripts.html" %}
    <script>
      $(document).ready(function() {
        // add the preview warning, with total row count
        $("#preview-warning").insertBefore($(".hxltable"));
      });
    </script>
  </body>
</html>
