georchestra / mapstore2-georchestra

geOrchestra newest viewer
Other
6 stars 23 forks source link

saving permalink from default map fails #642

Closed landryb closed 8 months ago

landryb commented 1 year ago

Describe the bug the share plugin is enabled by default in localConfig.json - that includes the new permalink feature.

as stated in https://github.com/georchestra/mapstore2-georchestra/issues/640#issuecomment-1669475414 saving a permalink from a context works. what doesnt work here is saving a permalink from the default map (eg being on /mapstore/)

To Reproduce Steps to reproduce the behavior:

  1. Go to mapstore default map
  2. Click on share plugin
  3. Go to permalink tab
  4. Enter details
  5. Hit generate permalink
  6. Nothing happens

Expected behavior Permalink should be saved

instead, there's a JS traceback in the error console pointing at the array access in https://github.com/geosolutions-it/MapStore2/blob/3e1d020e5799de91d61a141e2bae6835456ac13b/web/client/epics/permalink.js#L128

Error in epic "savePermalinkEpic". Original error: TypeError: G[l] is not a function
    savePermalinkEpic https://georchestra.dev.craig.fr/mapstore/dist/plugins/permalink.d158d48d3bd1ebf992cd.chunk.js:1
    _next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2
    next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2
    _next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2
    next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2
    _next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2
    next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2
    _next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2
[mapstore:2367:25](https://georchestra.dev.craig.fr/mapstore/#/)
Uncaught TypeError: G[l] is not a function
    savePermalinkEpic https://georchestra.dev.craig.fr/mapstore/dist/plugins/permalink.d158d48d3bd1ebf992cd.chunk.js:1
    _next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2
    next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2
    _next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2
    next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2
    _next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2
    next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2
    _next https://georchestra.dev.craig.fr/mapstore/dist/geOrchestra.js?d158d48d3bd1ebf992cd:2

will try to reproduce with plain mapstore to have a better traceback

landryb commented 1 year ago

cant reproduce with plain mapstore, but ofc this doesnt have the same plugin list.. now checking if this can be a conflict with another plugin (maybe usersession ?)

landryb commented 1 year ago

it works fine on a random map (eg on /mapstore/#/viewer/66) so it seems to blow only on the 'default map' (eg /mapstore/#) where we don't know yet the resource type/it doesnt have a sane default ? @dsuren1 @tdipisa

landryb commented 1 year ago

the code in savePermalinkEpic doesnt check for permalinkType being empty/undefined, and it doesnt have a default value.

landryb commented 1 year ago

maybe there should be type = 'map' as the default value returned by getPathInfo in https://github.com/geosolutions-it/MapStore2/blob/master/web/client/components/permalink/Permalink.jsx#L51 ?

tdipisa commented 1 year ago

@landryb I will check this use case with the team to get back to you as soon as possible.

dsuren1 commented 1 year ago

MS ref issue: https://github.com/geosolutions-it/MapStore2/issues/9335

catmorales commented 10 months ago

Thank you to update the docker image 2023.02.00-RC2-geOrchestra We have the same problem as decribed above, thank you to backport this fix in the docker image .

landryb commented 10 months ago

can confirm it's working with a war built from 76035d4, i can create permalinks as a logged in user on the default map.

catmorales commented 10 months ago

I have tested it now and it don't work for me .

The test: https://portail-test.sig.rennesmetropole.fr Release : 2023.02.00-RC3-geOrchestra - Image docker

1- On Chrome I have created a permalink in the default map of georchestra with my account , the permalink is public. In our default map user session is active. Permalink is : https://portail-test.sig.rennesmetropole.fr/mapstore/#/permalink/2b0c869a-6d84-420f-bd4d-acc92b162853 Map is: permalien

2- On Firefox Open the permalink in other browser with other account Link is redirected to https://portail-test.sig.rennesmetropole.fr/mapstore/#/viewer/8496 , Layers are OK but Backgrouds layers and bounding box are not those expected in the permalink.

image

Permalink in the default map not store all active user session !

dsuren1 commented 10 months ago

@catmorales I tried loading the permalink and the map link directly and it loads up fine as you can see from screen capture attached

https://github.com/georchestra/mapstore2-georchestra/assets/26929983/80d24a2d-f773-4937-b850-d4e69bdb0d12

landryb commented 10 months ago

@catmorales' permalink redirects to cas here, is it expected ? also can it be a conflict with usersession taking precedence over the map, which would be unexpected ?

catmorales commented 10 months ago

Thank you for testing. Issue seems linked to Firefox because @MaelREBOUX tested with both (as me) and there is just an issue with firefox.

catmorales commented 10 months ago

permalink redirects to cas here, is it expected ?

@landryb yes it is expected in our professional geOrchestra platform : everybody must be connected to use geOrchestra's functionnality.

dsuren1 commented 9 months ago

Thank you for testing. Issue seems linked to Firefox because @MaelREBOUX tested with both (as me) and there is just an issue with firefox.

@catmorales I tested the same in firefox too and was able to load the permalink fine. (Firebox v119.0)

https://github.com/georchestra/mapstore2-georchestra/assets/26929983/ce97fbeb-9725-4500-8a2c-a52223a227a9

tdipisa commented 9 months ago

@catmorales do you have some more feedback? It seems we are not able to reproduce the issue. All seems working as expected for us. We have followed steps above and we have also checked we a new default empty map but the result is always consistent. Could it be perhaps due to a spurious user session on your side?

catmorales commented 9 months ago

@tdipisa I've tested it newly now and I suspect that the problem occurs when there is and old user session in the browser, so when I load the permalink in the same windows , I have to delete the current user session to see the complete map of the permalink It seems like a conflict between user sessions.

1- my current map in the default context: image 2- loading the permalink https://portail-test.sig.rennesmetropole.fr/mapstore/#/permalink/2b0c869a-6d84-420f-bd4d-acc92b162853 image 3- after deleting the current session image

tdipisa commented 9 months ago

@catmorales as I wrote above, that's was my suspect too but it is how user session works. It takes the priority by design and the problem involving this issue has been resolved, I think. Isn't it?

dsuren1 commented 9 months ago

@catmorales It's not user session conflict (Loading a new permalink will obtain details from config saved and copied over to current session). The permalink creation is similar to application's save and works by obtaining the current state of the map/context and related configurations. Hence opening the permalink created will open to the exact state when it was created

Ex: Map has 2 layers and layer-1 is hidden from TOC -> Save the map -> Open the saved map will show layer-1 hidden and layer-2 visible. The same is applicable for permalink creation and loading it

Could you please confirm, the following

Tested

I created a permalink with these layer

image

Permalink created https://portail-test.sig.rennesmetropole.fr/mapstore/#/permalink/74b7681d-b72c-4730-9e2c-c7b8a9670894

Kindly try this permalink and let me know how it looks at your end

catmorales commented 8 months ago

@dsuren1 We have just tested your permalink and the result is in the video bellow: permalink_user_session

It seems difficult to explain this behaviour to our users ...

dsuren1 commented 8 months ago

Hi @catmorales I think I know why this behavior is specific to georchestra and was not able reproducible in MS.

The georchestra's configuration enables contextOnly: true of UserSession plugin. This configuration allows the context to share only one session and if set to false each context sub-map will have its own session. I tried this locally and I was able to reproduce the issue you mentioned above. When setting this configuration contextOnly: false, the default context has it own session while the permalink created from this has it's own session and when loading them simulataneously it loaded up fine since each has it own session to refer to

Could you please try the same, by updating localConfig.json as shown below and let me know how it goes. If you are happy with the outcome, we can update the same in the repo's config

   "userSessions": {
      "enabled": true,
      "contextOnly": false
    }

Note: localConfig -> userSessions and not on the plugin cfg

I'm not sure why this configuration was set to true as there was no specific ticket requesting this change. Looks like it was setup this way from the time session plugins was added to georchestra.

tdipisa commented 8 months ago

Thank you @dsuren1. We are looking forward to hearing from you soon for the above.

catmorales commented 8 months ago

@dsuren1 I've changed it in the first part of the localconfig.json :

"useAuthenticationRules": true,
    "loadAfterTheme": true,
    "userSessions": {
        "enabled": true,
        "contextOnly": false
    },
    "header": {
        "height": 90,
        "url": "/header/"

and the results is OK Thank you very much.