agnes-the-ai-analyst/app/web/templates/admin_welcome.html
2026-05-03 16:10:48 +02:00

90 lines
3.4 KiB
HTML

{% extends "base.html" %}
{% block title %}Welcome Prompt — Admin{% endblock %}
{% block content %}
<div class="admin-page">
<h1>Analyst Welcome Prompt</h1>
<p class="muted">
This is the CLAUDE.md generated for analysts when they run
<code>da analyst setup</code>. Edit it to customize the onboarding
instructions for this instance. Leave empty (or click <em>Reset to default</em>)
to use the OSS-shipped default.
</p>
{% if is_override %}
<p class="status">
Overridden by <strong>{{ updated_by }}</strong> on
{{ updated_at.strftime("%Y-%m-%d %H:%M UTC") if updated_at else "—" }}.
</p>
{% else %}
<p class="status">Using shipped default.</p>
{% endif %}
<h2>Available placeholders</h2>
<pre class="placeholder-cheatsheet">
{{ "{{ instance.name }}" }} — instance display name
{{ "{{ instance.subtitle }}" }} — operator name
{{ "{{ server.url }}" }} — full server URL
{{ "{{ server.hostname }}" }} — host part
{{ "{{ sync_interval }}" }} — refresh cadence (instance.yaml)
{{ "{{ data_source.type }}" }} — keboola | bigquery | local
{{ "{{ tables }}" }} — list of {name, description, query_mode}
{{ "{{ metrics.count }}" }}, {{ "{{ metrics.categories }}" }}
{{ "{{ marketplaces }}" }} — RBAC-filtered list of {slug, name, plugins[]}
{{ "{{ user.email }}" }}, {{ "{{ user.name }}" }}, {{ "{{ user.is_admin }}" }}, {{ "{{ user.groups }}" }}
{{ "{{ now }}" }}, {{ "{{ today }}" }}
</pre>
<form id="welcome-form" onsubmit="return false">
<textarea id="content" rows="30" cols="100">{{ current or default_template }}</textarea>
<div class="actions">
<button type="button" id="save-btn">Save override</button>
<button type="button" id="reset-btn" class="secondary">Reset to default</button>
<button type="button" id="preview-btn" class="secondary">Preview</button>
</div>
<div id="result" class="result"></div>
<pre id="preview" class="preview" hidden></pre>
</form>
</div>
<script>
const $ = (id) => document.getElementById(id);
const result = $("result");
$("save-btn").addEventListener("click", async () => {
result.textContent = "Saving…";
const r = await fetch("/api/admin/welcome-template", {
method: "PUT",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({content: $("content").value}),
});
if (r.ok) {
result.textContent = "Saved.";
} else {
const err = await r.json();
result.textContent = "Error: " + (err.detail || r.statusText);
}
});
$("reset-btn").addEventListener("click", async () => {
if (!confirm("Reset to OSS default? Your override will be lost.")) return;
const r = await fetch("/api/admin/welcome-template", {method: "DELETE"});
if (r.ok) {
result.textContent = "Reset. Reload to see the default.";
} else {
result.textContent = "Error: " + r.statusText;
}
});
$("preview-btn").addEventListener("click", async () => {
const r = await fetch("/api/welcome?server_url=" + encodeURIComponent(window.location.origin));
if (r.ok) {
const j = await r.json();
$("preview").textContent = j.content;
$("preview").hidden = false;
} else {
const err = await r.json();
result.textContent = "Render error: " + (err.detail || r.statusText);
}
});
</script>
{% endblock %}