forked from geosolutions-it/geonode-mapstore-client
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #1559 Implement a UI component to trigger asynchronous operations…
… on a resource (#1882)
- Loading branch information
1 parent
c4cf850
commit 6fba83a
Showing
44 changed files
with
2,154 additions
and
1,813 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
geonode_mapstore_client/client/js/api/geonode/v2/constants.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); | ||
}; |
Oops, something went wrong.