{% extends "django_sql_dashboard/base.html" %}
{% load django_sql_dashboard %}

{% block title %}{{ html_title }}{% endblock %}

{% block extra_head %}
{{ block.super }}
{% if dashboard.view_policy == "unlisted" %}
  <meta name="robots" content="noindex">
{% endif %}
{% endblock %}

{% block content %}
{% if user_can_execute_sql %}<p><a href="{% url 'django_sql_dashboard-index' %}">Dashboard index</a></p>{% endif %}
<h1>{% if dashboard.title %}{{ dashboard.title }}{% else %}{{ dashboard.slug }}{% endif %}</h1>
{% if dashboard.description %}
  <p>{{ dashboard.description }}</p>
{% endif %}

<p style="color: #666; font-size: 0.9em; margin-top: -1em">
  {% if user_owns_dashboard %}
    Owned by you,
  {% else %}
    Owned by <strong>{{ dashboard.owned_by }}</strong>,
  {% endif %}
  visibility: {{ dashboard.view_summary }}
  {% if user_can_edit_dashboard %}
    - <a href="{{ dashboard.get_edit_url }}">edit</a>
  {% endif %}
</p>

<form action="{{ request.path }}" method="GET">
  {% if parameter_values %}
    <h3>Query parameters</h3>
    <div class="query-parameters">
    {% for name, value in parameter_values %}
        <label for="qp{{ forloop.counter }}">{{ name }}</label>
        <input type="text" id="qp{{ forloop.counter }}" name="{{ name }}" value="{{ value }}">
    {% endfor %}
    </div>
    <input
      class="btn"
      type="submit"
      value="Run quer{% if query_results|length > 1 %}ies{% else %}y{% endif %}"
    />
  {% endif %}
  {% for result in query_results %}
    {% include result.templates with result=result %}
  {% endfor %}
</form>
{% include "django_sql_dashboard/_script.html" %}
{% endblock %}
