대시보드 이슈 정리 1차
This commit is contained in:
parent
94cc56592f
commit
f472883c31
13 changed files with 592 additions and 311 deletions
|
|
@ -155,32 +155,9 @@ export const api = {
|
|||
===================================================================== */
|
||||
|
||||
/** GET /auth/me — auth.py MeResponse */
|
||||
export interface MeResponse {
|
||||
user_id: string;
|
||||
email: string;
|
||||
display_name: string;
|
||||
role: string; // "learner" | "teacher" | "admin"
|
||||
cohort_ids: string[];
|
||||
consent_at: number | null;
|
||||
}
|
||||
|
||||
export interface ConsentResponse {
|
||||
consent_at: number | null;
|
||||
}
|
||||
|
||||
export interface AuthConfigResponse {
|
||||
google_oauth_configured: boolean;
|
||||
saml_configured: boolean;
|
||||
providers: Array<{
|
||||
provider: "google" | "saml";
|
||||
configured: boolean;
|
||||
enabled: boolean;
|
||||
login_path: string;
|
||||
}>;
|
||||
allowed_email_domains: string[];
|
||||
redirect_uri: string;
|
||||
dev_login_enabled: boolean;
|
||||
}
|
||||
export type MeResponse = ApiSchema<"MeResponse">;
|
||||
export type ConsentResponse = ApiSchema<"ConsentResponse">;
|
||||
export type AuthConfigResponse = ApiSchema<"AuthConfigResponse">;
|
||||
|
||||
export const authApi = {
|
||||
config: () => api.get<AuthConfigResponse>("/auth/config"),
|
||||
|
|
@ -191,34 +168,11 @@ export const authApi = {
|
|||
export type SessionStage = "라포" | "탐색" | "개입" | "정리";
|
||||
|
||||
/** GET /personas — personas.py PersonaSummary */
|
||||
export interface PersonaSummary {
|
||||
code: string;
|
||||
display_name: string;
|
||||
difficulty: "easy" | "moderate" | "hard" | string;
|
||||
theory_target: string[];
|
||||
demographics: Record<string, unknown>;
|
||||
presenting_summary: string;
|
||||
voice_preset: string | null;
|
||||
source: string;
|
||||
degraded: boolean;
|
||||
}
|
||||
export type PersonaSummary = ApiSchema<"PersonaSummary">;
|
||||
|
||||
export type PersonaReviewStatus = "draft" | "review" | "approved" | "archived";
|
||||
export type PersonaReviewAction = "approve" | "reject";
|
||||
|
||||
export interface PersonaReviewSummary {
|
||||
persona_id: string;
|
||||
code: string;
|
||||
version: number;
|
||||
status: PersonaReviewStatus;
|
||||
display_name: string;
|
||||
difficulty: "easy" | "moderate" | "hard" | string;
|
||||
theory_target: string[];
|
||||
source_provenance: string;
|
||||
is_synthetic: boolean;
|
||||
created_at: string | null;
|
||||
approved_at: string | null;
|
||||
}
|
||||
export type PersonaReviewAction = ApiSchema<"PersonaReviewDecisionRequest">["action"];
|
||||
export type PersonaReviewSummary = ApiSchema<"PersonaReviewSummary">;
|
||||
|
||||
export type PersonaDraftPayload = ApiSchema<"PersonaDraftPayload">;
|
||||
export type PersonaDraftDetail = ApiSchema<"PersonaDraftDetail">;
|
||||
|
|
@ -240,39 +194,15 @@ export type TurnResponse = ApiSchema<"TurnResponse">;
|
|||
/** POST /sessions/{id}/end — sessions.py SessionEndResponse */
|
||||
export type SessionEndResponse = ApiSchema<"SessionEndResponse">;
|
||||
|
||||
export interface CrisisResource {
|
||||
title: string;
|
||||
number: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface LearnerSessionSummary {
|
||||
session_id: string;
|
||||
persona_code: string;
|
||||
persona_name: string;
|
||||
session_no: number;
|
||||
status: "active" | "ended";
|
||||
stage: string;
|
||||
turn_count: number;
|
||||
learner_turn_count: number;
|
||||
client_turn_count: number;
|
||||
started_at: string;
|
||||
ended_at: string | null;
|
||||
review_ready: boolean;
|
||||
}
|
||||
export type CrisisResource = ApiSchema<"CrisisResourceResponse">;
|
||||
export type LearnerSessionSummary = ApiSchema<"LearnerSessionSummary">;
|
||||
|
||||
export interface LearnerSessionsResponse {
|
||||
source: string;
|
||||
sessions: LearnerSessionSummary[];
|
||||
}
|
||||
|
||||
export interface SessionDetailTurn {
|
||||
turn_seq: number;
|
||||
speaker: "learner" | "client";
|
||||
stage: string;
|
||||
text: string;
|
||||
created_at: string;
|
||||
}
|
||||
export type SessionDetailTurn = ApiSchema<"SessionDetailTurn">;
|
||||
|
||||
export interface SessionDetailResponse {
|
||||
session_id: string;
|
||||
|
|
@ -289,30 +219,10 @@ export interface SessionDetailResponse {
|
|||
review_ready: boolean;
|
||||
}
|
||||
|
||||
export interface ReviewClient {
|
||||
name: string;
|
||||
initial: string;
|
||||
persona: string;
|
||||
}
|
||||
|
||||
export interface ReviewTechnique {
|
||||
kind: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface ReviewNonverbalEvent {
|
||||
kind: "audio" | "silence" | "pace" | "barge_in";
|
||||
label: string;
|
||||
detail: string;
|
||||
}
|
||||
|
||||
export interface ReviewNote {
|
||||
author: "ai" | "instructor" | string;
|
||||
tone: "good" | "watch";
|
||||
title: string;
|
||||
body: string;
|
||||
quote?: string | null;
|
||||
}
|
||||
export type ReviewClient = ApiSchema<"ReviewClient">;
|
||||
export type ReviewTechnique = ApiSchema<"ReviewTechnique">;
|
||||
export type ReviewNonverbalEvent = ApiSchema<"ReviewNonverbalEvent">;
|
||||
export type ReviewNote = ApiSchema<"ReviewNote">;
|
||||
|
||||
export interface ReviewTurn {
|
||||
id: string;
|
||||
|
|
@ -325,36 +235,11 @@ export interface ReviewTurn {
|
|||
note?: ReviewNote | null;
|
||||
}
|
||||
|
||||
export interface ReviewPhaseSegment {
|
||||
key: string;
|
||||
label: string;
|
||||
weight: number;
|
||||
}
|
||||
|
||||
export interface ReviewValencePoint {
|
||||
t: number;
|
||||
v: number;
|
||||
}
|
||||
|
||||
export interface ReviewRubricRow {
|
||||
name: string;
|
||||
cluster: string;
|
||||
ratio: number;
|
||||
quality: "good" | "watch";
|
||||
freq: string;
|
||||
}
|
||||
|
||||
export interface ReviewPoint {
|
||||
title: string;
|
||||
body: string;
|
||||
jumpTo?: string | null;
|
||||
}
|
||||
|
||||
export interface ReviewWorksheetEvidence {
|
||||
turnId: string;
|
||||
speaker: "learner" | "client";
|
||||
quote: string;
|
||||
}
|
||||
export type ReviewPhaseSegment = ApiSchema<"ReviewPhaseSegment">;
|
||||
export type ReviewValencePoint = ApiSchema<"ReviewValencePoint">;
|
||||
export type ReviewRubricRow = ApiSchema<"ReviewRubricRow">;
|
||||
export type ReviewPoint = ApiSchema<"ReviewPoint">;
|
||||
export type ReviewWorksheetEvidence = ApiSchema<"ReviewWorksheetEvidence">;
|
||||
|
||||
export interface ReviewWorksheetItem {
|
||||
key: string;
|
||||
|
|
@ -608,82 +493,23 @@ export const sessionApi = {
|
|||
stream: openSessionStream,
|
||||
};
|
||||
|
||||
export type AdminHealthStatus = "ok" | "degraded" | "down";
|
||||
|
||||
export interface AdminServiceHealth {
|
||||
key: string;
|
||||
name: string;
|
||||
status: AdminHealthStatus;
|
||||
detail: string;
|
||||
metric: string;
|
||||
load: number;
|
||||
}
|
||||
|
||||
export interface AdminHealthResponse {
|
||||
status: AdminHealthStatus;
|
||||
environment: string;
|
||||
engine_mode: string;
|
||||
services: AdminServiceHealth[];
|
||||
}
|
||||
|
||||
export interface AdminUsageBreakdown {
|
||||
provider: string;
|
||||
model: string;
|
||||
turns: number;
|
||||
tokens_in: number;
|
||||
tokens_out: number;
|
||||
cost_usd: number;
|
||||
}
|
||||
|
||||
export interface AdminUsageBudget {
|
||||
limit_usd: number;
|
||||
used_ratio: number;
|
||||
remaining_usd: number | null;
|
||||
status: "disabled" | "ok" | "warn" | "exceeded";
|
||||
}
|
||||
|
||||
export interface AdminUsageResponse {
|
||||
source: "database" | "server_session_registry";
|
||||
durable: boolean;
|
||||
window_days: number;
|
||||
generated_at: number;
|
||||
total_turns: number;
|
||||
metered_turns: number;
|
||||
tokens_in: number;
|
||||
tokens_out: number;
|
||||
cost_usd: number;
|
||||
budget: AdminUsageBudget;
|
||||
by_provider: AdminUsageBreakdown[];
|
||||
}
|
||||
export type AdminHealthStatus = ApiSchema<"AdminHealthResponse">["status"];
|
||||
export type AdminServiceHealth = ApiSchema<"AdminServiceHealth">;
|
||||
export type AdminHealthResponse = ApiSchema<"AdminHealthResponse">;
|
||||
export type AdminUsageBreakdown = ApiSchema<"AdminUsageBreakdown">;
|
||||
export type AdminUsageBudget = ApiSchema<"AdminUsageBudget">;
|
||||
export type AdminUsageResponse = ApiSchema<"AdminUsageResponse">;
|
||||
|
||||
export const adminApi = {
|
||||
health: () => api.get<AdminHealthResponse>("/admin/health"),
|
||||
usage: (windowDays = 7) => api.get<AdminUsageResponse>(`/admin/usage?window_days=${windowDays}`),
|
||||
};
|
||||
|
||||
export interface AdminManagedUser {
|
||||
user_id: string;
|
||||
email: string;
|
||||
display_name: string;
|
||||
role: "learner" | "teacher" | "admin";
|
||||
cohort_ids: string[];
|
||||
affiliation: string;
|
||||
active_sessions: number;
|
||||
created_at: number;
|
||||
last_seen_at: number;
|
||||
source: "database" | "server_session_registry";
|
||||
}
|
||||
|
||||
export interface AdminUsersResponse {
|
||||
source: "database" | "server_session_registry";
|
||||
durable: boolean;
|
||||
users: AdminManagedUser[];
|
||||
}
|
||||
|
||||
export type AdminUserCreateRequest = Pick<
|
||||
AdminManagedUser,
|
||||
"email" | "display_name" | "role" | "affiliation" | "cohort_ids"
|
||||
>;
|
||||
export type AdminManagedUser = ApiSchema<"AdminUserResponse">;
|
||||
export type AdminUsersResponse = ApiSchema<"AdminUsersResponse">;
|
||||
export type AdminUserCreateRequest = ApiSchema<"AdminUserCreate">;
|
||||
export type AdminUserPatchRequest = ApiSchema<"AdminUserPatch">;
|
||||
export type AdminUserDeleteResponse = ApiSchema<"AdminUserDeleteResponse">;
|
||||
|
||||
export const adminUsersApi = {
|
||||
list: () => api.get<AdminUsersResponse>("/admin/users"),
|
||||
|
|
@ -691,13 +517,13 @@ export const adminUsersApi = {
|
|||
apiFetch<AdminManagedUser>("/admin/users", { method: "POST", body }),
|
||||
update: (
|
||||
userId: string,
|
||||
body: Partial<Pick<AdminManagedUser, "display_name" | "role" | "affiliation" | "cohort_ids">>,
|
||||
body: AdminUserPatchRequest,
|
||||
) => apiFetch<AdminManagedUser>(`/admin/users/${encodeURIComponent(userId)}`, {
|
||||
method: "PATCH",
|
||||
body,
|
||||
}),
|
||||
deactivate: (userId: string) =>
|
||||
apiFetch<{ ok: boolean; user_id: string }>(`/admin/users/${encodeURIComponent(userId)}`, {
|
||||
apiFetch<AdminUserDeleteResponse>(`/admin/users/${encodeURIComponent(userId)}`, {
|
||||
method: "DELETE",
|
||||
}),
|
||||
};
|
||||
|
|
@ -718,33 +544,8 @@ export interface TeacherSessionSummary {
|
|||
ended_at: string | null;
|
||||
}
|
||||
|
||||
export interface TeacherSafetyAlert {
|
||||
id: string;
|
||||
session_id: string;
|
||||
learner_id: string;
|
||||
learner_label: string;
|
||||
persona_code: string;
|
||||
session_no: number;
|
||||
trigger_type: string;
|
||||
ko_risk_level: number;
|
||||
escalated: boolean;
|
||||
created_at: string;
|
||||
resource_title: string;
|
||||
resource_number: string;
|
||||
}
|
||||
|
||||
export interface TeacherGrowthPoint {
|
||||
session_id: string;
|
||||
session_no: number;
|
||||
persona_code: string;
|
||||
stage: string;
|
||||
started_at: string;
|
||||
ended_at: string | null;
|
||||
score: number | null;
|
||||
rapport: number | null;
|
||||
technique_count: number;
|
||||
watch_count: number;
|
||||
}
|
||||
export type TeacherSafetyAlert = ApiSchema<"TeacherSafetyAlert">;
|
||||
export type TeacherGrowthPoint = ApiSchema<"TeacherGrowthPoint">;
|
||||
|
||||
export interface TeacherLearnerGrowth {
|
||||
learner_id: string;
|
||||
|
|
@ -779,61 +580,30 @@ export const teacherApi = {
|
|||
dashboard: () => api.get<TeacherDashboardResponse>("/teacher/dashboard"),
|
||||
};
|
||||
|
||||
export interface UserProfileResponse {
|
||||
user_id: string;
|
||||
email: string;
|
||||
display_name: string;
|
||||
role: RoleString;
|
||||
cohort_ids: string[];
|
||||
affiliation: string;
|
||||
}
|
||||
|
||||
export interface NotificationPreferences {
|
||||
session_done: boolean;
|
||||
safety_signal: boolean;
|
||||
learner_progress: boolean;
|
||||
product_news: boolean;
|
||||
}
|
||||
|
||||
export interface UserPreferencesResponse {
|
||||
theme: "system" | "light" | "dark" | string;
|
||||
voice_preset_id: string;
|
||||
voice_rate: number;
|
||||
notifications: NotificationPreferences;
|
||||
}
|
||||
|
||||
export interface VoicePresetResponse {
|
||||
id: string;
|
||||
voice_id: string;
|
||||
name: string;
|
||||
desc: string;
|
||||
persona_hint: string;
|
||||
}
|
||||
export type UserProfileResponse = ApiSchema<"UserProfileResponse">;
|
||||
export type NotificationPreferences = ApiSchema<"NotificationPreferences">;
|
||||
export type UserPreferencesResponse = ApiSchema<"UserPreferencesResponse">;
|
||||
export type UserPreferencesPatchRequest = ApiSchema<"UserPreferencesPatch">;
|
||||
export type UserProfilePatchRequest = ApiSchema<"UserProfilePatch">;
|
||||
export type VoicePresetResponse = ApiSchema<"VoicePresetResponse">;
|
||||
|
||||
export type RoleString = "learner" | "teacher" | "admin" | string;
|
||||
|
||||
export const userApi = {
|
||||
me: () => api.get<UserProfileResponse>("/users/me"),
|
||||
updateMe: (body: { display_name?: string; affiliation?: string }) =>
|
||||
updateMe: (body: UserProfilePatchRequest) =>
|
||||
apiFetch<UserProfileResponse>("/users/me", { method: "PATCH", body }),
|
||||
preferences: () => api.get<UserPreferencesResponse>("/users/me/preferences"),
|
||||
updatePreferences: (body: Partial<UserPreferencesResponse>) =>
|
||||
updatePreferences: (body: UserPreferencesPatchRequest) =>
|
||||
apiFetch<UserPreferencesResponse>("/users/me/preferences", { method: "PATCH", body }),
|
||||
voicePresets: () => api.get<VoicePresetResponse[]>("/users/me/voice-presets"),
|
||||
};
|
||||
|
||||
export interface AdminEngineConfigResponse {
|
||||
engine_mode: string;
|
||||
engine_url: string;
|
||||
model: string;
|
||||
updated_by: string | null;
|
||||
updated_at: number | null;
|
||||
durable: boolean;
|
||||
source: "database" | "runtime_cache" | "runtime_default" | string;
|
||||
}
|
||||
export type AdminEngineConfigResponse = ApiSchema<"AdminEngineConfigResponse">;
|
||||
export type AdminEngineConfigPatchRequest = ApiSchema<"AdminEngineConfigPatch">;
|
||||
|
||||
export const adminEngineApi = {
|
||||
get: () => api.get<AdminEngineConfigResponse>("/admin/engine-config"),
|
||||
update: (body: Partial<Pick<AdminEngineConfigResponse, "engine_mode" | "engine_url" | "model">>) =>
|
||||
update: (body: AdminEngineConfigPatchRequest) =>
|
||||
apiFetch<AdminEngineConfigResponse>("/admin/engine-config", { method: "PATCH", body }),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ import {
|
|||
} from "../lib/api";
|
||||
|
||||
type UserDraft = Pick<AdminManagedUser, "display_name" | "role" | "affiliation" | "cohort_ids">;
|
||||
type NewUserDraft = AdminUserCreateRequest;
|
||||
type NewUserDraft = Required<Pick<AdminUserCreateRequest, "email" | "display_name" | "role">> &
|
||||
Pick<UserDraft, "affiliation" | "cohort_ids">;
|
||||
const MAX_RENDERED_USERS = 40;
|
||||
|
||||
const EMPTY_NEW_USER: NewUserDraft = {
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ export default function Professor() {
|
|||
<Badge tone={personaReviewTone(persona.status)}>
|
||||
{personaReviewStatusLabel(persona.status)}
|
||||
</Badge>
|
||||
<span>{formatDateTime(persona.created_at)}</span>
|
||||
<span>{formatDateTime(persona.created_at ?? null)}</span>
|
||||
</div>
|
||||
<div className="pf-persona__actions">
|
||||
<Button
|
||||
|
|
|
|||
|
|
@ -127,6 +127,22 @@ function SettingsSkeleton({
|
|||
);
|
||||
}
|
||||
|
||||
const DEFAULT_NOTIFICATION_PREFERENCES: NotificationPreferences = {
|
||||
session_done: true,
|
||||
safety_signal: true,
|
||||
learner_progress: true,
|
||||
product_news: false,
|
||||
};
|
||||
|
||||
function completeNotificationPreferences(
|
||||
preferences?: NotificationPreferences | null,
|
||||
): NotificationPreferences {
|
||||
return {
|
||||
...DEFAULT_NOTIFICATION_PREFERENCES,
|
||||
...preferences,
|
||||
};
|
||||
}
|
||||
|
||||
export default function Settings() {
|
||||
const { user } = useAuth();
|
||||
const role = user?.role ?? "learner";
|
||||
|
|
@ -313,11 +329,12 @@ export default function Settings() {
|
|||
|
||||
const savePreferences = async (key: string) => {
|
||||
if (!preferencesReady || !preferences) return;
|
||||
const notifications = completeNotificationPreferences(preferences.notifications);
|
||||
const next = await userApi.updatePreferences({
|
||||
theme: dark ? "dark" : "light",
|
||||
voice_preset_id: preferences.voice_preset_id,
|
||||
voice_rate: preferences.voice_rate,
|
||||
notifications: preferences.notifications,
|
||||
notifications,
|
||||
});
|
||||
setPreferences(next);
|
||||
flashSaved(key);
|
||||
|
|
@ -348,7 +365,7 @@ export default function Settings() {
|
|||
setPreferences((cur) => cur ? ({
|
||||
...cur,
|
||||
notifications: {
|
||||
...cur.notifications,
|
||||
...completeNotificationPreferences(cur.notifications),
|
||||
[key]: value,
|
||||
},
|
||||
}) : cur);
|
||||
|
|
@ -362,13 +379,12 @@ export default function Settings() {
|
|||
: false;
|
||||
const engineStorageLabel = !engineConfig
|
||||
? "확인 중"
|
||||
: engineConfig.source === "unconfigured"
|
||||
? "미구성"
|
||||
: engineConfig.durable
|
||||
: engineConfig.durable
|
||||
? "DB 저장"
|
||||
: "런타임 적용";
|
||||
const engineService = adminHealth?.services.find((service) => service.key === "engine");
|
||||
const engineServiceStatus = engineService?.status ?? "degraded";
|
||||
const notificationPreferences = completeNotificationPreferences(preferences?.notifications);
|
||||
|
||||
return (
|
||||
<AppShell contextLabel="설정" hideNav hideTopbar bleed>
|
||||
|
|
@ -828,7 +844,7 @@ export default function Settings() {
|
|||
</div>
|
||||
<Toggle
|
||||
checked={Boolean(
|
||||
preferences.notifications[item.id as keyof NotificationPreferences],
|
||||
notificationPreferences[item.id as keyof NotificationPreferences],
|
||||
)}
|
||||
onChange={(next) =>
|
||||
updateNotification(item.id as keyof NotificationPreferences, next)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue