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

Fix #1559 Implement a UI component to trigger asynchronous operations on a resource #1882

Merged
merged 5 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading