Interface (States & Input blocks)
Overview
This Vue component, named StateTable, provides a user interface for managing state files and input files. It allows users to view, search, filter, and interact with these files in a tabular format.
Key Features
- Tabbed interface for States and Inputs
- Searchable and filterable table
- Expandable rows with detailed file content
- Ability to start workflows
- File status management
- File deletion
Component Structure
Data Properties
-
activeTab: Controls which tab is currently active (0 for States, 1 for Inputs) -
pagination: Controls table pagination -
tabs: Defines the available tabs and their configurations -
apiBaseUrl: Base URL for API requests -
search: Stores the current search term -
workerStatusOptions: Available status options for workers -
selectedStatus,selectedGroup: For filtering in respective tabs -
rows: Stores the main data displayed in the table
Computed Properties
-
filteredData: Returns the filtered and searched data for the table -
filteredWorkerFields: Filters specific fields from worker data for display
Methods
-
selectTab(index): Switches between States and Inputs tabs -
fetchApiData(endpoint): Fetches data from the API -
refreshFiles(): Refreshes the file list -
startWorkflow(user_code, payload): Initiates a new workflow -
checkWorkflowStatus(workflowID, resolve, reject): Checks the status of a running workflow -
fetchFiles(): Fetches and processes the list of files -
fetchFileContent(filePath, row): Retrieves detailed content for a specific file -
startWorkflowForRow(row, activeTab): Starts a workflow for a specific row -
toggleExpand(row): Expands/collapses a row to show/hide details -
saveStatus(row): Saves the current status of a file -
uploadFile(jsonData, fileName, path, currentFileIndex, totalFiles): Uploads a file to the server -
deleteFile(row): Deletes a file from the server
Usage Guide
Viewing Files
- The component displays two tabs: "States" and "Inputs"
- Each tab shows a table with relevant information about the files
- Use the search bar to filter files by any field
- Use the status/group dropdown (depending on the active tab) to filter files
Interacting with Files
File Actions
-
Start Workflow:
- Click "Start Workflow" in the expanded view to initiate a workflow for that file
- For States, it uses the
workflow-manageruser code - For Inputs, it uses the
generate-stateuser code
-
Save State (States tab only):
- Click "Save State" to update the file on the server with any changes
-
Delete State (States tab only):
- Click "Delete State" to remove the file from the server
Managing Worker and Item States
- In the expanded view, each worker and item has a status dropdown
- Click on the status to open the dropdown and select a new status
Refreshing Data
- Click the refresh button (circular arrow icon) to fetch the latest data from the server
API Integration
The component interacts with several API endpoints:
- File listing:
${apiBaseUrl}/api/v1/explorer/view/?path=components/states_files.jsonor${apiBaseUrl}/api/v1/explorer/view/?path=components/inputs_files.json - File content:
${apiBaseUrl}/api/v1/explorer/view/?path=${filePath} - Workflow start:
${apiBaseUrl}/workflow/api/workflow/run-workflow/ - Workflow status check:
${apiBaseUrl}/workflow/api/workflow/${workflowID}/ - File upload:
${apiBaseUrl}/api/v1/explorer/upload/ - File deletion:
${apiBaseUrl}/api/v1/explorer/delete/?path=${filePath}&is_dir=false
Notes for Developers
- The component uses custom icons (
IconRefresh,IconCopy,IconDownload,IconTabActive) which should be properly imported - Authorization is handled by the
authorization()function from@/utils/customFetch - The component relies on the Quasar framework for UI components (e.g.,
q-table,q-input,q-select) Error handling is implemented for API calls, but you may want to enhance user feedback for errors
Potential Enhancements
Implement pagination on the server-side for better performance with large datasetsAdd more robust error handling and user notificationsImplement a more sophisticated state management system (e.g., Vuex) for complex state interactionsAdd unit and integration tests to ensure reliability