Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blank map window after login/logout #519

Closed
rsrg-zwiama opened this issue Jan 12, 2024 · 4 comments
Closed

blank map window after login/logout #519

rsrg-zwiama opened this issue Jan 12, 2024 · 4 comments

Comments

@rsrg-zwiama
Copy link

With the latest version of qwc2, the map window shows blank page after login and log out and the background switcher button disappears. I can reproduce this with the qwc demo app (docker) and the latest image for the demo app. With login and logout the theme parameter disappears from the url.
login call:
http://127.0.0.1:8088/auth/login?url=http%3A%2F%2F127.0.0.1%3A8088%2F%3Ft%3Dqwc_demo%26l%3Dedit_points%252Cedit_lines%252Cedit_polygons%252Cgeographic_lines%252Ccountry_names%252Cstates_provinces%252Ccountries%26bl%3Dmapnik%26c%3D1000000%252C6000000%26s%3D25000000
url after login:
http://127.0.0.1:8088/?c=1000000%2C6000000&s=25000000
I get following error in the browser:

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at l (LayerUtils.js:64:31)
    at Object.restoreOrderedLayerParams (LayerUtils.js:55:9)
    at To (ServiceLayerUtils.js:328:97)
    at ThemeUtils.js:39:36
    at redux-thunk.mjs:3:25
    at n.<computed> [as setCurrentTheme] (XMLText.js:61:51)
    at ThemeUtils.js:225:1
    at b (PermaLinkUtils.js:106:10)
    at ThemeUtils.js:200:46

I have tracked the problem to this commit: qgis/qwc2@9faa1bf

The map loads as expected, when I disable the if statement:

                    if (!entry.sublayer.style) {
                        entry.sublayer.style = Object.keys(entry.sublayer.styles)[0];
                    }

In restoreOrderedLayerParams https://github.com/qgis/qwc2/blob/3244e1ae20500517d98f9310830fabea2028f393/utils/LayerUtils.js#L51

    restoreOrderedLayerParams(themeLayer, layerConfigs, permalinkLayers, externalLayers) {
        const exploded = LayerUtils.explodeLayers([themeLayer]);
        let reordered = [];
        // Iterate over layer configs and reorder items accordingly, create external layer placeholders as neccessary
        for (const layerConfig of layerConfigs) {
            if (layerConfig.type === 'theme') {
                const entry = exploded.find(e => e.sublayer.name === layerConfig.name);
                if (entry) {
                    entry.sublayer.opacity = layerConfig.opacity;
                    entry.sublayer.visibility = layerConfig.visibility || layerConfig.tristate;
                    entry.sublayer.tristate = layerConfig.tristate;
                    entry.sublayer.style = layerConfig.style;
                    if (!entry.sublayer.style) {
                        entry.sublayer.style = Object.keys(entry.sublayer.styles)[0];
                    }
                    reordered.push(entry);
                }
            } else if (layerConfig.type === 'separator') {
                reordered = reordered.concat(LayerUtils.createSeparatorLayer(layerConfig.name));
            } else {
                reordered = reordered.concat(LayerUtils.createExternalLayerPlaceholder(layerConfig, externalLayers, layerConfig.id));
            }

Same code is also used in restoreLayerParams https://github.com/qgis/qwc2/blob/3244e1ae20500517d98f9310830fabea2028f393/utils/LayerUtils.js#L29

@manisandro
Copy link
Member

Thanks, fixed in [1]

[1] qgis/qwc2@d01f505

@rsrg-zwiama
Copy link
Author

rsrg-zwiama commented Jan 18, 2024

Thanks @manisandro
But I think my problem is in restoreOrderedLayerParams Line 64 https://github.com/qgis/qwc2/blob/3244e1ae20500517d98f9310830fabea2028f393/utils/LayerUtils.js#L64 where the same code is used

@manisandro
Copy link
Member

Right, fixed as well. Thanks

@rsrg-zwiama
Copy link
Author

Great thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants