g3w-suite / g3w-client-plugin-sidebar

0 stars 1 forks source link

Unable to load the sidebar plugin in production environment #5

Open gisuser0 opened 2 months ago

gisuser0 commented 2 months ago

Checklist

Subject of the issue

I followed these instructions:

https://github.com/g3w-suite/g3w-client?tab=readme-ov-file#project-setup

to develop the client and I followed these instructions:

https://github.com/g3w-suite/g3w-client/tree/dev/src/plugins

to add this plugin (sidebar).

I updated the config.js file accordingly:

const G3W_PLUGINS = [
  'sidebar'
];

I changed base(); with base(this); in the service.js file (to avoid js error) and I run the cmd:

npm run dev

The plugin works and the sidebar item is shown in the client GUI (both in localhost:3000 and localhost:8000).

When I try to deploy the plugin in the production environment (g3w-admin) with the command:

npm run build

the following structure is created:

g3w-admin
└── g3w-admin/
    └── sidebar/
        └── static
            └── sidebar
                └── js
                    ├── plugin.js
                    └── source
                        └── plugins
                            └── sidebar
                                └── plugin.js.map

but when I run the client with the command:

paver start

this error appears: No module named 'sidebar.urls'

If I add the file 'sidebar.url' in the folder g3w-admin/sidebar

content: urlpatterns = []

the error disappears but the plugin is not loaded in the GUI.

I added 'sidebar' also in the local_settings.py:

G3WADMIN_LOCAL_MORE_APPS = [
    'editing',
    'caching',
    'filemanager',
    'qplotly',
    'qtimeseries',
    'sidebar',
]

Do I need to edit any other config files to load the plugin in production?

Thanks in advance for any suggestions.

Steps to reproduce

``

Environment

[g3wsdk.info]

Link to your project

No response

Additional info

No response

Raruto commented 2 months ago

Hi @gisuser0,

paver start

I don't use paver for development, but maybe it's just Python cache, have you already tried restarting the server?

https://github.com/g3w-suite/g3w-admin?tab=readme-ov-file#how-to-develop

NB For the future, if you intend to develop a third-party plugin, I also recommend you think about installable pip plugins (so you don't risk "breaking" core code)

https://github.com/g3w-suite/g3w-suite-docker/blob/dev/README_DEV.md#developing-a-python-plugin-pip-install

Through https://github.com/g3w-suite/g3w-admin/pull/746 you can also get an additional idea of ​​how to develop a custom plugin.js in such way (using much modern code).

Sorry for the inconvenience, but we are in a fairly heavy refactoring process.

👋 Raruto

Raruto commented 1 month ago

@gisuser0 were you able to solve it?

Feel free to send some PRs to improve/fix existing code/docs.

👋 Raruto