GeoNode / geonode-mapstore-client

MapStore Client for GeoNode
http://geonode.org/geonode-mapstore-client/master
Other
14 stars 107 forks source link

#1710 - Update calls with catalog_list preset #1711

Closed dsuren1 closed 5 months ago

dsuren1 commented 5 months ago

Description

This PR adds catalog_list preset to required service calls. Added new presets (Note: few presets are not integrated yet on the client code. To be tested after this PR is merged)

[!NOTE] Branch is active in development.demo and under testing

Issue

giohappy commented 5 months ago

@dsuren1 branch is deployed and built on dev demo.

I see the preset applied to the catalog list, but I don't see them in the other pages. I'll let you investigate. BTW, also maps could probably benefit from a reduction of requested fields, don't you think?

giohappy commented 5 months ago

@dsuren1 I guess data could be removed from the catalog_list preset, right? If confirmed you can remove it inside this PR

giohappy commented 5 months ago

@etj we're introducing additional presets in this PR. @dsuren1 is asking if the backend could ignore fields requested in a preset which are not supported by the current endpoint. An example is the viewer preset. It could be used for the different types of resources if it would simply ignore fields that are not supported by a specific resource, instead of throwing an error. Otherwise, multiple presets must be defined for the different resource types.

etj commented 5 months ago

@dsuren1 is asking if the backend could ignore fields requested in a preset which are not supported by the current endpoint.

Nope, the preset handler simply replaces the preset query param with the configured params. The issue description clearly states:

The filter will only expand a preset wherever it is declared. It does not know whether the called entrypoint will really deal with the parameters, so it will be up to the client to make sure the preset will really work with the requested operation.

giohappy commented 5 months ago

Nope, the preset handler simply replaces the preset query param with the configured params. The https://github.com/GeoNode/geonode/issues/12104 clearly states:

@dsuren1 in that case we could avoid duplicating the fields inside multiple presets by using a common configuration and then use it for the different presets. Something like this:

viewer_common_fields = ["field_1', 'field_2,' 'fields_3']
settings.REST_API_PRESETS["dataset_viewer"] = {
    "exclude[]": ["*"],
    "include[]": viewer_common_fields + [
        'field_4'
    ]

settings.REST_API_PRESETS["map_viewer"] = {
    "exclude[]": ["*"],
    "include[]": viewer_common_fields + [
        'field_5'
    ]
etj commented 5 months ago

@giohappy Pls note that you can specify multiple presets in the query, so you may have

http://yourserver/yourpath?api_preset=common&api_preset=map_viewer

This can be useful for a couple of presets at maximum, then it would become so complex that having a new preset would be simpler.

So, a sample configuration may be


settings.REST_API_PRESETS["common"] = {
    "exclude[]": ["*"],
    "include[]":  [
        'id', 'title', 
    ]

settings.REST_API_PRESETS["map_viewer"] = {
    "include[]": [
        'field_5'
    ]