Saving an enabled plugin threw away hot_reload_plugin's (ok, message), so a plugin that failed to load live read "Enabled, not loaded" with nothing more. Now: - a live-load failure is recorded with its reason, as a boot failure is, and logged; a later success clears it; - any save of an enabled plugin that isn't running tries to start it, not only the off-to-on toggle; - enabling one already running is a success, not a failure; - the plugin's page offers "Restart to load" while it is enabled and not running. Quart never marks the app as having served its first request, so register_blueprint after startup is allowed: hot-loading is not refused wholesale, as #6087 suspected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
152 lines
7.9 KiB
HTML
152 lines
7.9 KiB
HTML
{# steward/templates/settings/plugin_detail.html #}
|
|
{% extends "base.html" %}
|
|
{% from "_macros.html" import crumbs %}
|
|
{% block title %}{{ plugin.get('name', plugin._dir) }} Settings — Steward{% endblock %}
|
|
{% from "settings/_tabs.html" import settings_tabs %}
|
|
{% block section_tabs %}{{ settings_tabs("plugins") }}{% endblock %}
|
|
{% block breadcrumb %}{{ crumbs([("Settings", "/settings/"), ("Plugins", "/settings/plugins/"), (plugin.get('name', plugin._dir), "")]) }}{% endblock %}
|
|
{% block content %}
|
|
|
|
<div style="display:flex;align-items:center;gap:1rem;margin-bottom:1.5rem;">
|
|
<h1 class="page-title" style="margin-bottom:0;">{{ plugin.get('name', plugin._dir) }}</h1>
|
|
<span style="color:var(--text-muted);font-size:0.82rem;">v{{ plugin.get('version', '?') }}</span>
|
|
{% if fail_reason %}
|
|
<span style="font-size:0.75rem;padding:0.15em 0.55em;border-radius:3px;
|
|
background:color-mix(in srgb,var(--red) 15%,var(--bg));color:var(--red);">Error</span>
|
|
{% elif is_loaded %}
|
|
<span style="font-size:0.75rem;padding:0.15em 0.55em;border-radius:3px;
|
|
background:color-mix(in srgb,var(--green) 12%,var(--bg));color:var(--green);">Loaded</span>
|
|
{% elif plugin._enabled %}
|
|
<span style="font-size:0.75rem;padding:0.15em 0.55em;border-radius:3px;
|
|
background:var(--bg-elevated);color:var(--text-muted);">Enabled, not loaded</span>
|
|
{% else %}
|
|
<span style="font-size:0.75rem;padding:0.15em 0.55em;border-radius:3px;
|
|
background:var(--bg-elevated);color:var(--text-muted);">Disabled</span>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% if fail_reason %}
|
|
<div style="display:flex;align-items:flex-start;gap:0.5rem;padding:0.6rem 0.9rem;margin-bottom:1rem;
|
|
background:color-mix(in srgb,var(--red) 10%,var(--bg));
|
|
border:1px solid color-mix(in srgb,var(--red) 30%,var(--border));
|
|
border-radius:6px;font-size:0.84rem;max-width:720px;">
|
|
<span style="color:var(--red);flex-shrink:0;">✕</span>
|
|
<span><strong style="color:var(--red);">Failed to load</strong>
|
|
<span style="color:var(--text-muted);margin-left:0.3rem;">— {{ fail_reason }}</span>
|
|
</span>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if plugin._enabled and not is_loaded and not plugin._always_on %}
|
|
<div id="restart-banner" style="display:flex;align-items:center;gap:0.75rem;flex-wrap:wrap;
|
|
margin-bottom:1rem;max-width:720px;font-size:0.84rem;color:var(--text-muted);">
|
|
<span>It's enabled but not running{% if fail_reason %}: it couldn't be started while Steward runs{% endif %}.
|
|
A restart loads it.</span>
|
|
<form method="post" action="/settings/plugins/restart/"
|
|
hx-post="/settings/plugins/restart/" hx-target="#restart-banner" hx-swap="outerHTML"
|
|
data-confirm="Restart the app now? This will briefly interrupt all monitoring."
|
|
style="margin:0;">{{ csrf_field() }}
|
|
<button type="submit" class="btn btn-sm">Restart to load</button>
|
|
</form>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if plugin.get('description') %}
|
|
<p style="color:var(--text-muted);font-size:0.88rem;margin-bottom:1.25rem;max-width:620px;">{{ plugin.description }}</p>
|
|
{% endif %}
|
|
|
|
<form method="post" action="/settings/plugins/{{ plugin._dir }}/" style="max-width:720px;">{{ csrf_field() }}
|
|
|
|
{# ── Enable toggle; a built-in plugin has none (always on) ─────────────────── #}
|
|
{% if plugin._always_on %}
|
|
<div class="card" style="padding:1rem 1.25rem;margin-bottom:1rem;">
|
|
<div style="font-weight:500;">Built in: always on</div>
|
|
<div style="font-size:0.8rem;color:var(--text-muted);margin-top:0.4rem;">
|
|
Steward relies on this one (hosts, maintenance, drive and update alerts, Docker collection), so it can't
|
|
be turned off. Its settings below still apply.
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
<div class="card" style="padding:1rem 1.25rem;margin-bottom:1rem;">
|
|
<div style="display:flex;align-items:center;gap: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:500;cursor:pointer;">
|
|
Enable this plugin
|
|
</label>
|
|
</div>
|
|
<div style="font-size:0.8rem;color:var(--text-muted);margin-top:0.4rem;margin-left:1.6rem;">
|
|
Enabling loads the plugin straight away. Disabling takes effect after a restart.
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{# ── Config fields ─────────────────────────────────────────────────────────── #}
|
|
{% if plugin.get('config') %}
|
|
<div class="card" style="padding:1.25rem;margin-bottom:1rem;">
|
|
<div class="section-title" style="margin-bottom:1rem;">Configuration</div>
|
|
<div style="display:grid;gap:0.75rem;">
|
|
|
|
{% for cfg_key, cfg_default in plugin.config.items() %}
|
|
|
|
{% if cfg_default is mapping %}
|
|
<div style="padding:0.75rem;background:var(--bg);border-radius:5px;border:1px solid var(--border);">
|
|
<div style="font-size:0.74rem;color:var(--text-muted);text-transform:uppercase;
|
|
letter-spacing:0.05em;margin-bottom:0.6rem;">{{ field_label(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 %}
|
|
<div style="display:grid;gap:0.5rem;">
|
|
{% for sub_key, sub_default in cfg_default.items() %}
|
|
{% 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;color:var(--text);">{{ field_label(sub_key) }}</label>
|
|
</div>
|
|
{% else %}
|
|
<div class="form-group" style="margin:0;">
|
|
<label style="font-size:0.82rem;">{{ field_label(sub_key) }}</label>
|
|
<input type="text"
|
|
name="plugin.{{ plugin._dir }}.{{ cfg_key }}.{{ sub_key }}"
|
|
value="{{ sub_cfg.get(sub_key, sub_default) }}">
|
|
</div>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
{% elif cfg_default is sameas false or cfg_default is sameas true %}
|
|
<div style="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;color:var(--text);">{{ field_label(cfg_key) }}</label>
|
|
</div>
|
|
|
|
{% else %}
|
|
<div class="form-group" style="margin:0;">
|
|
<label style="font-size:0.82rem;">{{ field_label(cfg_key) }}</label>
|
|
{% set secret = is_plugin_secret(cfg_key) %}
|
|
<input type="{% if secret %}password{% else %}text{% endif %}"
|
|
name="plugin.{{ plugin._dir }}.{{ cfg_key }}"
|
|
value="{% if secret %}{% else %}{{ plugin._config.get(cfg_key, cfg_default) }}{% endif %}"
|
|
{% if secret %}autocomplete="new-password" placeholder="{{ 'kept; type to change' if plugin._config.get(cfg_key) else 'none saved' }}"{% endif %}>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<button type="submit" class="btn">Save</button>
|
|
|
|
</form>
|
|
{% endblock %}
|