feat: improve report and comment workflows
This commit is contained in:
+44
-15
@@ -41,6 +41,8 @@ const api = {
|
||||
}) => ipcRenderer.invoke('student:update-profile', profile),
|
||||
generateStudentComment: (payload: { profileId: string }) =>
|
||||
ipcRenderer.invoke('student:generate-comment', payload),
|
||||
generateStudentComments: (payload: { classId?: string; profileIds?: string[] }) =>
|
||||
ipcRenderer.invoke('student:generate-comments', payload),
|
||||
listModels: (payload: { baseUrl: string; apiKey: string }) =>
|
||||
ipcRenderer.invoke('models:list', payload),
|
||||
testModelConnection: (modelConfig: {
|
||||
@@ -155,25 +157,52 @@ const api = {
|
||||
downloadReport: (id: string) => ipcRenderer.invoke('reports:download', id),
|
||||
downloadClassReports: (payload: { classId: string }) =>
|
||||
ipcRenderer.invoke('reports:download-class', payload),
|
||||
onReportGenerationProgress: (callback: (progress: {
|
||||
batchId: string
|
||||
status: 'started' | 'student-started' | 'student-finished' | 'student-failed' | 'finished'
|
||||
classId: string
|
||||
className: string
|
||||
studentId?: string
|
||||
studentName?: string
|
||||
current: number
|
||||
total: number
|
||||
report?: unknown
|
||||
error?: string
|
||||
}) => void) => {
|
||||
const listener = (_: Electron.IpcRendererEvent, progress: Parameters<typeof callback>[0]) =>
|
||||
callback(progress)
|
||||
onReportGenerationProgress: (
|
||||
callback: (progress: {
|
||||
batchId: string
|
||||
status: 'started' | 'student-started' | 'student-finished' | 'student-failed' | 'finished'
|
||||
classId: string
|
||||
className: string
|
||||
studentId?: string
|
||||
studentName?: string
|
||||
current: number
|
||||
total: number
|
||||
report?: unknown
|
||||
error?: string
|
||||
}) => void
|
||||
): (() => void) => {
|
||||
const listener = (
|
||||
_: Electron.IpcRendererEvent,
|
||||
progress: Parameters<typeof callback>[0]
|
||||
): void => callback(progress)
|
||||
|
||||
ipcRenderer.on('reports:generation-progress', listener)
|
||||
return () => ipcRenderer.removeListener('reports:generation-progress', listener)
|
||||
},
|
||||
deleteReport: (id: string) => ipcRenderer.invoke('reports:delete', id)
|
||||
onCommentGenerationProgress: (
|
||||
callback: (progress: {
|
||||
batchId: string
|
||||
status: 'started' | 'student-started' | 'student-finished' | 'student-failed' | 'finished'
|
||||
classId?: string
|
||||
className?: string
|
||||
studentId?: string
|
||||
studentName?: string
|
||||
current: number
|
||||
total: number
|
||||
profile?: unknown
|
||||
error?: string
|
||||
}) => void
|
||||
): (() => void) => {
|
||||
const listener = (
|
||||
_: Electron.IpcRendererEvent,
|
||||
progress: Parameters<typeof callback>[0]
|
||||
): void => callback(progress)
|
||||
|
||||
ipcRenderer.on('comments:generation-progress', listener)
|
||||
return () => ipcRenderer.removeListener('comments:generation-progress', listener)
|
||||
},
|
||||
deleteReport: (id: string) => ipcRenderer.invoke('reports:delete', id),
|
||||
deleteAllReports: () => ipcRenderer.invoke('reports:delete-all')
|
||||
}
|
||||
|
||||
// Use `contextBridge` APIs to expose Electron APIs to
|
||||
|
||||
Reference in New Issue
Block a user