{% extends "admin/base_site.html" %}
{% load i18n %}

{% block content %}
<div id="content-main">
  <h2>{% trans "Django Config" %}</h2>
  <input type="text" id="config-filter" placeholder="{% trans 'Filter' %}" />
  <table id="config-table">
    <thead>
      <tr><th>{% trans "Name" %}</th><th>{% trans "Value" %}</th></tr>
    </thead>
    <tbody>
    {% for key, value in django_settings %}
      <tr><td>{{ key }}</td><td>{{ value }}</td></tr>
    {% empty %}
      <tr><td colspan="2">{% trans "No settings." %}</td></tr>
    {% endfor %}
    </tbody>
  </table>
</div>
<script>
  function setupFilter(inputId, tableId) {
    const input = document.getElementById(inputId);
    const table = document.getElementById(tableId);
    if (!input || !table) return;
    input.addEventListener('input', function () {
      const term = this.value.toLowerCase();
      for (const row of table.tBodies[0].rows) {
        row.style.display = row.textContent.toLowerCase().includes(term) ? '' : 'none';
      }
    });
  }
  document.addEventListener('DOMContentLoaded', function () {
    setupFilter('config-filter', 'config-table');
  });
</script>
{% endblock %}
