24 KiB
File Page Requirements
This document contains the complete frontend requirements for all file management pages and components. All UI components are dynamically generated from backend metadata—no hardcoding required.
Table of Contents
- Overview
- Page Structure and Layout
- User Interactions and Functionality
- Backend Routes and API Integration
- Field and Attribute Reference
- Dynamic Rendering Guidelines
Overview
The file management page enables users to manage files within their mandate. The frontend consists of a single page (/files) with different views/states:
- List View - Browse, search, filter, and sort files (all information displayed in table)
- Edit View - Edit file properties in popup/modal
- Upload View - Upload new files
All views use backend-driven UI generation, meaning field definitions, labels, validation rules, and UI structure come entirely from backend metadata through the /api/attributes/FileItem endpoint. Views are managed through component state and routing within the same page, not as separate routes.
Page Structure and Layout
File Management Page (/files)
The file management page uses different views/states to handle different user interactions. Views are managed through component state and routing within the same page component.
List View
State: view === 'list' or selectedFileId === null
What the user sees:
-
Main Content Area:
- Table or card grid displaying all files in the mandate
- Each file row/card shows: file name, MIME type, file size, creation date, mandate ID
- Action buttons column in table (rendered on first load):
- "Edit" button - opens popup/modal edit form for file name
- "Delete" button - shows confirmation dialog and deletes file
- "Download" button - downloads file to user's device
- "Add to Prompt" button - navigates to
/chat-playgroundwith file attached
- All necessary file information displayed in table (no detail view needed)
-
Search and Filter Controls:
- General search input box (searches across all text fields)
- Field-specific filter controls (one filter per visible field)
- Active filter indicators (chips/badges showing applied filters)
- "Clear all filters" button when filters are active
-
Sorting Controls:
- Clickable column headers with sort indicators (up/down arrows)
- Visual indication of current sort field and direction
- Support for multi-level sorting
-
Pagination Controls:
- Page information display ("Page X of Y", "Showing 1-20 of 45 files")
- Previous/Next page buttons
- Page number buttons
- Page size selector (10, 20, 50, 100 items per page)
-
Action Buttons:
- "Upload File" button - opens file upload dialog
Edit View (Popup/Modal)
State: view === 'edit' and selectedFileId !== null (popup/modal overlay)
What the user sees:
- Edit Form in Popup/Modal:
- Dynamic form with editable file fields only (typically fileName)
- Field labels with required indicators (asterisk for required fields)
- Help text/tooltips from field descriptions
- Input validation errors displayed inline
- Form pre-populated with current file values
- Save and Cancel buttons in modal footer
- On save: Updates file name, closes modal, refreshes table
- On cancel: Closes modal without saving
Upload View
State: view === 'upload' or upload dialog open
What the user sees:
-
Upload Dialog/Form:
- File input/picker for selecting files
- Drag-and-drop area with visual feedback
- Selected files list with preview
- Upload progress indicator
- Duplicate file handling information
-
Action Buttons:
- Upload button (starts upload)
- Cancel button (closes upload dialog)
-
Confirmation Dialogs:
- Delete confirmation dialog (on file detail page)
User Interactions and Functionality
Browsing and Discovery
Search Functionality:
- User types in general search box
- Frontend debounces input (300-500ms delay)
- Search applies across all text fields in file objects
- Results update automatically
- Page resets to page 1 when search changes
Field Filtering:
- User selects field to filter by
- Frontend shows appropriate filter UI based on field type:
- Text fields → Text input with operator selection (contains, equals, startsWith, endsWith)
- Integer fields → Number input with comparison operators (gt, gte, lt, lte) or range inputs
- Timestamp fields → Date picker with comparison operators or date range picker
- Select fields → Dropdown with options from backend metadata
- User applies filter → Filter appears as active chip/badge
- User can remove individual filters
- Multiple filters work together (AND logic)
- Page resets to page 1 when filters change
Sorting:
- User clicks column header
- Sort direction toggles (asc → desc → remove)
- Multiple columns can be sorted (multi-level sorting)
- Sort indicators show on column headers
- All filters and search preserved when sorting
Pagination:
- User clicks page number or navigation button
- Page updates and data refetches
- All filters, search, and sort preserved
- User changes page size → Page resets to 1, data refetches
View Switching:
- All file information displayed in table (no detail view navigation needed)
Uploading Files
Upload Interaction:
- User clicks "Upload File" button → Opens upload dialog/form
- OR user drags and drops file(s) onto upload area
- Drag and drop area highlights when files are dragged over
- User selects file(s) from device picker OR drops file(s) on upload area
- File upload starts immediately (no size validation)
- User clicks Cancel → Closes upload dialog, no action
Drag and Drop Support:
- Upload area supports drag and drop functionality
- Visual feedback when files are dragged over (highlight drop zone)
- Multiple files can be dropped at once
- Files are accepted and uploaded immediately upon drop
Upload Submission:
- File sent as multipart/form-data
- Optional
workflowIdparameter can be included - No file size validation (all file sizes accepted)
- Success → File appears in list, show success message with duplicate info if applicable
- Error handling:
- 403 (permission denied) → Show permission error
- 400 (validation errors) → Display backend validation errors
- Other errors → Show generic error message
Duplicate Handling:
- Backend returns duplicate information in response
- Frontend displays appropriate message:
- Exact duplicate → "File already exists with identical content. Reusing existing file."
- Name conflict → "File already exists with different content. Uploaded as '[new name]'."
- New file → "File uploaded successfully"
Editing Files
Edit Interaction:
- User clicks "Edit" button in table row → Opens popup/modal edit form
- Form pre-populated with current file values
- User modifies file name in form
- Client-side validation shows errors immediately
- User clicks Save → Form validates and submits
- User clicks Cancel → Closes modal without saving
Form Validation:
- Required field validation (shows error if empty)
- Type validation (e.g., text fields must be valid text)
- Validation errors displayed inline below fields
Form Submission:
- Only changed fields sent (or all form data)
- Success → Close popup/modal, refresh table, show success message
- Error handling:
- 403 (permission denied) → Show permission error in modal
- 400 (validation errors) → Display backend validation errors in modal
- Other errors → Show generic error message in modal
Downloading Files
Download Action:
- User clicks "Download" button in table
- Frontend shows loading state
- Frontend calls
GET /api/files/{fileId}/download - Browser triggers download with proper filename
- Success → File downloads to user's device
- Error handling:
- 403 (permission denied) → Show permission error
- 404 (not found) → Show not found error
- Other errors → Show generic error message
Implementation Notes:
- Download should use proper Content-Disposition header handling
- Filename should be properly encoded for Unicode characters
Adding File to Prompt
Add to Prompt Action:
- User clicks "Add to Prompt" button in table
- Frontend fetches file data to get file ID
- Frontend navigates to
/chat-playgroundpage - Frontend pre-selects the file in the file picker/attachments area
- Frontend displays file name as context
- User can enter prompt text and optionally add more files
- User clicks "Start" or "Send" button
- Frontend calls
POST /api/chat/playground/startwith file ID inlistFileIdarray
Add to Prompt Submission:
- File ID included in
listFileIdarray in request body - Prompt text required (user must enter prompt)
- Success → Workflow starts with file attached, chat playground updates
- Error handling:
- 403 (permission denied) → Show permission error
- 400 (validation errors) → Display backend validation errors
- Other errors → Show generic error message
Deleting Files
Delete Action:
- User clicks delete button (on detail page or list)
- Confirmation dialog appears with file name
- Warning about permanent deletion
- User confirms → File deleted
- User cancels → Dialog closes, no action
Delete Success Handling:
- Success message displayed
- Remove file from list or refresh table
Backend Routes and API Integration
Complete Route Reference
All backend routes used by file pages:
| Route | Method | Purpose | When Used | Access Control |
|---|---|---|---|---|
/api/files/list |
GET | Get all files (with pagination) | Initial page load, pagination changes, sort changes, filter changes, search changes | All authenticated users (filtered by mandate) |
/api/files/{fileId} |
GET | Get file details | Detail page load, edit page load | All authenticated users |
/api/files/{fileId} |
PUT | Update file | Edit form submission | All authenticated users |
/api/files/{fileId} |
DELETE | Delete file | User confirms deletion | All authenticated users |
/api/files/upload |
POST | Upload file | User selects and uploads file | All authenticated users |
/api/files/{fileId}/download |
GET | Download file | User clicks download button | All authenticated users |
/api/files/stats |
GET | Get file statistics | Optional: display statistics on page | All authenticated users |
/api/chat/playground/start |
POST | Start workflow with file | User clicks "Add to Prompt" and starts workflow | All authenticated users |
/api/attributes/FileItem |
GET | Get field definitions | Page load (once per page) - used to generate all UI components | All authenticated users |
API Request Patterns
Pagination Request:
GET /api/files/list?pagination={"page":1,"pageSize":20,"sort":[],"filters":null}
paginationparameter is JSON-encoded string- If user wants all files: omit
paginationparameter entirely - Filters structure:
{"search":"query","fieldName":"value",...} - Optional
mandateIdquery parameter to filter by mandate
Upload Request:
POST /api/files/upload
Content-Type: multipart/form-data
Body: {
file: <file data>,
workflowId: "optional-workflow-id" (optional)
}
- File sent as multipart/form-data
workflowIdis optional form field- No file size limits (all sizes accepted)
- Handle 403 (permission denied) and 400 (validation errors)
- Response includes duplicate information:
{ "message": "File uploaded successfully", "file": {...}, "duplicateType": "new_file" | "exact_duplicate" | "name_conflict", "originalFileName": "...", "storedFileName": "...", "isDuplicate": false }
Update Request:
PUT /api/files/{fileId}
Content-Type: application/json
Body: {fieldName: value, ...}
- Send only changed fields or all form data
- Handle 403 (permission denied) and 400 (validation errors)
Download Request:
GET /api/files/{fileId}/download
- Returns file content with Content-Disposition header
- Browser automatically triggers download
- Filename properly encoded for Unicode characters
Add to Prompt Request:
POST /api/chat/playground/start?workflowMode=Dynamic
Content-Type: application/json
Body: {
"prompt": "User prompt text here...",
"listFileId": ["fileId1", "fileId2"],
"userLanguage": "en"
}
workflowModequery parameter is required: "Actionplan", "Dynamic", or "Template" (default: "Dynamic")listFileIdarray contains file IDs to attach (includes the file from "Add to Prompt" button)promptfield contains user's prompt textuserLanguageshould match user's preferred language- Handle 403 (permission denied) and 400 (validation errors)
Delete Requests:
DELETE /api/files/{fileId}
- Delete operation requires user confirmation
- Handle 403 (permission denied) and 404 (not found) gracefully
Response Handling
Paginated Response:
{
"items": [...],
"pagination": {
"currentPage": 1,
"pageSize": 20,
"totalItems": 45,
"totalPages": 3,
"sort": [...],
"filters": {...}
}
}
Error Responses:
- 403 Forbidden → Show permission error message
- 404 Not Found → Show "not found" error message
- 400 Bad Request → Display validation errors from response
- 500 Internal Server Error → Show generic error message
Field and Attribute Reference
Complete Field List
The following is a comprehensive list of all parameters, attributes, and fields that will be displayed for files. All of these are provided by the backend through the /api/attributes/FileItem endpoint and should never be hardcoded in the frontend.
Core File Fields
Identification Fields:
id- Unique file identifier (text, readonly, not required, visible)mandateId- ID of the mandate this file belongs to (text, readonly, not required, visible)
File Properties:
fileName- Name of the file (text, editable, required, visible)mimeType- MIME type of the file (text, readonly, not required, visible)fileHash- Hash of the file (text, readonly, not required, visible)fileSize- Size of the file in bytes (integer, readonly, not required, visible)creationDate- Date when the file was created (timestamp, readonly, not required, visible)
Pagination Parameters
Request Parameters (PaginationParams):
page- Current page number (1-based, minimum 1)pageSize- Number of items per page (minimum 1, maximum 1000)sort- Array of sort field configurations- Each sort field contains:
field- Field name to sort by (must match a file field name)direction- Sort direction: "asc" or "desc"
- Each sort field contains:
filters- Filter criteria dictionarysearch- General search term (searches across all text fields, case-insensitive)- Field-specific filters:
{fieldName: value}or{fieldName: {operator: "operator", value: value}} - Supported operators: "equals", "contains", "startsWith", "endsWith", "gt", "gte", "lt", "lte", "in", "notIn"
Response Metadata (PaginationMetadata):
currentPage- Current page number (1-based)pageSize- Number of items per pagetotalItems- Total number of items across all pages (after filters applied)totalPages- Total number of pages (calculated from totalItems / pageSize)sort- Current sort configuration applied (array of SortField objects)filters- Current filters applied (mirrors request filters)
Attribute Definition Structure
Each field returned from /api/attributes/FileItem contains:
name- Field name (e.g., "fileName", "mimeType", "fileSize", "id")type- Field data type (e.g., "text", "integer", "timestamp", "checkbox")label- Localized field label (object with language keys: {"en": "English Label", "fr": "French Label"})description- Field description textrequired- Boolean indicating if field is requiredreadonly- Boolean indicating if field is read-onlyeditable- Boolean indicating if field can be edited (inverse of readonly)visible- Boolean indicating if field should be displayed in UIoptions- Array of options for select fields (each option hasvalueand localizedlabel)
Dynamic Rendering Guidelines
The frontend must render all UI components dynamically based on backend metadata. No field definitions, labels, validation rules, or UI structure should be hardcoded.
Table Column Generation
When rendering the file list table:
- Fetch attribute definitions from
/api/attributes/FileItem - Filter attributes where
visible: trueto determine which columns to display - Use
labelproperty for column headers (select appropriate language based on user preference) - Use
typeproperty to determine how to format cell values:textfields → Display as plain textintegerfields → Display as formatted number (for fileSize, show human-readable format like "1.5 MB")timestampfields → Format as relative time ("2 hours ago") or absolute date/time based on user preferenceselectfields → Display value using label from options array (match value to option.value, then display option.label)checkboxfields → Display as checkmark icon or "Yes"/"No" text
- Use
readonlyproperty to determine if column should be sortable (readonly fields may still be sortable, but editable fields definitely are) - Generate click handlers for column headers to update sort parameters and refetch data
- Add Actions Column:
- Render action buttons in each table row on first load
- Include "Edit" button - opens popup/modal edit form for file name
- Include "Delete" button - shows confirmation dialog
- Include "Download" button - triggers file download
- Include "Add to Prompt" button - navigates to
/chat-playgroundwith file attached - Buttons should be visible and accessible in each row
Filter Control Generation
When rendering filter controls:
- Fetch attribute definitions from
/api/attributes/FileItem - Filter attributes where
visible: trueto determine which filters to show - For each visible field, generate appropriate filter UI based on
type:textfields → Text input filter (supports "contains", "equals", "startsWith", "endsWith" operators)integerfields → Number range filter (min/max inputs) or single number input with comparison operators (gt, gte, lt, lte)timestampfields → Date range picker or single date picker with comparison operatorsselectfields → Dropdown filter with options fromoptionsarray (use localized labels)checkboxfields → Boolean toggle filter (true/false/any)
- Use
labelproperty for filter labels (localized) - When user applies filter, update
filtersobject in pagination parameters and refetch data - Display active filters as chips/badges showing field label and value
- Allow removing individual filters by removing them from
filtersobject
Search Implementation
For general search functionality:
- Display a single search input box (not field-specific)
- When user types, update
filters.searchin pagination parameters - Debounce search input (wait 300-500ms after user stops typing before sending request)
- Search applies across all text fields in the file object
- Reset to page 1 when search query changes
- Combine search with field-specific filters (both are in the
filtersobject)
Form Field Generation
When rendering edit forms:
- Fetch attribute definitions from
/api/attributes/FileItem - Filter attributes where
visible: trueANDeditable: trueto determine which fields to show - For each editable field, generate appropriate form input based on
type:textfields → Text inputintegerfields → Number input with appropriate min/max constraintstimestampfields → Date/time pickerselectfields → Dropdown/select input with options fromoptionsarray (use localized labels)checkboxfields → Checkbox input
- Use
labelproperty for field labels (localized) - Use
requiredproperty to show required indicators (asterisk, etc.) - Use
descriptionproperty to show help text or tooltips - Validate form before submission:
- Check all
required: truefields have values - Validate types (e.g., integer fields must be numbers)
- Validate select fields (value must be in options array)
- Check all
- On submit, send only changed fields or all form data to update endpoint
Display Formatting
When displaying field values:
- Use
typeproperty to determine formatting:text→ Display as-is (may need HTML escaping)integer→ Format with thousand separators if needed- For
fileSizefield specifically → Format as human-readable (e.g., "1.5 MB", "500 KB", "2.3 GB") timestamp→ Format as relative time or absolute date/timeselect→ Look up value inoptionsarray and display localized labelcheckbox→ Display as checkmark icon or "Yes"/"No" text
- Handle
nullorundefinedvalues gracefully (show "-" or "Not set") - Use
readonlyproperty to determine if field should show edit indicators - Special formatting for file fields:
- File Size → Always show in human-readable format (bytes → KB → MB → GB)
- MIME Type → Display as badge with icon if possible
- File Hash → Display as truncated hash (first 8-12 characters) with copy button
- Creation Date → Show relative time in list view, absolute date in detail view
File Size Formatting
For the fileSize field (integer in bytes), always format as human-readable:
function formatFileSize(bytes: number): string {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i];
}
Localization
All labels and options support multiple languages:
- Use user's preferred language (from user settings or browser locale)
- Access localized labels from
labelobject:label[userLanguage]orlabel.enas fallback - For select options, use
option.label[userLanguage]oroption.label.enas fallback - If label for current language is missing, fall back to English
Key Principles
- Never hardcode field names, labels, types, or validation rules
- Always fetch attribute definitions from backend before rendering UI
- Use attribute metadata to determine what to display and how to display it
- Support all field types dynamically - if backend adds new types, frontend should handle them
- Respect
visible,editable,readonly, andrequiredflags from backend - Use localized labels from backend metadata
- Generate filters, forms, and tables entirely from attribute definitions
- When backend adds new fields, frontend should automatically display them without code changes
- Handle all error cases gracefully (403, 404, 400, 413, 500)
- Provide user feedback for all actions (loading states, success messages, error messages)
- Format file sizes in human-readable format
- Handle file uploads with proper duplicate detection feedback
Summary
This document provides complete frontend requirements for all file management pages and components. All requirements follow the principle of backend-driven UI generation—no hardcoding of field definitions, labels, or validation rules. The frontend should dynamically generate all UI components from backend metadata provided through the /api/attributes/FileItem endpoint.
Key Architecture Pattern: The file management interface is a single page (/files) with different views managed through component state. All interactions happen within the same page component without separate routes.
For generic patterns that apply across all entity types (not just files), see the Dynamic Forms and Pagination documentation.