Files
FabledSteward/roundtable/templates/settings/index.html
T
2026-04-13 17:13:55 -04:00

158 lines
8.5 KiB
HTML

{# roundtable/templates/settings/index.html #}
{% extends "base.html" %}
{% block title %}Settings — Fabled Scryer{% endblock %}
{% block content %}
<h1 class="page-title">Settings</h1>
<form method="post" action="/settings/">
<div style="display:grid;gap:1.5rem;">
{# ── General ──────────────────────────────────────────────────────────── #}
<div class="card">
<h2 class="section-title" style="margin-bottom:1rem;">General</h2>
<div class="form-group">
<label>Session lifetime (hours)</label>
<input type="number" name="session.lifetime_hours" min="1" max="720"
value="{{ settings['session.lifetime_hours'] }}">
</div>
<div class="form-group">
<label>Data retention (days)</label>
<input type="number" name="data.retention_days" min="1"
value="{{ settings['data.retention_days'] }}">
</div>
<div class="form-group">
<label>Monitor poll interval (seconds)</label>
<input type="number" name="monitors.poll_interval_seconds" min="10"
value="{{ settings['monitors.poll_interval_seconds'] }}">
</div>
</div>
{# ── SMTP ─────────────────────────────────────────────────────────────── #}
<div class="card">
<h2 class="section-title" style="margin-bottom:1rem;">Email (SMTP)</h2>
<div class="form-group">
<label>SMTP host</label>
<input type="text" name="smtp.host" value="{{ settings['smtp.host'] }}" placeholder="mail.example.com">
</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:1rem;">
<div class="form-group">
<label>Port</label>
<input type="number" name="smtp.port" value="{{ settings['smtp.port'] }}">
</div>
<div class="form-group" style="display:flex;align-items:center;gap:0.5rem;padding-top:1.5rem;">
<input type="checkbox" name="smtp.tls" id="smtp-tls"
{% if settings['smtp.tls'] %}checked{% endif %}>
<label for="smtp-tls" style="margin:0;">Use TLS</label>
</div>
</div>
<div class="form-group">
<label>Username</label>
<input type="text" name="smtp.username" value="{{ settings['smtp.username'] }}" autocomplete="off">
</div>
<div class="form-group">
<label>Password <span style="color:#606080;font-size:0.8rem;">(leave blank to keep current)</span></label>
<input type="password" name="smtp.password" placeholder="••••••••" autocomplete="new-password">
</div>
<div class="form-group">
<label>Recipients <span style="color:#606080;font-size:0.8rem;">(comma-separated)</span></label>
<input type="text" name="smtp.recipients"
value="{{ settings['smtp.recipients'] | join(', ') }}"
placeholder="admin@example.com, ops@example.com">
</div>
</div>
{# ── Webhook ──────────────────────────────────────────────────────────── #}
<div class="card">
<h2 class="section-title" style="margin-bottom:1rem;">Webhook</h2>
<div class="form-group">
<label>Webhook URL <span style="color:#606080;font-size:0.8rem;">(leave blank to disable)</span></label>
<input type="text" name="webhook.url" value="{{ settings['webhook.url'] }}"
placeholder="https://discord.com/api/webhooks/...">
</div>
<div class="form-group">
<label>Payload template <span style="color:#606080;font-size:0.8rem;">(Jinja2, must produce valid JSON)</span></label>
<textarea name="webhook.template" rows="3" style="font-family:ui-monospace,monospace;font-size:0.85rem;">{{ settings['webhook.template'] }}</textarea>
</div>
</div>
{# ── Ansible Sources ──────────────────────────────────────────────────── #}
<div class="card">
<h2 class="section-title" style="margin-bottom:1rem;">Ansible Sources</h2>
<p style="color:#606080;font-size:0.85rem;margin-bottom:0.75rem;">JSON array of source objects. Each requires <code>name</code>, <code>type</code> (git or local), and either <code>url</code> or <code>path</code>.</p>
<textarea name="ansible.sources" rows="8" style="font-family:ui-monospace,monospace;font-size:0.85rem;">{{ settings['ansible.sources'] | tojson(indent=2) }}</textarea>
</div>
{# ── Plugins ──────────────────────────────────────────────────────────── #}
{% if discovered_plugins %}
<div class="card">
<h2 class="section-title" style="margin-bottom:1rem;">Plugins</h2>
{% for plugin in discovered_plugins %}
<div style="border:1px solid #2a2a4a;border-radius:4px;padding:1rem;margin-bottom:0.75rem;">
<div style="display:flex;align-items:center;gap:0.75rem;margin-bottom:0.75rem;">
<input type="checkbox" name="plugin.{{ plugin._dir }}.enabled"
id="plugin-{{ plugin._dir }}-enabled"
{% if plugin._enabled %}checked{% endif %}>
<label for="plugin-{{ plugin._dir }}-enabled"
style="margin:0;font-weight:bold;color:#c0c0e0;">
{{ plugin.get('name', plugin._dir) }}
<span style="color:#606080;font-size:0.8rem;font-weight:normal;">
v{{ plugin.get('version', '?') }} — {{ plugin.get('description', '') }}
</span>
</label>
</div>
{% for cfg_key, cfg_default in plugin.get('config', {}).items() %}
{% if cfg_default is mapping %}
{# Nested dict — render each sub-key as its own field #}
<div style="margin-left:1.5rem;margin-bottom:0.6rem;">
<div style="font-size:0.82rem;color:var(--text-muted);margin-bottom:0.35rem;text-transform:uppercase;letter-spacing:0.04em;">{{ cfg_key }}</div>
{% set sub_cfg = plugin._config.get(cfg_key, cfg_default) if plugin._config.get(cfg_key, cfg_default) is mapping else cfg_default %}
{% for sub_key, sub_default in cfg_default.items() %}
<div class="form-group" style="margin-left:1rem;">
{% if sub_default is sameas false or sub_default is sameas true %}
<div style="display:flex;align-items:center;gap:0.5rem;">
<input type="checkbox"
name="plugin.{{ plugin._dir }}.{{ cfg_key }}.{{ sub_key }}"
id="plugin-{{ plugin._dir }}-{{ cfg_key }}-{{ sub_key }}"
{% if sub_cfg.get(sub_key, sub_default) %}checked{% endif %}>
<label for="plugin-{{ plugin._dir }}-{{ cfg_key }}-{{ sub_key }}"
style="margin:0;font-size:0.85rem;">{{ sub_key }}</label>
</div>
{% else %}
<label style="font-size:0.85rem;">{{ sub_key }}</label>
<input type="text"
name="plugin.{{ plugin._dir }}.{{ cfg_key }}.{{ sub_key }}"
value="{{ sub_cfg.get(sub_key, sub_default) }}">
{% endif %}
</div>
{% endfor %}
</div>
{% elif cfg_default is sameas false or cfg_default is sameas true %}
<div class="form-group" style="margin-left:1.5rem;display:flex;align-items:center;gap:0.5rem;">
<input type="checkbox"
name="plugin.{{ plugin._dir }}.{{ cfg_key }}"
id="plugin-{{ plugin._dir }}-{{ cfg_key }}"
{% if plugin._config.get(cfg_key, cfg_default) %}checked{% endif %}>
<label for="plugin-{{ plugin._dir }}-{{ cfg_key }}" style="margin:0;font-size:0.85rem;">{{ cfg_key }}</label>
</div>
{% else %}
<div class="form-group" style="margin-left:1.5rem;">
<label style="font-size:0.85rem;">{{ cfg_key }}</label>
<input type="text" name="plugin.{{ plugin._dir }}.{{ cfg_key }}"
value="{{ plugin._config.get(cfg_key, cfg_default) }}">
</div>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</div>
{% endif %}
</div>
<div style="margin-top:1.5rem;">
<button type="submit" class="btn">Save Settings</button>
<span style="color:#606080;font-size:0.85rem;margin-left:1rem;">
Changes take effect immediately. Monitor interval, plugin enable/disable require a restart.
</span>
</div>
</form>
{% endblock %}