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

Review operations configurations #1890

Merged
merged 1 commit into from
Oct 25, 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import FaIcon from '@js/components/FaIcon';
import Message from '@mapstore/framework/components/I18N/Message';
import ViewerLayout from '@js/components/ViewerLayout';
import uuidv1 from 'uuid/v1';
import uniq from 'lodash/uniq';
import { getFileNameParts } from '@js/utils/FileUtils';
import tooltip from '@mapstore/framework/components/misc/enhancers/tooltip';
import PendingUploadCard from './PendingUploadCard';
Expand Down Expand Up @@ -109,7 +110,7 @@ function UploadPanel({
return handleAdd([getDefaultRemoteResource({ id: uuidv1(), type: 'remote', url: '' })]);
};

const supportedLabels = supportedFiles.map(supportedFile => supportedFile.label).join(', ');
const supportedLabels = uniq(supportedFiles.map(supportedFile => supportedFile.label)).join(', ');
const uploadsList = uploads.filter(upload => upload.type === 'file' ? upload.supported : true);
const supportedUploads = uploads.filter(upload => upload.supported);
const readyUploads = uploads.filter(upload => upload.ready);
Expand Down
20 changes: 10 additions & 10 deletions geonode_mapstore_client/client/js/plugins/Operation/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Message from '@mapstore/framework/components/I18N/Message';
* @prop {string} iconName a font awesome icon name for the central section
* @prop {string} titleMsgId title for the central section
* @prop {string} descriptionMsgId description for the central section
* @prop {string} source the operation source used in the upload process
* @prop {string} action the operation action used in the upload process
* @prop {boolean} pageReload if true the page is reloaded after clicking on reload
* @prop {object} api an object with the api configuration for upload and execution request
* @prop {object} api.upload configuration for the upload process
Expand All @@ -57,25 +57,25 @@ import Message from '@mapstore/framework/components/I18N/Message';
* "iconName": "file",
* "titleMsgId": "gnviewer.operationTitle",
* "descriptionMsgId": "gnviewer.operationDescription",
* "source": "upload",
* "action": "upload",
* "api": {
* "upload": {
* "url": "{context.getEndpointUrl('uploads', '/upload')}",
* "maxParallelUploads": 1,
* "enableRemoteUploads": false,
* "supportedFiles": "{context.getSupportedFilesByResourceType('dataset', { source: ['upload'] })}",
* "supportedFiles": "{context.getSupportedFilesByResourceType('dataset', { actions: ['upload'] })}",
* "body": {
* "file": {
* "base_file": "{context.getUploadMainFile}",
* "resource_pk": "{context.get(state('gnResourceData'), 'pk')}"
* "resource_pk": "{context.get(state('gnResourceData'), 'pk')}",
* "action": "upload"
* }
* }
* },
* "executionRequest": {
* "url": "{context.getEndpointUrl('executionrequest')}",
* "params": {
* "filter{source}": "resource_file_upload",
* "filter{name.endswith}": ".xml",
* "filter{action}": "upload",
* "sort[]": "-created",
* "filter{geonode_resource}": "{context.get(state('gnResourceData'), 'pk')}"
* }
Expand All @@ -100,22 +100,22 @@ function Operation({
iconName,
titleMsgId,
descriptionMsgId,
source,
action,
pageReload
}) {

// open the import ui if a blocking execution is still running
const executions = resource?.executions;
useEffect(() => {
if (executions && source && blocking) {
if (executions && action && blocking) {
const runningExecution = executions
.find((execution) => execution.status === 'running'
&& execution?.input_params?.source === source);
&& execution?.input_params?.action === action);
if (runningExecution) {
onSelect(id);
}
}
}, [id, blocking, source, executions]);
}, [id, blocking, action, executions]);

if (selected !== id) {
return null;
Expand Down
12 changes: 6 additions & 6 deletions geonode_mapstore_client/client/js/routes/UploadDataset.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,21 @@ function UploadDataset({
body: {
file: {
'base_file': getUploadMainFile,
'store_spatial_files': true
'store_spatial_files': true,
'action': 'upload'
},
remote: {
'url': getUploadProperty('url'),
'title': getUploadProperty('url'),
'type': getUploadProperty('remoteType')
'type': getUploadProperty('remoteType'),
'action': 'upload'
}
}
},
executionRequest: {
url: getEndpointUrl(EXECUTION_REQUEST),
params: {
'filter{action}': 'import',
'filter{source}': 'upload',
'filter{action}': 'upload',
'sort[]': '-created'
}
}
Expand Down Expand Up @@ -83,11 +84,10 @@ function UploadDataset({
setForceRequests(prevForceRequests => prevForceRequests + 1);
}
});

return (
<UploadPanel
enableRemoteUploads
supportedFiles={getSupportedFilesByResourceType('dataset', { source: ['upload'] })}
supportedFiles={getSupportedFilesByResourceType('dataset', { actions: ['upload'] })}
maxParallelUploads={getMaxParallelUploads()}
maxAllowedSize={getMaxAllowedSizeByResourceType('dataset')}
progress={progress}
Expand Down
126 changes: 7 additions & 119 deletions geonode_mapstore_client/client/js/utils/UploadUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const getMaxAllowedSizeByResourceType = (resourceType) => {
return maxAllowedSize;
};

export const getSupportedFilesByResourceType = (resourceType, { source } = {}) => {
export const getSupportedFilesByResourceType = (resourceType, { actions } = {}) => {
if (resourceType === 'document') {
const { allowedDocumentTypes } = getConfigProp('geoNodeSettings') || [];
return allowedDocumentTypes.map((ext) => {
Expand All @@ -205,122 +205,10 @@ export const getSupportedFilesByResourceType = (resourceType, { source } = {}) =
};
});
}
// const { upload: uploadSettings = {} } = getConfigProp('geoNodeSettings') || {};
// const { supportedDatasetFileTypes: supportedDatasetTypes } = uploadSettings;
return [
{
"id": "shp",
"label": "ESRI Shapefile",
"required_ext": ["shp", "prj", "dbf", "shx"],
"optional_ext": ["xml", "sld", "cpg", "cst"],
"source": ["upload"],
"format": "vector"
},
{
"id": "csv",
"label": "CSV",
"required_ext": ["csv"],
"optional_ext": ["sld", "xml"],
"source": ["upload"],
"format": "vector"
},
{
"id": "gpkg",
"label": "GeoPackage",
"required_ext": ["gpkg"],
"source": ["upload"],
"format": "vector"
},
{
"id": "json",
"label": "GeoJSON",
"required_ext": ["json"],
"optional_ext": ["sld", "xml"],
"source": ["upload"],
"format": "vector"
},
{
"id": "geojson",
"label": "GeoJSON",
"required_ext": ["geojson"],
"optional_ext": ["sld", "xml"],
"source": ["upload"],
"format": "vector"
},
{
"id": "kml",
"label": "KML",
"required_ext": ["kml"],
"source": ["upload"],
"format": "vector"
},
{
"id": "kmz",
"label": "KMZ",
"required_ext": ["kmz"],
"source": ["upload"],
"format": "vector"
},
{
"id": "3dtiles",
"label": "3D Tiles",
"required_ext": ["zip"],
"source": ["upload"],
"format": "vector"
},
{
"id": "tiff",
"label": "TIFF",
"required_ext": ["tiff"],
"optional_ext": ["xml", "sld"],
"source": ["upload"],
"format": "raster"
},
{
"id": "tif",
"label": "TIF",
"required_ext": ["tif"],
"optional_ext": ["xml", "sld"],
"source": ["upload"],
"format": "raster"
},
{
"id": "geotiff",
"label": "GeoTIFF",
"required_ext": ["geotiff"],
"optional_ext": ["xml", "sld"],
"source": ["upload"],
"format": "raster"
},
{
"id": "geotif",
"label": "GeoTIF",
"required_ext": ["geotif"],
"optional_ext": ["xml", "sld"],
"source": ["upload"],
"format": "raster"
},
{
"id": "zip",
"label": "Zip Archive",
"required_ext": ["zip"],
"optional_ext": ["xml", "sld"],
"source": ["upload"],
"format": "archive"
},
{
"id": "sld",
"label": "Styled Layer Descriptor 1.0, 1.1 (SLD)",
"required_ext": ["sld"],
"source": ["resource_style_upload"],
"format": "metadata"
},
{
"id": "xml",
"label": "XML Metadata File (XML - ISO, FGDC, ebRIM, Dublin Core)",
"required_ext": ["xml"],
"source": ["resource_metadata_upload"],
"format": "metadata"
}
].filter(supportedType => source ? supportedType.source.some(value => source.includes(value)) : true);
const { upload: uploadSettings = {} } = getConfigProp('geoNodeSettings') || {};
const { supportedDatasetFileTypes: supportedDatasetTypes } = uploadSettings;
return (supportedDatasetTypes || [])
.map((supportedType) => supportedType.formats.map(format => ({ ...supportedType, ...format })))
.flat()
.filter(supportedType => actions ? supportedType.actions.some(value => actions.includes(value)) : true);
};
33 changes: 16 additions & 17 deletions geonode_mapstore_client/static/mapstore/configs/localConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -1227,25 +1227,24 @@
"blocking": true,
"iconName": "paint-brush",
"titleMsgId": "gnviewer.uploadDatasetStyle",
"source": "resource_file_upload",
"action": "resource_style_upload",
"api": {
"upload": {
"url": "{context.getEndpointUrl('uploads', '/upload')}",
"maxParallelUploads": 1,
"body": {
"file": {
"resource_pk": "{context.get(state('gnResourceData'), 'pk')}",
"base_file": "{context.getUploadMainFile}"
"base_file": "{context.getUploadMainFile}",
"action": "resource_style_upload"
}
},
"supportedFiles": "{context.getSupportedFilesByResourceType('dataset', { source: ['resource_style_upload'] })}"
"supportedFiles": "{context.getSupportedFilesByResourceType('dataset', { actions: ['resource_style_upload'] })}"
},
"executionRequest": {
"url": "{context.getEndpointUrl('executionrequest')}",
"params": {
"filter{source}": "resource_file_upload",
"filter{name.endswith}": ".sld",
"filter{action}": "import",
"filter{action}": "resource_style_upload",
"sort[]": "-created",
"filter{geonode_resource}": "{context.get(state('gnResourceData'), 'pk')}"
}
Expand All @@ -1267,25 +1266,25 @@
"iconName": "file-code-o",
"titleMsgId": "gnviewer.uploadDatasetMetadata",
"blocking": true,
"source": "resource_file_upload",
"action": "resource_metadata_upload",
"pageReload": true,
"api": {
"upload": {
"url": "{context.getEndpointUrl('uploads', '/upload')}",
"maxParallelUploads": 1,
"body": {
"file": {
"resource_pk": "{context.get(state('gnResourceData'), 'pk')}",
"base_file": "{context.getUploadMainFile}"
"base_file": "{context.getUploadMainFile}",
"action": "resource_metadata_upload"
}
},
"supportedFiles": "{context.getSupportedFilesByResourceType('dataset', { source: ['resource_metadata_upload'] })}"
"supportedFiles": "{context.getSupportedFilesByResourceType('dataset', { actions: ['resource_metadata_upload'] })}"
},
"executionRequest": {
"url": "{context.getEndpointUrl('executionrequest')}",
"params": {
"filter{source}": "resource_file_upload",
"filter{name.endswith}": ".xml",
"filter{action}": "import",
"filter{action}": "resource_metadata_upload",
"sort[]": "-created",
"filter{geonode_resource}": "{context.get(state('gnResourceData'), 'pk')}"
}
Expand All @@ -1307,7 +1306,7 @@
"iconName": "refresh",
"titleMsgId": "gnviewer.replaceDatasetTitle",
"blocking": true,
"source": "upload",
"action": "replace",
"pageReload": true,
"api": {
"upload": {
Expand All @@ -1318,16 +1317,16 @@
"resource_pk": "{context.get(state('gnResourceData'), 'pk')}",
"base_file": "{context.getUploadMainFile}",
"store_spatial_files": true,
"overwrite_existing_layer": true
"overwrite_existing_layer": true,
"action": "replace"
}
},
"supportedFiles": "{context.getSupportedFilesByResourceType('dataset', { source: ['upload'] })}"
"supportedFiles": "{context.getSupportedFilesByResourceType('dataset', { actions: ['replace'] })}"
},
"executionRequest": {
"url": "{context.getEndpointUrl('executionrequest')}",
"params": {
"filter{source}": "upload",
"filter{action}": "import",
"filter{action}": "replace",
"sort[]": "-created",
"filter{geonode_resource}": "{context.get(state('gnResourceData'), 'pk')}"
}
Expand Down
Loading