GeoNode / geonode-mapstore-client

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

Adopt `catalog_list` REST API preset for querying resources #1710

Closed giohappy closed 5 months ago

giohappy commented 5 months ago

The client will add a new api_preset=catalog_list parameter to the GET requests for listing resources. This will limit the retrieved fields to the ones listed here, reducing the load on the server and the I/O.

Notice that executions are already included in the preset, so no need to include them again as a parameter.

@dsuren1 I suppose the same can be done for the requests performed inside the viewer's GeoNode catalogs (Add Layer inside maps, etc.).

dsuren1 commented 5 months ago

/resources (in catalogue), /maps (in dashboard) - Works fine with catalog_list preset

@giohappy Kindly clarify

etj commented 5 months ago

@dsuren1 presets were added to simplify called URLs. I'd suggest using a preset for the dataset query, since 7 include[] are quite a lot, and then I'd use a preset for documents as well for coherence with the other calls, but in this case it's up to your personal easthetic.

giohappy commented 5 months ago

@dsuren1 I can create the presets in a branch and let you test them before merging.

dsuren1 commented 5 months ago

@giohappy

Presets

settings.REST_API_PRESETS["catalog_list"] = {
        "exclude[]": ["*"],
        "include[]": [
            "advertised",
            "detail_url",
            "is_approved",
            "is_copyable",
            "is_published",
            "owner",
            "perms",
            "pk",
            "raw_abstract",
            "resource_type",
            "subtype",
            "title",
            "data",
            "executions",
            "thumbnail_url"
        ],
    }
    settings.REST_API_PRESETS["datasets"] = {
        "exclude[]": ["*"],
        "include[]": [
            "advertised",
            "detail_url",
            "owner",
            "perms",
            "pk",
            "raw_abstract",
            "resource_type",
            "subtype",
            "title",
            "data",
            "executions",
            "thumbnail_url",
            "alternate",
            "links",
            "featureinfo_custom_template",
            "has_time",
            "default_style",
            "ptype",
            "extent"
        ],
    }
    settings.REST_API_PRESETS["documents"] = {
        "exclude[]": ["*"],
        "include[]": [
            "pk",
            "raw_abstract",
            "resource_type",
            "subtype",
            "title",
            "data",
            "executions",
            "thumbnail_url",
            "alternate",
            "attribution",
            "href"
        ],
    }
giohappy commented 5 months ago

@dsuren1 you can add the presets yourself. Take into account that maps already do a request to datasets when the onload completes. @allyoucanmap says that it's done to retrieve the perms for the maplayers. For this case we can simply use the include if we only need permissions and a few more attributes. Probably something like this could be enough exclude[]=*&include[]=perms&include[]=pk&include[]=alternate

dsuren1 commented 5 months ago

@giohappy Yes, a separate datasets call to get perms by dataset names alone is made for which we can use the param you have suggested :thumbsup: I intend to add preset for datasets catalog which requires the above mentioned props to form a layer.