Skip to content

Commit

Permalink
Fix #1559 Implement a UI component to trigger asynchronous operations…
Browse files Browse the repository at this point in the history
… on a resource (#1882)
  • Loading branch information
allyoucanmap authored Oct 16, 2024
1 parent c4cf850 commit 6fba83a
Show file tree
Hide file tree
Showing 44 changed files with 2,154 additions and 1,813 deletions.
69 changes: 69 additions & 0 deletions geonode_mapstore_client/client/js/api/geonode/v2/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2024, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
import axios from '@mapstore/framework/libs/ajax';
import {
parseDevHostname,
getApiToken,
getGeoNodeLocalConfig
} from '@js/utils/APIUtils';

let endpoints = {
// default values
'resources': '/api/v2/resources',
'documents': '/api/v2/documents',
'datasets': '/api/v2/datasets',
'maps': '/api/v2/maps',
'geoapps': '/api/v2/geoapps',
'users': '/api/v2/users',
'resource_types': '/api/v2/resources/resource_types',
'categories': '/api/v2/categories',
'owners': '/api/v2/owners',
'keywords': '/api/v2/keywords',
'regions': '/api/v2/regions',
'groups': '/api/v2/groups',
'executionrequest': '/api/v2/executionrequest',
'facets': '/api/v2/facets',
'upload': '/uploads/upload'
};

export const RESOURCES = 'resources';
export const DOCUMENTS = 'documents';
export const DATASETS = 'datasets';
export const MAPS = 'maps';
export const GEOAPPS = 'geoapps';
export const USERS = 'users';
export const RESOURCE_TYPES = 'resource_types';
export const GROUPS = 'groups';
export const EXECUTION_REQUEST = 'executionrequest';
export const FACETS = 'facets';
export const UPLOADS_UPLOAD = 'upload';

export const setEndpoints = (data) => {
endpoints = { ...endpoints, ...data };
};

export const getEndpointUrl = (id, parts) => {
return parseDevHostname(parts ? `${endpoints[id]}${parts}` : endpoints[id]);
};

/**
* get all thw endpoints available from API V2
*/
export const getEndpoints = () => {
const apikey = getApiToken();
const endpointV2 = getGeoNodeLocalConfig('geoNodeApi.endpointV2', '/api/v2/');
return axios.get(parseDevHostname(endpointV2), {
params: {
...(apikey && { apikey })
}
})
.then(({ data }) => {
setEndpoints(data);
return data;
});
};
Loading

0 comments on commit 6fba83a

Please sign in to comment.