DumbAssets icon indicating copy to clipboard operation
DumbAssets copied to clipboard

Integration manager with Paperless & Papra integrations

Open gitmotion opened this issue 1 year ago • 7 comments

Summary by CodeRabbit

  • New Features

    • Introduced a modular integration system supporting external document management integrations (e.g., Paperless NGX, Papra, Home Assistant).
    • Added settings UI for managing and configuring integrations, including dynamic schema-driven forms and connection testing.
    • Enabled linking, searching, and attaching external documents to assets and sub-assets via a new modal interface.
    • Integration badges now appear on asset file previews and in the UI.
    • Enhanced file duplication logic to support external files.
  • UI/Style

    • Added new stylesheets for integration settings, external document search modal, Home Assistant integration, demo mode, and responsive layouts.
    • Updated file preview and upload UI to support integration badges and improved styling.
  • Documentation

    • Added comprehensive guides and references for implementing and managing integrations, including schema conventions and development checklists.
  • Bug Fixes

    • Improved handling and validation of sensitive integration credentials and external file paths.
  • Chores

    • Refactored codebase to support new integration managers and modular architecture.
    • Updated server endpoints and static asset handling for integration support.

gitmotion avatar Jul 15 '25 23:07 gitmotion

The preview deployment is ready. 🟢

Open Preview | Open Build Logs

Last updated at: 2025-07-25 20:06:20 CET

control-dw[bot] avatar Jul 15 '25 23:07 control-dw[bot]

Bugbot run

abiteman avatar Jul 15 '25 23:07 abiteman

😱 Found 4 issues. Time to roll up your sleeves! 😱

⚠️ Only 5 files were analyzed due to processing limits.

Need help? Join our Discord for support!
https://discord.gg/qEjHQk64Z9

recurseml[bot] avatar Jul 17 '25 03:07 recurseml[bot]

[!IMPORTANT]

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update introduces a comprehensive, schema-driven integration system to the application, affecting both backend and frontend. It adds an Integration Manager for centralized integration handling, new integration modules (Paperless NGX, Papra, Home Assistant), dynamic UI generation for integration settings, external document linking in asset management, and extensive new CSS for responsive and integration-specific styling. Documentation is added to guide integration development.

Changes

File(s) Change Summary
.github/copilot-instructions.md, integrations/INTEGRATION.md Added detailed documentation for the new schema-driven integration framework, including backend and frontend conventions, schema reference, error handling, and development checklist.
integrations/homeassistant.js, integrations/paperless.js, integrations/papra.js Added new integration modules for Home Assistant, Paperless NGX, and Papra, each defining a schema, configuration validation, API interaction methods, and Express route registration for integration-specific endpoints.
integrations/integrationManager.js Introduced an Integration Manager class to register, manage, validate, and expose integrations, handling sensitive data masking, config validation, and route registration.
public/assets/css/styles.css, public/assets/css/demo-styles.css, Added and updated CSS for integration settings UI, file type hints, and removed demo mode styles.
public/assets/css/homeassistant-styles.css, public/assets/css/integration-styles.css, Added new CSS files for Home Assistant and general integration UI, including modal, buttons, filter controls, results, badges, and responsive design.
public/assets/css/responsive-styles.css Added responsive CSS rules for various breakpoints to optimize layout and usability across devices.
public/index.html, public/login.html Updated HTML to use new CSS files, added external document linking buttons, a modal for external doc search, and an integrations section in settings.
public/managers/externalDocManager.js Added a manager for searching and linking external documents from integrations, supporting dynamic integration filters, debounced search, pagination, and UI updates.
public/managers/integrations.js Added a manager for loading, rendering, and managing integration settings in the UI, supporting schema-driven field generation, toggling, and connection testing.
public/managers/modalManager.js Enhanced modal manager to support attaching, previewing, and removing external documents from integrations for assets and sub-assets, including badge rendering.
public/managers/settings.js Updated settings manager to load and save integration settings dynamically, applying them to the form and reloading active integrations after save.
public/script.js Refactored main initialization to instantiate and inject new managers (IntegrationsManager, ExternalDocManager) into relevant modules, enabling integration features throughout the app.
server.js Added integration management to server: new API endpoints for integrations, configuration validation, secure token handling, registration of integration routes, and enhanced file duplication logic for external files.
src/constants.js Introduced a constants file for integration categories, statuses, field types, token masking, and API endpoints.
src/services/render/assetRenderer.js Added support for rendering integration badges on asset file previews by injecting integrationsManager and updating file grid HTML generation.
src/services/render/previewRenderer.js, src/services/render/index.js Enhanced preview rendering to display integration badges, handle integration-specific previews, and inject integrationsManager. Added and exported an initialization function for preview rendering.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend
    participant IntegrationsManager (Frontend)
    participant ExternalDocManager
    participant ModalManager
    participant Backend
    participant IntegrationManager (Backend)
    participant IntegrationModule

    User->>Frontend: Opens Settings or clicks "Link External"
    Frontend->>IntegrationsManager (Frontend): Load integrations (GET /api/integrations)
    IntegrationsManager (Frontend)->>Backend: GET /api/integrations
    Backend->>IntegrationManager (Backend): getIntegrationsForSettings()
    IntegrationManager (Backend)-->>Backend: Return schemas (with sensitive fields masked)
    Backend-->>IntegrationsManager (Frontend): Integration schemas
    IntegrationsManager (Frontend)-->>Frontend: Render dynamic integration UI

    User->>Frontend: Clicks "Test Connection"
    Frontend->>Backend: POST /api/integrations/:id/test (with config)
    Backend->>IntegrationManager (Backend): prepareConfigForTesting()
    IntegrationManager (Backend)->>IntegrationModule: testConnection()
    IntegrationModule-->>IntegrationManager (Backend): Status/result
    IntegrationManager (Backend)-->>Backend: Status/result
    Backend-->>Frontend: Success/error response

    User->>Frontend: Clicks "Link External" for file attachment
    Frontend->>ExternalDocManager: Open modal, load integrations (GET /api/integrations/enabled)
    ExternalDocManager->>Backend: GET /api/integrations/enabled
    Backend->>IntegrationManager (Backend): getEnabledIntegrations()
    IntegrationManager (Backend)-->>Backend: Enabled integrations
    Backend-->>ExternalDocManager: Enabled integrations
    ExternalDocManager-->>Frontend: Render modal with filters

    User->>ExternalDocManager: Search or browse documents
    ExternalDocManager->>Backend: GET /api/{integration}/search
    Backend->>IntegrationModule: searchDocuments()
    IntegrationModule-->>Backend: Search results
    Backend-->>ExternalDocManager: Results
    ExternalDocManager-->>Frontend: Display results

    User->>ExternalDocManager: Clicks "Link" on a document
    ExternalDocManager->>ModalManager: Attach external document
    ModalManager-->>Frontend: Show preview with integration badge

Poem

🐇
A hop, a leap, integrations bloom,
With badges bright, they chase the gloom.
Paperless, Papra, Home Assistant too,
Linking docs and settings—something new!
Modals shimmer, badges gleam,
Schema-driven magic, a rabbit’s dream.
Hooray for code that hops so far—
Now every system’s not so far!

✨ Finishing Touches
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch integration-manager-with-paperless

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Jul 17 '25 03:07 coderabbitai[bot]

@coderabbitai review

abiteman avatar Jul 17 '25 03:07 abiteman

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot] avatar Jul 17 '25 03:07 coderabbitai[bot]

[!NOTE] Generated docstrings for this pull request at https://github.com/DumbWareio/DumbAssets/pull/114

coderabbitai[bot] avatar Jul 17 '25 03:07 coderabbitai[bot]