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.
84 lines
1.7 KiB
TypeScript
84 lines
1.7 KiB
TypeScript
import { prisma } from '../prisma.js';
|
|
|
|
/**
|
|
* Get user's favorite apps, ordered by position.
|
|
*/
|
|
export async function getUserFavorites(userId: string) {
|
|
return prisma.userFavorite.findMany({
|
|
where: { userId },
|
|
orderBy: { order: 'asc' },
|
|
include: {
|
|
app: {
|
|
include: {
|
|
statuses: {
|
|
orderBy: { checkedAt: 'desc' },
|
|
take: 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Add an app to user's favorites (append to end).
|
|
*/
|
|
export async function addFavorite(userId: string, appId: string) {
|
|
// Check if already favorited
|
|
const existing = await prisma.userFavorite.findUnique({
|
|
where: { userId_appId: { userId, appId } }
|
|
});
|
|
if (existing) {
|
|
throw new Error('App is already in favorites');
|
|
}
|
|
|
|
// Get the next order value
|
|
const maxFav = await prisma.userFavorite.findFirst({
|
|
where: { userId },
|
|
orderBy: { order: 'desc' },
|
|
select: { order: true }
|
|
});
|
|
const nextOrder = (maxFav?.order ?? -1) + 1;
|
|
|
|
return prisma.userFavorite.create({
|
|
data: {
|
|
userId,
|
|
appId,
|
|
order: nextOrder
|
|
},
|
|
include: {
|
|
app: true
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Remove an app from user's favorites.
|
|
*/
|
|
export async function removeFavorite(userId: string, appId: string) {
|
|
const existing = await prisma.userFavorite.findUnique({
|
|
where: { userId_appId: { userId, appId } }
|
|
});
|
|
if (!existing) {
|
|
throw new Error('App is not in favorites');
|
|
}
|
|
|
|
await prisma.userFavorite.delete({
|
|
where: { userId_appId: { userId, appId } }
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reorder user's favorites by setting order based on array position.
|
|
*/
|
|
export async function reorderFavorites(userId: string, favoriteIds: string[]) {
|
|
const updates = favoriteIds.map((id, index) =>
|
|
prisma.userFavorite.update({
|
|
where: { id },
|
|
data: { order: index }
|
|
})
|
|
);
|
|
|
|
return prisma.$transaction(updates);
|
|
}
|