feat(caddy-builder): DC-106 visual reverse proxy builder (frontend)
The /api/v1/caddycode/{generate,validate,templates} endpoints already
existed (commit 7f83151, GLM grade B); the frontend visual builder
page is the missing piece. This commit ships:
- status/js/caddy-builder.js — IIFE module that injects a modal with
a form-driven visual builder. Form state → JSON payload → live
POST /generate → preview pane. 5 presets loaded from
/api/v1/caddycode/templates (simple, websocket, auth-gated,
cors-api, subdirectory). Custom headers list (add/remove rows),
live validation, copy-to-clipboard, reset. State machine is a
single plain-object `state` snapshot — debounced regeneration
(250 ms). Exposes window.__caddyBuilder for testing.
- status/css/caddy-builder.css — page-specific styles, themed
via existing --bg / --border / --accent / --ok-fg / --warn-fg /
--err-fg CSS variables. Mobile-friendly single-column layout
below 880 px.
- status/index.html — adds /css/caddy-builder.css link + the
"🔧 Reverse Proxy Builder" button in the Tools menu (id
caddy-builder-btn). No other UI changes.
- status/build.js — registers caddy-builder.js in features.js
bundle. Same load-order conventions as the surrounding modules.
- dashcaddy-api/__tests__/unit/caddy-builder.unit.test.js — 19
pure-function tests covering state defaults, buildPayload
(whitespace trim, blank-key drop, authService/stripPrefix
nullification, all booleans explicit), applyTemplate (5
presets + unknown-id no-op), and generate() against mocked
fetch (POST shape, 400 error capture, network-failure
graceful handling, short-circuit on missing fields).
Includes XSS regression: verifies the global escapeHtml
contract used by renderHeadersList is safe against
<script>/quote-injection.
Verified:
- jest __tests__/unit/caddy-builder.unit.test.js: 19/19 pass
- jest __tests__/routes/caddycode-fleet.routes.test.js: 8/8 pass
- node build.js: features.js now bundles 27 files (was 26),
no errors, new SW cache tag dashcaddy-shell-1ceeb68cff
- Live dry-run of the backend /generate endpoint with the
state the form produces matches the existing 1633-test
baseline (no regression in caddycode routes)
- Frontend bundle grep finds 6 distinct caddy-builder
identifiers in dist/features.js
This commit is contained in:
@@ -0,0 +1,197 @@
|
||||
/* ===== DC-106: Reverse Proxy Builder styles ===== */
|
||||
|
||||
.cb-section {
|
||||
padding: 12px 14px;
|
||||
margin-bottom: 12px;
|
||||
background: var(--card-base, var(--bg));
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.cb-label {
|
||||
display: block;
|
||||
font-size: 0.85rem;
|
||||
margin-bottom: 10px;
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
.cb-label > input[type="text"],
|
||||
.cb-label > select {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin-top: 4px;
|
||||
padding: 6px 10px;
|
||||
font-size: 0.85rem;
|
||||
font-family: inherit;
|
||||
color: var(--fg);
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.cb-label > input[type="text"]:focus,
|
||||
.cb-label > select:focus {
|
||||
outline: 2px solid var(--accent, #4a9eff);
|
||||
outline-offset: -1px;
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.cb-label > input[type="text"]:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.cb-label small {
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
font-size: 0.75rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.cb-label small code {
|
||||
background: var(--code-bg, rgba(0,0,0,0.06));
|
||||
padding: 1px 4px;
|
||||
border-radius: 3px;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
.cb-checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 0.85rem;
|
||||
margin-bottom: 8px;
|
||||
color: var(--fg);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cb-checkbox input[type="checkbox"] {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cb-preview {
|
||||
flex: 1;
|
||||
min-height: 380px;
|
||||
max-height: 540px;
|
||||
margin: 0;
|
||||
padding: 12px;
|
||||
background: var(--code-bg, #0e1116);
|
||||
color: var(--code-fg, #e6e6e6);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
overflow: auto;
|
||||
font-family: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, "Courier New", monospace;
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.45;
|
||||
white-space: pre;
|
||||
tab-size: 2;
|
||||
}
|
||||
|
||||
.cb-preview code {
|
||||
font-family: inherit;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
color: inherit;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.cb-validation {
|
||||
margin-top: 8px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.cb-issues {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.cb-err {
|
||||
padding: 6px 10px;
|
||||
background: color-mix(in srgb, var(--err-fg, #e74c3c) 12%, transparent);
|
||||
border-left: 3px solid var(--err-fg, #e74c3c);
|
||||
border-radius: 4px;
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
.cb-warn {
|
||||
padding: 6px 10px;
|
||||
background: color-mix(in srgb, var(--warn-fg, #f0c674) 12%, transparent);
|
||||
border-left: 3px solid var(--warn-fg, #f0c674);
|
||||
border-radius: 4px;
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
.cb-ok {
|
||||
display: inline-block;
|
||||
padding: 4px 10px;
|
||||
background: color-mix(in srgb, var(--ok-fg, #27ae60) 12%, transparent);
|
||||
border-left: 3px solid var(--ok-fg, #27ae60);
|
||||
border-radius: 4px;
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
.cb-error {
|
||||
margin-top: 8px;
|
||||
padding: 8px 10px;
|
||||
background: color-mix(in srgb, var(--err-fg, #e74c3c) 12%, transparent);
|
||||
border-left: 3px solid var(--err-fg, #e74c3c);
|
||||
border-radius: 4px;
|
||||
color: var(--fg);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.cb-header-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 2fr auto;
|
||||
gap: 6px;
|
||||
margin-bottom: 6px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.cb-header-row input {
|
||||
padding: 5px 8px;
|
||||
font-size: 0.8rem;
|
||||
font-family: inherit;
|
||||
color: var(--fg);
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.cb-header-row input:focus {
|
||||
outline: 2px solid var(--accent, #4a9eff);
|
||||
outline-offset: -1px;
|
||||
}
|
||||
|
||||
.cb-header-row button {
|
||||
padding: 4px 8px;
|
||||
font-size: 0.85rem;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
color: var(--muted);
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cb-header-row button:hover {
|
||||
border-color: var(--err-fg, #e74c3c);
|
||||
color: var(--err-fg, #e74c3c);
|
||||
}
|
||||
|
||||
/* Modal sizing override for the builder — needs wider content */
|
||||
#caddy-builder-modal .weather-modal-content {
|
||||
width: min(1100px, 95vw);
|
||||
max-height: 92vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
@media (max-width: 880px) {
|
||||
#caddy-builder-modal .weather-modal-content > div[style*="grid-template-columns"] {
|
||||
grid-template-columns: 1fr !important;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user