feat(accounts): add admin accounts and user preferences
Remove public registration, support administrator-managed accounts, and persist personal preferences. Refs #2 #5 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -10,7 +10,7 @@ export interface OllamaModelInfo {
|
||||
name: string; size: number; modified_at: string
|
||||
details: { parameter_size: string; quantization_level: string; family: string }
|
||||
}
|
||||
export interface Source { id: string; name: string; type: string; enabled: boolean }
|
||||
export interface Source { id: string; name: string; type: string; enabled: boolean; article_limit: number }
|
||||
export interface ScrapeJob {
|
||||
id: string; source_id: string; source_name: string; status: string
|
||||
started_at: { Time: string; Valid: boolean } | null
|
||||
@ -51,7 +51,8 @@ export const adminApi = {
|
||||
|
||||
// Sources
|
||||
listSources: () => api.get<Source[]>('/admin/sources'),
|
||||
updateSource: (id: string, enabled: boolean) => api.put<void>(`/admin/sources/${id}`, { enabled }),
|
||||
updateSource: (id: string, enabled: boolean, article_limit?: number) =>
|
||||
api.put<void>(`/admin/sources/${id}`, { enabled, ...(article_limit === undefined ? {} : { article_limit }) }),
|
||||
|
||||
// Jobs
|
||||
listJobs: () => api.get<ScrapeJob[]>('/admin/scrape-jobs'),
|
||||
@ -67,6 +68,8 @@ export const adminApi = {
|
||||
updateSchedule: (slots: ScheduleSlot[]) => api.put<void>('/admin/schedule', { slots }),
|
||||
|
||||
// Users
|
||||
createUser: (data: { email: string; role: 'user' | 'admin'; password: string }) =>
|
||||
api.post<AdminUser>('/admin/users', data),
|
||||
listUsers: () => api.get<AdminUser[]>('/admin/users'),
|
||||
updateUser: (id: string, email: string, role: string) =>
|
||||
api.put<AdminUser>(`/admin/users/${id}`, { email, role }),
|
||||
|
||||
11
frontend/src/api/preferences.ts
Normal file
11
frontend/src/api/preferences.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { api } from './client'
|
||||
|
||||
export interface UserPreferences {
|
||||
language: 'fr' | 'en'
|
||||
ranking_mode: 'title' | 'title_content'
|
||||
}
|
||||
|
||||
export const preferencesApi = {
|
||||
get: () => api.get<UserPreferences>('/me/preferences'),
|
||||
update: (preferences: UserPreferences) => api.put<UserPreferences>('/me/preferences', preferences),
|
||||
}
|
||||
Reference in New Issue
Block a user