fix: migrate UI to V2 API and fix admin dashboard
Backend fixes: - Fix markdown generation using correct 'markdown_content' key in tasks.py - Update admin service to return flat data structure matching frontend types - Add task_count and failed_tasks fields to user statistics - Fix top users endpoint to return complete user data Frontend fixes: - Migrate ResultsPage from V1 batch API to V2 task API with polling - Create TaskDetailPage component with markdown preview and download buttons - Refactor ExportPage to support multi-task selection using V2 download endpoints - Fix login infinite refresh loop with concurrency control flags - Create missing Checkbox UI component New features: - Add /tasks/:taskId route for task detail view - Implement multi-task batch export functionality - Add real-time task status polling (2s interval) OpenSpec: - Archive completed proposal 2025-11-17-fix-v2-api-ui-issues - Create result-export and task-management specifications 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
# Result Export - Delta Changes
|
||||
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Export Interface
|
||||
The Export page SHALL support downloading OCR results in multiple formats using V2 task APIs.
|
||||
|
||||
#### Scenario: Export page uses V2 download endpoints
|
||||
- **WHEN** user selects a format and clicks export button
|
||||
- **THEN** frontend SHALL call V2 endpoint `/api/v2/tasks/{task_id}/download/{format}`
|
||||
- **AND** frontend SHALL NOT call V1 `/api/v2/export` endpoint (which returns 404)
|
||||
- **AND** file SHALL download successfully
|
||||
|
||||
#### Scenario: Export supports multiple formats
|
||||
- **WHEN** user exports a completed task
|
||||
- **THEN** system SHALL support downloading as TXT, JSON, Excel, Markdown, and PDF
|
||||
- **AND** each format SHALL use correct V2 download endpoint
|
||||
- **AND** downloaded files SHALL contain task OCR results
|
||||
|
||||
### Requirement: Multi-Task Export Selection
|
||||
The Export page SHALL allow users to select and export multiple tasks.
|
||||
|
||||
#### Scenario: Select multiple tasks for export
|
||||
- **WHEN** Export page loads
|
||||
- **THEN** page SHALL display list of user's completed tasks
|
||||
- **AND** page SHALL provide checkboxes to select multiple tasks
|
||||
- **AND** page SHALL NOT require batch ID from upload store (legacy V1 behavior)
|
||||
|
||||
#### Scenario: Export selected tasks
|
||||
- **WHEN** user selects multiple tasks and clicks export
|
||||
- **THEN** system SHALL download each selected task's results in chosen format
|
||||
- **AND** downloaded files SHALL be named distinctly (e.g., `{task_id}_result.{ext}`)
|
||||
- **AND** system MAY provide option to download as ZIP archive for multiple files
|
||||
|
||||
### Requirement: Export Configuration Persistence
|
||||
Export settings (format, thresholds, templates) SHALL apply consistently to V2 task downloads.
|
||||
|
||||
#### Scenario: Apply confidence threshold to export
|
||||
- **WHEN** user sets confidence threshold to 0.7 and exports
|
||||
- **THEN** downloaded results SHALL only include OCR text with confidence >= 0.7
|
||||
- **AND** threshold SHALL apply via V2 download endpoint query parameters
|
||||
|
||||
#### Scenario: Apply CSS template to PDF export
|
||||
- **WHEN** user selects CSS template for PDF format
|
||||
- **THEN** downloaded PDF SHALL use selected styling
|
||||
- **AND** template SHALL be passed to V2 `/tasks/{id}/download/pdf` endpoint
|
||||
@@ -0,0 +1,51 @@
|
||||
# Task Management - Delta Changes
|
||||
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Task Result Generation
|
||||
The OCR service SHALL generate both JSON and Markdown result files for completed tasks with actual content.
|
||||
|
||||
#### Scenario: Markdown file contains OCR results
|
||||
- **WHEN** a task completes OCR processing successfully
|
||||
- **THEN** the generated `.md` file SHALL contain the extracted text in markdown format
|
||||
- **AND** the file size SHALL be greater than 0 bytes
|
||||
- **AND** the markdown SHALL include headings, paragraphs, and formatting based on OCR layout detection
|
||||
|
||||
#### Scenario: Result files stored in task directory
|
||||
- **WHEN** OCR processing completes for task ID `88c6c2d2-37e1-48fd-a50f-406142987bdf`
|
||||
- **THEN** result files SHALL be stored in `storage/results/88c6c2d2-37e1-48fd-a50f-406142987bdf/`
|
||||
- **AND** both `<filename>_result.json` and `<filename>_result.md` SHALL exist
|
||||
- **AND** both files SHALL contain valid OCR output data
|
||||
|
||||
### Requirement: Task Detail View
|
||||
The frontend SHALL provide a dedicated page for viewing individual task details.
|
||||
|
||||
#### Scenario: Navigate to task detail page
|
||||
- **WHEN** user clicks "View Details" button on task in Task History page
|
||||
- **THEN** browser SHALL navigate to `/tasks/{task_id}`
|
||||
- **AND** TaskDetailPage component SHALL render
|
||||
|
||||
#### Scenario: Display task information
|
||||
- **WHEN** TaskDetailPage loads for a valid task ID
|
||||
- **THEN** page SHALL display task metadata (filename, status, processing time, confidence)
|
||||
- **AND** page SHALL show markdown preview of OCR results
|
||||
- **AND** page SHALL provide download buttons for JSON, Markdown, and PDF formats
|
||||
|
||||
#### Scenario: Download from task detail page
|
||||
- **WHEN** user clicks download button for a specific format
|
||||
- **THEN** browser SHALL download the file using `/api/v2/tasks/{task_id}/download/{format}` endpoint
|
||||
- **AND** downloaded file SHALL contain the task's OCR results in requested format
|
||||
|
||||
### Requirement: Results Page V2 Migration
|
||||
The Results page SHALL use V2 task-based APIs instead of V1 batch APIs.
|
||||
|
||||
#### Scenario: Load task results instead of batch
|
||||
- **WHEN** Results page loads with a task ID in upload store
|
||||
- **THEN** page SHALL call `apiClientV2.getTask(taskId)` to fetch task details
|
||||
- **AND** page SHALL NOT call any V1 batch status endpoints
|
||||
- **AND** task information SHALL display correctly
|
||||
|
||||
#### Scenario: Handle missing task gracefully
|
||||
- **WHEN** Results page loads without a task ID
|
||||
- **THEN** page SHALL display helpful message directing user to upload page
|
||||
- **AND** page SHALL provide button to navigate to `/upload`
|
||||
Reference in New Issue
Block a user