1c0a7cb850
Phase 4 — New Widget Types: - Clock/Weather, System Stats, RSS/Feed, Calendar, Markdown, Metric/Counter, Link Group, Camera/Stream widgets - Backend services with caching for each data source - Full creation form with dynamic config fields per type Phase 5 — Visual & Styling Enhancements: - Glassmorphism card style (solid/glass/outline) - Board-level themes with per-board hue/saturation - Animated SVG status rings replacing static dots - Card size options (compact/medium/large) - Custom CSS injection (admin + per-board, sanitized) - Wallpaper backgrounds with blur/overlay/parallax Phase 6 — Functional Features: - Favorites bar with drag-and-drop reordering - Recent apps tracking with privacy toggle - Uptime dashboard page (/status, guest-accessible) - Notifications system (Discord/Slack/Telegram/HTTP webhooks) - App tags with filtering in board view - Multi-URL app cards with expandable sub-links - Personal API tokens with scoped permissions - Audit log with retention and admin viewer Phase 7 — Quality of Life: - Onboarding wizard (5-step first-launch setup) - App URL health preview with favicon/title detection - Board templates (4 built-in + custom import/export) - Keyboard shortcut overlay (j/k nav, 1-9 boards, ? help) 212 files changed, 15641 insertions, 980 deletions. Build, lint, type check, and 222 tests all pass.
74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
import { prisma } from '../prisma.js';
|
|
import { DEFAULTS } from '$lib/utils/constants.js';
|
|
|
|
/**
|
|
* Check whether the onboarding wizard should be shown.
|
|
* Returns true if no users exist OR SystemSettings.onboardingComplete is false.
|
|
*/
|
|
export async function isOnboardingNeeded(): Promise<boolean> {
|
|
const userCount = await prisma.user.count();
|
|
if (userCount === 0) {
|
|
return true;
|
|
}
|
|
|
|
try {
|
|
const settings = await prisma.systemSettings.findUnique({
|
|
where: { id: DEFAULTS.SYSTEM_SETTINGS_ID },
|
|
select: { onboardingComplete: true }
|
|
});
|
|
|
|
// If no settings record exists yet, onboarding is needed
|
|
if (!settings) {
|
|
return true;
|
|
}
|
|
|
|
return !settings.onboardingComplete;
|
|
} catch {
|
|
// If SystemSettings table doesn't exist yet, onboarding is needed
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Mark onboarding as complete in SystemSettings.
|
|
*/
|
|
export async function completeOnboarding(): Promise<void> {
|
|
await prisma.systemSettings.upsert({
|
|
where: { id: DEFAULTS.SYSTEM_SETTINGS_ID },
|
|
update: { onboardingComplete: true },
|
|
create: {
|
|
id: DEFAULTS.SYSTEM_SETTINGS_ID,
|
|
onboardingComplete: true
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Get the current onboarding status.
|
|
*/
|
|
export async function getOnboardingStatus(): Promise<{
|
|
readonly needed: boolean;
|
|
readonly hasUsers: boolean;
|
|
readonly onboardingComplete: boolean;
|
|
}> {
|
|
const userCount = await prisma.user.count();
|
|
const hasUsers = userCount > 0;
|
|
|
|
let onboardingComplete = false;
|
|
try {
|
|
const settings = await prisma.systemSettings.findUnique({
|
|
where: { id: DEFAULTS.SYSTEM_SETTINGS_ID },
|
|
select: { onboardingComplete: true }
|
|
});
|
|
onboardingComplete = settings?.onboardingComplete ?? false;
|
|
} catch {
|
|
onboardingComplete = false;
|
|
}
|
|
|
|
return {
|
|
needed: !hasUsers || !onboardingComplete,
|
|
hasUsers,
|
|
onboardingComplete
|
|
};
|
|
}
|