diff --git a/app/views/integrations.py b/app/views/integrations.py index 3c65daa3..232115ec 100644 --- a/app/views/integrations.py +++ b/app/views/integrations.py @@ -63,18 +63,27 @@ async def integrations_dashboard(request: Request, db: Session = Depends(get_db) tier_id = "free" if owner_id: - integrations = ( - db.query(UserIntegration) - .filter(UserIntegration.owner_id == owner_id) - .order_by(UserIntegration.id) - .all() - ) - dest_count = sum(1 for i in integrations if i.direction == IntegrationDirection.DESTINATION) - src_count = sum( - 1 - for i in integrations - if i.direction == IntegrationDirection.SOURCE and i.integration_type in _MAILBOX_SOURCE_TYPES - ) + from sqlalchemy import func + + dest_count = ( + db.query(func.count()) + .select_from(UserIntegration) + .filter( + UserIntegration.owner_id == owner_id, + UserIntegration.direction == IntegrationDirection.DESTINATION, + ) + .scalar() + ) or 0 + src_count = ( + db.query(func.count()) + .select_from(UserIntegration) + .filter( + UserIntegration.owner_id == owner_id, + UserIntegration.direction == IntegrationDirection.SOURCE, + UserIntegration.integration_type.in_(list(_MAILBOX_SOURCE_TYPES)), + ) + .scalar() + ) or 0 tier_id = get_user_tier_id(db, owner_id) tier = get_tier(tier_id, db) tier_name = tier.get("name", tier_id) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index d06943a4..7cb85543 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -140,6 +140,39 @@ In addition to the system-wide IMAP mailboxes configured by the administrator vi The quota bar on the Email Ingestion page shows your current usage against your plan limit. If you have reached the limit, delete an existing account or upgrade your plan. +#### Integrations Dashboard + +The **Integrations** page (`/integrations`) provides a unified view of all your configured ingestion sources and storage destinations. Instead of managing each integration type separately, you can create, edit, test, and delete any integration from a single dashboard. + +**Opening the dashboard:** Click **Integrations** in the top navigation bar. + +**Quota indicators** at the top of the page show your current usage: +- **Mailbox Sources** — how many IMAP ingestion accounts you have vs. your plan limit +- **Storage Destinations** — how many storage targets you have vs. your plan limit +- An **Upgrade Plan** link appears when you have reached your plan limit + +**Adding a new integration:** + +1. Click **Add Integration**. +2. Choose a **Direction** — Source (ingestion) or Destination (storage). +3. Choose an **Integration Type** (e.g. IMAP, S3, Dropbox, WebDAV). +4. Fill in the type-specific fields — the form adapts dynamically based on your choice: + - **IMAP** — host, port, username, password, SSL toggle + - **S3** — bucket, region, access key, secret key + - **WebDAV / Nextcloud** — URL, folder, username, password + - **FTP / SFTP** — host, port, remote path, username, password + - **Dropbox / Google Drive / OneDrive** — folder path, with a link to the OAuth setup page + - **Email Forward** — recipient email address + - **Watch Folder** — folder path + - **Paperless NGX** — URL and API token +5. Click **Test Connection** to verify the settings before saving. +6. Click **Save** to persist the integration. + +**Managing existing integrations:** +- Click **Test** on any card to re-verify the connection. +- Click **Edit** to update the configuration or credentials. +- Click **Delete** to permanently remove the integration. + ### Watch Folders (Automatic Folder Ingestion) Watch folders allow DocuElevate to automatically monitor directories for new files and ingest them without any manual action. diff --git a/frontend/templates/integrations_dashboard.html b/frontend/templates/integrations_dashboard.html index 5814eb9c..434ba630 100644 --- a/frontend/templates/integrations_dashboard.html +++ b/frontend/templates/integrations_dashboard.html @@ -610,7 +610,7 @@ -