import { Component, createSignal, Show } from 'solid-js'; import { showError, showSuccess } from '@/utils/toast'; interface WelcomeStepProps { onNext: () => void; bootstrapToken: string; setBootstrapToken: (token: string) => void; isUnlocked: boolean; setIsUnlocked: (unlocked: boolean) => void; } export const WelcomeStep: Component = (props) => { const [isValidating, setIsValidating] = createSignal(false); const [tokenPath, setTokenPath] = createSignal(''); const [isDocker, setIsDocker] = createSignal(false); const [inContainer, setInContainer] = createSignal(false); const [lxcCtid, setLxcCtid] = createSignal(''); // Fetch bootstrap info on mount const fetchBootstrapInfo = async () => { try { const response = await fetch('/api/security/status'); if (response.ok) { const data = await response.json(); if (data.bootstrapTokenPath) { setTokenPath(data.bootstrapTokenPath); setIsDocker(data.isDocker || false); setInContainer(data.inContainer || false); setLxcCtid(data.lxcCtid || ''); } } } catch (error) { console.error('Failed to fetch bootstrap info:', error); } }; // Call on component load fetchBootstrapInfo(); const handleUnlock = async () => { if (!props.bootstrapToken.trim()) { showError('Please enter the bootstrap token'); return; } setIsValidating(true); try { const response = await fetch('/api/security/validate-bootstrap-token', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ token: props.bootstrapToken.trim() }), }); if (!response.ok) { throw new Error('Invalid bootstrap token'); } props.setIsUnlocked(true); showSuccess('Token verified!'); props.onNext(); } catch (_error) { showError('Invalid bootstrap token. Please check and try again.'); } finally { setIsValidating(false); } }; const getTokenCommand = () => { const path = tokenPath() || '/etc/pulse/.bootstrap_token'; if (isDocker()) { return `docker exec cat ${path}`; } if (inContainer() && lxcCtid()) { return `pct exec ${lxcCtid()} -- cat ${path}`; } if (inContainer()) { return `pct exec -- cat ${path}`; } return `cat ${path}`; }; return (
{/* Logo */}

Welcome to Pulse

Unified infrastructure monitoring

{/* Feature highlights */}
πŸ–₯️
Proxmox
🐳
Docker
☸️
Kubernetes
{/* Bootstrap token unlock */}

Unlock Setup

Retrieve the bootstrap token from your host:

{getTokenCommand()}
props.setBootstrapToken(e.currentTarget.value)} onKeyPress={(e) => e.key === 'Enter' && handleUnlock()} class="w-full px-4 py-3 bg-white/10 border border-white/20 rounded-xl text-white placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono" placeholder="Paste your bootstrap token" autofocus />
); };