Skip to content

Commit 42fc178

Browse files
authored
Support for import / export map (branch c125_annotation) (#3004)
* Work in progress for c125-1 * Implemented map loading * Fix #1 add import export functionalities * renamed also epic to mapexport * fixed translations
1 parent a0b07f7 commit 42fc178

44 files changed

Lines changed: 1727 additions & 21 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2018, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
const expect = require('expect');
10+
const { exportMap, EXPORT_MAP} = require('../mapexport');
11+
12+
describe('mapExport actions', () => {
13+
14+
it('exportMap', () => {
15+
const action = exportMap();
16+
expect(action).toExist();
17+
expect(action.type).toBe(EXPORT_MAP);
18+
expect(action.format).toBe("mapstore2");
19+
});
20+
});

web/client/actions/mapexport.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright 2018, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
const EXPORT_MAP = "EXPORT::EXPORT_MAP";
9+
10+
module.exports = {
11+
EXPORT_MAP,
12+
exportMap: (format = "mapstore2") => ({ type: EXPORT_MAP, format})
13+
};

web/client/actions/mapimport.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* Copyright 2016, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
const SET_LAYERS = 'IMPORT::SET_LAYERS';
9+
const ON_ERROR = 'IMPORT::ON_ERROR';
10+
const ON_SELECT_LAYER = 'IMPORT::ON_SELECT_LAYER';
11+
const LOADING = 'IMPORT::LOADING';
12+
const ON_LAYER_ADDED = 'IMPORT::ON_LAYER_ADDED';
13+
const UPDATE_BBOX = 'IMPORT::UPDATE_BBOX';
14+
const ON_SUCCESS = 'IMPORT::ON_SUCCESS';
15+
16+
function setLayers(layers, errors) {
17+
return {
18+
type: SET_LAYERS,
19+
layers,
20+
errors
21+
};
22+
}
23+
function onSelectLayer(layer) {
24+
return {
25+
type: ON_SELECT_LAYER,
26+
layer
27+
};
28+
}
29+
function onError(error) {
30+
return {
31+
type: ON_ERROR,
32+
error
33+
};
34+
}
35+
function setLoading(status) {
36+
return {
37+
type: LOADING,
38+
status
39+
};
40+
}
41+
function onLayerAdded(layer) {
42+
return {
43+
type: ON_LAYER_ADDED,
44+
layer
45+
};
46+
}
47+
function updateBBox(bbox) {
48+
return {
49+
type: UPDATE_BBOX,
50+
bbox
51+
};
52+
}
53+
function onSuccess(message) {
54+
return {
55+
type: ON_SUCCESS,
56+
message
57+
};
58+
}
59+
60+
module.exports = {
61+
SET_LAYERS,
62+
ON_ERROR,
63+
LOADING,
64+
ON_SELECT_LAYER,
65+
ON_LAYER_ADDED,
66+
UPDATE_BBOX,
67+
ON_SUCCESS,
68+
setLayers,
69+
onError,
70+
setLoading,
71+
onSelectLayer,
72+
onLayerAdded,
73+
updateBBox,
74+
onSuccess
75+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2018, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
const React = require('react');
9+
const DragZone = require('./dragZone/DragZone.jsx');
10+
const Content = require('./dragZone/Content');
11+
const processFiles = require('./dragZone/enhancers/processFiles');
12+
const useFiles = require('./dragZone/enhancers/useFiles');
13+
const dropZoneHandlers = require('./dragZone/enhancers/dropZoneHandlers');
14+
15+
const { compose } = require('recompose');
16+
module.exports = compose(
17+
processFiles,
18+
useFiles,
19+
dropZoneHandlers
20+
)(
21+
({
22+
onClose = () => {},
23+
onDrop = () => {},
24+
onRef = () => {},
25+
...props
26+
}) => <DragZone
27+
onClose={onClose}
28+
onDrop={onDrop}
29+
onRef={onRef}
30+
>
31+
<Content {...props} />
32+
</DragZone>);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2018, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
const {compose, branch, renderComponent} = require('recompose');
9+
const LoadingContent = require('./LoadingContent');
10+
const ErrorContent = require('./ErrorContent');
11+
const NormalContent = require('./NormalContent');
12+
13+
module.exports = compose(
14+
branch(
15+
({loading}) => loading,
16+
renderComponent(LoadingContent),
17+
),
18+
branch(
19+
({error}) => error,
20+
renderComponent(ErrorContent)
21+
)
22+
)(NormalContent);
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2018, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
const React = require('react');
9+
const Dropzone = require('react-dropzone');
10+
const { Button: RButton, Glyphicon } = require('react-bootstrap');
11+
12+
const tooltip = require('../../misc/enhancers/tooltip');
13+
const Button = tooltip(RButton);
14+
module.exports = ({
15+
accept,
16+
children,
17+
onRef = () => {},
18+
onClose = () => {},
19+
onDrop = () => {},
20+
onDragEnter = () => {},
21+
onDragLeave = () => {}
22+
}) => (<Dropzone
23+
disableClick
24+
ref={onRef}
25+
id="DRAGDROP_IMPORT_ZONE"
26+
style={{ position: "relative", height: '100%' }}
27+
accept={accept}
28+
onDrop={onDrop}
29+
onDragEnter={onDragEnter}
30+
onDragLeave={onDragLeave}>
31+
<div
32+
style={{
33+
position: 'fixed',
34+
top: 0,
35+
right: 0,
36+
bottom: 0,
37+
left: 0,
38+
background: 'rgba(0,0,0,0.5)',
39+
color: '#fff',
40+
zIndex: 2000,
41+
display: 'flex',
42+
textAlign: 'center'
43+
}}>
44+
<Button
45+
style={{
46+
border: "none",
47+
background: "transparent",
48+
color: "white",
49+
fontSize: 35,
50+
top: 0,
51+
right: 0,
52+
position: 'absolute'
53+
}}
54+
onClick={()=> onClose()}
55+
><Glyphicon glyph="1-close" />
56+
</Button>
57+
<div style={{
58+
margin: 'auto',
59+
maxWidth: 550
60+
}}>
61+
{children}
62+
</div>
63+
</div>
64+
</Dropzone>);
65+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2018, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
const React = require('react');
9+
const {Button} = require('react-bootstrap');
10+
const Message = require('../../I18N/Message');
11+
const HTML = require('../../I18N/HTML');
12+
13+
module.exports = ({
14+
openFileDialog
15+
}) => (<div>
16+
<HTML msgId="mapImport.dropZone.heading" />
17+
{openFileDialog
18+
? <Button bsStyle="primary" onClick={openFileDialog}><Message msgId="mapImport.dropZone.selectFiles" /></Button>
19+
: null
20+
}
21+
<br />
22+
<br />
23+
<HTML msgId="mapImport.dropZone.infoSupported" />
24+
<hr />
25+
<HTML msgId="mapImport.dropZone.note" />
26+
</div>);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2018, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
const React = require('react');
10+
const { Glyphicon, Alert } = require('react-bootstrap');
11+
const DropText = require('./DropText');
12+
const Message = require('../../I18N/Message');
13+
const errorMessages = {
14+
"FILE_NOT_SUPPORTED": <Message msgId="mapImport.errors.fileNotSupported" />
15+
};
16+
const toErrorMessage = error =>
17+
error
18+
? errorMessages[error.message]
19+
|| errorMessages[error]
20+
|| <span><Message msgId="mapImport.errors.unknownError" />:<Alert bsStyle="warning">{error.message}</Alert></span>
21+
: <Message msgId="mapImport.errors.unknownError" />;
22+
23+
module.exports = ({ error, ...props }) => (<div style={{
24+
margin: 'auto',
25+
maxWidth: 550
26+
}}>
27+
<div>
28+
<Glyphicon
29+
glyph="exclamation-mark"
30+
style={{
31+
fontSize: 80
32+
}}/>
33+
</div>
34+
<h5>
35+
{toErrorMessage(error)}
36+
</h5>
37+
{/*<h4 className="text-danger" style={{backgroundColor: 'rgba(255, 255, 255, 0.7)', padding: 12}}>
38+
!!Mockup Message -
39+
Here additional message eg. error on shapefile parsing
40+
- Mockup Message!!
41+
</h4>*/}
42+
<DropText {...props}/>
43+
</div>);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2018, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
const React = require('react');
10+
11+
const Loader = require('../../misc/Loader');
12+
const Message = require('../../I18N/Message');
13+
14+
module.exports = () => (<div style={{
15+
margin: 'auto',
16+
maxWidth: 550
17+
}}>
18+
<Loader
19+
size={80}
20+
color="#ffffff"
21+
style={{
22+
margin: 'auto'
23+
}}/>
24+
<h4>
25+
<Message msgId="loading" />
26+
</h4>
27+
</div>);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2018, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
const React = require('react');
9+
const { Glyphicon } = require('react-bootstrap');
10+
const DropText = require('./DropText');
11+
12+
13+
module.exports = (props) => (<div>
14+
<div>
15+
<Glyphicon
16+
glyph="upload"
17+
style={{
18+
fontSize: 80
19+
}} />
20+
</div>
21+
<DropText {...props} />
22+
</div>);

0 commit comments

Comments
 (0)