Skip to main content

A report editor plugin that is powered by an LSP

Project description

inventree-report-lsp-plugin

License: GPL3 CI

A report editor plugin that is powered by django-template-lsp.

Screenshot

⚙️ Installation

  1. Install the inventree-report-lsp-plugin from the Admin Center > Plugins > Install plugin. (Make sure the user interface plugin integration is enabled.)
  2. Now the LSP server needs to be started separately via the inventree-report-lsp cmd and the requests to /plugins/report-lsp/ws need to be proxied to it. If you're using the official docker stack, follow the guide below:

[!IMPORTANT] At least InvenTree v0.18.0 is required to use this plugin.

🐳 Docker

Add this extra container to the docker-compose.yml file:

    inventree-report-lsp:
        image: inventree/inventree:${INVENTREE_TAG:-stable}
        container_name: inventree-report-lsp
        command: /bin/ash -c "invoke plugins && inventree-report-lsp"
        env_file:
            - .env
        volumes:
            - ${INVENTREE_EXT_VOLUME}:/home/inventree/data:z
        restart: unless-stopped

Add this proxy_route to the Caddyfile:

                 forward_auth {$INVENTREE_SERVER:"http://inventree-server:8000"} {
                         uri /auth/
                 }
         }
 
+        reverse_proxy /plugin/report-lsp/ws "http://inventree-report-lsp:8765"
 
         # All other requests are proxied to the InvenTree server
         reverse_proxy {$INVENTREE_SERVER:"http://inventree-server:8000"} {

🏃 Usage

Goto the Admin Center > Label Templates or Report Templates. Click on any in the table and select the "Report Editor". For the first load, this can take some time (up to ~30s) until the data is collected. The status bar at the bottom should show LSP Running (Connected) when its ready.

🧑‍💻 Development

For this plugin to work in development, the inventree source has to be patched temporary:

  1. Add this to the InvenTree vite.config.ts:

           proxy: {
             '/media': {
               target: 'http://localhost:8000',
               changeOrigin: true,
               secure: true
             },
    +        '/static/plugins/report-lsp/dist/': {
    +          target: 'http://localhost:5212',
    +          changeOrigin: true,
    +          secure: true,
    +          ws: true
    +        },
    +        "/plugin/report-lsp/ws": {
    +          target: "http://localhost:8765",
    +          changeOrigin: true,
    +          secure: true,
    +          ws: true,
    +        }
           },
    
  2. Remove Strict Mode temporary from src/frontend/src/main.tsx:

     ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
    -  <React.StrictMode>
           <MainView />
    -  </React.StrictMode>
     );
    
  3. Set the INVENTREE_REPORT_LSP_DEV to True before starting the dev server

  4. Install this package as editable pip package into your venv via

    pip install -e path/to/the/inventree-report-lsp-plugin
    
  5. Install frontend dependencies via cd frontend && npm ci

  6. Run the LSP in the background by invoking the inventree-report-lsp command in a terminal where the venv is activated. (If you want to use a custom djlsp instance because you want to do changes there, you need to specify the INVENTREE_DJANGO_LSP_SERVER_CMD env variable. E.g. /path/to/django-template-lsp/env/bin/djlsp)

  7. Run the Frontend dev server via cd frontend && npm run dev

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inventree_report_lsp_plugin-0.1.1.tar.gz (10.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inventree_report_lsp_plugin-0.1.1-py3-none-any.whl (10.4 MB view details)

Uploaded Python 3

File details

Details for the file inventree_report_lsp_plugin-0.1.1.tar.gz.

File metadata

File hashes

Hashes for inventree_report_lsp_plugin-0.1.1.tar.gz
Algorithm Hash digest
SHA256 53e98f6bf7ad0acec6ce51acf2990c4aac9b6f93468946e7ab64a30d0e9ca7b2
MD5 3ec228402f0fb3ca9969d46538cf40e4
BLAKE2b-256 a9f58bbb0e85fc5dea66dbf611c7d70de01a9d41ab022015dfbee0cfcc9e9576

See more details on using hashes here.

Provenance

The following attestation bundles were made for inventree_report_lsp_plugin-0.1.1.tar.gz:

Publisher: ci.yml on wolflu05/inventree-report-lsp-plugin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file inventree_report_lsp_plugin-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for inventree_report_lsp_plugin-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 596e3e9bcba0465a07b5038ce0e0d94aa68c871e8bab5265e27a9fbb3fe75fab
MD5 cb8eb22ea01f939c3c43f86efa6d4115
BLAKE2b-256 76e993929dc50fb310e0ff119bd0e8747c0b00b732f0d2b2195ae56618ca1cd1

See more details on using hashes here.

Provenance

The following attestation bundles were made for inventree_report_lsp_plugin-0.1.1-py3-none-any.whl:

Publisher: ci.yml on wolflu05/inventree-report-lsp-plugin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page