Skip to content

Implement django api for custom blocks - #478

Open
Sarvesh-Mishra1981 wants to merge 1 commit into
JdeRobot:masterfrom
Sarvesh-Mishra1981:feature/marketplace-django-api
Open

Implement django api for custom blocks#478
Sarvesh-Mishra1981 wants to merge 1 commit into
JdeRobot:masterfrom
Sarvesh-Mishra1981:feature/marketplace-django-api

Conversation

@Sarvesh-Mishra1981

Copy link
Copy Markdown
Collaborator

No description provided.

@BkPankaj

Copy link
Copy Markdown
Collaborator

@Sarvesh-Mishra1981
Please update the PR with the following:

  • Changes Made (Detailed): Clearly describe all the changes you have made.
  • Related Issues: Link the relevant GitHub issue. If no issue exists, please create one first and link it to this PR to maintain a proper development workflow.
  • Screenshots: Include screenshots for UI-related changes.
  • Video: If the changes are too extensive to be adequately demonstrated with screenshots, please attach a short video showing the functionality.

Please follow these standard development practices before opening a PR for review.

@Sarvesh-Mishra1981

Copy link
Copy Markdown
Collaborator Author

Ok I will do the same

@BkPankaj

Copy link
Copy Markdown
Collaborator

Kindly follow same with #471 PR

@Sarvesh-Mishra1981

Copy link
Copy Markdown
Collaborator Author

What this PR resolves

This PR addresses the feedback regarding how downloaded Marketplace custom blocks are stored. Previously, blocks were temporarily cached in the browser's localStorage, which led to data loss if the cache was cleared and kept the backend unaware of the installed blocks. This PR completely removes the localStorage approach and introduces a permanent, full-stack Django file-storage architecture so custom blocks are securely saved to the hard drive and synchronized with the backend.

What's New

  • Backend Storage System: Added a new directory backend/custom_blocks/ to permanently store downloaded custom blocks as .vc3 JSON files.
  • REST API Endpoints: Built two new Django endpoints (/api/install_block and /api/installed_blocks) to allow the React frontend to natively read and write blocks to the server's filesystem.

Files Changed

Backend

  • backend/app/urls.py
    • Added routing paths for the two new API endpoints (install_block and installed_blocks).
  • backend/app/views.py
    • Implemented the install_block POST function to catch incoming block JSON and physically write it to backend/custom_blocks/.
    • Implemented the installed_blocks GET function to parse all .vc3 files in the directory and return them as a JSON array to the frontend.

Frontend

  • frontend/src/components/marketplace/MarketplacePanel.tsx
    • Deleted the localStorage logic inside handleInstall().
    • Updated the component to use fetch() to POST the block data directly to the new Django backend endpoint.
  • frontend/src/components/menu/index.tsx
    • Rewrote the loadDownloads() function. Instead of parsing the browser cache, the UI now queries the new Django GET endpoint to dynamically populate the Downloads menu with the physical files stored on the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants