feat: bổ sung phần profile của user

This commit is contained in:
2026-07-22 18:50:34 +07:00
parent 9bf9f38864
commit c4302da931
2 changed files with 0 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
# Implementation Plan: Project Management, Save As, and File Management inside Profile
We will add robust cloud/local project management, a custom "Save Project" name modal, a "Save As..." dialog offering server/local options, and a comprehensive file and project manager inside the User Profile Modal.
## User Review Required
> [!IMPORTANT]
> The profile modal will now contain three tabs: Account, Cloud Projects, and My Uploaded Files. Unused files (those not in the current session tracks or any saved projects) can be deleted by the user to free up quota storage.
>
> **Save As...** will trigger a modal allowing the user to type a new name and save it to either the server or export locally as a `.sfs` file.
---
## Proposed Changes
### Backend APIs
#### [MODIFY] [projects.py](file:///home/locpham/SonicForgeStudio/app/api/v1/projects.py)
- **`GET /cloud/{project_id}`**: Retrieves a specific user cloud project.
- **`DELETE /cloud/{project_id}`**: Deletes a specific user cloud project.
- **`PUT /cloud/{project_id}`**: Updates/overwrites an existing user cloud project.
#### [MODIFY] [audio.py](file:///home/locpham/SonicForgeStudio/app/api/v1/audio.py)
- **`POST /upload`**, **`run_python_dsp_tool`** (for synth), and **`ai_cut_audio`**: Prefix file IDs with `user_{user_id}_` to establish file ownership and quota tracking securely.
- **`POST /my-files`**: Lists all files starting with `user_{user_id}_` on the server disk. Identifies if they are referenced in the active project session or any database project records to compute their `is_in_use` status.
- **`DELETE /my-files/{file_id}`**: Deletes a user's uploaded/generated file from the server uploads and processed directories after verifying ownership.
---
### Frontend Services & UI
#### [MODIFY] [api.js](file:///home/locpham/SonicForgeStudio/app/static/js/services/api.js)
- Expose APIs for fetching, deleting, and updating cloud projects.
- Expose APIs for listing and deleting user audio files.
#### [MODIFY] [app.jsx](file:///home/locpham/SonicForgeStudio/app/static/js/app.jsx)
- **State Additions**:
- `currentProjectId`: Tracks the ID of the loaded cloud project (synced with localStorage).
- `saveProjectModalOpen`, `saveAsModalOpen`: Controls the new custom modals.
- **Save Project Modal**:
- Modal with an input for project name, used when saving a project that doesn't have a name yet.
- **Save As Modal**:
- Allows choosing to save under a new name either locally (.sfs file) or on the server.
- **Profile Modal Extensions**:
- Add Tabs: **Account Settings**, **Cloud Projects**, **My Uploaded Files**.
- **Cloud Projects Tab**: Displays saved projects with load (open DAW project) and delete options.
- **My Uploaded Files Tab**: Displays files with sizes, creation dates, usage badges, individual delete buttons, and a global "Clean Up Unused Files" button.
---
## Verification Plan
### Automated Tests
- Run backend lint and sanity checks.
```bash
python -m flake8 app/api/v1/projects.py app/api/v1/audio.py
```
### Manual Verification
1. Create a new project, press Save, verify the custom input modal appears.
2. Upload some files, check the Profile -> My Uploaded Files tab. Verify the files are listed as "In Use".
3. Remove a track containing a file, verify the file changes to "Not In Use". Press delete to free up quota.
4. Click File -> Save As... and select either Cloud or Local .sfs and verify name updates and downloads.