<style type="text/css">{% include "style.css" %}</style>

{% set dashboard_id = request.args.get('dashboard', '0') | int %}
{% set bootstrap = extension.bootstrap(dashboard_id) %}
<script id="favaDashboardsBootstrap" type="application/json">
{{ {
  "dashboard": bootstrap["dashboards"][dashboard_id],
  "ledger": bootstrap["ledger"],
  "utils": bootstrap["utils"]
}|tojson }}
</script>

<div class="headerline">
  {% for dashboard in bootstrap.dashboards %}
  <h3>
    {%- if dashboard_id == loop.index0 -%}
      {{ dashboard.name }}
    {%- else -%}
      <a href="{{ url_for('extension_report', extension_name='FavaDashboards', dashboard=loop.index0) }}">{{ dashboard.name }}</a>
    {%- endif -%}
  </h3>
  {% endfor %}
</div>

<div id="dashboard">
  {% for panel in bootstrap.dashboards[dashboard_id].panels %}
  <div class="panel" style="width: {{ panel.width|default("100%") }}">
    {% if panel.title %}
    <h2>
      {%- if panel.link %}<a href="{{ panel.link }}">{% endif -%}
      {{ panel.title }}
      {%- if panel.link %}</a>{% endif -%}
    </h2>
    {% endif %}
    <div id="panel{{ loop.index0 }}" style="height: {{ panel.height|default("400px") }}"></div>
  </div>
  {% endfor %}
</div>
