hub: extract config_form_body sub-template + configFormData builder (v0.48.0 part 1)
Behavior-neutral extraction (the host_detail_body pattern): the config form's
<form> + in-flight script move to a {{define}} sub-template; config_form.html
keeps the chrome. renderConfigForm/handleConfigNewForm/handleConfigEditForm
now go through the one configFormData builder (nil overrides = parse stored
ConfigJSON). Prepares the customer page Edit tab embed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TZc5w5jDhFLv6qDC32KN5v
This commit is contained in:
+40
-59
@@ -421,25 +421,43 @@ func (s *Server) handleCustomerUnified(w http.ResponseWriter, r *http.Request, c
|
||||
}
|
||||
}
|
||||
|
||||
// configFormView is the render model of the customer config form — consumed by the standalone
|
||||
// config_form.html chrome AND embedded in the customer page's Edit tab as .ConfigForm
|
||||
// (v0.48.0 edit-a; the hostDetailData/host_detail_body pattern).
|
||||
type configFormView struct {
|
||||
IsNew bool
|
||||
Config *store.CustomerConfig
|
||||
Overrides map[string]interface{}
|
||||
ActiveNav string
|
||||
Error string
|
||||
CSRFField template.HTML
|
||||
PBSDR pbsDRView
|
||||
}
|
||||
|
||||
// configFormData assembles the config form's view model. overrides carries SUBMITTED form values
|
||||
// for the validation-error re-render (typed values must survive — B3); pass nil to fall back to
|
||||
// the STORED cfg.ConfigJSON (the normal read path).
|
||||
func (s *Server) configFormData(r *http.Request, isNew bool, cfg *store.CustomerConfig, overrides map[string]interface{}, errMsg string) configFormView {
|
||||
if overrides == nil {
|
||||
json.Unmarshal([]byte(cfg.ConfigJSON), &overrides)
|
||||
}
|
||||
if overrides == nil {
|
||||
overrides = make(map[string]interface{})
|
||||
}
|
||||
return configFormView{
|
||||
IsNew: isNew,
|
||||
Config: cfg,
|
||||
Overrides: overrides,
|
||||
ActiveNav: "configs",
|
||||
Error: errMsg,
|
||||
CSRFField: s.csrfField(r),
|
||||
PBSDR: s.pbsDRViewFor(cfg.CustomerID),
|
||||
}
|
||||
}
|
||||
|
||||
// handleConfigNewForm shows the form to create a new customer config.
|
||||
func (s *Server) handleConfigNewForm(w http.ResponseWriter, r *http.Request) {
|
||||
data := struct {
|
||||
IsNew bool
|
||||
Config *store.CustomerConfig
|
||||
Overrides map[string]interface{}
|
||||
ActiveNav string
|
||||
Error string
|
||||
CSRFField template.HTML
|
||||
PBSDR pbsDRView
|
||||
}{
|
||||
IsNew: true,
|
||||
Config: &store.CustomerConfig{},
|
||||
Overrides: make(map[string]interface{}),
|
||||
ActiveNav: "configs",
|
||||
CSRFField: s.csrfField(r),
|
||||
PBSDR: s.pbsDRViewFor(""),
|
||||
}
|
||||
s.templates.ExecuteTemplate(w, "config_form.html", data)
|
||||
s.renderConfigForm(w, r, true, &store.CustomerConfig{}, nil, "")
|
||||
}
|
||||
|
||||
// handleConfigCreate processes the form submission to create a new config.
|
||||
@@ -528,26 +546,7 @@ func (s *Server) handleConfigEditForm(w http.ResponseWriter, r *http.Request, cu
|
||||
return
|
||||
}
|
||||
|
||||
var overrides map[string]interface{}
|
||||
json.Unmarshal([]byte(cfg.ConfigJSON), &overrides)
|
||||
|
||||
data := struct {
|
||||
IsNew bool
|
||||
Config *store.CustomerConfig
|
||||
Overrides map[string]interface{}
|
||||
ActiveNav string
|
||||
Error string
|
||||
CSRFField template.HTML
|
||||
PBSDR pbsDRView
|
||||
}{
|
||||
IsNew: false,
|
||||
Config: cfg,
|
||||
Overrides: overrides,
|
||||
ActiveNav: "configs",
|
||||
CSRFField: s.csrfField(r),
|
||||
PBSDR: s.pbsDRViewFor(customerID),
|
||||
}
|
||||
s.templates.ExecuteTemplate(w, "config_form.html", data)
|
||||
s.renderConfigForm(w, r, false, cfg, nil, "")
|
||||
}
|
||||
|
||||
// handleConfigUpdate processes the edit form submission.
|
||||
@@ -965,29 +964,11 @@ func (s *Server) handleCreateConfigFromReport(w http.ResponseWriter, r *http.Req
|
||||
http.Redirect(w, r, "/configs/"+customerID+"/edit", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
// renderConfigForm is a helper to re-render the form with an error.
|
||||
// renderConfigForm renders the STANDALONE config form page (chrome + config_form_body) — the
|
||||
// create flow and the validation-error re-render. The customer page's Edit tab embeds the same
|
||||
// body via configFormData directly.
|
||||
func (s *Server) renderConfigForm(w http.ResponseWriter, r *http.Request, isNew bool, cfg *store.CustomerConfig, overrides map[string]interface{}, errMsg string) {
|
||||
if overrides == nil {
|
||||
overrides = make(map[string]interface{})
|
||||
}
|
||||
data := struct {
|
||||
IsNew bool
|
||||
Config *store.CustomerConfig
|
||||
Overrides map[string]interface{}
|
||||
ActiveNav string
|
||||
Error string
|
||||
CSRFField template.HTML
|
||||
PBSDR pbsDRView
|
||||
}{
|
||||
IsNew: isNew,
|
||||
Config: cfg,
|
||||
Overrides: overrides,
|
||||
ActiveNav: "configs",
|
||||
Error: errMsg,
|
||||
CSRFField: s.csrfField(r),
|
||||
PBSDR: s.pbsDRViewFor(cfg.CustomerID),
|
||||
}
|
||||
s.templates.ExecuteTemplate(w, "config_form.html", data)
|
||||
s.templates.ExecuteTemplate(w, "config_form.html", s.configFormData(r, isNew, cfg, overrides, errMsg))
|
||||
}
|
||||
|
||||
// buildConfigJSON builds the config_json from optional form fields.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Felhom Hub — {{if .IsNew}}Add Customer{{else}}Edit {{.Config.CustomerID}}{{end}}</title>
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<link rel="stylesheet" href="/style.css?v={{hubVersion}}">
|
||||
</head>
|
||||
<body>
|
||||
{{template "icon_sprite"}}
|
||||
@@ -28,200 +28,9 @@
|
||||
<div class="flash flash-error">{{.Error}}</div>
|
||||
{{end}}
|
||||
|
||||
<form method="POST" action="{{if .IsNew}}/configs/new{{else}}/configs/{{.Config.CustomerID}}/edit{{end}}" class="config-form">
|
||||
{{.CSRFField}}
|
||||
<div class="card">
|
||||
<h2>Customer Identity</h2>
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label for="customer_id">Customer ID *</label>
|
||||
<input type="text" id="customer_id" name="customer_id"
|
||||
value="{{.Config.CustomerID}}"
|
||||
pattern="[a-zA-Z0-9.\-]+"
|
||||
placeholder="e.g. customer-1"
|
||||
{{if not .IsNew}}readonly{{end}}
|
||||
required>
|
||||
{{if .IsNew}}<span class="form-hint">Letters, numbers, dots, hyphens only</span>{{end}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="customer_name">Display Name *</label>
|
||||
<input type="text" id="customer_name" name="customer_name"
|
||||
value="{{.Config.CustomerName}}"
|
||||
placeholder="e.g. Kovács család"
|
||||
required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="domain">Domain *</label>
|
||||
<input type="text" id="domain" name="domain"
|
||||
value="{{.Config.Domain}}"
|
||||
placeholder="e.g. kovacs.felhom.eu"
|
||||
required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input type="email" id="email" name="email"
|
||||
value="{{.Config.Email}}"
|
||||
placeholder="e.g. kovacs@example.com">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<details class="card" {{if index .Overrides "infrastructure"}}open{{end}}>
|
||||
<summary><h2 style="display:inline">Infrastructure</h2></summary>
|
||||
<div class="form-grid" style="margin-top: 1rem;">
|
||||
<div class="form-group">
|
||||
<label for="cf_tunnel_token">Cloudflare Tunnel Token</label>
|
||||
<input type="text" id="cf_tunnel_token" name="cf_tunnel_token"
|
||||
value="{{with .Overrides}}{{with index . "infrastructure"}}{{with index . "cf_tunnel_token"}}{{.}}{{end}}{{end}}{{end}}"
|
||||
placeholder="Optional">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="cf_api_token">Cloudflare API Token</label>
|
||||
<input type="text" id="cf_api_token" name="cf_api_token"
|
||||
value="{{with .Overrides}}{{with index . "infrastructure"}}{{with index . "cf_api_token"}}{{.}}{{end}}{{end}}{{end}}"
|
||||
placeholder="DNS-01 + WAF permissions">
|
||||
<small class="form-hint">Szükséges jogosultságok: Zone DNS:Edit (ACME), Zone WAF:Edit (geo-korlátozás)</small>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details class="card" {{if index .Overrides "git"}}open{{end}}>
|
||||
<summary><h2 style="display:inline">Git Sync</h2></summary>
|
||||
<p class="text-muted" style="margin: 0.5rem 0 0; font-size: 0.85rem;">Opcionális — csak privát alkalmazás-katalógushoz. A verziófrissítés enélkül is működik.</p>
|
||||
<div class="form-grid" style="margin-top: 1rem;">
|
||||
<div class="form-group">
|
||||
<label for="git_username">Git Username</label>
|
||||
<input type="text" id="git_username" name="git_username"
|
||||
value="{{with .Overrides}}{{with index . "git"}}{{with index . "username"}}{{.}}{{end}}{{end}}{{end}}"
|
||||
placeholder="For private catalog">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="git_token">Git Token</label>
|
||||
<input type="text" id="git_token" name="git_token"
|
||||
value="{{with .Overrides}}{{with index . "git"}}{{with index . "token"}}{{.}}{{end}}{{end}}{{end}}"
|
||||
placeholder="For private catalog">
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details class="card" {{if index .Overrides "logging"}}open{{end}}>
|
||||
<summary><h2 style="display:inline">Hibakeresési mód (fejlesztői)</h2></summary>
|
||||
<div class="form-grid" style="margin-top: 1rem;">
|
||||
<div class="form-group">
|
||||
<label><input type="checkbox" name="debug_mode"
|
||||
{{with .Overrides}}{{with index . "logging"}}{{if eq (index . "level") "debug"}}checked{{end}}{{end}}{{end}}>
|
||||
Debug mód — bőbeszédű napló + /debug menü a vezérlőn</label>
|
||||
<small class="form-hint">Bekapcsolva a vezérlő újraindul a következő ciklusban; a menü: https://felhom.<domain>/debug. Tesztelés után kapcsold ki.</small>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details class="card" {{if index .Overrides "offsite"}}open{{end}}>
|
||||
<summary><h2 style="display:inline">Offsite backup</h2></summary>
|
||||
<div class="form-grid" style="margin-top: 1rem;">
|
||||
<div class="form-group">
|
||||
<label><input type="checkbox" name="offsite_enabled"
|
||||
{{with .Overrides}}{{with index . "offsite"}}{{if index . "enabled"}}checked{{end}}{{end}}{{end}}>
|
||||
Enable offsite (provisions a Hetzner Storage Box on save)</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="offsite_type">Type</label>
|
||||
<select id="offsite_type" name="offsite_type">
|
||||
<option value="shared" {{with .Overrides}}{{with index . "offsite"}}{{if eq (index . "type") "shared"}}selected{{end}}{{end}}{{end}}>Shared (sub-account on the pool box)</option>
|
||||
<option value="dedicated" {{with .Overrides}}{{with index . "offsite"}}{{if eq (index . "type") "dedicated"}}selected{{end}}{{end}}{{end}}>Dedicated (own box)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="offsite_quota_gb">Soft-quota GB (shared)</label>
|
||||
<input type="number" id="offsite_quota_gb" name="offsite_quota_gb"
|
||||
value="{{with .Overrides}}{{with index . "offsite"}}{{with index . "quota_gb"}}{{.}}{{end}}{{end}}{{end}}" placeholder="e.g. 50">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="offsite_box_type">Box type (dedicated)</label>
|
||||
<select id="offsite_box_type" name="offsite_box_type">
|
||||
<option value="bx11" {{with .Overrides}}{{with index . "offsite"}}{{if eq (index . "box_type") "bx11"}}selected{{end}}{{end}}{{end}}>bx11 (1 TB)</option>
|
||||
<option value="bx21" {{with .Overrides}}{{with index . "offsite"}}{{if eq (index . "box_type") "bx21"}}selected{{end}}{{end}}{{end}}>bx21 (5 TB)</option>
|
||||
<option value="bx31" {{with .Overrides}}{{with index . "offsite"}}{{if eq (index . "box_type") "bx31"}}selected{{end}}{{end}}{{end}}>bx31 (10 TB)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{{with .Overrides}}{{with index . "offsite"}}{{if index . "host"}}
|
||||
<p class="form-hint" style="margin-top:.5rem">Provisioned: {{index . "user"}}@{{index . "host"}}:{{index . "repo_path"}} — the transient password is delivered to the controller once (never shown here).</p>
|
||||
<!-- F4: explicit operator recovery for a consumed-password dead-end (fresh-guest DR).
|
||||
Rides the parent form (nested forms are invalid HTML) via formaction; the _csrf field
|
||||
submits with it. Resets the box credential + stages a fresh one-time password. -->
|
||||
<button type="submit" class="btn btn-outline" style="margin-top:.5rem"
|
||||
formaction="/configs/{{$.Config.CustomerID}}/offsite-reissue" formmethod="POST"
|
||||
onclick="return confirm('Re-issue the offsite credentials?\n\nThe box password is reset and a fresh one-time password is staged for the controller. Guests with a working installed key are unaffected (key-auth-first); a stuck fresh guest picks the new password up on its next config refresh.')">
|
||||
Re-issue offsite credentials</button>
|
||||
{{if eq (index . "type") "shared"}}
|
||||
<!-- SLICE 4: operator freeze lever (readonly on the sub-account) — MANUAL only, never
|
||||
automatic: freezing also blocks prune, the customer's only way down from over-quota. -->
|
||||
<button type="submit" class="btn btn-outline" style="margin-top:.5rem"
|
||||
formaction="/configs/{{$.Config.CustomerID}}/offsite-freeze" formmethod="POST"
|
||||
onclick="return confirm('Freeze the offsite storage (read-only)?\n\nNew backups AND prune will fail until unfrozen — use for runaway usage only.')">
|
||||
Freeze offsite (read-only)</button>
|
||||
<button type="submit" class="btn btn-outline" name="unfreeze" value="1" style="margin-top:.5rem"
|
||||
formaction="/configs/{{$.Config.CustomerID}}/offsite-freeze" formmethod="POST"
|
||||
onclick="return confirm('Unfreeze the offsite storage (read-write again)?')">
|
||||
Unfreeze offsite</button>
|
||||
{{end}}
|
||||
{{end}}{{end}}{{end}}
|
||||
</details>
|
||||
|
||||
<details class="card" {{if .PBSDR.Enabled}}open{{end}}>
|
||||
<summary><h2 style="display:inline">PBS DR tier (ep0)</h2></summary>
|
||||
<div class="form-grid" style="margin-top: 1rem;">
|
||||
<div class="form-group">
|
||||
<label><input type="checkbox" name="pbsdr_enabled" {{if .PBSDR.Enabled}}checked{{end}}>
|
||||
Enable PBS DR (provisions the ep0 namespace + token on save; the host agent applies the storage entry)</label>
|
||||
{{if not .PBSDR.Supported}}
|
||||
<small class="form-hint">Not configured on this hub (no tenantsync key) — enabling will fail until it is.</small>
|
||||
{{else if .PBSDR.NoHost}}
|
||||
<small class="form-hint">No host enrolled for this customer yet — enabling fails until the agent enrolls and reports its WG key.</small>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pbsdr_storage_id">PVE storage id</label>
|
||||
<input type="text" id="pbsdr_storage_id" name="pbsdr_storage_id"
|
||||
value="{{.PBSDR.StorageID}}" placeholder="felhom-pbs">
|
||||
<small class="form-hint">The storage-entry id the agent creates on the box. Default felhom-pbs; the demo host's adopted manual entry is felhom-offsite.</small>
|
||||
</div>
|
||||
</div>
|
||||
{{if .PBSDR.Provisioned}}
|
||||
<p class="form-hint" style="margin-top:.5rem">Provisioned: namespace {{.PBSDR.Namespace}}, token {{.PBSDR.TokenID}} (host {{.PBSDR.HostID}}) — the token secret is delivered to the host agent once (never shown here).</p>
|
||||
<!-- The offsite F4 precedent: explicit operator re-key for a consumed-secret dead-end.
|
||||
Rides the parent form via formaction; _csrf submits with it. -->
|
||||
<button type="submit" class="btn btn-outline" style="margin-top:.5rem"
|
||||
formaction="/configs/{{.Config.CustomerID}}/pbsdr-reissue" formmethod="POST"
|
||||
onclick="return confirm('Re-issue the PBS credentials?\n\nThe endpoint token is re-keyed and a fresh one-time secret is staged for the host agent. A box with a working storage entry re-applies on its next desired-state fetch.')">
|
||||
Re-issue PBS credentials</button>
|
||||
{{end}}
|
||||
</details>
|
||||
|
||||
<div style="margin-top: 1.5rem; display: flex; gap: 1rem; align-items: center;">
|
||||
<button type="submit" class="btn">{{if .IsNew}}Create Configuration{{else}}Save Changes{{end}}</button>
|
||||
<a href="{{if .IsNew}}/configs{{else}}/customers/{{.Config.CustomerID}}{{end}}" class="btn btn-outline">Cancel</a>
|
||||
<span id="cfg-inflight" class="form-hint" style="display:none">Saving… offsite provisioning can take up to a minute — please do not click again.</span>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
// F5: the offsite save takes ~25–60s (create + action-wait + host-key scan). Without feedback
|
||||
// operators re-click, which used to strand the provision (live finding F1). Disable all submit
|
||||
// buttons + show the in-flight notice once a submit is underway (deferred a tick so the
|
||||
// clicked button's formaction still applies).
|
||||
(function () {
|
||||
var form = document.querySelector('form.config-form');
|
||||
if (!form) return;
|
||||
form.addEventListener('submit', function () {
|
||||
document.getElementById('cfg-inflight').style.display = 'inline';
|
||||
var btns = form.querySelectorAll('button[type=submit]');
|
||||
setTimeout(function () {
|
||||
for (var i = 0; i < btns.length; i++) btns[i].disabled = true;
|
||||
}, 0);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
{{/* v0.48.0 edit-a: the form body is shared with the customer page's Edit tab —
|
||||
one sub-template, two render surfaces (the host_detail_body pattern). */}}
|
||||
{{template "config_form_body" .}}
|
||||
|
||||
<footer>
|
||||
<p>Felhom Hub {{hubVersion}} — Configuration Management</p>
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
{{define "config_form_body"}}
|
||||
<form method="POST" action="{{if .IsNew}}/configs/new{{else}}/configs/{{.Config.CustomerID}}/edit{{end}}" class="config-form">
|
||||
{{.CSRFField}}
|
||||
<div class="card">
|
||||
<h2>Customer Identity</h2>
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label for="customer_id">Customer ID *</label>
|
||||
<input type="text" id="customer_id" name="customer_id"
|
||||
value="{{.Config.CustomerID}}"
|
||||
pattern="[a-zA-Z0-9.\-]+"
|
||||
placeholder="e.g. customer-1"
|
||||
{{if not .IsNew}}readonly{{end}}
|
||||
required>
|
||||
{{if .IsNew}}<span class="form-hint">Letters, numbers, dots, hyphens only</span>{{end}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="customer_name">Display Name *</label>
|
||||
<input type="text" id="customer_name" name="customer_name"
|
||||
value="{{.Config.CustomerName}}"
|
||||
placeholder="e.g. Kovács család"
|
||||
required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="domain">Domain *</label>
|
||||
<input type="text" id="domain" name="domain"
|
||||
value="{{.Config.Domain}}"
|
||||
placeholder="e.g. kovacs.felhom.eu"
|
||||
required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input type="email" id="email" name="email"
|
||||
value="{{.Config.Email}}"
|
||||
placeholder="e.g. kovacs@example.com">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<details class="card" {{if index .Overrides "infrastructure"}}open{{end}}>
|
||||
<summary><h2 style="display:inline">Infrastructure</h2></summary>
|
||||
<div class="form-grid" style="margin-top: 1rem;">
|
||||
<div class="form-group">
|
||||
<label for="cf_tunnel_token">Cloudflare Tunnel Token</label>
|
||||
<input type="text" id="cf_tunnel_token" name="cf_tunnel_token"
|
||||
value="{{with .Overrides}}{{with index . "infrastructure"}}{{with index . "cf_tunnel_token"}}{{.}}{{end}}{{end}}{{end}}"
|
||||
placeholder="Optional">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="cf_api_token">Cloudflare API Token</label>
|
||||
<input type="text" id="cf_api_token" name="cf_api_token"
|
||||
value="{{with .Overrides}}{{with index . "infrastructure"}}{{with index . "cf_api_token"}}{{.}}{{end}}{{end}}{{end}}"
|
||||
placeholder="DNS-01 + WAF permissions">
|
||||
<small class="form-hint">Szükséges jogosultságok: Zone DNS:Edit (ACME), Zone WAF:Edit (geo-korlátozás)</small>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details class="card" {{if index .Overrides "git"}}open{{end}}>
|
||||
<summary><h2 style="display:inline">Git Sync</h2></summary>
|
||||
<p class="text-muted" style="margin: 0.5rem 0 0; font-size: 0.85rem;">Opcionális — csak privát alkalmazás-katalógushoz. A verziófrissítés enélkül is működik.</p>
|
||||
<div class="form-grid" style="margin-top: 1rem;">
|
||||
<div class="form-group">
|
||||
<label for="git_username">Git Username</label>
|
||||
<input type="text" id="git_username" name="git_username"
|
||||
value="{{with .Overrides}}{{with index . "git"}}{{with index . "username"}}{{.}}{{end}}{{end}}{{end}}"
|
||||
placeholder="For private catalog">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="git_token">Git Token</label>
|
||||
<input type="text" id="git_token" name="git_token"
|
||||
value="{{with .Overrides}}{{with index . "git"}}{{with index . "token"}}{{.}}{{end}}{{end}}{{end}}"
|
||||
placeholder="For private catalog">
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details class="card" {{if index .Overrides "logging"}}open{{end}}>
|
||||
<summary><h2 style="display:inline">Hibakeresési mód (fejlesztői)</h2></summary>
|
||||
<div class="form-grid" style="margin-top: 1rem;">
|
||||
<div class="form-group">
|
||||
<label><input type="checkbox" name="debug_mode"
|
||||
{{with .Overrides}}{{with index . "logging"}}{{if eq (index . "level") "debug"}}checked{{end}}{{end}}{{end}}>
|
||||
Debug mód — bőbeszédű napló + /debug menü a vezérlőn</label>
|
||||
<small class="form-hint">Bekapcsolva a vezérlő újraindul a következő ciklusban; a menü: https://felhom.<domain>/debug. Tesztelés után kapcsold ki.</small>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details class="card" {{if index .Overrides "offsite"}}open{{end}}>
|
||||
<summary><h2 style="display:inline">Offsite backup</h2></summary>
|
||||
<div class="form-grid" style="margin-top: 1rem;">
|
||||
<div class="form-group">
|
||||
<label><input type="checkbox" name="offsite_enabled"
|
||||
{{with .Overrides}}{{with index . "offsite"}}{{if index . "enabled"}}checked{{end}}{{end}}{{end}}>
|
||||
Enable offsite (provisions a Hetzner Storage Box on save)</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="offsite_type">Type</label>
|
||||
<select id="offsite_type" name="offsite_type">
|
||||
<option value="shared" {{with .Overrides}}{{with index . "offsite"}}{{if eq (index . "type") "shared"}}selected{{end}}{{end}}{{end}}>Shared (sub-account on the pool box)</option>
|
||||
<option value="dedicated" {{with .Overrides}}{{with index . "offsite"}}{{if eq (index . "type") "dedicated"}}selected{{end}}{{end}}{{end}}>Dedicated (own box)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="offsite_quota_gb">Soft-quota GB (shared)</label>
|
||||
<input type="number" id="offsite_quota_gb" name="offsite_quota_gb"
|
||||
value="{{with .Overrides}}{{with index . "offsite"}}{{with index . "quota_gb"}}{{.}}{{end}}{{end}}{{end}}" placeholder="e.g. 50">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="offsite_box_type">Box type (dedicated)</label>
|
||||
<select id="offsite_box_type" name="offsite_box_type">
|
||||
<option value="bx11" {{with .Overrides}}{{with index . "offsite"}}{{if eq (index . "box_type") "bx11"}}selected{{end}}{{end}}{{end}}>bx11 (1 TB)</option>
|
||||
<option value="bx21" {{with .Overrides}}{{with index . "offsite"}}{{if eq (index . "box_type") "bx21"}}selected{{end}}{{end}}{{end}}>bx21 (5 TB)</option>
|
||||
<option value="bx31" {{with .Overrides}}{{with index . "offsite"}}{{if eq (index . "box_type") "bx31"}}selected{{end}}{{end}}{{end}}>bx31 (10 TB)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{{with .Overrides}}{{with index . "offsite"}}{{if index . "host"}}
|
||||
<p class="form-hint" style="margin-top:.5rem">Provisioned: {{index . "user"}}@{{index . "host"}}:{{index . "repo_path"}} — the transient password is delivered to the controller once (never shown here).</p>
|
||||
<!-- F4: explicit operator recovery for a consumed-password dead-end (fresh-guest DR).
|
||||
Rides the parent form (nested forms are invalid HTML) via formaction; the _csrf field
|
||||
submits with it. Resets the box credential + stages a fresh one-time password. -->
|
||||
<button type="submit" class="btn btn-outline" style="margin-top:.5rem"
|
||||
formaction="/configs/{{$.Config.CustomerID}}/offsite-reissue" formmethod="POST"
|
||||
onclick="return confirm('Re-issue the offsite credentials?\n\nThe box password is reset and a fresh one-time password is staged for the controller. Guests with a working installed key are unaffected (key-auth-first); a stuck fresh guest picks the new password up on its next config refresh.')">
|
||||
Re-issue offsite credentials</button>
|
||||
{{if eq (index . "type") "shared"}}
|
||||
<!-- SLICE 4: operator freeze lever (readonly on the sub-account) — MANUAL only, never
|
||||
automatic: freezing also blocks prune, the customer's only way down from over-quota. -->
|
||||
<button type="submit" class="btn btn-outline" style="margin-top:.5rem"
|
||||
formaction="/configs/{{$.Config.CustomerID}}/offsite-freeze" formmethod="POST"
|
||||
onclick="return confirm('Freeze the offsite storage (read-only)?\n\nNew backups AND prune will fail until unfrozen — use for runaway usage only.')">
|
||||
Freeze offsite (read-only)</button>
|
||||
<button type="submit" class="btn btn-outline" name="unfreeze" value="1" style="margin-top:.5rem"
|
||||
formaction="/configs/{{$.Config.CustomerID}}/offsite-freeze" formmethod="POST"
|
||||
onclick="return confirm('Unfreeze the offsite storage (read-write again)?')">
|
||||
Unfreeze offsite</button>
|
||||
{{end}}
|
||||
{{end}}{{end}}{{end}}
|
||||
</details>
|
||||
|
||||
<details class="card" {{if .PBSDR.Enabled}}open{{end}}>
|
||||
<summary><h2 style="display:inline">PBS DR tier (ep0)</h2></summary>
|
||||
<div class="form-grid" style="margin-top: 1rem;">
|
||||
<div class="form-group">
|
||||
<label><input type="checkbox" name="pbsdr_enabled" {{if .PBSDR.Enabled}}checked{{end}}>
|
||||
Enable PBS DR (provisions the ep0 namespace + token on save; the host agent applies the storage entry)</label>
|
||||
{{if not .PBSDR.Supported}}
|
||||
<small class="form-hint">Not configured on this hub (no tenantsync key) — enabling will fail until it is.</small>
|
||||
{{else if .PBSDR.NoHost}}
|
||||
<small class="form-hint">No host enrolled for this customer yet — enabling fails until the agent enrolls and reports its WG key.</small>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pbsdr_storage_id">PVE storage id</label>
|
||||
<input type="text" id="pbsdr_storage_id" name="pbsdr_storage_id"
|
||||
value="{{.PBSDR.StorageID}}" placeholder="felhom-pbs">
|
||||
<small class="form-hint">The storage-entry id the agent creates on the box. Default felhom-pbs; the demo host's adopted manual entry is felhom-offsite.</small>
|
||||
</div>
|
||||
</div>
|
||||
{{if .PBSDR.Provisioned}}
|
||||
<p class="form-hint" style="margin-top:.5rem">Provisioned: namespace {{.PBSDR.Namespace}}, token {{.PBSDR.TokenID}} (host {{.PBSDR.HostID}}) — the token secret is delivered to the host agent once (never shown here).</p>
|
||||
<!-- The offsite F4 precedent: explicit operator re-key for a consumed-secret dead-end.
|
||||
Rides the parent form via formaction; _csrf submits with it. -->
|
||||
<button type="submit" class="btn btn-outline" style="margin-top:.5rem"
|
||||
formaction="/configs/{{.Config.CustomerID}}/pbsdr-reissue" formmethod="POST"
|
||||
onclick="return confirm('Re-issue the PBS credentials?\n\nThe endpoint token is re-keyed and a fresh one-time secret is staged for the host agent. A box with a working storage entry re-applies on its next desired-state fetch.')">
|
||||
Re-issue PBS credentials</button>
|
||||
{{end}}
|
||||
</details>
|
||||
|
||||
<div style="margin-top: 1.5rem; display: flex; gap: 1rem; align-items: center;">
|
||||
<button type="submit" class="btn">{{if .IsNew}}Create Configuration{{else}}Save Changes{{end}}</button>
|
||||
<a href="{{if .IsNew}}/configs{{else}}/customers/{{.Config.CustomerID}}{{end}}" class="btn btn-outline">Cancel</a>
|
||||
<span id="cfg-inflight" class="form-hint" style="display:none">Saving… offsite provisioning can take up to a minute — please do not click again.</span>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
// F5: the offsite save takes ~25–60s (create + action-wait + host-key scan). Without feedback
|
||||
// operators re-click, which used to strand the provision (live finding F1). Disable all submit
|
||||
// buttons + show the in-flight notice once a submit is underway (deferred a tick so the
|
||||
// clicked button's formaction still applies).
|
||||
(function () {
|
||||
var form = document.querySelector('form.config-form');
|
||||
if (!form) return;
|
||||
form.addEventListener('submit', function () {
|
||||
document.getElementById('cfg-inflight').style.display = 'inline';
|
||||
var btns = form.querySelectorAll('button[type=submit]');
|
||||
setTimeout(function () {
|
||||
for (var i = 0; i < btns.length; i++) btns[i].disabled = true;
|
||||
}, 0);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
{{end}}
|
||||
Reference in New Issue
Block a user