Refactor drag handling and update tests
- Renamed `initiate_drag` to `handle_drag` in MainWindow and updated related tests. - Improved drag handling logic to utilize a bridge for starting file drags. - Updated `_on_drag_started` and `_on_drag_failed` methods to match new signatures. - Modified test cases to reflect changes in drag handling and assertions. Enhance path validation and logging - Updated `PathValidator` to log warnings for nonexistent roots instead of raising errors. - Adjusted tests to verify the new behavior of skipping nonexistent roots. Update web application UI and functionality - Changed displayed text for drag items to reflect local paths and Azure Blob Storage URLs. - Added debug logging for drag operations in the web application. - Improved instructions for testing drag and drop functionality. Add configuration documentation and example files - Created `CONFIG_README.md` to provide detailed configuration instructions for WebDrop Bridge. - Added `config.example.json` and `config_test.json` for reference and testing purposes. Implement URL conversion logic - Introduced `URLConverter` class to handle conversion of Azure Blob Storage URLs to local paths. - Added unit tests for URL conversion to ensure correct functionality. Develop download interceptor script - Created `download_interceptor.js` to intercept download-related actions in the web application. - Implemented logging for fetch calls, XMLHttpRequests, and Blob URL creations. Add download test page and related tests - Created `test_download.html` for testing various download scenarios. - Implemented `test_download.py` to verify download path resolution and file construction. - Added `test_url_mappings.py` to ensure URL mappings are loaded correctly. Add unit tests for URL converter - Created `test_url_converter.py` to validate URL conversion logic and mapping behavior.
This commit is contained in:
parent
c9704efc8d
commit
88dc358894
21 changed files with 1870 additions and 432 deletions
209
CONFIG_README.md
Normal file
209
CONFIG_README.md
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
# WebDrop Bridge Configuration Guide
|
||||
|
||||
## Configuration File Location
|
||||
|
||||
WebDrop Bridge supports two configuration methods:
|
||||
|
||||
1. **JSON Configuration File** (Recommended for Azure URL mapping)
|
||||
- Windows: `%APPDATA%\webdrop_bridge\config.json`
|
||||
- macOS/Linux: `~/.config/webdrop_bridge/config.json`
|
||||
|
||||
2. **Environment Variables** (`.env` file in project root)
|
||||
- Used as fallback if JSON config doesn't exist
|
||||
|
||||
## JSON Configuration Format
|
||||
|
||||
Create a `config.json` file with the following structure:
|
||||
|
||||
```json
|
||||
{
|
||||
"app_name": "WebDrop Bridge",
|
||||
"webapp_url": "https://wps.agravity.io/",
|
||||
"url_mappings": [
|
||||
{
|
||||
"url_prefix": "https://wpsagravitystg.file.core.windows.net/wpsagravitysync/",
|
||||
"local_path": "Z:"
|
||||
}
|
||||
],
|
||||
"allowed_roots": [
|
||||
"Z:\\"
|
||||
],
|
||||
"allowed_urls": [],
|
||||
"check_file_exists": true,
|
||||
"auto_check_updates": true,
|
||||
"update_check_interval_hours": 24,
|
||||
"log_level": "INFO",
|
||||
"log_file": "logs/webdrop_bridge.log",
|
||||
"window_width": 1024,
|
||||
"window_height": 768,
|
||||
"enable_logging": true
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration Options
|
||||
|
||||
### Core Settings
|
||||
|
||||
- **`webapp_url`** (string): URL of the web application to load
|
||||
- Example: `"https://wps.agravity.io/"`
|
||||
- Supports `http://`, `https://`, or `file:///` URLs
|
||||
|
||||
- **`url_mappings`** (array): Azure Blob Storage URL to local path mappings
|
||||
- Each mapping has:
|
||||
- `url_prefix`: Azure URL prefix (must end with `/`)
|
||||
- `local_path`: Local drive letter or path
|
||||
- Example:
|
||||
```json
|
||||
{
|
||||
"url_prefix": "https://wpsagravitystg.file.core.windows.net/wpsagravitysync/",
|
||||
"local_path": "Z:"
|
||||
}
|
||||
```
|
||||
|
||||
- **`allowed_roots`** (array): Whitelisted root directories for file access
|
||||
- Security feature: Only files within these directories can be dragged
|
||||
- Example: `["Z:\\", "C:\\Users\\Public"]`
|
||||
|
||||
### Azure URL Mapping Example
|
||||
|
||||
When the web application provides a drag URL like:
|
||||
```
|
||||
https://wpsagravitystg.file.core.windows.net/wpsagravitysync/aN5PysnXIuRECzcRbvHkjL7g0/Hintergrund_Agravity.png
|
||||
```
|
||||
|
||||
It will be converted to:
|
||||
```
|
||||
Z:\aN5PysnXIuRECzcRbvHkjL7g0\Hintergrund_Agravity.png
|
||||
```
|
||||
|
||||
### Security Settings
|
||||
|
||||
- **`check_file_exists`** (boolean): Validate files exist before allowing drag
|
||||
- Default: `true`
|
||||
- Set to `false` only for testing
|
||||
|
||||
- **`allowed_urls`** (array): Allowed URL patterns for web content
|
||||
- Empty array = no restriction
|
||||
- Example: `["wps.agravity.io", "*.example.com"]`
|
||||
|
||||
### Update Settings
|
||||
|
||||
- **`auto_check_updates`** (boolean): Automatically check for updates on startup
|
||||
- Default: `true`
|
||||
|
||||
- **`update_check_interval_hours`** (number): Hours between update checks
|
||||
- Default: `24`
|
||||
|
||||
### UI Settings
|
||||
|
||||
- **`window_width`**, **`window_height`** (number): Initial window size in pixels
|
||||
- Default: `1024` x `768`
|
||||
|
||||
- **`log_level`** (string): Logging verbosity
|
||||
- Options: `"DEBUG"`, `"INFO"`, `"WARNING"`, `"ERROR"`, `"CRITICAL"`
|
||||
- Default: `"INFO"`
|
||||
|
||||
- **`enable_logging`** (boolean): Whether to write logs to file
|
||||
- Default: `true`
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. Copy `config.example.json` to your config directory:
|
||||
```powershell
|
||||
# Windows
|
||||
mkdir "$env:APPDATA\webdrop_bridge"
|
||||
copy config.example.json "$env:APPDATA\webdrop_bridge\config.json"
|
||||
```
|
||||
|
||||
2. Edit the configuration file with your Azure URL mappings and local paths
|
||||
|
||||
3. Restart WebDrop Bridge
|
||||
|
||||
## Multiple URL Mappings
|
||||
|
||||
You can configure multiple Azure storage accounts:
|
||||
|
||||
```json
|
||||
{
|
||||
"url_mappings": [
|
||||
{
|
||||
"url_prefix": "https://storage1.file.core.windows.net/container1/",
|
||||
"local_path": "Z:"
|
||||
},
|
||||
{
|
||||
"url_prefix": "https://storage2.file.core.windows.net/container2/",
|
||||
"local_path": "Y:"
|
||||
}
|
||||
],
|
||||
"allowed_roots": [
|
||||
"Z:\\",
|
||||
"Y:\\"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Environment Variable Fallback
|
||||
|
||||
If no JSON config exists, WebDrop Bridge will load from `.env`:
|
||||
|
||||
```env
|
||||
APP_NAME=WebDrop Bridge
|
||||
WEBAPP_URL=https://wps.agravity.io/
|
||||
ALLOWED_ROOTS=Z:/
|
||||
LOG_LEVEL=INFO
|
||||
WINDOW_WIDTH=1024
|
||||
WINDOW_HEIGHT=768
|
||||
```
|
||||
|
||||
**Note:** Environment variables don't support `url_mappings`. Use JSON config for Azure URL mapping.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "No mapping found for URL"
|
||||
- Check that `url_prefix` matches the Azure URL exactly (including trailing `/`)
|
||||
- Verify `url_mappings` is configured in your JSON config file
|
||||
- Check logs in `logs/webdrop_bridge.log`
|
||||
|
||||
### "Path is not within allowed roots"
|
||||
- Ensure the mapped local path (e.g., `Z:`) is listed in `allowed_roots`
|
||||
- Make sure the drive is mounted and accessible
|
||||
|
||||
### "File does not exist"
|
||||
- Verify the Azure sync is working and files are available locally
|
||||
- Set `check_file_exists: false` temporarily for testing
|
||||
- Check that the path mapping is correct
|
||||
|
||||
## Example Configurations
|
||||
|
||||
### Production (Agravity WPS)
|
||||
|
||||
```json
|
||||
{
|
||||
"webapp_url": "https://wps.agravity.io/",
|
||||
"url_mappings": [
|
||||
{
|
||||
"url_prefix": "https://wpsagravitystg.file.core.windows.net/wpsagravitysync/",
|
||||
"local_path": "Z:"
|
||||
}
|
||||
],
|
||||
"allowed_roots": ["Z:\\"],
|
||||
"log_level": "INFO"
|
||||
}
|
||||
```
|
||||
|
||||
### Development (Local Testing)
|
||||
|
||||
```json
|
||||
{
|
||||
"webapp_url": "file:///./webapp/index.html",
|
||||
"url_mappings": [
|
||||
{
|
||||
"url_prefix": "https://test.blob.core.windows.net/test/",
|
||||
"local_path": "C:\\temp\\test"
|
||||
}
|
||||
],
|
||||
"allowed_roots": ["C:\\temp\\test"],
|
||||
"check_file_exists": false,
|
||||
"log_level": "DEBUG"
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue