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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AGENTS.md - Requirements & Decisions
|
| 2 |
+
|
| 3 |
+
This document records the requirements, architecture decisions, and rationale for the S3 to HF Bucket Importer.
|
| 4 |
+
|
| 5 |
+
## Requirements
|
| 6 |
+
|
| 7 |
+
### Functional
|
| 8 |
+
|
| 9 |
+
1. **OAuth Login**: Users sign in with Hugging Face OAuth. Scopes: `manage-repos` (create buckets), `jobs` (run Jobs), plus default `openid` + `profile`.
|
| 10 |
+
|
| 11 |
+
2. **S3 Configuration**: Users provide AWS credentials (Access Key ID, Secret Access Key), region, bucket name, optional endpoint URL (for S3-compatible services like MinIO), and optional source prefix.
|
| 12 |
+
|
| 13 |
+
3. **File Browser**: Display S3 bucket contents in a tree view with:
|
| 14 |
+
- Lazy loading (only load folder contents on expand)
|
| 15 |
+
- Checkboxes for file/folder selection
|
| 16 |
+
- Select all / Deselect all
|
| 17 |
+
- File count and size statistics
|
| 18 |
+
- CORS fallback mode if browser can't access S3 directly
|
| 19 |
+
|
| 20 |
+
4. **Destination Configuration**: User provides:
|
| 21 |
+
- Bucket name (`bucket` or `namespace/bucket` format)
|
| 22 |
+
- Optional destination prefix
|
| 23 |
+
- Auto-create bucket if it doesn't exist
|
| 24 |
+
|
| 25 |
+
5. **Import Execution**: Launch an HF Job that:
|
| 26 |
+
- Installs `huggingface_hub[s3]` from branch `cursor/s3-to-hf-bucket-ingestion-f144`
|
| 27 |
+
- Runs `hf buckets import` with appropriate arguments
|
| 28 |
+
- Passes S3 credentials as encrypted secrets
|
| 29 |
+
- Uses CPU hardware (I/O-bound task)
|
| 30 |
+
|
| 31 |
+
6. **No Local Storage**: Nothing persists in the browser. Page refresh = start over. All credentials are in-memory only.
|
| 32 |
+
|
| 33 |
+
### Non-Functional
|
| 34 |
+
|
| 35 |
+
- Professional, confidence-inspiring design
|
| 36 |
+
- Dark theme inspired by HF Buckets announcement
|
| 37 |
+
- Responsive (works on mobile)
|
| 38 |
+
- Clear error messages and graceful degradation
|
| 39 |
+
|
| 40 |
+
## Architecture Decisions
|
| 41 |
+
|
| 42 |
+
### Decision 1: No Build Step
|
| 43 |
+
|
| 44 |
+
**Choice**: Vanilla HTML/CSS/JS with ES modules from CDN (esm.sh)
|
| 45 |
+
|
| 46 |
+
**Alternatives considered**:
|
| 47 |
+
- Vite + vanilla JS (tree-shaking, npm packages)
|
| 48 |
+
- React/Vue/Svelte (component model)
|
| 49 |
+
|
| 50 |
+
**Rationale**:
|
| 51 |
+
- Simplest deployment: just upload files to a static Space
|
| 52 |
+
- No `node_modules`, no `package.json`, no build config
|
| 53 |
+
- CDN imports are cached by the browser across sessions
|
| 54 |
+
- The app is a single page with ~4 states - doesn't warrant a framework
|
| 55 |
+
- AWS SDK v3 is ~500KB from CDN but cached effectively
|
| 56 |
+
- Easy for anyone to maintain: just HTML/CSS/JS, no tooling knowledge needed
|
| 57 |
+
|
| 58 |
+
### Decision 2: CDN Provider (esm.sh)
|
| 59 |
+
|
| 60 |
+
**Choice**: esm.sh for ES module CDN
|
| 61 |
+
|
| 62 |
+
**Rationale**:
|
| 63 |
+
- Reliable ESM CDN that handles CommonJS -> ESM conversion
|
| 64 |
+
- Supports import maps natively
|
| 65 |
+
- Handles transitive dependencies for AWS SDK v3
|
| 66 |
+
- Alternative was jsdelivr+esm or unpkg, but esm.sh has better ESM support
|
| 67 |
+
|
| 68 |
+
### Decision 3: CORS Fallback Strategy
|
| 69 |
+
|
| 70 |
+
**Choice**: Try browser-side S3 listing, gracefully degrade to manual mode
|
| 71 |
+
|
| 72 |
+
**Alternatives considered**:
|
| 73 |
+
- Skip browser listing entirely (simpler but less interactive)
|
| 74 |
+
- Require CORS (better UX but higher friction)
|
| 75 |
+
|
| 76 |
+
**Rationale**:
|
| 77 |
+
- Most S3 buckets won't have CORS configured for our domain
|
| 78 |
+
- Attempting listing first gives the best UX for configured buckets
|
| 79 |
+
- Manual fallback (include/exclude patterns) lets everyone use the tool
|
| 80 |
+
- Clear CORS instructions help users enable browsing if they want
|
| 81 |
+
|
| 82 |
+
### Decision 4: Selection-to-Pattern Mapping
|
| 83 |
+
|
| 84 |
+
**Choice**: Compute include or exclude patterns, whichever set is smaller
|
| 85 |
+
|
| 86 |
+
**Rationale**:
|
| 87 |
+
- `hf buckets import` supports `--include` and `--exclude` with fnmatch patterns
|
| 88 |
+
- When most files are selected, use `--exclude` for the few deselected
|
| 89 |
+
- When few files are selected, use `--include` for the selected ones
|
| 90 |
+
- Folder-level patterns (e.g., `folder/*`) keep command lines short
|
| 91 |
+
- Shell-escaping prevents injection in the Job command
|
| 92 |
+
|
| 93 |
+
### Decision 5: Job Configuration
|
| 94 |
+
|
| 95 |
+
**Choice**: `python:3.12` Docker image with `pip install` + `bash -c`
|
| 96 |
+
|
| 97 |
+
**Alternatives considered**:
|
| 98 |
+
- Custom Docker image with huggingface_hub pre-installed
|
| 99 |
+
- `ghcr.io/astral-sh/uv` image with `uv run`
|
| 100 |
+
|
| 101 |
+
**Rationale**:
|
| 102 |
+
- `python:3.12` is a standard, well-maintained image
|
| 103 |
+
- `pip install` from git is simple and reliable
|
| 104 |
+
- `bash -c` allows chaining install + import in one command
|
| 105 |
+
- Once `hf buckets import` is released, change to `pip install 'huggingface_hub[s3]>=X.Y.Z'`
|
| 106 |
+
- CPU-only hardware (`cpu-basic`) is sufficient - this is purely I/O-bound
|
| 107 |
+
|
| 108 |
+
### Decision 6: Bucket Creation
|
| 109 |
+
|
| 110 |
+
**Choice**: Call `POST /api/repos/create` with `type: "bucket"` before submitting the Job
|
| 111 |
+
|
| 112 |
+
**Rationale**:
|
| 113 |
+
- The Job needs the bucket to exist before it can write to it
|
| 114 |
+
- Creating from the browser (pre-Job) ensures the user has proper permissions
|
| 115 |
+
- Handle 409 (already exists) gracefully
|
| 116 |
+
|
| 117 |
+
### Decision 7: Token Handling
|
| 118 |
+
|
| 119 |
+
**Choice**: Pass OAuth token as Job secret (`HF_TOKEN`), S3 credentials as secrets too
|
| 120 |
+
|
| 121 |
+
**Rationale**:
|
| 122 |
+
- Secrets are encrypted server-side by the Jobs API
|
| 123 |
+
- Injected as environment variables at runtime
|
| 124 |
+
- Never appear in logs or the HF UI
|
| 125 |
+
- The `hf` CLI automatically uses `HF_TOKEN` for authentication
|
| 126 |
+
- boto3/s3fs automatically uses `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
|
| 127 |
+
|
| 128 |
+
## OAuth Scopes
|
| 129 |
+
|
| 130 |
+
| Scope | Purpose |
|
| 131 |
+
|-------|---------|
|
| 132 |
+
| `openid` | ID token (always included) |
|
| 133 |
+
| `profile` | Username, avatar (always included) |
|
| 134 |
+
| `manage-repos` | Create and manage buckets |
|
| 135 |
+
| `jobs` | Create and monitor HF Jobs |
|
| 136 |
+
|
| 137 |
+
## API Endpoints Used
|
| 138 |
+
|
| 139 |
+
| Method | Endpoint | Purpose |
|
| 140 |
+
|--------|----------|---------|
|
| 141 |
+
| GET | `/api/whoami-v2` | Get user info + orgs |
|
| 142 |
+
| POST | `/api/repos/create` | Create destination bucket |
|
| 143 |
+
| POST | `/api/jobs/{namespace}` | Submit import Job |
|
| 144 |
+
| GET | `/api/jobs/{namespace}/{id}` | Poll Job status |
|
| 145 |
+
|
| 146 |
+
## Security Model
|
| 147 |
+
|
| 148 |
+
1. **S3 credentials**: Only transmitted from browser to HF Jobs API as encrypted secrets. Never stored in localStorage, cookies, or any persistent storage.
|
| 149 |
+
|
| 150 |
+
2. **OAuth token**: Held in JavaScript memory only. Not persisted. Passed to Job as encrypted secret for HF API authentication.
|
| 151 |
+
|
| 152 |
+
3. **Shell injection prevention**: All user inputs interpolated into the Job command are escaped using single-quote wrapping with internal quote escaping.
|
| 153 |
+
|
| 154 |
+
4. **No backend**: The static site has no server-side code. All API calls are made directly from the browser to S3 and HF APIs.
|
| 155 |
+
|
| 156 |
+
## File Structure
|
| 157 |
+
|
| 158 |
+
```
|
| 159 |
+
s3-importer/
|
| 160 |
+
├── README.md # Space YAML frontmatter + project docs
|
| 161 |
+
├── AGENTS.md # This file
|
| 162 |
+
├── index.html # HTML structure + import maps
|
| 163 |
+
├── style.css # Dark theme (CSS custom properties)
|
| 164 |
+
└── app.js # Application logic (ES module, ~500 lines)
|
| 165 |
+
```
|
| 166 |
+
|
| 167 |
+
## Future Improvements
|
| 168 |
+
|
| 169 |
+
- [ ] Show Job logs inline (stream from `/api/jobs/{namespace}/{id}/logs`)
|
| 170 |
+
- [ ] Support AWS session tokens (for temporary credentials / assumed roles)
|
| 171 |
+
- [ ] Remember recent imports (optional, opt-in localStorage)
|
| 172 |
+
- [ ] Support importing to existing bucket with merge strategy
|
| 173 |
+
- [ ] Add a "dry run" option that shows what would be imported
|
| 174 |
+
- [ ] Update `huggingface_hub` install to stable release once available
|
README.md
CHANGED
|
@@ -1,10 +1,121 @@
|
|
| 1 |
---
|
| 2 |
-
title: S3 Importer
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: green
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: S3 to HF Bucket Importer
|
| 3 |
+
emoji: "\U0001FAA3"
|
| 4 |
+
colorFrom: gray
|
| 5 |
colorTo: green
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
hf_oauth: true
|
| 9 |
+
hf_oauth_scopes:
|
| 10 |
+
- manage-repos
|
| 11 |
+
- jobs
|
| 12 |
+
hf_oauth_expiration_minutes: 480
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# S3 to HF Bucket Importer
|
| 16 |
+
|
| 17 |
+
A static one-page web app that helps users import data from AWS S3 (or any S3-compatible storage) into [Hugging Face Storage Buckets](https://huggingface.co/docs/hub/storage-buckets).
|
| 18 |
+
|
| 19 |
+
**Live**: [huggingface.co/spaces/wauplin/s3-importer](https://huggingface.co/spaces/wauplin/s3-importer)
|
| 20 |
+
|
| 21 |
+
## How it works
|
| 22 |
+
|
| 23 |
+
1. **Sign in** with your Hugging Face account (OAuth)
|
| 24 |
+
2. **Connect** to your S3 bucket by providing credentials
|
| 25 |
+
3. **Browse & select** files/folders to import (requires CORS on your S3 bucket, see below)
|
| 26 |
+
4. **Choose destination** HF bucket (auto-created if needed) and optional prefix
|
| 27 |
+
5. **Import** - launches an HF Job that runs `hf buckets import` server-side
|
| 28 |
+
|
| 29 |
+
Everything runs in the browser. No data is stored locally. The actual data transfer happens in an [HF Job](https://huggingface.co/docs/hub/jobs) (server-side), so your browser doesn't need to stay open.
|
| 30 |
+
|
| 31 |
+
## Architecture
|
| 32 |
+
|
| 33 |
+
- **Static HTML Space** - no backend, no build step
|
| 34 |
+
- **OAuth** via `@huggingface/hub` (CDN) for authentication
|
| 35 |
+
- **AWS SDK v3** via CDN for browser-side S3 listing
|
| 36 |
+
- **HF Jobs API** for server-side data transfer using `hf buckets import`
|
| 37 |
+
|
| 38 |
+
### Files
|
| 39 |
+
|
| 40 |
+
| File | Purpose |
|
| 41 |
+
|------|---------|
|
| 42 |
+
| `index.html` | HTML structure, import maps, meta tags |
|
| 43 |
+
| `style.css` | Dark theme stylesheet |
|
| 44 |
+
| `app.js` | All application logic (ES module) |
|
| 45 |
+
| `README.md` | This file + Space YAML config |
|
| 46 |
+
| `AGENTS.md` | Requirements and architecture decisions |
|
| 47 |
+
|
| 48 |
+
## S3 CORS Configuration
|
| 49 |
+
|
| 50 |
+
To browse your S3 bucket from the browser, CORS must be enabled on the bucket. Add this CORS configuration:
|
| 51 |
+
|
| 52 |
+
```json
|
| 53 |
+
[
|
| 54 |
+
{
|
| 55 |
+
"AllowedOrigins": ["https://wauplin-s3-importer.hf.space"],
|
| 56 |
+
"AllowedMethods": ["GET", "HEAD"],
|
| 57 |
+
"AllowedHeaders": ["*"],
|
| 58 |
+
"MaxAgeSeconds": 3600
|
| 59 |
+
}
|
| 60 |
+
]
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
**Without CORS**: The app gracefully degrades to a "manual mode" where you can still import everything (or specify include/exclude patterns) without browsing.
|
| 64 |
+
|
| 65 |
+
### How to set CORS on AWS S3
|
| 66 |
+
|
| 67 |
+
1. Go to your S3 bucket in the AWS Console
|
| 68 |
+
2. Navigate to **Permissions** > **Cross-origin resource sharing (CORS)**
|
| 69 |
+
3. Paste the JSON above and save
|
| 70 |
+
|
| 71 |
+
## HF Job Details
|
| 72 |
+
|
| 73 |
+
The import Job runs:
|
| 74 |
+
```bash
|
| 75 |
+
pip install 'huggingface_hub[s3] @ git+https://github.com/huggingface/huggingface_hub.git@cursor/s3-to-hf-bucket-ingestion-f144'
|
| 76 |
+
hf buckets import 's3://bucket/prefix' 'namespace/bucket-name' [--include ...] [--exclude ...] --workers 4 --verbose
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
- **Docker image**: `python:3.12`
|
| 80 |
+
- **Hardware**: `cpu-basic` (I/O-bound task, no GPU needed)
|
| 81 |
+
- **Secrets**: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `HF_TOKEN` (encrypted server-side)
|
| 82 |
+
- **Environment**: `AWS_DEFAULT_REGION`, optionally `AWS_ENDPOINT_URL`
|
| 83 |
+
|
| 84 |
+
## OAuth Scopes
|
| 85 |
+
|
| 86 |
+
| Scope | Reason |
|
| 87 |
+
|-------|--------|
|
| 88 |
+
| `manage-repos` | Create destination buckets |
|
| 89 |
+
| `jobs` | Create and monitor import Jobs |
|
| 90 |
+
| `openid` + `profile` | Always included, for user identity |
|
| 91 |
+
|
| 92 |
+
## Maintenance Notes
|
| 93 |
+
|
| 94 |
+
### Updating `huggingface_hub` version
|
| 95 |
+
|
| 96 |
+
Once the `hf buckets import` command is released in a stable version, update the pip install command in `app.js` (search for `git+https://github.com/huggingface/huggingface_hub`). Replace with:
|
| 97 |
+
```
|
| 98 |
+
pip install 'huggingface_hub[s3]>=X.Y.Z'
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
### CDN Dependencies
|
| 102 |
+
|
| 103 |
+
Dependencies are loaded from `esm.sh` via import maps in `index.html`. To update versions, edit the import map URLs. Current deps:
|
| 104 |
+
- `@huggingface/hub` - OAuth helpers
|
| 105 |
+
- `@aws-sdk/client-s3` - S3 listing
|
| 106 |
+
|
| 107 |
+
### Token Lifetime
|
| 108 |
+
|
| 109 |
+
OAuth tokens expire after 8 hours (configurable in YAML frontmatter via `hf_oauth_expiration_minutes`). The token is also passed to the Job as a secret. For very long imports (>8h), the Job's token may expire. Consider increasing `hf_oauth_expiration_minutes` if needed.
|
| 110 |
+
|
| 111 |
+
## Development
|
| 112 |
+
|
| 113 |
+
This is a static site with no build step. To develop locally:
|
| 114 |
+
|
| 115 |
+
1. Serve files with any HTTP server: `python -m http.server 8000`
|
| 116 |
+
2. OAuth won't work locally (needs HF Space environment variables). Test OAuth flow on the deployed Space.
|
| 117 |
+
3. S3 listing works locally if CORS is configured for `http://localhost:8000`.
|
| 118 |
+
|
| 119 |
+
## License
|
| 120 |
+
|
| 121 |
+
MIT
|
app.js
ADDED
|
@@ -0,0 +1,1033 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// S3 to HF Bucket Importer - Application Logic
|
| 2 |
+
// Everything runs in the browser. No data is stored locally.
|
| 3 |
+
|
| 4 |
+
import { oauthLoginUrl, oauthHandleRedirectIfPresent } from "@huggingface/hub";
|
| 5 |
+
import { S3Client, ListObjectsV2Command } from "@aws-sdk/client-s3";
|
| 6 |
+
|
| 7 |
+
// ============================================================
|
| 8 |
+
// State
|
| 9 |
+
// ============================================================
|
| 10 |
+
|
| 11 |
+
const state = {
|
| 12 |
+
// Auth
|
| 13 |
+
oauthResult: null,
|
| 14 |
+
username: "",
|
| 15 |
+
orgs: [],
|
| 16 |
+
|
| 17 |
+
// S3
|
| 18 |
+
s3Client: null,
|
| 19 |
+
s3Bucket: "",
|
| 20 |
+
s3Prefix: "",
|
| 21 |
+
s3Region: "",
|
| 22 |
+
s3Endpoint: "",
|
| 23 |
+
awsAccessKeyId: "",
|
| 24 |
+
awsSecretAccessKey: "",
|
| 25 |
+
|
| 26 |
+
// Tree
|
| 27 |
+
tree: [], // top-level nodes
|
| 28 |
+
allFiles: new Map(), // key -> { size, selected }
|
| 29 |
+
allFolders: new Map(), // prefix -> { selected, children loaded }
|
| 30 |
+
totalFiles: 0,
|
| 31 |
+
totalSize: 0,
|
| 32 |
+
selectedFiles: 0,
|
| 33 |
+
selectedSize: 0,
|
| 34 |
+
|
| 35 |
+
// Mode
|
| 36 |
+
corsFallback: false,
|
| 37 |
+
|
| 38 |
+
// Job
|
| 39 |
+
jobId: null,
|
| 40 |
+
jobNamespace: null,
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
// ============================================================
|
| 44 |
+
// DOM references
|
| 45 |
+
// ============================================================
|
| 46 |
+
|
| 47 |
+
const $ = (id) => document.getElementById(id);
|
| 48 |
+
|
| 49 |
+
const dom = {
|
| 50 |
+
signInScreen: $("sign-in-screen"),
|
| 51 |
+
signInBtn: $("btn-sign-in"),
|
| 52 |
+
signInError: $("sign-in-error"),
|
| 53 |
+
appHeader: $("app-header"),
|
| 54 |
+
userInfo: $("user-info"),
|
| 55 |
+
mainApp: $("main-app"),
|
| 56 |
+
|
| 57 |
+
// S3
|
| 58 |
+
s3Section: $("s3-section"),
|
| 59 |
+
s3Status: $("s3-status"),
|
| 60 |
+
awsAccessKey: $("aws-access-key"),
|
| 61 |
+
awsSecretKey: $("aws-secret-key"),
|
| 62 |
+
awsRegion: $("aws-region"),
|
| 63 |
+
s3Bucket: $("s3-bucket"),
|
| 64 |
+
s3Endpoint: $("s3-endpoint"),
|
| 65 |
+
s3Prefix: $("s3-prefix"),
|
| 66 |
+
btnConnect: $("btn-connect"),
|
| 67 |
+
s3ConnectError: $("s3-connect-error"),
|
| 68 |
+
|
| 69 |
+
// Browser
|
| 70 |
+
browserSection: $("browser-section"),
|
| 71 |
+
browserNormal: $("browser-normal"),
|
| 72 |
+
browserCorsFallback: $("browser-cors-fallback"),
|
| 73 |
+
treeContainer: $("tree-container"),
|
| 74 |
+
statSelectedCount: $("stat-selected-count"),
|
| 75 |
+
statSelectedSize: $("stat-selected-size"),
|
| 76 |
+
statTotalCount: $("stat-total-count"),
|
| 77 |
+
statTotalSize: $("stat-total-size"),
|
| 78 |
+
btnSelectAll: $("btn-select-all"),
|
| 79 |
+
btnDeselectAll: $("btn-deselect-all"),
|
| 80 |
+
manualInclude: $("manual-include"),
|
| 81 |
+
manualExclude: $("manual-exclude"),
|
| 82 |
+
btnContinueImport: $("btn-continue-import"),
|
| 83 |
+
|
| 84 |
+
// Import
|
| 85 |
+
importSection: $("import-section"),
|
| 86 |
+
destBucket: $("dest-bucket"),
|
| 87 |
+
destPrefix: $("dest-prefix"),
|
| 88 |
+
destPreview: $("dest-preview"),
|
| 89 |
+
jobFlavor: $("job-flavor"),
|
| 90 |
+
jobWorkers: $("job-workers"),
|
| 91 |
+
jobTimeout: $("job-timeout"),
|
| 92 |
+
patternsInfo: $("patterns-info"),
|
| 93 |
+
patternsPreview: $("patterns-preview"),
|
| 94 |
+
importError: $("import-error"),
|
| 95 |
+
btnStartImport: $("btn-start-import"),
|
| 96 |
+
|
| 97 |
+
// Status
|
| 98 |
+
statusSection: $("status-section"),
|
| 99 |
+
jobStatusIcon: $("job-status-icon"),
|
| 100 |
+
jobStatusBadge: $("job-status-badge"),
|
| 101 |
+
jobStatusTitle: $("job-status-title"),
|
| 102 |
+
jobIdDisplay: $("job-id-display"),
|
| 103 |
+
jobLink: $("job-link"),
|
| 104 |
+
jobStatusMessage: $("job-status-message"),
|
| 105 |
+
btnNewImport: $("btn-new-import"),
|
| 106 |
+
};
|
| 107 |
+
|
| 108 |
+
// ============================================================
|
| 109 |
+
// Utilities
|
| 110 |
+
// ============================================================
|
| 111 |
+
|
| 112 |
+
function formatSize(bytes) {
|
| 113 |
+
if (bytes === 0) return "0 B";
|
| 114 |
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
| 115 |
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
| 116 |
+
const val = bytes / Math.pow(1024, i);
|
| 117 |
+
return `${val < 10 ? val.toFixed(2) : val < 100 ? val.toFixed(1) : Math.round(val)} ${units[i]}`;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
function shellEscape(str) {
|
| 121 |
+
return "'" + str.replace(/'/g, "'\\''") + "'";
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
function show(el) { el.classList.remove("hidden"); }
|
| 125 |
+
function hide(el) { el.classList.add("hidden"); }
|
| 126 |
+
|
| 127 |
+
function setLoading(btn, loading, text) {
|
| 128 |
+
if (loading) {
|
| 129 |
+
btn._origText = btn.textContent;
|
| 130 |
+
btn.disabled = true;
|
| 131 |
+
btn.innerHTML = `<span class="spinner"></span> ${text || "Loading..."}`;
|
| 132 |
+
} else {
|
| 133 |
+
btn.disabled = false;
|
| 134 |
+
btn.textContent = btn._origText || text || "Submit";
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
// ============================================================
|
| 139 |
+
// OAuth
|
| 140 |
+
// ============================================================
|
| 141 |
+
|
| 142 |
+
async function initOAuth() {
|
| 143 |
+
try {
|
| 144 |
+
const result = await oauthHandleRedirectIfPresent();
|
| 145 |
+
if (result) {
|
| 146 |
+
state.oauthResult = result;
|
| 147 |
+
state.username = result.userInfo.preferred_username || result.userInfo.name || result.userInfo.sub;
|
| 148 |
+
await fetchUserOrgs();
|
| 149 |
+
showLoggedIn();
|
| 150 |
+
return;
|
| 151 |
+
}
|
| 152 |
+
} catch (err) {
|
| 153 |
+
console.error("OAuth redirect handling failed:", err);
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
// Not logged in - show sign-in button
|
| 157 |
+
dom.signInBtn.disabled = false;
|
| 158 |
+
dom.signInBtn.addEventListener("click", async () => {
|
| 159 |
+
try {
|
| 160 |
+
dom.signInBtn.disabled = true;
|
| 161 |
+
const url = await oauthLoginUrl({ scopes: "openid profile manage-repos jobs" });
|
| 162 |
+
window.location.href = url;
|
| 163 |
+
} catch (err) {
|
| 164 |
+
show(dom.signInError);
|
| 165 |
+
dom.signInError.textContent = `Sign-in failed: ${err.message}`;
|
| 166 |
+
dom.signInBtn.disabled = false;
|
| 167 |
+
}
|
| 168 |
+
});
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
async function fetchUserOrgs() {
|
| 172 |
+
try {
|
| 173 |
+
const resp = await fetch("https://huggingface.co/api/whoami-v2", {
|
| 174 |
+
headers: { Authorization: `Bearer ${state.oauthResult.accessToken}` },
|
| 175 |
+
});
|
| 176 |
+
if (resp.ok) {
|
| 177 |
+
const data = await resp.json();
|
| 178 |
+
state.orgs = (data.orgs || []).map((o) => o.name);
|
| 179 |
+
}
|
| 180 |
+
} catch {
|
| 181 |
+
// Non-critical, ignore
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
function showLoggedIn() {
|
| 186 |
+
hide(dom.signInScreen);
|
| 187 |
+
show(dom.appHeader);
|
| 188 |
+
show(dom.mainApp);
|
| 189 |
+
|
| 190 |
+
const avatar = state.oauthResult.userInfo.picture || "";
|
| 191 |
+
const name = state.username;
|
| 192 |
+
dom.userInfo.innerHTML = `
|
| 193 |
+
${avatar ? `<img src="${avatar}" alt="${name}">` : ""}
|
| 194 |
+
<span class="username">${name}</span>
|
| 195 |
+
<button class="btn-sign-out" id="btn-sign-out">Sign out</button>
|
| 196 |
+
`;
|
| 197 |
+
document.getElementById("btn-sign-out").addEventListener("click", () => {
|
| 198 |
+
// Clear state and reload
|
| 199 |
+
window.location.href = window.location.pathname;
|
| 200 |
+
});
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
// ============================================================
|
| 204 |
+
// S3 Connection
|
| 205 |
+
// ============================================================
|
| 206 |
+
|
| 207 |
+
async function connectS3() {
|
| 208 |
+
const accessKey = dom.awsAccessKey.value.trim();
|
| 209 |
+
const secretKey = dom.awsSecretKey.value.trim();
|
| 210 |
+
const region = dom.awsRegion.value.trim() || "us-east-1";
|
| 211 |
+
const bucket = dom.s3Bucket.value.trim();
|
| 212 |
+
const endpoint = dom.s3Endpoint.value.trim();
|
| 213 |
+
const prefix = dom.s3Prefix.value.trim();
|
| 214 |
+
|
| 215 |
+
// Validation
|
| 216 |
+
if (!accessKey || !secretKey || !bucket) {
|
| 217 |
+
dom.s3ConnectError.textContent = "Please fill in all required fields.";
|
| 218 |
+
dom.s3ConnectError.style.color = "var(--error)";
|
| 219 |
+
return;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
dom.s3ConnectError.textContent = "";
|
| 223 |
+
setLoading(dom.btnConnect, true, "Connecting...");
|
| 224 |
+
|
| 225 |
+
// Store credentials for later use in Job
|
| 226 |
+
state.awsAccessKeyId = accessKey;
|
| 227 |
+
state.awsSecretAccessKey = secretKey;
|
| 228 |
+
state.s3Region = region;
|
| 229 |
+
state.s3Endpoint = endpoint;
|
| 230 |
+
state.s3Bucket = bucket;
|
| 231 |
+
state.s3Prefix = prefix.endsWith("/") || prefix === "" ? prefix : prefix + "/";
|
| 232 |
+
|
| 233 |
+
// Create S3 client
|
| 234 |
+
const clientConfig = {
|
| 235 |
+
region,
|
| 236 |
+
credentials: {
|
| 237 |
+
accessKeyId: accessKey,
|
| 238 |
+
secretAccessKey: secretKey,
|
| 239 |
+
},
|
| 240 |
+
};
|
| 241 |
+
if (endpoint) {
|
| 242 |
+
clientConfig.endpoint = endpoint;
|
| 243 |
+
clientConfig.forcePathStyle = true;
|
| 244 |
+
}
|
| 245 |
+
state.s3Client = new S3Client(clientConfig);
|
| 246 |
+
|
| 247 |
+
// Try listing
|
| 248 |
+
try {
|
| 249 |
+
const result = await listS3Prefix(state.s3Prefix);
|
| 250 |
+
state.corsFallback = false;
|
| 251 |
+
|
| 252 |
+
// Success - show browser
|
| 253 |
+
show(dom.browserSection);
|
| 254 |
+
show(dom.browserNormal);
|
| 255 |
+
hide(dom.browserCorsFallback);
|
| 256 |
+
dom.s3Status.textContent = "Connected";
|
| 257 |
+
dom.s3Status.className = "card-status connected";
|
| 258 |
+
show(dom.s3Status);
|
| 259 |
+
|
| 260 |
+
// Build initial tree
|
| 261 |
+
resetTree();
|
| 262 |
+
renderTreeLevel(result, state.s3Prefix, dom.treeContainer, 0);
|
| 263 |
+
updateStats();
|
| 264 |
+
} catch (err) {
|
| 265 |
+
console.error("S3 listing error:", err);
|
| 266 |
+
const msg = err.message || String(err);
|
| 267 |
+
|
| 268 |
+
// Check if it's a credentials error vs CORS
|
| 269 |
+
if (msg.includes("403") || msg.includes("AccessDenied") || msg.includes("InvalidAccessKeyId") || msg.includes("SignatureDoesNotMatch")) {
|
| 270 |
+
dom.s3ConnectError.textContent = "Invalid credentials or access denied. Check your Access Key and Secret.";
|
| 271 |
+
dom.s3ConnectError.style.color = "var(--error)";
|
| 272 |
+
setLoading(dom.btnConnect, false, "Connect & Browse");
|
| 273 |
+
return;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
if (msg.includes("404") || msg.includes("NoSuchBucket")) {
|
| 277 |
+
dom.s3ConnectError.textContent = "Bucket not found. Check the bucket name and region.";
|
| 278 |
+
dom.s3ConnectError.style.color = "var(--error)";
|
| 279 |
+
setLoading(dom.btnConnect, false, "Connect & Browse");
|
| 280 |
+
return;
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
// CORS or network error - fallback mode
|
| 284 |
+
state.corsFallback = true;
|
| 285 |
+
show(dom.browserSection);
|
| 286 |
+
hide(dom.browserNormal);
|
| 287 |
+
show(dom.browserCorsFallback);
|
| 288 |
+
dom.s3Status.textContent = "Connected (no browse)";
|
| 289 |
+
dom.s3Status.className = "card-status connected";
|
| 290 |
+
show(dom.s3Status);
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
setLoading(dom.btnConnect, false, "Connect & Browse");
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
async function listS3Prefix(prefix, continuationToken) {
|
| 297 |
+
const params = {
|
| 298 |
+
Bucket: state.s3Bucket,
|
| 299 |
+
Prefix: prefix || undefined,
|
| 300 |
+
Delimiter: "/",
|
| 301 |
+
MaxKeys: 1000,
|
| 302 |
+
};
|
| 303 |
+
if (continuationToken) {
|
| 304 |
+
params.ContinuationToken = continuationToken;
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
const command = new ListObjectsV2Command(params);
|
| 308 |
+
const response = await state.s3Client.send(command);
|
| 309 |
+
|
| 310 |
+
return {
|
| 311 |
+
folders: (response.CommonPrefixes || []).map((cp) => cp.Prefix),
|
| 312 |
+
files: (response.Contents || [])
|
| 313 |
+
.filter((obj) => obj.Key !== prefix) // exclude the prefix itself
|
| 314 |
+
.map((obj) => ({
|
| 315 |
+
key: obj.Key,
|
| 316 |
+
size: obj.Size || 0,
|
| 317 |
+
lastModified: obj.LastModified,
|
| 318 |
+
})),
|
| 319 |
+
isTruncated: response.IsTruncated,
|
| 320 |
+
continuationToken: response.NextContinuationToken,
|
| 321 |
+
};
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
// ============================================================
|
| 325 |
+
// Tree View
|
| 326 |
+
// ============================================================
|
| 327 |
+
|
| 328 |
+
function resetTree() {
|
| 329 |
+
state.tree = [];
|
| 330 |
+
state.allFiles.clear();
|
| 331 |
+
state.allFolders.clear();
|
| 332 |
+
state.totalFiles = 0;
|
| 333 |
+
state.totalSize = 0;
|
| 334 |
+
state.selectedFiles = 0;
|
| 335 |
+
state.selectedSize = 0;
|
| 336 |
+
dom.treeContainer.innerHTML = "";
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
function renderTreeLevel(result, parentPrefix, container, depth) {
|
| 340 |
+
// Render folders
|
| 341 |
+
for (const folderKey of result.folders) {
|
| 342 |
+
const relativeName = folderKey.slice(parentPrefix.length);
|
| 343 |
+
state.allFolders.set(folderKey, { selected: true, loaded: false });
|
| 344 |
+
const node = createTreeNode({
|
| 345 |
+
key: folderKey,
|
| 346 |
+
name: relativeName.replace(/\/$/, ""),
|
| 347 |
+
isFolder: true,
|
| 348 |
+
size: 0,
|
| 349 |
+
depth,
|
| 350 |
+
});
|
| 351 |
+
container.appendChild(node);
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
// Render files
|
| 355 |
+
for (const file of result.files) {
|
| 356 |
+
const relativeName = file.key.slice(parentPrefix.length);
|
| 357 |
+
state.allFiles.set(file.key, { size: file.size, selected: true });
|
| 358 |
+
state.totalFiles++;
|
| 359 |
+
state.totalSize += file.size;
|
| 360 |
+
state.selectedFiles++;
|
| 361 |
+
state.selectedSize += file.size;
|
| 362 |
+
const node = createTreeNode({
|
| 363 |
+
key: file.key,
|
| 364 |
+
name: relativeName,
|
| 365 |
+
isFolder: false,
|
| 366 |
+
size: file.size,
|
| 367 |
+
depth,
|
| 368 |
+
});
|
| 369 |
+
container.appendChild(node);
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
// Load more button
|
| 373 |
+
if (result.isTruncated) {
|
| 374 |
+
const loadMore = document.createElement("div");
|
| 375 |
+
loadMore.className = "tree-load-more";
|
| 376 |
+
loadMore.style.paddingLeft = `${(depth + 1) * 24 + 12}px`;
|
| 377 |
+
loadMore.textContent = "Load more...";
|
| 378 |
+
loadMore.addEventListener("click", async () => {
|
| 379 |
+
loadMore.textContent = "Loading...";
|
| 380 |
+
try {
|
| 381 |
+
const moreResult = await listS3Prefix(parentPrefix, result.continuationToken);
|
| 382 |
+
loadMore.remove();
|
| 383 |
+
renderTreeLevel(moreResult, parentPrefix, container, depth);
|
| 384 |
+
updateStats();
|
| 385 |
+
} catch (err) {
|
| 386 |
+
loadMore.textContent = `Error: ${err.message}. Click to retry.`;
|
| 387 |
+
}
|
| 388 |
+
});
|
| 389 |
+
container.appendChild(loadMore);
|
| 390 |
+
}
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
function createTreeNode({ key, name, isFolder, size, depth }) {
|
| 394 |
+
const row = document.createElement("div");
|
| 395 |
+
row.className = "tree-node";
|
| 396 |
+
row.dataset.key = key;
|
| 397 |
+
row.dataset.isFolder = isFolder;
|
| 398 |
+
|
| 399 |
+
// Indent
|
| 400 |
+
const indent = document.createElement("span");
|
| 401 |
+
indent.className = "indent";
|
| 402 |
+
indent.style.width = `${depth * 24}px`;
|
| 403 |
+
row.appendChild(indent);
|
| 404 |
+
|
| 405 |
+
// Expand icon (folders only)
|
| 406 |
+
const expandIcon = document.createElement("span");
|
| 407 |
+
expandIcon.className = `expand-icon ${isFolder ? "" : "hidden"}`;
|
| 408 |
+
expandIcon.textContent = "\u25B6"; // right triangle
|
| 409 |
+
row.appendChild(expandIcon);
|
| 410 |
+
|
| 411 |
+
// Checkbox
|
| 412 |
+
const checkbox = document.createElement("input");
|
| 413 |
+
checkbox.type = "checkbox";
|
| 414 |
+
checkbox.className = "node-checkbox";
|
| 415 |
+
checkbox.checked = true; // selected by default
|
| 416 |
+
checkbox.addEventListener("change", (e) => {
|
| 417 |
+
e.stopPropagation();
|
| 418 |
+
toggleSelection(key, isFolder, checkbox.checked);
|
| 419 |
+
});
|
| 420 |
+
checkbox.addEventListener("click", (e) => e.stopPropagation());
|
| 421 |
+
row.appendChild(checkbox);
|
| 422 |
+
|
| 423 |
+
// Icon
|
| 424 |
+
const icon = document.createElement("span");
|
| 425 |
+
icon.className = "node-icon";
|
| 426 |
+
icon.textContent = isFolder ? "\uD83D\uDCC1" : "\uD83D\uDCC4";
|
| 427 |
+
row.appendChild(icon);
|
| 428 |
+
|
| 429 |
+
// Name
|
| 430 |
+
const nameSpan = document.createElement("span");
|
| 431 |
+
nameSpan.className = "node-name";
|
| 432 |
+
nameSpan.textContent = name;
|
| 433 |
+
row.appendChild(nameSpan);
|
| 434 |
+
|
| 435 |
+
// Meta (size for files)
|
| 436 |
+
const meta = document.createElement("span");
|
| 437 |
+
meta.className = "node-meta";
|
| 438 |
+
meta.textContent = isFolder ? "" : formatSize(size);
|
| 439 |
+
row.appendChild(meta);
|
| 440 |
+
|
| 441 |
+
// Click handler for folders (expand/collapse)
|
| 442 |
+
if (isFolder) {
|
| 443 |
+
row.addEventListener("click", () => expandFolder(key, row, depth));
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
return row;
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
async function expandFolder(folderKey, row, depth) {
|
| 450 |
+
const expandIcon = row.querySelector(".expand-icon");
|
| 451 |
+
const folderState = state.allFolders.get(folderKey);
|
| 452 |
+
|
| 453 |
+
// Toggle collapse
|
| 454 |
+
if (expandIcon.classList.contains("expanded")) {
|
| 455 |
+
expandIcon.classList.remove("expanded");
|
| 456 |
+
// Hide children
|
| 457 |
+
let next = row.nextElementSibling;
|
| 458 |
+
while (next && next.dataset.parentFolder === folderKey) {
|
| 459 |
+
next.style.display = "none";
|
| 460 |
+
next = next.nextElementSibling;
|
| 461 |
+
}
|
| 462 |
+
return;
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
expandIcon.classList.add("expanded");
|
| 466 |
+
|
| 467 |
+
// If already loaded, just show children
|
| 468 |
+
if (folderState && folderState.loaded) {
|
| 469 |
+
let next = row.nextElementSibling;
|
| 470 |
+
while (next && next.dataset.parentFolder === folderKey) {
|
| 471 |
+
next.style.display = "";
|
| 472 |
+
next = next.nextElementSibling;
|
| 473 |
+
}
|
| 474 |
+
return;
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
// Load children
|
| 478 |
+
const loadingRow = document.createElement("div");
|
| 479 |
+
loadingRow.className = "tree-node loading";
|
| 480 |
+
loadingRow.dataset.parentFolder = folderKey;
|
| 481 |
+
loadingRow.innerHTML = `
|
| 482 |
+
<span class="indent" style="width:${(depth + 1) * 24}px"></span>
|
| 483 |
+
<span class="expand-icon hidden"></span>
|
| 484 |
+
<span class="node-icon"><span class="spinner"></span></span>
|
| 485 |
+
<span class="node-name">Loading...</span>
|
| 486 |
+
`;
|
| 487 |
+
row.after(loadingRow);
|
| 488 |
+
|
| 489 |
+
try {
|
| 490 |
+
const result = await listS3Prefix(folderKey);
|
| 491 |
+
loadingRow.remove();
|
| 492 |
+
folderState.loaded = true;
|
| 493 |
+
|
| 494 |
+
// Update meta with count
|
| 495 |
+
const meta = row.querySelector(".node-meta");
|
| 496 |
+
const totalItems = result.folders.length + result.files.length + (result.isTruncated ? "+" : "");
|
| 497 |
+
meta.textContent = `${totalItems} items`;
|
| 498 |
+
|
| 499 |
+
// Create a container fragment
|
| 500 |
+
const fragment = document.createDocumentFragment();
|
| 501 |
+
const tempContainer = document.createElement("div");
|
| 502 |
+
|
| 503 |
+
renderTreeLevel(result, folderKey, tempContainer, depth + 1);
|
| 504 |
+
|
| 505 |
+
// Mark all children with parent folder for collapse/expand
|
| 506 |
+
for (const child of tempContainer.children) {
|
| 507 |
+
child.dataset.parentFolder = folderKey;
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
// Insert after the folder row
|
| 511 |
+
let insertAfter = row;
|
| 512 |
+
while (tempContainer.firstChild) {
|
| 513 |
+
const child = tempContainer.firstChild;
|
| 514 |
+
child.dataset.parentFolder = folderKey;
|
| 515 |
+
insertAfter.after(child);
|
| 516 |
+
insertAfter = child;
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
// If folder is selected, ensure children are selected too
|
| 520 |
+
if (folderState.selected) {
|
| 521 |
+
// Children are already selected by default from renderTreeLevel
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
updateStats();
|
| 525 |
+
} catch (err) {
|
| 526 |
+
loadingRow.querySelector(".node-name").textContent = `Error: ${err.message}`;
|
| 527 |
+
loadingRow.querySelector(".node-icon").innerHTML = "";
|
| 528 |
+
}
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
function toggleSelection(key, isFolder, selected) {
|
| 532 |
+
if (isFolder) {
|
| 533 |
+
const folderState = state.allFolders.get(key);
|
| 534 |
+
if (folderState) folderState.selected = selected;
|
| 535 |
+
|
| 536 |
+
// Toggle all loaded children
|
| 537 |
+
for (const [fileKey, fileState] of state.allFiles) {
|
| 538 |
+
if (fileKey.startsWith(key)) {
|
| 539 |
+
const wasSelected = fileState.selected;
|
| 540 |
+
fileState.selected = selected;
|
| 541 |
+
if (wasSelected !== selected) {
|
| 542 |
+
state.selectedFiles += selected ? 1 : -1;
|
| 543 |
+
state.selectedSize += selected ? fileState.size : -fileState.size;
|
| 544 |
+
}
|
| 545 |
+
// Update checkbox in DOM
|
| 546 |
+
const row = dom.treeContainer.querySelector(`[data-key="${CSS.escape(fileKey)}"]`);
|
| 547 |
+
if (row) row.querySelector(".node-checkbox").checked = selected;
|
| 548 |
+
}
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
// Toggle child folders
|
| 552 |
+
for (const [folderKeyChild, folderState2] of state.allFolders) {
|
| 553 |
+
if (folderKeyChild.startsWith(key) && folderKeyChild !== key) {
|
| 554 |
+
folderState2.selected = selected;
|
| 555 |
+
const row = dom.treeContainer.querySelector(`[data-key="${CSS.escape(folderKeyChild)}"]`);
|
| 556 |
+
if (row) row.querySelector(".node-checkbox").checked = selected;
|
| 557 |
+
}
|
| 558 |
+
}
|
| 559 |
+
} else {
|
| 560 |
+
const fileState = state.allFiles.get(key);
|
| 561 |
+
if (fileState) {
|
| 562 |
+
const wasSelected = fileState.selected;
|
| 563 |
+
fileState.selected = selected;
|
| 564 |
+
if (wasSelected !== selected) {
|
| 565 |
+
state.selectedFiles += selected ? 1 : -1;
|
| 566 |
+
state.selectedSize += selected ? fileState.size : -fileState.size;
|
| 567 |
+
}
|
| 568 |
+
}
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
updateStats();
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
function selectAll(selected) {
|
| 575 |
+
for (const [key, fileState] of state.allFiles) {
|
| 576 |
+
fileState.selected = selected;
|
| 577 |
+
}
|
| 578 |
+
for (const [key, folderState] of state.allFolders) {
|
| 579 |
+
folderState.selected = selected;
|
| 580 |
+
}
|
| 581 |
+
|
| 582 |
+
// Update all checkboxes
|
| 583 |
+
dom.treeContainer.querySelectorAll(".node-checkbox").forEach((cb) => {
|
| 584 |
+
cb.checked = selected;
|
| 585 |
+
});
|
| 586 |
+
|
| 587 |
+
// Recalculate
|
| 588 |
+
if (selected) {
|
| 589 |
+
state.selectedFiles = state.totalFiles;
|
| 590 |
+
state.selectedSize = state.totalSize;
|
| 591 |
+
} else {
|
| 592 |
+
state.selectedFiles = 0;
|
| 593 |
+
state.selectedSize = 0;
|
| 594 |
+
}
|
| 595 |
+
updateStats();
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
function updateStats() {
|
| 599 |
+
dom.statSelectedCount.textContent = state.selectedFiles.toLocaleString();
|
| 600 |
+
dom.statSelectedSize.textContent = formatSize(state.selectedSize);
|
| 601 |
+
dom.statTotalCount.textContent = state.totalFiles.toLocaleString();
|
| 602 |
+
dom.statTotalSize.textContent = formatSize(state.totalSize);
|
| 603 |
+
}
|
| 604 |
+
|
| 605 |
+
// ============================================================
|
| 606 |
+
// Import Configuration
|
| 607 |
+
// ============================================================
|
| 608 |
+
|
| 609 |
+
function showImportSection() {
|
| 610 |
+
show(dom.importSection);
|
| 611 |
+
dom.importSection.scrollIntoView({ behavior: "smooth", block: "start" });
|
| 612 |
+
|
| 613 |
+
// Update patterns preview
|
| 614 |
+
updatePatternsPreview();
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
function updateDestPreview() {
|
| 618 |
+
const bucket = dom.destBucket.value.trim();
|
| 619 |
+
if (!bucket) {
|
| 620 |
+
hide(dom.destPreview);
|
| 621 |
+
return;
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
+
const fullBucket = bucket.includes("/") ? bucket : `${state.username}/${bucket}`;
|
| 625 |
+
const prefix = dom.destPrefix.value.trim();
|
| 626 |
+
const path = prefix ? `${fullBucket}/${prefix.replace(/\/$/, "")}` : fullBucket;
|
| 627 |
+
|
| 628 |
+
dom.destPreview.textContent = `hf://buckets/${path}`;
|
| 629 |
+
show(dom.destPreview);
|
| 630 |
+
}
|
| 631 |
+
|
| 632 |
+
function computePatterns() {
|
| 633 |
+
if (state.corsFallback) {
|
| 634 |
+
const includes = dom.manualInclude.value.trim().split("\n").filter(Boolean);
|
| 635 |
+
const excludes = dom.manualExclude.value.trim().split("\n").filter(Boolean);
|
| 636 |
+
return { include: includes, exclude: excludes };
|
| 637 |
+
}
|
| 638 |
+
|
| 639 |
+
// All files selected?
|
| 640 |
+
if (state.selectedFiles === state.totalFiles) {
|
| 641 |
+
return { include: [], exclude: [] };
|
| 642 |
+
}
|
| 643 |
+
|
| 644 |
+
// No files selected?
|
| 645 |
+
if (state.selectedFiles === 0) {
|
| 646 |
+
return { include: ["__nothing__"], exclude: [] };
|
| 647 |
+
}
|
| 648 |
+
|
| 649 |
+
// Compute selected/deselected
|
| 650 |
+
const selected = [];
|
| 651 |
+
const deselected = [];
|
| 652 |
+
|
| 653 |
+
for (const [key, fileState] of state.allFiles) {
|
| 654 |
+
const relKey = key.startsWith(state.s3Prefix) ? key.slice(state.s3Prefix.length) : key;
|
| 655 |
+
if (fileState.selected) {
|
| 656 |
+
selected.push(relKey);
|
| 657 |
+
} else {
|
| 658 |
+
deselected.push(relKey);
|
| 659 |
+
}
|
| 660 |
+
}
|
| 661 |
+
|
| 662 |
+
// Use whichever set is smaller
|
| 663 |
+
if (deselected.length <= selected.length) {
|
| 664 |
+
return { include: [], exclude: deselected };
|
| 665 |
+
} else {
|
| 666 |
+
// Try to group by folder
|
| 667 |
+
const patterns = compactPatterns(selected);
|
| 668 |
+
return { include: patterns, exclude: [] };
|
| 669 |
+
}
|
| 670 |
+
}
|
| 671 |
+
|
| 672 |
+
function compactPatterns(keys) {
|
| 673 |
+
// Group files by their parent folder and check if entire folder is selected
|
| 674 |
+
const folderCounts = new Map();
|
| 675 |
+
const folderTotals = new Map();
|
| 676 |
+
|
| 677 |
+
for (const key of keys) {
|
| 678 |
+
const parts = key.split("/");
|
| 679 |
+
if (parts.length > 1) {
|
| 680 |
+
const folder = parts.slice(0, -1).join("/") + "/";
|
| 681 |
+
folderCounts.set(folder, (folderCounts.get(folder) || 0) + 1);
|
| 682 |
+
}
|
| 683 |
+
}
|
| 684 |
+
|
| 685 |
+
// Count total files per folder
|
| 686 |
+
for (const [fileKey] of state.allFiles) {
|
| 687 |
+
const relKey = fileKey.startsWith(state.s3Prefix) ? fileKey.slice(state.s3Prefix.length) : fileKey;
|
| 688 |
+
const parts = relKey.split("/");
|
| 689 |
+
if (parts.length > 1) {
|
| 690 |
+
const folder = parts.slice(0, -1).join("/") + "/";
|
| 691 |
+
folderTotals.set(folder, (folderTotals.get(folder) || 0) + 1);
|
| 692 |
+
}
|
| 693 |
+
}
|
| 694 |
+
|
| 695 |
+
const patterns = [];
|
| 696 |
+
const coveredKeys = new Set();
|
| 697 |
+
|
| 698 |
+
// If entire folder is selected, use folder/*
|
| 699 |
+
for (const [folder, count] of folderCounts) {
|
| 700 |
+
if (count === (folderTotals.get(folder) || 0)) {
|
| 701 |
+
patterns.push(`${folder}*`);
|
| 702 |
+
for (const key of keys) {
|
| 703 |
+
if (key.startsWith(folder)) coveredKeys.add(key);
|
| 704 |
+
}
|
| 705 |
+
}
|
| 706 |
+
}
|
| 707 |
+
|
| 708 |
+
// Add remaining individual files
|
| 709 |
+
for (const key of keys) {
|
| 710 |
+
if (!coveredKeys.has(key)) {
|
| 711 |
+
patterns.push(key);
|
| 712 |
+
}
|
| 713 |
+
}
|
| 714 |
+
|
| 715 |
+
return patterns;
|
| 716 |
+
}
|
| 717 |
+
|
| 718 |
+
function updatePatternsPreview() {
|
| 719 |
+
const patterns = computePatterns();
|
| 720 |
+
const s3Uri = `s3://${state.s3Bucket}/${state.s3Prefix}`;
|
| 721 |
+
const destBucket = dom.destBucket.value.trim();
|
| 722 |
+
const fullDest = destBucket.includes("/") ? destBucket : `${state.username}/${destBucket}`;
|
| 723 |
+
const destPrefix = dom.destPrefix.value.trim();
|
| 724 |
+
const dest = destPrefix ? `${fullDest}/${destPrefix.replace(/\/$/, "")}` : fullDest;
|
| 725 |
+
const workers = dom.jobWorkers.value || "4";
|
| 726 |
+
|
| 727 |
+
let cmd = `hf buckets import ${shellEscape(s3Uri)} ${shellEscape(dest)}`;
|
| 728 |
+
|
| 729 |
+
if (patterns.include.length > 0) {
|
| 730 |
+
for (const p of patterns.include) {
|
| 731 |
+
cmd += ` --include ${shellEscape(p)}`;
|
| 732 |
+
}
|
| 733 |
+
}
|
| 734 |
+
if (patterns.exclude.length > 0) {
|
| 735 |
+
for (const p of patterns.exclude) {
|
| 736 |
+
cmd += ` --exclude ${shellEscape(p)}`;
|
| 737 |
+
}
|
| 738 |
+
}
|
| 739 |
+
|
| 740 |
+
cmd += ` --workers ${workers} --verbose`;
|
| 741 |
+
|
| 742 |
+
dom.patternsPreview.textContent = cmd;
|
| 743 |
+
show(dom.patternsInfo);
|
| 744 |
+
}
|
| 745 |
+
|
| 746 |
+
// ============================================================
|
| 747 |
+
// Bucket Creation
|
| 748 |
+
// ============================================================
|
| 749 |
+
|
| 750 |
+
async function ensureBucketExists(namespace, bucketName) {
|
| 751 |
+
const token = state.oauthResult.accessToken;
|
| 752 |
+
|
| 753 |
+
// Try to create bucket
|
| 754 |
+
const body = {
|
| 755 |
+
type: "bucket",
|
| 756 |
+
name: bucketName,
|
| 757 |
+
private: true,
|
| 758 |
+
};
|
| 759 |
+
if (namespace !== state.username) {
|
| 760 |
+
body.organization = namespace;
|
| 761 |
+
}
|
| 762 |
+
|
| 763 |
+
const resp = await fetch("https://huggingface.co/api/repos/create", {
|
| 764 |
+
method: "POST",
|
| 765 |
+
headers: {
|
| 766 |
+
Authorization: `Bearer ${token}`,
|
| 767 |
+
"Content-Type": "application/json",
|
| 768 |
+
},
|
| 769 |
+
body: JSON.stringify(body),
|
| 770 |
+
});
|
| 771 |
+
|
| 772 |
+
if (resp.ok || resp.status === 409) {
|
| 773 |
+
// Created or already exists
|
| 774 |
+
return true;
|
| 775 |
+
}
|
| 776 |
+
|
| 777 |
+
const errorText = await resp.text();
|
| 778 |
+
throw new Error(`Failed to create bucket: ${resp.status} - ${errorText}`);
|
| 779 |
+
}
|
| 780 |
+
|
| 781 |
+
// ============================================================
|
| 782 |
+
// Job Submission
|
| 783 |
+
// ============================================================
|
| 784 |
+
|
| 785 |
+
async function submitImportJob() {
|
| 786 |
+
const destBucketInput = dom.destBucket.value.trim();
|
| 787 |
+
if (!destBucketInput) {
|
| 788 |
+
showImportError("Please provide a destination bucket name.");
|
| 789 |
+
return;
|
| 790 |
+
}
|
| 791 |
+
|
| 792 |
+
// Parse namespace/bucket
|
| 793 |
+
let namespace, bucketName;
|
| 794 |
+
if (destBucketInput.includes("/")) {
|
| 795 |
+
[namespace, bucketName] = destBucketInput.split("/", 2);
|
| 796 |
+
} else {
|
| 797 |
+
namespace = state.username;
|
| 798 |
+
bucketName = destBucketInput;
|
| 799 |
+
}
|
| 800 |
+
|
| 801 |
+
const destPrefix = dom.destPrefix.value.trim().replace(/\/$/, "");
|
| 802 |
+
const fullDest = destPrefix ? `${namespace}/${bucketName}/${destPrefix}` : `${namespace}/${bucketName}`;
|
| 803 |
+
const s3Uri = `s3://${state.s3Bucket}/${state.s3Prefix}`;
|
| 804 |
+
const flavor = dom.jobFlavor.value;
|
| 805 |
+
const workers = parseInt(dom.jobWorkers.value) || 4;
|
| 806 |
+
const timeout = parseInt(dom.jobTimeout.value) || 7200;
|
| 807 |
+
const token = state.oauthResult.accessToken;
|
| 808 |
+
|
| 809 |
+
hideImportError();
|
| 810 |
+
setLoading(dom.btnStartImport, true, "Creating bucket & submitting job...");
|
| 811 |
+
|
| 812 |
+
try {
|
| 813 |
+
// Step 1: Ensure bucket exists
|
| 814 |
+
await ensureBucketExists(namespace, bucketName);
|
| 815 |
+
|
| 816 |
+
// Step 2: Build command
|
| 817 |
+
const patterns = computePatterns();
|
| 818 |
+
let script = "pip install -q 'huggingface_hub[s3] @ git+https://github.com/huggingface/huggingface_hub.git@cursor/s3-to-hf-bucket-ingestion-f144'";
|
| 819 |
+
script += ` && hf buckets import ${shellEscape(s3Uri)} ${shellEscape(fullDest)}`;
|
| 820 |
+
|
| 821 |
+
if (patterns.include.length > 0) {
|
| 822 |
+
for (const p of patterns.include) {
|
| 823 |
+
script += ` --include ${shellEscape(p)}`;
|
| 824 |
+
}
|
| 825 |
+
}
|
| 826 |
+
if (patterns.exclude.length > 0) {
|
| 827 |
+
for (const p of patterns.exclude) {
|
| 828 |
+
script += ` --exclude ${shellEscape(p)}`;
|
| 829 |
+
}
|
| 830 |
+
}
|
| 831 |
+
|
| 832 |
+
script += ` --workers ${workers} --verbose`;
|
| 833 |
+
|
| 834 |
+
// Step 3: Submit job
|
| 835 |
+
const jobPayload = {
|
| 836 |
+
dockerImage: "python:3.12",
|
| 837 |
+
command: ["bash", "-c", script],
|
| 838 |
+
arguments: [],
|
| 839 |
+
flavor,
|
| 840 |
+
timeout,
|
| 841 |
+
environment: {
|
| 842 |
+
AWS_DEFAULT_REGION: state.s3Region || "us-east-1",
|
| 843 |
+
},
|
| 844 |
+
secrets: {
|
| 845 |
+
AWS_ACCESS_KEY_ID: state.awsAccessKeyId,
|
| 846 |
+
AWS_SECRET_ACCESS_KEY: state.awsSecretAccessKey,
|
| 847 |
+
HF_TOKEN: token,
|
| 848 |
+
},
|
| 849 |
+
};
|
| 850 |
+
|
| 851 |
+
if (state.s3Endpoint) {
|
| 852 |
+
jobPayload.environment.AWS_ENDPOINT_URL = state.s3Endpoint;
|
| 853 |
+
}
|
| 854 |
+
|
| 855 |
+
const resp = await fetch(`https://huggingface.co/api/jobs/${namespace}`, {
|
| 856 |
+
method: "POST",
|
| 857 |
+
headers: {
|
| 858 |
+
Authorization: `Bearer ${token}`,
|
| 859 |
+
"Content-Type": "application/json",
|
| 860 |
+
},
|
| 861 |
+
body: JSON.stringify(jobPayload),
|
| 862 |
+
});
|
| 863 |
+
|
| 864 |
+
if (!resp.ok) {
|
| 865 |
+
const errorText = await resp.text();
|
| 866 |
+
throw new Error(`Job creation failed (${resp.status}): ${errorText}`);
|
| 867 |
+
}
|
| 868 |
+
|
| 869 |
+
const jobData = await resp.json();
|
| 870 |
+
state.jobId = jobData.id;
|
| 871 |
+
state.jobNamespace = namespace;
|
| 872 |
+
|
| 873 |
+
// Show status
|
| 874 |
+
showJobStatus(jobData);
|
| 875 |
+
pollJobStatus();
|
| 876 |
+
} catch (err) {
|
| 877 |
+
showImportError(err.message);
|
| 878 |
+
setLoading(dom.btnStartImport, false, "Start Import");
|
| 879 |
+
}
|
| 880 |
+
}
|
| 881 |
+
|
| 882 |
+
function showImportError(msg) {
|
| 883 |
+
dom.importError.textContent = msg;
|
| 884 |
+
show(dom.importError);
|
| 885 |
+
}
|
| 886 |
+
|
| 887 |
+
function hideImportError() {
|
| 888 |
+
hide(dom.importError);
|
| 889 |
+
}
|
| 890 |
+
|
| 891 |
+
// ============================================================
|
| 892 |
+
// Job Status
|
| 893 |
+
// ============================================================
|
| 894 |
+
|
| 895 |
+
function showJobStatus(jobData) {
|
| 896 |
+
hide(dom.s3Section);
|
| 897 |
+
hide(dom.browserSection);
|
| 898 |
+
hide(dom.importSection);
|
| 899 |
+
show(dom.statusSection);
|
| 900 |
+
|
| 901 |
+
const jobUrl = `https://huggingface.co/jobs/${state.jobNamespace}/${jobData.id}`;
|
| 902 |
+
dom.jobIdDisplay.textContent = `Job ID: ${jobData.id}`;
|
| 903 |
+
dom.jobLink.href = jobUrl;
|
| 904 |
+
updateJobStatusUI(jobData.status?.stage || "SCHEDULING");
|
| 905 |
+
}
|
| 906 |
+
|
| 907 |
+
function updateJobStatusUI(stage) {
|
| 908 |
+
const lowerStage = stage.toLowerCase();
|
| 909 |
+
dom.jobStatusBadge.textContent = stage;
|
| 910 |
+
dom.jobStatusBadge.className = `job-status-badge ${lowerStage}`;
|
| 911 |
+
|
| 912 |
+
switch (stage) {
|
| 913 |
+
case "SCHEDULING":
|
| 914 |
+
dom.jobStatusIcon.textContent = "\uD83D\uDE80";
|
| 915 |
+
dom.jobStatusTitle.textContent = "Import Job Submitted";
|
| 916 |
+
dom.jobStatusMessage.textContent = "Your job is being scheduled. This usually takes a few seconds.";
|
| 917 |
+
break;
|
| 918 |
+
case "RUNNING":
|
| 919 |
+
dom.jobStatusIcon.textContent = "\u2699\uFE0F";
|
| 920 |
+
dom.jobStatusTitle.textContent = "Import in Progress";
|
| 921 |
+
dom.jobStatusMessage.textContent = "Your data is being transferred from S3 to your HF bucket. You can close this page - the job will continue running.";
|
| 922 |
+
break;
|
| 923 |
+
case "COMPLETED":
|
| 924 |
+
dom.jobStatusIcon.textContent = "\u2705";
|
| 925 |
+
dom.jobStatusTitle.textContent = "Import Complete!";
|
| 926 |
+
dom.jobStatusMessage.textContent = "Your data has been successfully imported to the HF bucket.";
|
| 927 |
+
break;
|
| 928 |
+
case "ERROR":
|
| 929 |
+
dom.jobStatusIcon.textContent = "\u274C";
|
| 930 |
+
dom.jobStatusTitle.textContent = "Import Failed";
|
| 931 |
+
dom.jobStatusMessage.textContent = "The import job encountered an error. Check the job logs for details.";
|
| 932 |
+
break;
|
| 933 |
+
case "CANCELED":
|
| 934 |
+
dom.jobStatusIcon.textContent = "\u23F9\uFE0F";
|
| 935 |
+
dom.jobStatusTitle.textContent = "Import Canceled";
|
| 936 |
+
dom.jobStatusMessage.textContent = "The import job was canceled.";
|
| 937 |
+
break;
|
| 938 |
+
default:
|
| 939 |
+
dom.jobStatusIcon.textContent = "\u2753";
|
| 940 |
+
dom.jobStatusTitle.textContent = `Status: ${stage}`;
|
| 941 |
+
dom.jobStatusMessage.textContent = "";
|
| 942 |
+
}
|
| 943 |
+
}
|
| 944 |
+
|
| 945 |
+
async function pollJobStatus() {
|
| 946 |
+
if (!state.jobId) return;
|
| 947 |
+
|
| 948 |
+
const token = state.oauthResult.accessToken;
|
| 949 |
+
const terminalStages = new Set(["COMPLETED", "ERROR", "CANCELED", "DELETED"]);
|
| 950 |
+
|
| 951 |
+
const poll = async () => {
|
| 952 |
+
try {
|
| 953 |
+
const resp = await fetch(
|
| 954 |
+
`https://huggingface.co/api/jobs/${state.jobNamespace}/${state.jobId}`,
|
| 955 |
+
{ headers: { Authorization: `Bearer ${token}` } }
|
| 956 |
+
);
|
| 957 |
+
if (resp.ok) {
|
| 958 |
+
const data = await resp.json();
|
| 959 |
+
const stage = data.status?.stage || "UNKNOWN";
|
| 960 |
+
updateJobStatusUI(stage);
|
| 961 |
+
|
| 962 |
+
if (terminalStages.has(stage)) return; // stop polling
|
| 963 |
+
}
|
| 964 |
+
} catch {
|
| 965 |
+
// Network error, keep polling
|
| 966 |
+
}
|
| 967 |
+
|
| 968 |
+
setTimeout(poll, 5000);
|
| 969 |
+
};
|
| 970 |
+
|
| 971 |
+
// Start polling after a short delay
|
| 972 |
+
setTimeout(poll, 3000);
|
| 973 |
+
}
|
| 974 |
+
|
| 975 |
+
function resetForNewImport() {
|
| 976 |
+
hide(dom.statusSection);
|
| 977 |
+
show(dom.s3Section);
|
| 978 |
+
state.jobId = null;
|
| 979 |
+
state.jobNamespace = null;
|
| 980 |
+
|
| 981 |
+
// Reset browser and import sections
|
| 982 |
+
hide(dom.browserSection);
|
| 983 |
+
hide(dom.importSection);
|
| 984 |
+
hide(dom.s3Status);
|
| 985 |
+
setLoading(dom.btnStartImport, false, "Start Import");
|
| 986 |
+
}
|
| 987 |
+
|
| 988 |
+
// ============================================================
|
| 989 |
+
// Event Listeners
|
| 990 |
+
// ============================================================
|
| 991 |
+
|
| 992 |
+
function initEventListeners() {
|
| 993 |
+
dom.btnConnect.addEventListener("click", connectS3);
|
| 994 |
+
|
| 995 |
+
dom.btnSelectAll.addEventListener("click", () => selectAll(true));
|
| 996 |
+
dom.btnDeselectAll.addEventListener("click", () => selectAll(false));
|
| 997 |
+
|
| 998 |
+
dom.btnContinueImport.addEventListener("click", showImportSection);
|
| 999 |
+
|
| 1000 |
+
dom.destBucket.addEventListener("input", () => {
|
| 1001 |
+
updateDestPreview();
|
| 1002 |
+
updatePatternsPreview();
|
| 1003 |
+
});
|
| 1004 |
+
dom.destPrefix.addEventListener("input", () => {
|
| 1005 |
+
updateDestPreview();
|
| 1006 |
+
updatePatternsPreview();
|
| 1007 |
+
});
|
| 1008 |
+
dom.jobWorkers.addEventListener("input", updatePatternsPreview);
|
| 1009 |
+
|
| 1010 |
+
dom.btnStartImport.addEventListener("click", submitImportJob);
|
| 1011 |
+
dom.btnNewImport.addEventListener("click", resetForNewImport);
|
| 1012 |
+
|
| 1013 |
+
// Allow Enter key on S3 form
|
| 1014 |
+
dom.s3Section.addEventListener("keydown", (e) => {
|
| 1015 |
+
if (e.key === "Enter") {
|
| 1016 |
+
e.preventDefault();
|
| 1017 |
+
connectS3();
|
| 1018 |
+
}
|
| 1019 |
+
});
|
| 1020 |
+
}
|
| 1021 |
+
|
| 1022 |
+
// ============================================================
|
| 1023 |
+
// Init
|
| 1024 |
+
// ============================================================
|
| 1025 |
+
|
| 1026 |
+
async function main() {
|
| 1027 |
+
initEventListeners();
|
| 1028 |
+
await initOAuth();
|
| 1029 |
+
}
|
| 1030 |
+
|
| 1031 |
+
main().catch((err) => {
|
| 1032 |
+
console.error("App initialization error:", err);
|
| 1033 |
+
});
|
index.html
CHANGED
|
@@ -1,19 +1,259 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>S3 to HF Bucket Importer</title>
|
| 7 |
+
<meta name="description" content="Import your data from AWS S3 to Hugging Face Storage Buckets">
|
| 8 |
+
<link rel="stylesheet" href="style.css">
|
| 9 |
+
</head>
|
| 10 |
+
<body>
|
| 11 |
+
<div class="app-container">
|
| 12 |
+
|
| 13 |
+
<!-- Header (shown when logged in) -->
|
| 14 |
+
<header id="app-header" class="app-header hidden">
|
| 15 |
+
<div class="logo">
|
| 16 |
+
<span class="logo-icon">🪣</span>
|
| 17 |
+
<span class="logo-text">S3 <span>→</span> HF Buckets</span>
|
| 18 |
+
</div>
|
| 19 |
+
<div id="user-info" class="user-info"></div>
|
| 20 |
+
</header>
|
| 21 |
+
|
| 22 |
+
<!-- Sign-in screen -->
|
| 23 |
+
<section id="sign-in-screen" class="sign-in-screen">
|
| 24 |
+
<div class="hero-icon">🪣</div>
|
| 25 |
+
<h1>S3 <span>→ HF Buckets</span></h1>
|
| 26 |
+
<p class="subtitle">
|
| 27 |
+
Import your data from Amazon S3 (or any S3-compatible storage)
|
| 28 |
+
into Hugging Face Storage Buckets. Fast, secure, server-side transfer.
|
| 29 |
+
</p>
|
| 30 |
+
<button id="btn-sign-in" class="btn-sign-in" disabled>
|
| 31 |
+
<svg viewBox="0 0 95 88" fill="none" xmlns="http://www.w3.org/2000/svg">
|
| 32 |
+
<path d="M47.2119 76.5C37.3119 76.5 29.2119 68.4 29.2119 58.5C29.2119 48.6 37.3119 40.5 47.2119 40.5C57.1119 40.5 65.2119 48.6 65.2119 58.5C65.2119 68.4 57.1119 76.5 47.2119 76.5Z" fill="currentColor"/>
|
| 33 |
+
<path d="M47.5 0C21.8 0 0.5 16.5 0.5 37C0.5 48.6 7.1 59 17.5 65.8C17 67.9 15.6 72.4 12.1 76.8C11.3 77.8 12 79.3 13.3 79.2C19.1 78.7 27.1 77 32.5 73.2C37.1 74.7 42.2 75.5 47.5 75.5C73.2 75.5 94.5 59 94.5 37C94.5 16.5 73.2 0 47.5 0ZM27 43.5C22.3 43.5 18.5 39.7 18.5 35C18.5 30.3 22.3 26.5 27 26.5C31.7 26.5 35.5 30.3 35.5 35C35.5 39.7 31.7 43.5 27 43.5ZM68 43.5C63.3 43.5 59.5 39.7 59.5 35C59.5 30.3 63.3 26.5 68 26.5C72.7 26.5 76.5 30.3 76.5 35C76.5 39.7 72.7 43.5 68 43.5Z" fill="currentColor"/>
|
| 34 |
+
</svg>
|
| 35 |
+
Sign in with Hugging Face
|
| 36 |
+
</button>
|
| 37 |
+
<div id="sign-in-error" class="alert alert-error mt-4 hidden"></div>
|
| 38 |
+
<div class="features">
|
| 39 |
+
<div class="feature">
|
| 40 |
+
<div class="feature-icon">🔒</div>
|
| 41 |
+
<h3>Secure</h3>
|
| 42 |
+
<p>Credentials are encrypted and never stored</p>
|
| 43 |
+
</div>
|
| 44 |
+
<div class="feature">
|
| 45 |
+
<div class="feature-icon">☁️</div>
|
| 46 |
+
<h3>Server-side</h3>
|
| 47 |
+
<p>Transfer runs on HF infrastructure via Jobs</p>
|
| 48 |
+
</div>
|
| 49 |
+
<div class="feature">
|
| 50 |
+
<div class="feature-icon">⚡</div>
|
| 51 |
+
<h3>Fast</h3>
|
| 52 |
+
<p>Parallel downloads with configurable workers</p>
|
| 53 |
+
</div>
|
| 54 |
+
</div>
|
| 55 |
+
</section>
|
| 56 |
+
|
| 57 |
+
<!-- Main app (shown when logged in) -->
|
| 58 |
+
<main id="main-app" class="hidden">
|
| 59 |
+
|
| 60 |
+
<!-- Step 1: S3 Connection -->
|
| 61 |
+
<section id="s3-section" class="card">
|
| 62 |
+
<div class="card-header">
|
| 63 |
+
<span class="step-badge">1</span>
|
| 64 |
+
<h2>Connect to S3</h2>
|
| 65 |
+
<span id="s3-status" class="card-status hidden"></span>
|
| 66 |
+
</div>
|
| 67 |
+
<div class="form-grid">
|
| 68 |
+
<div class="form-group">
|
| 69 |
+
<label>AWS Access Key ID <span class="required">*</span></label>
|
| 70 |
+
<input type="text" id="aws-access-key" placeholder="AKIA..." autocomplete="off" spellcheck="false">
|
| 71 |
+
</div>
|
| 72 |
+
<div class="form-group">
|
| 73 |
+
<label>AWS Secret Access Key <span class="required">*</span></label>
|
| 74 |
+
<input type="password" id="aws-secret-key" placeholder="Your secret key" autocomplete="off">
|
| 75 |
+
</div>
|
| 76 |
+
<div class="form-group">
|
| 77 |
+
<label>AWS Region</label>
|
| 78 |
+
<input type="text" id="aws-region" value="us-east-1" placeholder="us-east-1">
|
| 79 |
+
</div>
|
| 80 |
+
<div class="form-group">
|
| 81 |
+
<label>S3 Bucket Name <span class="required">*</span></label>
|
| 82 |
+
<input type="text" id="s3-bucket" placeholder="my-data-bucket" spellcheck="false">
|
| 83 |
+
</div>
|
| 84 |
+
<div class="form-group">
|
| 85 |
+
<label>Endpoint URL <span class="text-muted">(optional, for S3-compatible services)</span></label>
|
| 86 |
+
<input type="text" id="s3-endpoint" placeholder="https://s3.example.com" spellcheck="false">
|
| 87 |
+
</div>
|
| 88 |
+
<div class="form-group">
|
| 89 |
+
<label>Source Prefix <span class="text-muted">(optional)</span></label>
|
| 90 |
+
<input type="text" id="s3-prefix" placeholder="data/exports/" spellcheck="false">
|
| 91 |
+
<span class="hint">Only import files under this prefix</span>
|
| 92 |
+
</div>
|
| 93 |
+
</div>
|
| 94 |
+
<div class="form-actions">
|
| 95 |
+
<button id="btn-connect" class="btn btn-primary">Connect & Browse</button>
|
| 96 |
+
<span id="s3-connect-error" class="text-muted"></span>
|
| 97 |
+
</div>
|
| 98 |
+
</section>
|
| 99 |
+
|
| 100 |
+
<!-- Step 2: File Browser -->
|
| 101 |
+
<section id="browser-section" class="card hidden">
|
| 102 |
+
<div class="card-header">
|
| 103 |
+
<span class="step-badge">2</span>
|
| 104 |
+
<h2>Browse & Select Files</h2>
|
| 105 |
+
</div>
|
| 106 |
+
|
| 107 |
+
<!-- Normal browser mode -->
|
| 108 |
+
<div id="browser-normal">
|
| 109 |
+
<div class="file-browser-header">
|
| 110 |
+
<div class="file-browser-stats">
|
| 111 |
+
<span>Selected: <span class="stat-value" id="stat-selected-count">0</span> files</span>
|
| 112 |
+
<span>Size: <span class="stat-value" id="stat-selected-size">0 B</span></span>
|
| 113 |
+
<span>Total: <span class="stat-value" id="stat-total-count">0</span> files, <span class="stat-value" id="stat-total-size">0 B</span></span>
|
| 114 |
+
</div>
|
| 115 |
+
<div class="file-browser-actions">
|
| 116 |
+
<button id="btn-select-all" class="btn btn-secondary btn-sm">Select All</button>
|
| 117 |
+
<button id="btn-deselect-all" class="btn btn-secondary btn-sm">Deselect All</button>
|
| 118 |
+
</div>
|
| 119 |
+
</div>
|
| 120 |
+
<div id="tree-container" class="tree-container"></div>
|
| 121 |
+
</div>
|
| 122 |
+
|
| 123 |
+
<!-- CORS fallback mode -->
|
| 124 |
+
<div id="browser-cors-fallback" class="cors-fallback hidden">
|
| 125 |
+
<div class="alert alert-warning">
|
| 126 |
+
<span class="alert-icon">⚠️</span>
|
| 127 |
+
<div>
|
| 128 |
+
<strong>Cannot browse this S3 bucket from the browser.</strong><br>
|
| 129 |
+
This usually means CORS is not configured on the S3 bucket.
|
| 130 |
+
You can still import files by specifying patterns below, or import everything.
|
| 131 |
+
</div>
|
| 132 |
+
</div>
|
| 133 |
+
<div class="cors-help">
|
| 134 |
+
<details>
|
| 135 |
+
<summary>How to enable CORS on your S3 bucket</summary>
|
| 136 |
+
<p style="margin-top: 8px; font-size: 13px; color: var(--text-secondary);">
|
| 137 |
+
Add this CORS configuration to your S3 bucket (AWS Console → Bucket → Permissions → CORS):
|
| 138 |
+
</p>
|
| 139 |
+
<pre>[
|
| 140 |
+
{
|
| 141 |
+
"AllowedOrigins": ["https://wauplin-s3-importer.hf.space"],
|
| 142 |
+
"AllowedMethods": ["GET", "HEAD"],
|
| 143 |
+
"AllowedHeaders": ["*"],
|
| 144 |
+
"MaxAgeSeconds": 3600
|
| 145 |
+
}
|
| 146 |
+
]</pre>
|
| 147 |
+
</details>
|
| 148 |
+
</div>
|
| 149 |
+
<div class="manual-patterns mt-4">
|
| 150 |
+
<div class="form-group">
|
| 151 |
+
<label>Include patterns <span class="text-muted">(one per line, leave empty to import all)</span></label>
|
| 152 |
+
<textarea id="manual-include" rows="3" placeholder="*.parquet train/** metadata.json"></textarea>
|
| 153 |
+
</div>
|
| 154 |
+
<div class="form-group mt-4">
|
| 155 |
+
<label>Exclude patterns <span class="text-muted">(one per line)</span></label>
|
| 156 |
+
<textarea id="manual-exclude" rows="3" placeholder="*.tmp logs/**"></textarea>
|
| 157 |
+
</div>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
|
| 161 |
+
<div class="form-actions">
|
| 162 |
+
<button id="btn-continue-import" class="btn btn-primary">Continue to Import</button>
|
| 163 |
+
</div>
|
| 164 |
+
</section>
|
| 165 |
+
|
| 166 |
+
<!-- Step 3: Import Configuration -->
|
| 167 |
+
<section id="import-section" class="card hidden">
|
| 168 |
+
<div class="card-header">
|
| 169 |
+
<span class="step-badge">3</span>
|
| 170 |
+
<h2>Configure Import</h2>
|
| 171 |
+
</div>
|
| 172 |
+
|
| 173 |
+
<div class="form-grid">
|
| 174 |
+
<div class="form-group">
|
| 175 |
+
<label>Destination Bucket <span class="required">*</span></label>
|
| 176 |
+
<input type="text" id="dest-bucket" placeholder="my-bucket or namespace/my-bucket" spellcheck="false">
|
| 177 |
+
<span class="hint">Use <code>namespace/bucket</code> or just <code>bucket</code> (defaults to your username)</span>
|
| 178 |
+
</div>
|
| 179 |
+
<div class="form-group">
|
| 180 |
+
<label>Destination Prefix <span class="text-muted">(optional)</span></label>
|
| 181 |
+
<input type="text" id="dest-prefix" placeholder="imported/2024/" spellcheck="false">
|
| 182 |
+
<span class="hint">Import files under this folder in the bucket</span>
|
| 183 |
+
</div>
|
| 184 |
+
</div>
|
| 185 |
+
|
| 186 |
+
<div id="dest-preview" class="dest-preview mt-4 hidden"></div>
|
| 187 |
+
|
| 188 |
+
<hr>
|
| 189 |
+
|
| 190 |
+
<div class="config-row">
|
| 191 |
+
<div class="form-group">
|
| 192 |
+
<label>Hardware</label>
|
| 193 |
+
<select id="job-flavor">
|
| 194 |
+
<option value="cpu-basic">CPU Basic ($0.04/hr)</option>
|
| 195 |
+
<option value="cpu-upgrade">CPU Upgrade ($0.07/hr)</option>
|
| 196 |
+
</select>
|
| 197 |
+
</div>
|
| 198 |
+
<div class="form-group">
|
| 199 |
+
<label>Workers</label>
|
| 200 |
+
<input type="number" id="job-workers" value="4" min="1" max="16">
|
| 201 |
+
<span class="hint">Parallel download threads</span>
|
| 202 |
+
</div>
|
| 203 |
+
<div class="form-group">
|
| 204 |
+
<label>Timeout</label>
|
| 205 |
+
<select id="job-timeout">
|
| 206 |
+
<option value="1800">30 minutes</option>
|
| 207 |
+
<option value="3600">1 hour</option>
|
| 208 |
+
<option value="7200" selected>2 hours</option>
|
| 209 |
+
<option value="21600">6 hours</option>
|
| 210 |
+
<option value="43200">12 hours</option>
|
| 211 |
+
</select>
|
| 212 |
+
</div>
|
| 213 |
+
</div>
|
| 214 |
+
|
| 215 |
+
<div id="patterns-info" class="hidden">
|
| 216 |
+
<label style="font-size: 13px; font-weight: 500; color: var(--text-secondary);">Import Command Preview</label>
|
| 217 |
+
<div id="patterns-preview" class="patterns-preview mt-4"></div>
|
| 218 |
+
</div>
|
| 219 |
+
|
| 220 |
+
<div id="import-error" class="alert alert-error mt-4 hidden"></div>
|
| 221 |
+
|
| 222 |
+
<div class="form-actions mt-4">
|
| 223 |
+
<button id="btn-start-import" class="btn btn-primary btn-full">
|
| 224 |
+
Start Import
|
| 225 |
+
</button>
|
| 226 |
+
</div>
|
| 227 |
+
</section>
|
| 228 |
+
|
| 229 |
+
<!-- Step 4: Job Status -->
|
| 230 |
+
<section id="status-section" class="card hidden">
|
| 231 |
+
<div class="job-status-card">
|
| 232 |
+
<div id="job-status-icon" class="status-icon">🚀</div>
|
| 233 |
+
<span id="job-status-badge" class="job-status-badge scheduling">Scheduling</span>
|
| 234 |
+
<h3 id="job-status-title">Import Job Submitted</h3>
|
| 235 |
+
<div id="job-id-display" class="job-id"></div>
|
| 236 |
+
<a id="job-link" class="job-link" href="#" target="_blank" rel="noopener">
|
| 237 |
+
View Job on Hugging Face →
|
| 238 |
+
</a>
|
| 239 |
+
<div id="job-status-message" class="mt-4 text-muted" style="font-size: 14px;"></div>
|
| 240 |
+
<div class="mt-6">
|
| 241 |
+
<button id="btn-new-import" class="btn btn-secondary">Start New Import</button>
|
| 242 |
+
</div>
|
| 243 |
+
</div>
|
| 244 |
+
</section>
|
| 245 |
+
|
| 246 |
+
</main>
|
| 247 |
+
</div>
|
| 248 |
+
|
| 249 |
+
<script type="importmap">
|
| 250 |
+
{
|
| 251 |
+
"imports": {
|
| 252 |
+
"@huggingface/hub": "https://esm.sh/@huggingface/hub@0.36.2",
|
| 253 |
+
"@aws-sdk/client-s3": "https://esm.sh/@aws-sdk/client-s3@3.787.0"
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
+
</script>
|
| 257 |
+
<script type="module" src="app.js"></script>
|
| 258 |
+
</body>
|
| 259 |
</html>
|
style.css
CHANGED
|
@@ -1,28 +1,857 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
body {
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
}
|
|
|
|
| 1 |
+
/* ============================================
|
| 2 |
+
S3 to HF Bucket Importer - Dark Theme
|
| 3 |
+
Inspired by HF Buckets announcement design
|
| 4 |
+
============================================ */
|
| 5 |
+
|
| 6 |
+
:root {
|
| 7 |
+
--bg-primary: #0a0e14;
|
| 8 |
+
--bg-secondary: #131920;
|
| 9 |
+
--bg-card: #161b22;
|
| 10 |
+
--bg-input: #0d1117;
|
| 11 |
+
--bg-hover: #1c2330;
|
| 12 |
+
|
| 13 |
+
--border: #30363d;
|
| 14 |
+
--border-focus: #40c9a2;
|
| 15 |
+
|
| 16 |
+
--accent: #40c9a2;
|
| 17 |
+
--accent-hover: #36b393;
|
| 18 |
+
--accent-subtle: rgba(64, 201, 162, 0.1);
|
| 19 |
+
|
| 20 |
+
--text-primary: #f0f0f0;
|
| 21 |
+
--text-secondary: #8b949e;
|
| 22 |
+
--text-muted: #6e7681;
|
| 23 |
+
|
| 24 |
+
--error: #f85149;
|
| 25 |
+
--error-bg: rgba(248, 81, 73, 0.1);
|
| 26 |
+
--success: #3fb950;
|
| 27 |
+
--success-bg: rgba(63, 185, 80, 0.1);
|
| 28 |
+
--warning: #d29922;
|
| 29 |
+
--warning-bg: rgba(210, 153, 34, 0.1);
|
| 30 |
+
|
| 31 |
+
--radius: 8px;
|
| 32 |
+
--radius-sm: 4px;
|
| 33 |
+
--radius-lg: 12px;
|
| 34 |
+
|
| 35 |
+
--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
|
| 36 |
+
--font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
|
| 37 |
+
|
| 38 |
+
--shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.4);
|
| 39 |
+
--shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/* ---- Reset & Base ---- */
|
| 43 |
+
|
| 44 |
+
*, *::before, *::after {
|
| 45 |
+
box-sizing: border-box;
|
| 46 |
+
margin: 0;
|
| 47 |
+
padding: 0;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
html {
|
| 51 |
+
font-size: 16px;
|
| 52 |
+
-webkit-font-smoothing: antialiased;
|
| 53 |
+
-moz-osx-font-smoothing: grayscale;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
body {
|
| 57 |
+
font-family: var(--font-sans);
|
| 58 |
+
background: var(--bg-primary);
|
| 59 |
+
color: var(--text-primary);
|
| 60 |
+
line-height: 1.6;
|
| 61 |
+
min-height: 100vh;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/* ---- Layout ---- */
|
| 65 |
+
|
| 66 |
+
.app-container {
|
| 67 |
+
max-width: 860px;
|
| 68 |
+
margin: 0 auto;
|
| 69 |
+
padding: 24px 20px 80px;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
/* ---- Header ---- */
|
| 73 |
+
|
| 74 |
+
.app-header {
|
| 75 |
+
display: flex;
|
| 76 |
+
align-items: center;
|
| 77 |
+
justify-content: space-between;
|
| 78 |
+
padding: 16px 0;
|
| 79 |
+
margin-bottom: 32px;
|
| 80 |
+
border-bottom: 1px solid var(--border);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
.app-header .logo {
|
| 84 |
+
display: flex;
|
| 85 |
+
align-items: center;
|
| 86 |
+
gap: 12px;
|
| 87 |
+
text-decoration: none;
|
| 88 |
+
color: var(--text-primary);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
.app-header .logo-icon {
|
| 92 |
+
font-size: 24px;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.app-header .logo-text {
|
| 96 |
+
font-size: 18px;
|
| 97 |
+
font-weight: 600;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
.app-header .logo-text span {
|
| 101 |
+
color: var(--accent);
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
.user-info {
|
| 105 |
+
display: flex;
|
| 106 |
+
align-items: center;
|
| 107 |
+
gap: 10px;
|
| 108 |
+
font-size: 14px;
|
| 109 |
+
color: var(--text-secondary);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.user-info img {
|
| 113 |
+
width: 32px;
|
| 114 |
+
height: 32px;
|
| 115 |
+
border-radius: 50%;
|
| 116 |
+
border: 2px solid var(--border);
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
.user-info .username {
|
| 120 |
+
font-weight: 500;
|
| 121 |
+
color: var(--text-primary);
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.btn-sign-out {
|
| 125 |
+
background: none;
|
| 126 |
+
border: 1px solid var(--border);
|
| 127 |
+
color: var(--text-secondary);
|
| 128 |
+
padding: 4px 12px;
|
| 129 |
+
border-radius: var(--radius-sm);
|
| 130 |
+
cursor: pointer;
|
| 131 |
+
font-size: 13px;
|
| 132 |
+
transition: all 0.15s;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
.btn-sign-out:hover {
|
| 136 |
+
border-color: var(--text-secondary);
|
| 137 |
+
color: var(--text-primary);
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
/* ---- Sign-in Screen ---- */
|
| 141 |
+
|
| 142 |
+
.sign-in-screen {
|
| 143 |
+
display: flex;
|
| 144 |
+
flex-direction: column;
|
| 145 |
+
align-items: center;
|
| 146 |
+
justify-content: center;
|
| 147 |
+
min-height: 60vh;
|
| 148 |
+
text-align: center;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
.sign-in-screen .hero-icon {
|
| 152 |
+
font-size: 64px;
|
| 153 |
+
margin-bottom: 24px;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
.sign-in-screen h1 {
|
| 157 |
+
font-size: 32px;
|
| 158 |
+
font-weight: 700;
|
| 159 |
+
margin-bottom: 8px;
|
| 160 |
+
letter-spacing: -0.5px;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
.sign-in-screen h1 span {
|
| 164 |
+
color: var(--accent);
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
.sign-in-screen .subtitle {
|
| 168 |
+
font-size: 16px;
|
| 169 |
+
color: var(--text-secondary);
|
| 170 |
+
margin-bottom: 40px;
|
| 171 |
+
max-width: 460px;
|
| 172 |
+
line-height: 1.7;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
.btn-sign-in {
|
| 176 |
+
display: inline-flex;
|
| 177 |
+
align-items: center;
|
| 178 |
+
gap: 10px;
|
| 179 |
+
background: var(--accent);
|
| 180 |
+
color: #000;
|
| 181 |
+
font-size: 16px;
|
| 182 |
+
font-weight: 600;
|
| 183 |
+
padding: 14px 32px;
|
| 184 |
+
border: none;
|
| 185 |
+
border-radius: var(--radius);
|
| 186 |
+
cursor: pointer;
|
| 187 |
+
transition: all 0.15s;
|
| 188 |
+
box-shadow: var(--shadow);
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
.btn-sign-in:hover {
|
| 192 |
+
background: var(--accent-hover);
|
| 193 |
+
transform: translateY(-1px);
|
| 194 |
+
box-shadow: var(--shadow-lg);
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
.btn-sign-in:active {
|
| 198 |
+
transform: translateY(0);
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
.btn-sign-in svg {
|
| 202 |
+
width: 22px;
|
| 203 |
+
height: 22px;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
.sign-in-screen .features {
|
| 207 |
+
margin-top: 48px;
|
| 208 |
+
display: flex;
|
| 209 |
+
gap: 32px;
|
| 210 |
+
flex-wrap: wrap;
|
| 211 |
+
justify-content: center;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
.sign-in-screen .feature {
|
| 215 |
+
text-align: center;
|
| 216 |
+
max-width: 180px;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
.sign-in-screen .feature-icon {
|
| 220 |
+
font-size: 28px;
|
| 221 |
+
margin-bottom: 8px;
|
| 222 |
}
|
| 223 |
|
| 224 |
+
.sign-in-screen .feature h3 {
|
| 225 |
+
font-size: 14px;
|
| 226 |
+
font-weight: 600;
|
| 227 |
+
margin-bottom: 4px;
|
| 228 |
}
|
| 229 |
|
| 230 |
+
.sign-in-screen .feature p {
|
| 231 |
+
font-size: 13px;
|
| 232 |
+
color: var(--text-secondary);
|
| 233 |
+
line-height: 1.5;
|
|
|
|
| 234 |
}
|
| 235 |
|
| 236 |
+
/* ---- Card / Section ---- */
|
| 237 |
+
|
| 238 |
.card {
|
| 239 |
+
background: var(--bg-card);
|
| 240 |
+
border: 1px solid var(--border);
|
| 241 |
+
border-radius: var(--radius-lg);
|
| 242 |
+
padding: 24px;
|
| 243 |
+
margin-bottom: 24px;
|
| 244 |
+
box-shadow: var(--shadow);
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
.card-header {
|
| 248 |
+
display: flex;
|
| 249 |
+
align-items: center;
|
| 250 |
+
gap: 10px;
|
| 251 |
+
margin-bottom: 20px;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
.card-header .step-badge {
|
| 255 |
+
display: inline-flex;
|
| 256 |
+
align-items: center;
|
| 257 |
+
justify-content: center;
|
| 258 |
+
width: 28px;
|
| 259 |
+
height: 28px;
|
| 260 |
+
border-radius: 50%;
|
| 261 |
+
background: var(--accent);
|
| 262 |
+
color: #000;
|
| 263 |
+
font-size: 14px;
|
| 264 |
+
font-weight: 700;
|
| 265 |
+
flex-shrink: 0;
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
.card-header h2 {
|
| 269 |
+
font-size: 18px;
|
| 270 |
+
font-weight: 600;
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
.card-header .card-status {
|
| 274 |
+
margin-left: auto;
|
| 275 |
+
font-size: 13px;
|
| 276 |
+
padding: 2px 10px;
|
| 277 |
+
border-radius: 12px;
|
| 278 |
+
font-weight: 500;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
.card-header .card-status.connected {
|
| 282 |
+
background: var(--success-bg);
|
| 283 |
+
color: var(--success);
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
/* ---- Forms ---- */
|
| 287 |
+
|
| 288 |
+
.form-grid {
|
| 289 |
+
display: grid;
|
| 290 |
+
grid-template-columns: 1fr 1fr;
|
| 291 |
+
gap: 16px;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
.form-group {
|
| 295 |
+
display: flex;
|
| 296 |
+
flex-direction: column;
|
| 297 |
+
gap: 6px;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
.form-group.full-width {
|
| 301 |
+
grid-column: 1 / -1;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
.form-group label {
|
| 305 |
+
font-size: 13px;
|
| 306 |
+
font-weight: 500;
|
| 307 |
+
color: var(--text-secondary);
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
.form-group label .required {
|
| 311 |
+
color: var(--error);
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
.form-group input,
|
| 315 |
+
.form-group select {
|
| 316 |
+
background: var(--bg-input);
|
| 317 |
+
border: 1px solid var(--border);
|
| 318 |
+
border-radius: var(--radius);
|
| 319 |
+
padding: 10px 12px;
|
| 320 |
+
font-size: 14px;
|
| 321 |
+
color: var(--text-primary);
|
| 322 |
+
font-family: var(--font-sans);
|
| 323 |
+
transition: border-color 0.15s;
|
| 324 |
+
width: 100%;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
.form-group input:focus,
|
| 328 |
+
.form-group select:focus {
|
| 329 |
+
outline: none;
|
| 330 |
+
border-color: var(--border-focus);
|
| 331 |
+
box-shadow: 0 0 0 2px var(--accent-subtle);
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
.form-group input::placeholder {
|
| 335 |
+
color: var(--text-muted);
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
.form-group .hint {
|
| 339 |
+
font-size: 12px;
|
| 340 |
+
color: var(--text-muted);
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
.form-row {
|
| 344 |
+
display: flex;
|
| 345 |
+
gap: 16px;
|
| 346 |
+
align-items: flex-end;
|
| 347 |
}
|
| 348 |
|
| 349 |
+
.form-row .form-group {
|
| 350 |
+
flex: 1;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
/* ---- Buttons ---- */
|
| 354 |
+
|
| 355 |
+
.btn {
|
| 356 |
+
display: inline-flex;
|
| 357 |
+
align-items: center;
|
| 358 |
+
justify-content: center;
|
| 359 |
+
gap: 8px;
|
| 360 |
+
font-family: var(--font-sans);
|
| 361 |
+
font-size: 14px;
|
| 362 |
+
font-weight: 600;
|
| 363 |
+
padding: 10px 20px;
|
| 364 |
+
border-radius: var(--radius);
|
| 365 |
+
border: none;
|
| 366 |
+
cursor: pointer;
|
| 367 |
+
transition: all 0.15s;
|
| 368 |
+
white-space: nowrap;
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
.btn:disabled {
|
| 372 |
+
opacity: 0.5;
|
| 373 |
+
cursor: not-allowed;
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
.btn-primary {
|
| 377 |
+
background: var(--accent);
|
| 378 |
+
color: #000;
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
.btn-primary:hover:not(:disabled) {
|
| 382 |
+
background: var(--accent-hover);
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
.btn-secondary {
|
| 386 |
+
background: transparent;
|
| 387 |
+
color: var(--text-primary);
|
| 388 |
+
border: 1px solid var(--border);
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
.btn-secondary:hover:not(:disabled) {
|
| 392 |
+
background: var(--bg-hover);
|
| 393 |
+
border-color: var(--text-secondary);
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
.btn-sm {
|
| 397 |
+
font-size: 13px;
|
| 398 |
+
padding: 6px 14px;
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
.btn-full {
|
| 402 |
+
width: 100%;
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
.form-actions {
|
| 406 |
+
margin-top: 20px;
|
| 407 |
+
display: flex;
|
| 408 |
+
gap: 12px;
|
| 409 |
+
align-items: center;
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
/* ---- Loading spinner ---- */
|
| 413 |
+
|
| 414 |
+
.spinner {
|
| 415 |
+
display: inline-block;
|
| 416 |
+
width: 16px;
|
| 417 |
+
height: 16px;
|
| 418 |
+
border: 2px solid transparent;
|
| 419 |
+
border-top-color: currentColor;
|
| 420 |
+
border-radius: 50%;
|
| 421 |
+
animation: spin 0.6s linear infinite;
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
@keyframes spin {
|
| 425 |
+
to { transform: rotate(360deg); }
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
/* ---- Alert / Messages ---- */
|
| 429 |
+
|
| 430 |
+
.alert {
|
| 431 |
+
padding: 12px 16px;
|
| 432 |
+
border-radius: var(--radius);
|
| 433 |
+
font-size: 14px;
|
| 434 |
+
line-height: 1.5;
|
| 435 |
+
display: flex;
|
| 436 |
+
align-items: flex-start;
|
| 437 |
+
gap: 10px;
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
.alert-error {
|
| 441 |
+
background: var(--error-bg);
|
| 442 |
+
border: 1px solid rgba(248, 81, 73, 0.3);
|
| 443 |
+
color: var(--error);
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
.alert-success {
|
| 447 |
+
background: var(--success-bg);
|
| 448 |
+
border: 1px solid rgba(63, 185, 80, 0.3);
|
| 449 |
+
color: var(--success);
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
.alert-warning {
|
| 453 |
+
background: var(--warning-bg);
|
| 454 |
+
border: 1px solid rgba(210, 153, 34, 0.3);
|
| 455 |
+
color: var(--warning);
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
.alert-info {
|
| 459 |
+
background: var(--accent-subtle);
|
| 460 |
+
border: 1px solid rgba(64, 201, 162, 0.3);
|
| 461 |
+
color: var(--accent);
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
.alert .alert-icon {
|
| 465 |
+
flex-shrink: 0;
|
| 466 |
+
font-size: 16px;
|
| 467 |
+
}
|
| 468 |
+
|
| 469 |
+
/* ---- File Browser / Tree View ---- */
|
| 470 |
+
|
| 471 |
+
.file-browser-header {
|
| 472 |
+
display: flex;
|
| 473 |
+
align-items: center;
|
| 474 |
+
justify-content: space-between;
|
| 475 |
+
margin-bottom: 16px;
|
| 476 |
+
flex-wrap: wrap;
|
| 477 |
+
gap: 12px;
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
.file-browser-stats {
|
| 481 |
+
font-size: 13px;
|
| 482 |
+
color: var(--text-secondary);
|
| 483 |
+
display: flex;
|
| 484 |
+
gap: 16px;
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
.file-browser-stats .stat-value {
|
| 488 |
+
color: var(--text-primary);
|
| 489 |
+
font-weight: 600;
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
.file-browser-actions {
|
| 493 |
+
display: flex;
|
| 494 |
+
gap: 8px;
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
.tree-container {
|
| 498 |
+
border: 1px solid var(--border);
|
| 499 |
+
border-radius: var(--radius);
|
| 500 |
+
background: var(--bg-input);
|
| 501 |
+
max-height: 450px;
|
| 502 |
+
overflow-y: auto;
|
| 503 |
+
overflow-x: auto;
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
.tree-container::-webkit-scrollbar {
|
| 507 |
+
width: 8px;
|
| 508 |
+
height: 8px;
|
| 509 |
+
}
|
| 510 |
+
|
| 511 |
+
.tree-container::-webkit-scrollbar-track {
|
| 512 |
+
background: transparent;
|
| 513 |
+
}
|
| 514 |
+
|
| 515 |
+
.tree-container::-webkit-scrollbar-thumb {
|
| 516 |
+
background: var(--border);
|
| 517 |
+
border-radius: 4px;
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
.tree-container::-webkit-scrollbar-thumb:hover {
|
| 521 |
+
background: var(--text-muted);
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
.tree-node {
|
| 525 |
+
display: flex;
|
| 526 |
+
align-items: center;
|
| 527 |
+
padding: 6px 12px;
|
| 528 |
+
gap: 8px;
|
| 529 |
+
cursor: pointer;
|
| 530 |
+
font-size: 14px;
|
| 531 |
+
border-bottom: 1px solid rgba(48, 54, 61, 0.4);
|
| 532 |
+
transition: background 0.1s;
|
| 533 |
+
white-space: nowrap;
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
.tree-node:hover {
|
| 537 |
+
background: var(--bg-hover);
|
| 538 |
+
}
|
| 539 |
+
|
| 540 |
+
.tree-node:last-child {
|
| 541 |
+
border-bottom: none;
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
.tree-node .indent {
|
| 545 |
+
flex-shrink: 0;
|
| 546 |
+
}
|
| 547 |
+
|
| 548 |
+
.tree-node .expand-icon {
|
| 549 |
+
width: 16px;
|
| 550 |
+
height: 16px;
|
| 551 |
+
flex-shrink: 0;
|
| 552 |
+
display: flex;
|
| 553 |
+
align-items: center;
|
| 554 |
+
justify-content: center;
|
| 555 |
+
color: var(--text-muted);
|
| 556 |
+
font-size: 12px;
|
| 557 |
+
transition: transform 0.15s;
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
.tree-node .expand-icon.expanded {
|
| 561 |
+
transform: rotate(90deg);
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
.tree-node .expand-icon.hidden {
|
| 565 |
+
visibility: hidden;
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
.tree-node .node-checkbox {
|
| 569 |
+
width: 16px;
|
| 570 |
+
height: 16px;
|
| 571 |
+
flex-shrink: 0;
|
| 572 |
+
accent-color: var(--accent);
|
| 573 |
+
cursor: pointer;
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
.tree-node .node-icon {
|
| 577 |
+
flex-shrink: 0;
|
| 578 |
+
font-size: 14px;
|
| 579 |
+
width: 18px;
|
| 580 |
+
text-align: center;
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
.tree-node .node-name {
|
| 584 |
+
font-family: var(--font-mono);
|
| 585 |
+
font-size: 13px;
|
| 586 |
+
flex: 1;
|
| 587 |
+
min-width: 0;
|
| 588 |
+
overflow: hidden;
|
| 589 |
+
text-overflow: ellipsis;
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
.tree-node .node-meta {
|
| 593 |
+
font-size: 12px;
|
| 594 |
+
color: var(--text-muted);
|
| 595 |
+
flex-shrink: 0;
|
| 596 |
+
margin-left: auto;
|
| 597 |
+
padding-left: 16px;
|
| 598 |
+
font-family: var(--font-mono);
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
.tree-node.loading .node-name {
|
| 602 |
+
color: var(--text-muted);
|
| 603 |
+
font-style: italic;
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
+
.tree-load-more {
|
| 607 |
+
padding: 8px 12px;
|
| 608 |
+
font-size: 13px;
|
| 609 |
+
color: var(--accent);
|
| 610 |
+
cursor: pointer;
|
| 611 |
+
text-align: center;
|
| 612 |
+
border-bottom: 1px solid rgba(48, 54, 61, 0.4);
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
.tree-load-more:hover {
|
| 616 |
+
background: var(--bg-hover);
|
| 617 |
+
}
|
| 618 |
+
|
| 619 |
+
/* ---- CORS Fallback ---- */
|
| 620 |
+
|
| 621 |
+
.cors-fallback {
|
| 622 |
+
margin-top: 16px;
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
.cors-fallback .cors-help {
|
| 626 |
+
margin-top: 12px;
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
.cors-fallback details {
|
| 630 |
+
border: 1px solid var(--border);
|
| 631 |
+
border-radius: var(--radius);
|
| 632 |
+
padding: 12px 16px;
|
| 633 |
+
background: var(--bg-secondary);
|
| 634 |
+
}
|
| 635 |
+
|
| 636 |
+
.cors-fallback details summary {
|
| 637 |
+
cursor: pointer;
|
| 638 |
+
font-size: 14px;
|
| 639 |
+
font-weight: 500;
|
| 640 |
+
color: var(--accent);
|
| 641 |
+
}
|
| 642 |
+
|
| 643 |
+
.cors-fallback details pre {
|
| 644 |
+
margin-top: 12px;
|
| 645 |
+
padding: 12px;
|
| 646 |
+
background: var(--bg-input);
|
| 647 |
+
border-radius: var(--radius-sm);
|
| 648 |
+
overflow-x: auto;
|
| 649 |
+
font-size: 13px;
|
| 650 |
+
font-family: var(--font-mono);
|
| 651 |
+
color: var(--text-secondary);
|
| 652 |
+
line-height: 1.5;
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
.manual-patterns {
|
| 656 |
+
margin-top: 16px;
|
| 657 |
+
}
|
| 658 |
+
|
| 659 |
+
.manual-patterns textarea {
|
| 660 |
+
width: 100%;
|
| 661 |
+
background: var(--bg-input);
|
| 662 |
+
border: 1px solid var(--border);
|
| 663 |
+
border-radius: var(--radius);
|
| 664 |
+
padding: 10px 12px;
|
| 665 |
+
font-size: 13px;
|
| 666 |
+
font-family: var(--font-mono);
|
| 667 |
+
color: var(--text-primary);
|
| 668 |
+
resize: vertical;
|
| 669 |
+
min-height: 60px;
|
| 670 |
+
line-height: 1.5;
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
.manual-patterns textarea:focus {
|
| 674 |
+
outline: none;
|
| 675 |
+
border-color: var(--border-focus);
|
| 676 |
+
box-shadow: 0 0 0 2px var(--accent-subtle);
|
| 677 |
+
}
|
| 678 |
+
|
| 679 |
+
/* ---- Destination Config ---- */
|
| 680 |
+
|
| 681 |
+
.dest-preview {
|
| 682 |
+
margin-top: 12px;
|
| 683 |
+
padding: 10px 14px;
|
| 684 |
+
background: var(--bg-input);
|
| 685 |
+
border: 1px solid var(--border);
|
| 686 |
+
border-radius: var(--radius);
|
| 687 |
+
font-family: var(--font-mono);
|
| 688 |
+
font-size: 13px;
|
| 689 |
+
color: var(--accent);
|
| 690 |
+
word-break: break-all;
|
| 691 |
+
}
|
| 692 |
+
|
| 693 |
+
/* ---- Import Config ---- */
|
| 694 |
+
|
| 695 |
+
.config-row {
|
| 696 |
+
display: flex;
|
| 697 |
+
gap: 16px;
|
| 698 |
+
margin-bottom: 16px;
|
| 699 |
+
}
|
| 700 |
+
|
| 701 |
+
.config-row .form-group {
|
| 702 |
+
flex: 1;
|
| 703 |
+
}
|
| 704 |
+
|
| 705 |
+
.patterns-preview {
|
| 706 |
+
margin-top: 12px;
|
| 707 |
+
padding: 12px;
|
| 708 |
+
background: var(--bg-input);
|
| 709 |
+
border: 1px solid var(--border);
|
| 710 |
+
border-radius: var(--radius);
|
| 711 |
+
font-family: var(--font-mono);
|
| 712 |
+
font-size: 12px;
|
| 713 |
+
color: var(--text-secondary);
|
| 714 |
+
max-height: 120px;
|
| 715 |
+
overflow-y: auto;
|
| 716 |
+
line-height: 1.6;
|
| 717 |
+
white-space: pre-wrap;
|
| 718 |
+
}
|
| 719 |
+
|
| 720 |
+
/* ---- Job Status ---- */
|
| 721 |
+
|
| 722 |
+
.job-status-card {
|
| 723 |
+
text-align: center;
|
| 724 |
+
padding: 32px 24px;
|
| 725 |
+
}
|
| 726 |
+
|
| 727 |
+
.job-status-card .status-icon {
|
| 728 |
+
font-size: 48px;
|
| 729 |
+
margin-bottom: 16px;
|
| 730 |
+
}
|
| 731 |
+
|
| 732 |
+
.job-status-card h3 {
|
| 733 |
+
font-size: 20px;
|
| 734 |
+
margin-bottom: 8px;
|
| 735 |
+
}
|
| 736 |
+
|
| 737 |
+
.job-status-card .job-id {
|
| 738 |
+
font-family: var(--font-mono);
|
| 739 |
+
font-size: 13px;
|
| 740 |
+
color: var(--text-muted);
|
| 741 |
+
margin-bottom: 20px;
|
| 742 |
+
}
|
| 743 |
+
|
| 744 |
+
.job-status-card .job-link {
|
| 745 |
+
display: inline-flex;
|
| 746 |
+
align-items: center;
|
| 747 |
+
gap: 6px;
|
| 748 |
+
color: var(--accent);
|
| 749 |
+
text-decoration: none;
|
| 750 |
+
font-size: 14px;
|
| 751 |
+
font-weight: 500;
|
| 752 |
+
}
|
| 753 |
+
|
| 754 |
+
.job-status-card .job-link:hover {
|
| 755 |
+
text-decoration: underline;
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
+
.job-status-badge {
|
| 759 |
+
display: inline-block;
|
| 760 |
+
padding: 4px 12px;
|
| 761 |
+
border-radius: 12px;
|
| 762 |
+
font-size: 13px;
|
| 763 |
+
font-weight: 600;
|
| 764 |
+
margin-bottom: 16px;
|
| 765 |
+
}
|
| 766 |
+
|
| 767 |
+
.job-status-badge.scheduling {
|
| 768 |
+
background: var(--warning-bg);
|
| 769 |
+
color: var(--warning);
|
| 770 |
+
}
|
| 771 |
+
|
| 772 |
+
.job-status-badge.running {
|
| 773 |
+
background: var(--accent-subtle);
|
| 774 |
+
color: var(--accent);
|
| 775 |
+
}
|
| 776 |
+
|
| 777 |
+
.job-status-badge.completed {
|
| 778 |
+
background: var(--success-bg);
|
| 779 |
+
color: var(--success);
|
| 780 |
+
}
|
| 781 |
+
|
| 782 |
+
.job-status-badge.error {
|
| 783 |
+
background: var(--error-bg);
|
| 784 |
+
color: var(--error);
|
| 785 |
+
}
|
| 786 |
+
|
| 787 |
+
/* ---- Utility ---- */
|
| 788 |
+
|
| 789 |
+
.hidden {
|
| 790 |
+
display: none !important;
|
| 791 |
+
}
|
| 792 |
+
|
| 793 |
+
.text-muted {
|
| 794 |
+
color: var(--text-secondary);
|
| 795 |
+
}
|
| 796 |
+
|
| 797 |
+
.text-accent {
|
| 798 |
+
color: var(--accent);
|
| 799 |
+
}
|
| 800 |
+
|
| 801 |
+
.text-mono {
|
| 802 |
+
font-family: var(--font-mono);
|
| 803 |
+
}
|
| 804 |
+
|
| 805 |
+
.mt-4 { margin-top: 16px; }
|
| 806 |
+
.mb-4 { margin-bottom: 16px; }
|
| 807 |
+
.mt-6 { margin-top: 24px; }
|
| 808 |
+
|
| 809 |
+
hr {
|
| 810 |
+
border: none;
|
| 811 |
+
border-top: 1px solid var(--border);
|
| 812 |
+
margin: 20px 0;
|
| 813 |
+
}
|
| 814 |
+
|
| 815 |
+
a {
|
| 816 |
+
color: var(--accent);
|
| 817 |
+
text-decoration: none;
|
| 818 |
+
}
|
| 819 |
+
|
| 820 |
+
a:hover {
|
| 821 |
+
text-decoration: underline;
|
| 822 |
+
}
|
| 823 |
+
|
| 824 |
+
/* ---- Responsive ---- */
|
| 825 |
+
|
| 826 |
+
@media (max-width: 640px) {
|
| 827 |
+
.app-container {
|
| 828 |
+
padding: 16px 12px 60px;
|
| 829 |
+
}
|
| 830 |
+
|
| 831 |
+
.form-grid {
|
| 832 |
+
grid-template-columns: 1fr;
|
| 833 |
+
}
|
| 834 |
+
|
| 835 |
+
.config-row {
|
| 836 |
+
flex-direction: column;
|
| 837 |
+
}
|
| 838 |
+
|
| 839 |
+
.sign-in-screen h1 {
|
| 840 |
+
font-size: 24px;
|
| 841 |
+
}
|
| 842 |
+
|
| 843 |
+
.sign-in-screen .features {
|
| 844 |
+
flex-direction: column;
|
| 845 |
+
align-items: center;
|
| 846 |
+
}
|
| 847 |
+
|
| 848 |
+
.file-browser-header {
|
| 849 |
+
flex-direction: column;
|
| 850 |
+
align-items: stretch;
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
.app-header {
|
| 854 |
+
flex-wrap: wrap;
|
| 855 |
+
gap: 8px;
|
| 856 |
+
}
|
| 857 |
}
|