{#
Python simple Raspberry-Pi camera module web interface
Copyright (C) 2020 Luiz Eduardo Amaral <luizamaral306@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
#}
{% macro title() %}
<h2 class="mb-0 mr-1">
  Picamip
  <a class="ml-2" style="" href="https://github.com/luxedo/picamip">
    <img class="mb-3" src="static/GitHub-Mark-32px.png" /><span></span>
  </a>
</h2>
{%- endmacro %}

{% macro button(action, method="GET", parameters={}, class="btn-primary", text="", text_class="h4", icon="", icon_size=48) -%}
<form class="d-inline" action="{{action}}" method="{{method}}">
  <button type="submit" class="{{class}}">
    <span class="{{text_class}} text-nowrap">
    <svg class="bi" width="{{icon_size}}" height="{{icon_size}}" fill="currentColor">
      <use xlink:href="{{icon}}"/>
    </svg>
    {{text}}
    </span>
  </button>
  {% for name, value in parameters.items() %}
    <input type="hidden" name={{name}} value={{value}} />
  {% endfor %}
</form>
{%- endmacro %}

{% macro jsButton(onsubmit, class="btn-primary", text="", text_class="h4", icon="", icon_size=48) -%}
<form class="d-inline" action="#" onsubmit="{{onsubmit}}">
  <button type="submit" class="{{class}} text-nowrap">
    <span class="{{text_class}}">
    <svg class="bi" width="{{icon_size}}" height="{{icon_size}}" fill="currentColor">
      <use xlink:href="{{icon}}"/>
    </svg>
    {{text}}
    </span>
  </button>
</form>
{%- endmacro %}

{% macro simpleModal(id, title, message, button) %}
<div
  class="modal fade"
  id="{{id}}"
  tabindex="-1"
  role="dialog"
  aria-labelledby="exampleModalLabel"
  aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">{{title}}</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
	{{message}}
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
	{{button}}
      </div>
    </div>
  </div>
</div>
{% endmacro %}

{% macro footer() %}
<div class="container-fluid">
  <div class="row">
    <div class="col-sm-6 offset-sm-3 mt-5 fixed-bottom text-center">
      <p>
        Copyright (c) 2020 Luiz Eduardo Amaral
        <a href="mailto:luizamaral306@gmail.com?Subject=OCDots">
          &lt;luizamaral306@gmail.com&gt;
        </a>
        <br />
        This software is under a
        <a href="https://www.gnu.org/licenses/gpl-3.0.en.html">GNU GPL3</a>
        license. Have fun!
        <span style="font-size: 1.5em; vertical-align: baseline">😉</span>
      </p>
    </div>
  </div>
</div>
{% endmacro %}
