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

#10026: Interactive legend for TOC layers [WMS] #10180

Merged
merged 18 commits into from
Apr 22, 2024

Conversation

mahmoudadel54
Copy link
Collaborator

@mahmoudadel54 mahmoudadel54 commented Apr 9, 2024

Description

In this PR, interactive legend functionality for WMS layers is implemented. User can configure enabling the interactive legend from advanced settings in catalog or from display tab in layer settings.
CQL filter format is used to apply this kind of layer filter. User can click on the interactive legend if the legend contain 'filter' expressions and it will reflect on the map. Any type of filter rather than the legend filter will keep the legend filter beside it.
Legend filter will be reset if user change the style and user can reset it manually by clicking on the selected filter legend again to remove the legend filter.

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

Issue

#10026

What is the current behavior?
#10026

What is the new behavior?
User now can configure and enable interactive legend for WMS and apply filter based on legend filter values from TOC

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

Description:
- Adding interactive legend for wms layers
- Add checkbox for enable the interactive legend for wms into layer settings and for the catalog as well
Description:
- implement reset legend filter in case changing styles for WMS
Description:
- Adding interactive legend for wfs and vector layers
- Add checkbox for enable the interactive legend for wfs and vector into layer settings and for the catalog as well [just for wfs]
- write unit tests based on code changes
- Merge branch 'master' into feature_10026_backup
- edit in some unit tests
- remove implementation of vector layer temp.
- edit loopFilterArrayToFilterObject method in StyleEditorUtils file to handle the subgroups in geostyle filter
- write a unit test for it
@mahmoudadel54 mahmoudadel54 marked this pull request as ready for review April 10, 2024 01:28
@mahmoudadel54 mahmoudadel54 linked an issue Apr 11, 2024 that may be closed by this pull request
6 tasks
@mahmoudadel54 mahmoudadel54 changed the title #10026: Interactive legend for TOC layers Apr 11, 2024
@tdipisa tdipisa modified the milestones: 2024.01.02, 2024.02.00 Apr 11, 2024
- enhance epics related to interactive legend
- remove duplicated file
- isolate WMS interactive legend code and remove WFS part
- edit some unit tests
- clean the code by remove all non related to wms interactive legend part
@mahmoudadel54 mahmoudadel54 changed the title #10026: Interactive legend for TOC layers [WMS/WFS] Apr 15, 2024
Copy link
Contributor

@allyoucanmap allyoucanmap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some other part to review:

  • if the filter is disabled (filter icon black) it should not be possible to interact with the legend, so the cursor should not be pointer and the hover state should not be visible.
    image
  • for some layer the json legend is not available even if the server supports it (eg. Meteorite_Landings_from_NASA_Open_Data_Portal). How should we handle this? (cc @tdipisa ). This happens also with raster layer
<ServiceException>
     java.lang.IllegalArgumentException: Trying to evaluate the function as Object but the method parameter is set as COLOR
Trying to evaluate the function as Object but the method parameter is set as COLOR
</ServiceException>
web/client/actions/layerFilter.js Outdated Show resolved Hide resolved
web/client/components/widgets/builder/wizard/MapWizard.jsx Outdated Show resolved Hide resolved
web/client/components/widgets/builder/wizard/MapWizard.jsx Outdated Show resolved Hide resolved
web/client/utils/LayersUtils.js Outdated Show resolved Hide resolved
web/client/components/data/query/QueryToolbar.jsx Outdated Show resolved Hide resolved
web/client/actions/layerFilter.js Outdated Show resolved Hide resolved
web/client/components/TOC/fragments/settings/Display.jsx Outdated Show resolved Hide resolved
web/client/components/TOC/fragments/settings/Display.jsx Outdated Show resolved Hide resolved
@tdipisa
Copy link
Member

tdipisa commented Apr 17, 2024

@allyoucanmap @mahmoudadel54

for some layer the json legend is not available even if the server supports it (eg. Meteorite_Landings_from_NASA_Open_Data_Portal). How should we handle this? (cc @tdipisa ). This happens also with raster layer

I think something like a kind of generic message in the legend section informing that the legend cannot be visualized with a proper L&F. Then, if the user move the mouse hover it an info popup appears to explain why including some more specific details coming from the service exception the client receives.

…iew comments]

- Refactor the filter legend and reset filter legend and create utils
- Handle multi-select legend filter
- handle adding popover info for failure getting json legend
- adding popover info show how to apply legend filter
- edit toc style
- remove unused epics and actions
- add translations
Copy link
Contributor

@allyoucanmap allyoucanmap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

please merge the two tooltip message in a single one:

If this option is enabled, filter by legend can be applied by clicking on legend items of this layer from the TOC. Note: This parameter requires specific configurations on GeoServer

web/client/actions/layerFilter.js Outdated Show resolved Hide resolved
web/client/actions/layerFilter.js Outdated Show resolved Hide resolved
web/client/components/data/query/QueryToolbar.jsx Outdated Show resolved Hide resolved
web/client/epics/__tests__/layerfilter-test.js Outdated Show resolved Hide resolved
web/client/epics/layerfilter.js Outdated Show resolved Hide resolved
web/client/plugins/TOC/components/VectorLegend.jsx Outdated Show resolved Hide resolved
web/client/selectors/widgets.js Outdated Show resolved Hide resolved
web/client/utils/StyleEditorUtils.js Outdated Show resolved Hide resolved
web/client/reducers/queryform.js Outdated Show resolved Hide resolved
web/client/themes/default/less/toc.less Outdated Show resolved Hide resolved
mahmoudadel54 and others added 4 commits April 19, 2024 11:24
…iew comments]

- remove the code that is  not related to wms
- remove unused unit tests
- edit translations
Copy link
Contributor

@allyoucanmap allyoucanmap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some finel changes:

  • when a item of the legend has no filter it should not show the pointer cursor and the hover highlight
  • please add some unit tests for the new two functions in FIlterUtils
…iew comments]

- remove hover/highlight effect if legend rule doesn't have filter statement in wms json legend
- write unit tests for  'updateLayerLegendFilter' and 'resetLayerLegendFilter' FilterUtils
@allyoucanmap allyoucanmap merged commit b0144c0 into geosolutions-it:master Apr 22, 2024
6 checks passed
@allyoucanmap
Copy link
Contributor

@ElenaGallo please test this new feature on dev, thanks

@ElenaGallo
Copy link
Contributor

ElenaGallo commented Apr 23, 2024

@mahmoudadel54 here what I found after my test:

1_ When the legend filter is set and then the map saved. The interactive legend is no longer enabled in the settings layer. Is this the correct behavior?

11.mp4

2_ When there is an attribute filter for the layer and then interactive legend is enabled, the interactive legend does not work as expected.

2.mp4

3_ On Dashboard the interactive legend is available on settings layer but it does not work on layer legend

3.mp4

4_ On Geostory the interactive legend is available on settings layer but it works only the first time

4.mp4
@tdipisa
Copy link
Member

tdipisa commented Apr 23, 2024

@mahmoudadel54 here what I found after my test:

1_ When the legend filter is set and then the map saved. The interactive legend is no longer enabled in the settings layer. Is this the correct behavior?

@mahmoudadel54 this need to be fixed asap. It should be a quick thing to fix.

2_ When there is an attribute filter for the layer and then interactive legend is enabled, the interactive legend does not work as expected.

We know that @ElenaGallo. This is an expected behavior for the moment. Since it is not possible yet in GS to filter the JSON legend according to the general filter defined in 'Layer filter', if you click on a style class not matching that filter the result if an empty layer in map. I suggest anyway to open a dedicated issue for this right now. @ElenaGallo please create it.

3_ On Dashboard the interactive legend is available on settings layer but it does not work on layer legend

The current implementation is partial and provides support only for the map viewer. We have already an issue defined for this purpose in #10235. That means that until we don't have a working implementation for Dashboards, the Enable interactive legend option should not be available there @mahmoudadel54

4_ On Geostory the interactive legend is available on settings layer but it works only the first time

@mahmoudadel54 is it possible to provide a quick fix for this? Otherwise the same as above for Dashboard is valid and a dedicated issue should be opened similar to #10235

@ElenaGallo
Copy link
Contributor

@tdipisa new issue for point two here: #10241

@mahmoudadel54
Copy link
Collaborator Author

4_ On Geostory the interactive legend is available on settings layer but it works only the first time

For the point 4 of the geostory, I have tried it by adding new map and adding layers on this map and it works well with me.

11111.mp4

After debugging the issue I found you used an existing saved map from mapstore. The existing layer in this map that you tried to apply legend filter on which is 'State' layer in the used map has a disabled flag in its filter object. This flag is set by clicking on this icon
image

I think it needs to be fixed.

There is an issue which make me to skip showing the interactive legend from geostory is there in an issue related to map consistency. If I make changes into filter object of map in mapEditor it will not reflect to the map viewer.
How I produce that:

  • create geostory
  • add new map with layers like 'States of US' the classified one
  • enable from map editor the interactive legend of this layer
  • clicks on legend to apply multi legend filter
  • save it and close
  • open map editor again, disable the interactive legend --> you will notice the map is updated and layer filter is reset
  • save it and close map editor.
  • the map viewer will display layer without reset the layer filter [consistency issue --> map of map viewer should be consistent with the changes in map editor]
22222.mp4

This consistency needs to be checked and fixed as well in the dedicated geostory/dashboard issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment