Adds the install-time Beginner/Advanced choice the user described, with
the linked dev-mode escape hatch and global body-class machinery that
any surface can hang advanced/dev-only DOM off.
Three-tier mental model, two flags in the data model:
Beginner default. nothing extra shown.
Advanced .lp-advanced DOM revealed; advanced wizard steps shown
Adv+Dev .lp-dev DOM also revealed; dev-only fields visible
Linking rule (enforced inside LpUi):
- enabling dev auto-enables advanced (dev w/o advanced is incoherent)
- disabling advanced auto-disables dev
Wire shape:
CFG_INSTALL_LEVEL beginner | advanced (general_basic)
CFG_DEV_MODE existing, unchanged behaviour
window.LpUi.{advanced,dev} {get(), set(), apply()}
localStorage keys lp.ui.advanced, lp.ui.dev, lp.ui.seeded
body classes lp-ui--advanced, lp-ui--dev
events lp-ui-advanced-changed, lp-ui-dev-changed
global CSS gates body:not(.lp-ui--advanced) .lp-advanced { hide }
body:not(.lp-ui--dev) .lp-dev { hide }
Setup wizard:
- New step 1 "Choose your experience" with Beginner/Advanced cards.
Beginner is preselected so race-through gets the safe default.
- Picking a level updates totalSteps live (4 for beginner, 5 for
advanced) so the progress bar reflects the choice.
- Metrics step (Prometheus + Grafana) is gated to Advanced — beginner
never sees it, never gets asked, never installs them by accident.
- Submit payload now carries install_level; setup-routes.js validates
it against the enum (beginner|advanced).
- scripts/setup/setup_apply.sh writes it to CFG_INSTALL_LEVEL via
updateConfigOption.
- On submit, LpUi.advanced.set is called immediately so the next
surface (running-tasks page) is already in the right mode — no
refresh needed.
WebUI bootstrap:
- js/utils/lp-ui.js loads first thing in index.html (before any other
bootstrap) so body.lp-ui--advanced is applied pre-paint — no FOUC
of advanced content on a fresh tab.
- On first run, seeds lp.ui.advanced from CFG_INSTALL_LEVEL.
Subsequent loads honour the user's per-browser override.
- Mirrors CFG_DEV_MODE → lp.ui.dev on the seed pass.
Dev-mode unlock:
- Existing 10-click LibrePortal-logo easter egg unchanged.
- NEW: same 10-click unlock on the Advanced toggle (in services-manager).
Reuses the countdown-toast pattern; on the 10th click delegates to
the topbar's _setDevMode so there's one canonical setter and the
config_update task path stays singular.
- TopbarComponent now exposes its instance as window.topbar so the
toggle's tap handler can reach _setDevMode.
- topbar._setDevMode also calls LpUi.dev.set(enabled) so the body
class flips immediately (no reload needed to see dev-only DOM).
Convention rolled out:
- Services tab's .service-rich panel was already gated on
body.lp-ui--advanced.
- .lp-advanced / .lp-dev are now first-class hide classes any
component can tag DOM with — see style.css globals.
Signed-off-by: librelad <librelad@digitalangels.vip>
160 lines
5.6 KiB
Bash
160 lines
5.6 KiB
Bash
#!/bin/bash
|
|
|
|
setupApplyConfig()
|
|
{
|
|
local payload_b64="$1"
|
|
|
|
if [[ -z "$payload_b64" ]]; then
|
|
isError "setupApplyConfig: no payload provided"
|
|
return 1
|
|
fi
|
|
|
|
local payload
|
|
payload=$(echo "$payload_b64" | base64 -d 2>/dev/null)
|
|
if [[ -z "$payload" ]]; then
|
|
isError "setupApplyConfig: failed to decode payload"
|
|
return 1
|
|
fi
|
|
|
|
isHeader "Applying Setup Wizard Configuration"
|
|
|
|
local install_name=$(echo "$payload" | jq -r '.install_name // empty')
|
|
local timezone=$(echo "$payload" | jq -r '.timezone // empty')
|
|
local install_level=$(echo "$payload" | jq -r '.install_level // empty')
|
|
local traefik_email=$(echo "$payload" | jq -r '.traefik_email // empty')
|
|
local domains_json=$(echo "$payload" | jq -c '.domains // []')
|
|
|
|
if [[ -n "$install_name" ]]; then
|
|
updateConfigOption "CFG_INSTALL_NAME" "$install_name"
|
|
isSuccessful "Install name set to '$install_name'"
|
|
fi
|
|
|
|
if [[ -n "$timezone" ]]; then
|
|
updateConfigOption "CFG_TIMEZONE" "$timezone"
|
|
isSuccessful "Timezone set to '$timezone'"
|
|
fi
|
|
|
|
# Experience level — seeds the WebUI's Advanced UI mode on first paint
|
|
# so a Beginner gets a stripped-down view and an Advanced user sees
|
|
# everything by default. The WebUI also exposes a per-browser toggle
|
|
# that overrides this; we just provide the install-time default.
|
|
if [[ "$install_level" == "beginner" || "$install_level" == "advanced" ]]; then
|
|
updateConfigOption "CFG_INSTALL_LEVEL" "$install_level"
|
|
isSuccessful "Experience level set to '$install_level'"
|
|
fi
|
|
|
|
local domains_count=$(echo "$domains_json" | jq -r 'length')
|
|
if [[ "$domains_count" -gt 0 ]]; then
|
|
local i=0
|
|
while [[ $i -lt $domains_count && $i -lt 9 ]]; do
|
|
local d=$(echo "$domains_json" | jq -r ".[$i]")
|
|
updateConfigOption "CFG_DOMAIN_$((i+1))" "$d"
|
|
isSuccessful "Domain $((i+1)) set to '$d'"
|
|
((i++))
|
|
done
|
|
fi
|
|
|
|
if [[ -n "$traefik_email" && "$traefik_email" != "null" ]]; then
|
|
# CFG_TRAEFIK_EMAIL lives in containers/traefik/traefik.config, not in
|
|
# the system $configs_dir, so findConfigFileForOption can't auto-locate
|
|
# it. Point updateConfigOption at the source file directly. Traefik
|
|
# may not be installed yet at this point — config gets copied from
|
|
# install_containers_dir into containers_dir during the app-install
|
|
# task, so we always update the source.
|
|
local traefik_config_file="$install_containers_dir/traefik/traefik.config"
|
|
if [[ -f "$traefik_config_file" ]]; then
|
|
updateConfigOption "CFG_TRAEFIK_EMAIL" "$traefik_email" "$traefik_config_file"
|
|
isSuccessful "Traefik LetsEncrypt email set to '$traefik_email'"
|
|
else
|
|
isNotice "Traefik source config not found at $traefik_config_file; skipping email write."
|
|
fi
|
|
fi
|
|
|
|
# App sub-options are no longer handled here. The setup-routes backend
|
|
# folds payload.appOptions into each install command's config_variables
|
|
# arg (CFG_REQUIREMENT_<APP>_<OPT>=<bool>) and dockerInstallApp writes
|
|
# them into the template config before install<App> runs.
|
|
|
|
sourceScanFiles "libreportal_configs"
|
|
isSuccessful "Configuration written. Selected apps will install next."
|
|
}
|
|
|
|
setupApplyFinalize()
|
|
{
|
|
isNotice "Initializing backup engine..."
|
|
if declare -f installResticHost >/dev/null 2>&1; then
|
|
installResticHost
|
|
else
|
|
isNotice "installResticHost not loaded; backup repos will init on first backup."
|
|
fi
|
|
|
|
isNotice "Refreshing WebUI data snapshots so the config page reflects wizard changes..."
|
|
if declare -f webuiLibrePortalUpdate >/dev/null 2>&1; then
|
|
webuiLibrePortalUpdate
|
|
else
|
|
isNotice "webuiLibrePortalUpdate not loaded; skipping refresh."
|
|
fi
|
|
|
|
if declare -f webuiGenerateBackupLocations >/dev/null 2>&1; then
|
|
webuiGenerateBackupLocations
|
|
webuiGenerateBackupDashboard
|
|
webuiGenerateBackupSnapshots all
|
|
webuiGenerateBackupAppStatus
|
|
fi
|
|
|
|
setupWizardMarkComplete
|
|
isSuccessful "Setup Wizard complete — your install is configured and ready."
|
|
}
|
|
|
|
setupApply()
|
|
{
|
|
setupApplyConfig "$1" || return 1
|
|
|
|
local payload=$(echo "$1" | base64 -d 2>/dev/null)
|
|
local apps_json=$(echo "$payload" | jq -c '.apps // []')
|
|
local apps_count=$(echo "$apps_json" | jq -r 'length')
|
|
|
|
if [[ "$apps_count" -gt 0 ]]; then
|
|
isHeader "Installing Selected Apps"
|
|
local i=0
|
|
while [[ $i -lt $apps_count ]]; do
|
|
local app_name=$(echo "$apps_json" | jq -r ".[$i]")
|
|
isNotice "[$((i+1))/$apps_count] Installing $app_name..."
|
|
dockerInstallApp "$app_name"
|
|
((i++))
|
|
done
|
|
fi
|
|
|
|
setupApplyFinalize
|
|
}
|
|
|
|
setupGenerateName()
|
|
{
|
|
if declare -f generateInstallName >/dev/null 2>&1; then
|
|
generateInstallName
|
|
else
|
|
echo "QuantumOtter"
|
|
fi
|
|
}
|
|
|
|
setupCheckDomainPointsHere()
|
|
{
|
|
local domain="$1"
|
|
if [[ -z "$domain" ]]; then
|
|
echo '{"matches":false,"error":"no domain"}'
|
|
return 1
|
|
fi
|
|
|
|
local server_ip
|
|
server_ip=$(dig +short +time=3 +tries=1 myip.opendns.com @resolver1.opendns.com 2>/dev/null | head -1)
|
|
[[ -z "$server_ip" ]] && server_ip=$(hostname -I 2>/dev/null | awk '{print $1}')
|
|
|
|
local domain_ip
|
|
domain_ip=$(dig +short +time=3 +tries=1 "$domain" A 2>/dev/null | head -1)
|
|
|
|
local matches="false"
|
|
[[ -n "$server_ip" && "$server_ip" == "$domain_ip" ]] && matches="true"
|
|
|
|
printf '{"matches":%s,"server_ip":"%s","domain_ip":"%s"}\n' "$matches" "$server_ip" "$domain_ip"
|
|
}
|