88dca32d3c
Milestone 72 phase D — the dashboard view IS the edit surface (operator ask): - /d/<id> renders the grid via Gridstack in STATIC mode — positioned exactly like before, live HTMX widget bodies keep polling. An "Edit" button flips the same grid interactive (grid.setStatic(false)) in place, so you drag/resize over real data. "Done" flips it back. Layout autosaves on change. - The widget picker is now a bottom drawer (position:fixed overlay) revealed by body.dash-editing — so the dashboard width is identical entering/leaving edit. - Add: POST returns a single grid item; JS inserts it + grid.makeWidget + htmx.process so it loads live data. Remove: POST 204 + grid.removeWidget. Per-panel drag handle + remove ✕ are in the DOM for editors, shown only while editing. - Gridstack loads for everyone (viewers get the static grid); edit wiring is gated on can_edit. Mobile collapses to one column. - Removed the separate /d/<id>/edit route + edit.html + _edit_panels.html (rule 22). Dashboard-list Edit and new-dashboard create now deep-link /d/<id>?edit=1 which opens edit mode on load. Browser-only behaviour — CI can't exercise it; needs an operator visual check. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
79 lines
4.3 KiB
HTML
79 lines
4.3 KiB
HTML
{# Bottom drawer — the widget picker, revealed by body.dash-editing. Fixed-position
|
|
overlay so it never changes the dashboard's width. Add forms are submitted via
|
|
JS (see index.html) which inserts the returned grid item in place. #}
|
|
<div class="widget-drawer" id="widget-drawer" aria-label="Add a widget">
|
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:0.75rem;
|
|
position:sticky;top:0;background:var(--bg-card);padding-bottom:0.5rem;">
|
|
<div class="section-title" style="margin-bottom:0;">Add a widget</div>
|
|
<button type="button" class="btn btn-sm" id="dash-edit-done">Done</button>
|
|
</div>
|
|
{% if addable %}
|
|
{% set _groups = [("core", "Core monitors"), ("capability", "Monitoring capabilities"), ("integration", "Integrations")] %}
|
|
{% for _gkey, _glabel in _groups %}
|
|
{% set _gw = addable | selectattr("group", "equalto", _gkey) | list %}
|
|
{% if _gw %}
|
|
<div style="font-size:0.72rem;text-transform:uppercase;letter-spacing:0.04em;color:var(--text-dim);margin:0.6rem 0 0.35rem;">{{ _glabel }}</div>
|
|
<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:0.5rem;">
|
|
{% for w in _gw %}
|
|
<div class="card" style="margin-bottom:0;padding:0;overflow:hidden;">
|
|
<details>
|
|
<summary style="display:flex;align-items:center;justify-content:space-between;gap:0.6rem;
|
|
padding:0.7rem 0.85rem;cursor:pointer;list-style:none;user-select:none;">
|
|
<div style="flex:1;min-width:0;">
|
|
<div style="font-weight:600;font-size:0.85rem;">{{ w.label }}</div>
|
|
<div style="font-size:0.74rem;color:var(--text-muted);margin-top:0.1rem;">{{ w.description }}</div>
|
|
</div>
|
|
<span class="btn btn-sm" style="flex-shrink:0;pointer-events:none;">Add ▾</span>
|
|
</summary>
|
|
<form action="/d/{{ dashboard.id }}/edit/add/{{ w.key }}" method="post"
|
|
class="add-widget-form"
|
|
style="padding:0.75rem 0.85rem;padding-top:0;border-top:1px solid var(--border);">
|
|
<div style="display:grid;gap:0.5rem;padding-top:0.75rem;">
|
|
<div>
|
|
<label style="font-size:0.74rem;color:var(--text-muted);display:block;margin-bottom:0.2rem;">
|
|
Widget title <span style="color:var(--text-dim);">(optional)</span>
|
|
</label>
|
|
<input type="text" name="title" placeholder="{{ w.label }}"
|
|
style="width:100%;padding:0.32rem 0.6rem;background:var(--bg);
|
|
border:1px solid var(--border-mid);border-radius:4px;
|
|
color:var(--text);font-size:0.85rem;">
|
|
</div>
|
|
{% for p in w.params %}
|
|
<div>
|
|
<label style="font-size:0.74rem;color:var(--text-muted);display:block;margin-bottom:0.2rem;">{{ p.label }}</label>
|
|
{% if p.type == "select" %}
|
|
<select name="param_{{ p.key }}"
|
|
style="width:100%;padding:0.32rem 0.6rem;background:var(--bg);
|
|
border:1px solid var(--border-mid);border-radius:4px;color:var(--text);font-size:0.85rem;">
|
|
{% for opt in p.options %}
|
|
<option value="{{ opt.value }}" {% if opt.value == p.default %}selected{% endif %}>{{ opt.label }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
{% elif p.type == "host" %}
|
|
<select name="param_{{ p.key }}" required
|
|
style="width:100%;padding:0.32rem 0.6rem;background:var(--bg);
|
|
border:1px solid var(--border-mid);border-radius:4px;color:var(--text);font-size:0.85rem;">
|
|
<option value="">— select a host —</option>
|
|
{% for h in hosts %}
|
|
<option value="{{ h.id }}">{{ h.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
{% endif %}
|
|
</div>
|
|
{% endfor %}
|
|
<button type="submit" class="btn btn-sm" style="width:100%;margin-top:0.1rem;">Add to dashboard</button>
|
|
</div>
|
|
</form>
|
|
</details>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% else %}
|
|
<div style="color:var(--text-muted);font-size:0.85rem;padding:0.5rem 0;">
|
|
No plugin widgets available. Enable plugins in Settings → Plugins.
|
|
</div>
|
|
{% endif %}
|
|
</div>
|