Skip to content

Commit

Permalink
Merge updates (#1717)
Browse files Browse the repository at this point in the history
* Update mapstore submodule to branch 2024.01.xx (#1712)

* update mapstore submodule to branch 2024.01.xx

* fix ifc lib location

* [Backport] #1710 - Update calls with catalog_list preset (#1711) (#1716)

* #1657 - Add unadvertised identifier to the resource (#1658)

* #1657 - Add unadvertised identifier to the resource

* Code refactor

* [create-pull-request] automated change (#1659)

Co-authored-by: giohappy <giohappy@users.noreply.github.com>

* Update VERSION

* Enable group facets (#1662)

* [create-pull-request] automated change (#1663)

Co-authored-by: dsuren1 <dsuren1@users.noreply.github.com>

* [Fixes #1665] Django upgrade to 4.2 LTS (#1664)

* Upgrade Django version

* Upgrade Django version

* Upgrade Django version

* Upgrade to django 4.2

---------

Co-authored-by: mattiagiupponi <mattia.giupponi@gmail.com>

* Bump to 4.4.x dev

* #1678: Enable react-player for audio file resources (#1679)

* [create-pull-request] automated change (#1680)

Co-authored-by: giohappy <giohappy@users.noreply.github.com>

* configure REST API preset for catalog listing (#1709)

* #1710 - Update calls with catalog_list preset (#1711)

* #1710 - Update calls with catalog_list preset

* Update presets and api calls

* Add param serializer

---------

Co-authored-by: geosolutions-pr-generator[bot] <87376048+geosolutions-pr-generator[bot]@users.noreply.github.com>
Co-authored-by: giohappy <giohappy@users.noreply.github.com>
Co-authored-by: Giovanni Allegri <giovanni.allegri@gmail.com>
Co-authored-by: mattiagiupponi <51856725+mattiagiupponi@users.noreply.github.com>
Co-authored-by: dsuren1 <dsuren1@users.noreply.github.com>
Co-authored-by: mattiagiupponi <mattia.giupponi@gmail.com>

---------

Co-authored-by: stefano bovio <stefano.bovio@geosolutionsgroup.com>
Co-authored-by: Suren <dsuren1@gmail.com>
Co-authored-by: geosolutions-pr-generator[bot] <87376048+geosolutions-pr-generator[bot]@users.noreply.github.com>
Co-authored-by: giohappy <giohappy@users.noreply.github.com>
Co-authored-by: mattiagiupponi <51856725+mattiagiupponi@users.noreply.github.com>
Co-authored-by: dsuren1 <dsuren1@users.noreply.github.com>
Co-authored-by: mattiagiupponi <mattia.giupponi@gmail.com>
  • Loading branch information
8 people authored Apr 17, 2024
1 parent 0d45111 commit b9af3d3
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 24 deletions.
147 changes: 147 additions & 0 deletions geonode_mapstore_client/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,153 @@ def run_setup_hooks(*args, **kwargs):
"TIMEOUT": 300,
"OPTIONS": {"MAX_ENTRIES": 10000},
}
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",
"executions",
"thumbnail_url"
],
}
settings.REST_API_PRESETS["dataset_list"] = {
"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",
"is_approved",
"is_published"
],
}
settings.REST_API_PRESETS["map_list"] = {
"exclude[]": ["*"],
"include[]": [
"advertised",
"detail_url",
"data",
"is_approved",
"is_copyable",
"is_published",
"owner",
"perms",
"pk",
"raw_abstract",
"resource_type",
"subtype",
"title",
"executions",
"thumbnail_url"
],
}
settings.REST_API_PRESETS["document_list"] = {
"exclude[]": ["*"],
"include[]": [
"pk",
"raw_abstract",
"resource_type",
"subtype",
"title",
"data",
"executions",
"thumbnail_url",
"alternate",
"attribution",
"href"
],
}
settings.REST_API_PRESETS["viewer_common"] = {
"exclude[]": ["*"],
"include[]": [
"abstract",
"advertised",
"alternate",
"attribution",
"category",
"created",
"date",
"date_type",
"detail_url",
"download_urls",
"embed_url",
"executions",
"extent",
"favorite",
"group",
"is_approved",
"is_copyable",
"is_published",
"keywords",
"language",
"last_updated",
"linked_resources",
"links",
"owner",
"perms",
"pk",
"poc",
"raw_abstract",
"regions",
"resource_type",
"sourcetype",
"subtype",
"supplemental_information",
"temporal_extent_end",
"temporal_extent_start",
"thumbnail_url",
"title",
"uuid"
],
}
settings.REST_API_PRESETS["map_viewer"] = {
"include[]": [
"data",
"maplayers"
]
}
settings.REST_API_PRESETS["document_viewer"] = {
"include[]": [
"href",
"extension"
]
}
settings.REST_API_PRESETS["dataset_viewer"] = {
"include[]": [
"featureinfo_custom_template",
"dataset_ows_url",
"default_style",
"ptype",
"store",
"has_time",
"attribute_set"
]
}


def connect_geoserver_style_visual_mode_signal():
Expand Down
64 changes: 43 additions & 21 deletions geonode_mapstore_client/client/js/api/geonode/v2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
getApiToken,
paramsSerializer,
getGeoNodeConfig,
getGeoNodeLocalConfig
getGeoNodeLocalConfig,
API_PRESET
} from '@js/utils/APIUtils';
import merge from 'lodash/merge';
import mergeWith from 'lodash/mergeWith';
Expand Down Expand Up @@ -141,7 +142,7 @@ export const getResources = ({
page,
page_size: pageSize,
'filter{metadata_only}': false, // exclude resources such as services
include: ['executions']
api_preset: API_PRESET.CATALOGS
};
return axios.get(parseDevHostname(endpoints[RESOURCES]), {
params: _params,
Expand Down Expand Up @@ -178,7 +179,8 @@ export const getMaps = ({
}),
...(sort && { sort: isArray(sort) ? sort : [ sort ]}),
page,
page_size: pageSize
page_size: pageSize,
api_preset: API_PRESET.MAPS
},
paramsSerializer
})
Expand Down Expand Up @@ -213,7 +215,8 @@ export const getDatasets = ({
}),
...(sort && { sort: isArray(sort) ? sort : [ sort ]}),
page,
page_size: pageSize
page_size: pageSize,
api_preset: API_PRESET.DATASETS
},
paramsSerializer
})
Expand Down Expand Up @@ -249,7 +252,8 @@ export const getDocumentsByDocType = (docType = 'image', {
...(sort && { sort: isArray(sort) ? sort : [ sort ]}),
'filter{subtype}': [docType],
page,
page_size: pageSize
page_size: pageSize,
api_preset: API_PRESET.DOCUMENTS
},
paramsSerializer
})
Expand Down Expand Up @@ -284,7 +288,7 @@ export const setFavoriteResource = (pk, favorite) => {
export const getResourceByPk = (pk) => {
return axios.get(parseDevHostname(`${endpoints[RESOURCES]}/${pk}`), {
params: {
include: ['executions']
api_preset: API_PRESET.VIEWER_COMMON
}
})
.then(({ data }) => data.resource);
Expand Down Expand Up @@ -321,22 +325,29 @@ export const removeLinkedResourcesByPk = (sourcePk, targetPks) => {
export const getResourceByUuid = (uuid) => {
return axios.get(parseDevHostname(`${endpoints[RESOURCES]}`), {
params: {
'filter{uuid}': uuid
'filter{uuid}': uuid,
api_preset: API_PRESET.VIEWER_COMMON
}
})
.then(({ data }) => data?.resources?.[0]);
};

export const getDatasetByPk = (pk) => {
return axios.get(parseDevHostname(`${endpoints[DATASETS]}/${pk}`))
return axios.get(parseDevHostname(`${endpoints[DATASETS]}/${pk}`), {
params: {
api_preset: [API_PRESET.VIEWER_COMMON, API_PRESET.DATASET]
},
paramsSerializer
})
.then(({ data }) => data.dataset);
};

export const getDocumentByPk = (pk) => {
return axios.get(parseDevHostname(`${endpoints[DOCUMENTS]}/${pk}`), {
params: {
include: ['executions']
}
api_preset: [API_PRESET.VIEWER_COMMON, API_PRESET.DOCUMENT]
},
paramsSerializer
})
.then(({ data }) => data.document);
};
Expand All @@ -346,7 +357,8 @@ export const getDocumentsByPk = (pk) => {
return axios.get(parseDevHostname(`${endpoints[DOCUMENTS]}/`), {
params: {
'filter{pk.in}': pks,
page_size: pks.length
page_size: pks.length,
api_preset: [API_PRESET.VIEWER_COMMON, API_PRESET.DOCUMENT]
},
paramsSerializer
})
Expand All @@ -362,11 +374,12 @@ export const createGeoApp = (body) => {
.then(({ data }) => data.geoapp);
};

export const getGeoAppByPk = (pk, includes = []) => {
export const getGeoAppByPk = (pk) => {
return axios.get(parseDevHostname(`${endpoints[GEOAPPS]}/${pk}`), {
params: {
full: true,
include: ['data', ...includes]
api_preset: API_PRESET.VIEWER_COMMON,
include: ['data']
}
})
.then(({ data }) => data.geoapp);
Expand Down Expand Up @@ -565,7 +578,12 @@ export const getResourceTypes = () => {

export const getDatasetByName = name => {
const url = parseDevHostname(`${endpoints[DATASETS]}/?filter{alternate}=${name}`);
return axios.get(url)
return axios.get(url, {
params: {
exclude: ['*'],
include: ['pk', 'perms', 'alternate']
}
})
.then(({data}) => data?.datasets[0]);
};

Expand All @@ -574,7 +592,9 @@ export const getDatasetsByName = names => {
return axios.get(url, {
params: {
page_size: names.length,
'filter{alternate.in}': names
'filter{alternate.in}': names,
exclude: ['*'],
include: ['pk', 'perms', 'alternate']
}
})
.then(({data}) => data?.datasets);
Expand Down Expand Up @@ -635,12 +655,13 @@ export const updateMap = (id, body = {}) => {
* @param {string[]} includes property to be included in the response
* @return {promise} it returns an object with the success map object response
*/
export const getMapByPk = (pk, includes = []) => {
export const getMapByPk = (pk) => {
return axios.get(parseDevHostname(`${endpoints[MAPS]}/${pk}/`),
{
params: {
include: ['data', ...includes]
}
api_preset: [API_PRESET.VIEWER_COMMON, API_PRESET.MAP]
},
paramsSerializer
})
.then(({ data }) => data?.map);
};
Expand All @@ -650,9 +671,9 @@ export const getMapsByPk = (pk) => {
return axios.get(parseDevHostname(`${endpoints[MAPS]}/`),
{
params: {
include: ['data'],
'filter{pk.in}': pks,
page_size: pks.length
page_size: pks.length,
api_preset: API_PRESET.MAPS
},
paramsSerializer
})
Expand All @@ -664,7 +685,8 @@ export const getFeaturedResources = (page = 1, page_size = 4) => {
params: {
page_size,
page,
'filter{featured}': true
'filter{featured}': true,
api_preset: API_PRESET.CATALOGS
}
}).then(({data}) => data);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const mediaMap = {
pdf: PdfViewer,
gltf: Scene3DViewer,
ifc: Scene3DViewer,
audio: MediaComponent,
unsupported: UnsupportedViewer
};

Expand Down
4 changes: 2 additions & 2 deletions geonode_mapstore_client/client/js/epics/gnresource.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ const resourceTypes = {
resourceObservable: (pk, options) =>
Observable.defer(() => axios.all([
getNewMapConfiguration(),
getMapByPk(pk, ['linked_resources'])
getMapByPk(pk)
.then((_resource) => {
const resource = getResourceWithLinkedResources(_resource);
const mapViewers = get(resource, 'linkedResources.linkedTo', [])
.find(({ resource_type: type } = {}) => type === ResourceTypes.VIEWER);
return mapViewers?.pk
? axios.all([{...resource}, getGeoAppByPk(mapViewers?.pk, ['linked_resources'])])
? axios.all([{...resource}, getGeoAppByPk(mapViewers?.pk)])
: Promise.resolve([{...resource}]);
})
.catch(() => null)
Expand Down
5 changes: 4 additions & 1 deletion geonode_mapstore_client/client/js/epics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ export const gnSetDatasetsPermissions = (actions$, { getState = () => {}} = {})
actions$.ofType(MAP_CONFIG_LOADED, ADD_LAYER)
.switchMap((action) => {
if (action.type === MAP_CONFIG_LOADED) {
const layerNames = action.config?.map?.layers?.filter((l) => l?.group !== "background").map((l) => l.name);
const layerNames = action.config?.map?.layers?.filter((l) => l?.group !== "background")?.map((l) => l.name) ?? [];
if (layerNames.length === 0) {
return Rx.Observable.empty();
}
return Rx.Observable.defer(() => getDatasetsByName(layerNames))
.switchMap((layers = []) => {
const stateLayers = layers.map((l) => ({
Expand Down
11 changes: 11 additions & 0 deletions geonode_mapstore_client/client/js/utils/APIUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ export const paramsSerializer = (params) => {
return queryParams;
};

export const API_PRESET = {
CATALOGS: 'catalog_list',
DATASETS: 'dataset_list',
DOCUMENTS: 'document_list',
MAPS: 'map_list',
VIEWER_COMMON: 'viewer_common',
DATASET: 'dataset_viewer',
DOCUMENT: 'document_viewer',
MAP: 'map_viewer'
};

export default {
parseDevHostname,
paramsSerializer
Expand Down
Loading

0 comments on commit b9af3d3

Please sign in to comment.