{% if not included %}
{% extends 'index.html' %}

{% block title %}
Control
{% endblock title %}

{% endif %}

{% set included = True %}

{% block head %}
{% endblock head %}

{% block content %}

<div id="fulvio" class="form mt-2 row">
  
  <div class="col">
        
        <fieldset class="row">

          <div class="col-md col-1 input-group">
            <button class="col btn btn-outline-primary"
                    data-control="fulvio-get">
              Fulvio GET
            </button>
            <span class="col-6 input-group-text">
              <var class="w-100 badge border text-bg-success"
                   data-status="fulvio-get"></var>
            </span>
          </div>
          
          <div class="col-md col-1 input-group">
            <button class="col btn btn-outline-primary"
                    data-control="fulvio-post">
              Fulvio POST
            </button>
            <input id="fulvio-input" data-parameter="fulvio-post"
                   class="form-control" type="text" value="ciccio">
            <span class="col-6 input-group-text">
              <var class="w-100 badge border text-bg-success"
                   data-status="fulvio-post"></var>
              <var class="w-100 badge border text-bg-danger"
                   data-status="fulvio-post-error"></var>
            </span>
          </div>          
          
        </fieldset>        

  </div>

</div>

<script>


  // Il resto della pagina lo trovi in web/pages/index.html
  // $(this).crud lo trovi in web/static/form-crud.js
  
  
  $('[data-control="fulvio-get"]').click(function(){
      $(this).crud("GET", "/api/fulvio/test").then(function(e){
          $('[data-status="fulvio-get"]').text(e.response)
          console.log(e)
      })
  })
  
  $('[data-control="fulvio-post"]').click(function(){
      var data = $('[data-parameter="fulvio-post"]').val()
      $(this).crud("POST", "/api/fulvio/test", data).then(function(e){
          $('[data-status="fulvio-post"]').text(e.response)
          $('[data-status="fulvio-post-error"]').text(e.error)
          console.log(e)
      })
  })

  
</script>

{% endblock content %}


{% block footer %}
{% endblock footer %}
