5.4 KiB
5.4 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous, requirements, must_haves
| phase | plan | type | wave | depends_on | files_modified | autonomous | requirements | must_haves | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 02-data-persistence-file-management | 01 | execute | 1 |
|
true |
|
|
-
GET /api/files - List all CSV files in the logger directory
- Returns JSON: {files: [{name, size, created}], total: count}
- Storage path: /myvscada/logger (configurable, default to src/data/logger)
- Handle missing directory gracefully
-
GET /api/files/<filename> - Get file contents
- Returns JSON: {name, content: "full file text", lines: count}
- Limit preview to first 100 lines for large files
-
DELETE /api/files/<filename> - Delete a file
- Returns JSON: {success: true/false}
- Confirm file exists before delete
- Handle errors gracefully
Use the existing Flask patterns from src/app.py:
- Use jsonify for responses
- Use request.get_json() for POST data
- Add error handling with try/except
- Follow existing route structure curl -s http://localhost:8080/api/files | python3 -c "import sys,json; d=json.load(sys.stdin); print('OK' if 'files' in d else 'FAIL')" API endpoints return valid JSON, file list shows files, delete removes files
- Main navigation menu (reuse from other templates)
- Page title: "Flash Memory Files"
- File list display:
- Table or card layout showing: filename, size, date
- "View" button for each file (opens modal)
- "Delete" button with confirmation
- Modal for viewing file contents:
- File name header
- Scrollable content area (pre/code block)
- Close button
- JavaScript:
- Fetch file list on page load
- Handle view button click -> fetch file content
- Handle delete button click -> confirm -> delete -> refresh list
- Use Bootstrap 5.3 + Bootstrap Icons (like existing templates)
- Touch-optimized 48px+ buttons
Base on the existing templates (settings.html, calibration.html) for:
- Bootstrap 5.3 structure
- Navigation menu
- CSS variables and touch targets
- Socket.IO integration (optional) curl -s http://localhost:8080/files | grep -q "Flash Memory" && echo "OK" || echo "FAIL" Files page loads, shows file list, view modal works, delete works
@app.route('/files')
def files():
"""File management page"""
return render_template('files.html',
page='files',
version=SOFTWARE_VERSION,
build_date=BUILD_DATE)
Add this route near the other page routes (index, settings, calibration). curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/files Route returns 200 OK
task 4: Add Files menu item to navigation src/templates/dashboard.html, src/templates/settings.html, src/templates/calibration.html Add "Files" navigation button to main menu in: - dashboard.html - settings.html - calibration.htmlThe navigation should link to /files route. Follow the existing nav structure with nav-btn class.
Example (add after calibration button):
<a href="/files" class="nav-btn btn btn-outline-primary">
<i class="bi bi-folder"></i> Files
</a>
<success_criteria> User can view list of CSV files, view file contents, and delete files from flash memory via web UI </success_criteria>
After completion, create `.planning/phases/02-data-persistence-file-management/02-01-SUMMARY.md`