{% extends "base.html" %} 
{% block title %}Triggers{% endblock %} 
{% block header %}Triggers{% endblock %}
{% block content %}
<div class="row mb-4">
  <div class="col-md-8 mx-auto">
    <div class="alert alert-info">
      <i class="bi bi-info-circle-fill me-2"></i>
      Execute functions directly from the web interface.
    </div>
  </div>
</div>

<div class="row">
  {% for func_name, properties in function_triggers.items() %}
  <div class="col-md-6 mb-4">
    <div class="class-instance">
      <h3 class="instance-name">
        <i class="bi bi-lightning me-2"></i>{{ func_name }}
      </h3>
      <form method="post" action="">
        <ul class="attributes-list">
          {% for param_name in properties.param_names %}
          <li class="attribute-item">
            <div class="form-group mb-3">
              <label for="{{ func_name }}-{{ param_name }}" class="form-label">
                <strong>{{ param_name }}:</strong>
              </label>
              <input
                type="text"
                class="form-control"
                id="{{ func_name }}-{{ param_name }}"
                name="arg[{{ param_name }}]"
                placeholder="Enter value"
              />
            </div>
          </li>
          {% endfor %}
        </ul>
        <input type="hidden" name="function_name" value="{{ func_name }}" />
        {% if csrf_token %}
        <input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
        {% endif %}
        <div class="text-center">
          <button class="btn trigger-button" type="submit">
            <i class="bi bi-lightning-charge me-1"></i>Trigger Function
          </button>
        </div>
      </form>
    </div>
  </div>
  {% endfor %}
</div>
{% endblock %}
