Skip to content

Commit 415b07f

Browse files
authored
Merge pull request #2937 from MV88/2922_align_210518
2922 align 210518
2 parents 5a403ea + 0561169 commit 415b07f

72 files changed

Lines changed: 835 additions & 417 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

buildConfig.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,25 @@ module.exports = (bundles, themeEntries, paths, extractThemesPlugin, prod, publi
158158
devServer: {
159159
proxy: {
160160
'/rest/geostore': {
161-
target: "https://dev.mapstore2.geo-solutions.it/mapstore",
162-
secure: false
161+
target: "https://dev.mapstore.geo-solutions.it/mapstore",
162+
secure: false,
163+
headers: {
164+
host: "dev.mapstore.geo-solutions.it"
165+
}
166+
},
167+
'/pdf': {
168+
target: "https://dev.mapstore.geo-solutions.it/mapstore",
169+
secure: false,
170+
headers: {
171+
host: "dev.mapstore.geo-solutions.it"
172+
}
173+
},
174+
'/mapstore/pdf': {
175+
target: "https://dev.mapstore.geo-solutions.it",
176+
secure: false,
177+
headers: {
178+
host: "dev.mapstore.geo-solutions.it"
179+
}
163180
},
164181
'/pdf': {
165182
target: "https://dev.mapstore2.geo-solutions.it/mapstore",
@@ -170,8 +187,11 @@ module.exports = (bundles, themeEntries, paths, extractThemesPlugin, prod, publi
170187
secure: false
171188
},
172189
'/proxy': {
173-
target: "https://dev.mapstore2.geo-solutions.it/mapstore",
174-
secure: false
190+
target: "https://dev.mapstore.geo-solutions.it/mapstore",
191+
secure: false,
192+
headers: {
193+
host: "dev.mapstore.geo-solutions.it"
194+
}
175195
},
176196
'/docs': {
177197
target: "http://localhost:8081",

docma-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
"web/client/plugins/AutoMapUpdate.jsx",
200200
"web/client/plugins/BackgroundSelector.jsx",
201201
"web/client/plugins/BackgroundSwitcher.jsx",
202+
"web/client/plugins/CreateNewMap.jsx",
202203
"web/client/plugins/DrawerMenu.jsx",
203204
"web/client/plugins/FeatureEditor.jsx",
204205
"web/client/plugins/GlobeViewSwitcher.jsx",

web/client/actions/__tests__/maps-test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const {
3838
MAP_ERROR, mapError, updatePermissions,
3939
MAP_METADATA_UPDATED, mapMetadataUpdated,
4040
METADATA_CHANGED, metadataChanged,
41+
setShowMapDetails, SHOW_DETAILS,
4142
updateAttribute, saveAll
4243
} = require('../maps');
4344

@@ -284,6 +285,13 @@ describe('Test correctness of the maps actions', () => {
284285
expect(a.type).toBe(TOGGLE_DETAILS_SHEET);
285286
expect(a.detailsSheetReadOnly).toBeTruthy();
286287

288+
});
289+
it('setShowMapDetails', () => {
290+
const showMapDetails = true;
291+
const action = setShowMapDetails(showMapDetails);
292+
expect(action.type).toBe(SHOW_DETAILS);
293+
expect(action.showMapDetails).toBe(showMapDetails);
294+
287295
});
288296
it('toggleGroupProperties', () => {
289297
const a = toggleGroupProperties();

web/client/actions/maps.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const UPDATE_DETAILS = 'MAPS:UPDATE_DETAILS';
4848
const SAVE_DETAILS = 'MAPS:SAVE_DETAILS';
4949
const DELETE_DETAILS = 'MAPS:DELETE_DETAILS';
5050
const SET_DETAILS_CHANGED = 'MAPS:SET_DETAILS_CHANGED';
51+
const SHOW_DETAILS = 'MAPS:SHOW_DETAILS';
5152
const SAVE_RESOURCE_DETAILS = 'MAPS:SAVE_RESOURCE_DETAILS';
5253
const DO_NOTHING = 'MAPS:DO_NOTHING';
5354
const DELETE_MAP = 'MAPS:DELETE_MAP';
@@ -124,6 +125,19 @@ function mapsLoaded(maps, params, searchText) {
124125
};
125126
}
126127

128+
/**
129+
* shows or hides map details, type `MAPS:SHOW_DETAILS`
130+
* @memberof actions.maps
131+
* @prop {boolean} showMapDetails flag used to trigger the showing/hiding of the map details
132+
* @return {action} type `MAPS:SHOW_DETAILS`
133+
*/
134+
function setShowMapDetails(showMapDetails) {
135+
return {
136+
type: SHOW_DETAILS,
137+
showMapDetails
138+
};
139+
}
140+
127141
/**
128142
* When a error occurred during maps loading
129143
* @memberof actions.maps
@@ -952,6 +966,7 @@ module.exports = {
952966
detailsSaving, DETAILS_SAVING,
953967
toggleDetailsEditability, TOGGLE_DETAILS_EDITABILITY,
954968
setFeaturedMapsEnabled, FEATURED_MAPS_SET_ENABLED,
969+
setShowMapDetails, SHOW_DETAILS,
955970
metadataChanged,
956971
loadMaps,
957972
mapsLoading,

web/client/api/CSW.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ var Api = {
8585
return new Promise((resolve) => {
8686
require.ensure(['../utils/ogc/CSW', '../utils/ogc/Filter'], () => {
8787
const {CSW, marshaller, unmarshaller} = require('../utils/ogc/CSW');
88-
8988
let body = marshaller.marshalString({
9089
name: "csw:GetRecords",
9190
value: CSW.getRecords(startPosition, maxRecords, filter)
@@ -128,8 +127,8 @@ var Api = {
128127
let uc = el.value.upperCorner;
129128
bbox = [lc[1], lc[0], uc[1], uc[0]];
130129
// TODO parse the extent's crs
131-
let crsCode = el.value && el.value.crs && el.value.crs.split(":::")[1];
132-
if (crsCode === "WGS 1984") {
130+
let crsCode = el.value && el.value.crs && _.last(el.value.crs.split(":"));
131+
if (crsCode === "WGS 1984" || crsCode === "WGS84") {
133132
crs = "EPSG:4326";
134133
} else if (crsCode) {
135134
// TODO check is valid EPSG code

web/client/components/TOC/Toolbar.jsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const ReactCSSTransitionGroup = require('react-addons-css-transition-group');
1414
const {head} = require('lodash');
1515
const ConfirmModal = require('../maps/modals/ConfirmModal');
1616
const LayerMetadataModal = require('./fragments/LayerMetadataModal');
17+
const Proj4js = require('proj4').default;
18+
const Message = require('../I18N/Message');
1719

1820
class Toolbar extends React.Component {
1921

@@ -137,6 +139,9 @@ class Toolbar extends React.Component {
137139

138140
render() {
139141
const status = this.getStatus();
142+
const currentEPSG = this.checkBbox();
143+
const epsgIsSupported = currentEPSG && Proj4js.defs(currentEPSG);
144+
140145
const layerMetadataModal = (<LayerMetadataModal
141146
key="toollayermetadatamodal"
142147
layerMetadata={this.props.layerMetadata}
@@ -154,12 +159,19 @@ class Toolbar extends React.Component {
154159
{this.props.text.addLayer}
155160
</Button>
156161
: null}
157-
{this.props.activateTool.activateZoomTool && (status === 'LAYER' || status === 'GROUP' || status === 'LAYERS' || status === 'GROUPS') && this.checkBbox() ?
162+
{this.props.activateTool.activateZoomTool && (status === 'LAYER' || status === 'GROUP' || status === 'LAYERS' || status === 'GROUPS') && currentEPSG ?
158163
<OverlayTrigger
159164
key="zoomTo"
160165
placement="top"
161-
overlay={<Tooltip id="toc-tooltip-zoomTo">{this.props.text.zoomToTooltip[this.props.selectedLayers.length > 1 ? 'LAYERS' : 'LAYER']}</Tooltip>}>
162-
<Button bsStyle="primary" className="square-button-md" onClick={this.zoomTo}>
166+
overlay={<Tooltip id="toc-tooltip-zoomTo">{
167+
epsgIsSupported ? this.props.text.zoomToTooltip[this.props.selectedLayers.length > 1 ? 'LAYERS' : 'LAYER']
168+
: <Message msgId="toc.epsgNotSupported" msgParams={{epsg: currentEPSG || ' '}}/>
169+
}</Tooltip>}>
170+
<Button
171+
bsStyle="primary"
172+
className="square-button-md"
173+
style={epsgIsSupported ? {opacity: 1.0, cursor: 'pointer'} : {opacity: 0.5, cursor: 'default'}}
174+
onClick={epsgIsSupported ? this.zoomTo : () => {}}>
163175
<Glyphicon glyph="zoom-to" />
164176
</Button>
165177
</OverlayTrigger>
@@ -268,7 +280,7 @@ class Toolbar extends React.Component {
268280
checkBbox = () => {
269281
const layersBbox = this.props.selectedLayers.filter(l => l.bbox).map(l => l.bbox);
270282
const uniqueCRS = layersBbox.length > 0 ? layersBbox.reduce((a, b) => a.crs === b.crs ? a : {crs: 'differentCRS'}) : {crs: 'differentCRS'};
271-
return !!head(layersBbox) && uniqueCRS.crs !== 'differentCRS';
283+
return !!head(layersBbox) && uniqueCRS.crs !== 'differentCRS' && uniqueCRS.crs;
272284
}
273285

274286
zoomTo = () => {

web/client/components/TOC/__tests__/Toolbar-test.jsx

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('TOC Toolbar', () => {
7070
maxy: 9,
7171
minx: -10,
7272
miny: -9
73-
}, crs: 'EPSG'
73+
}, crs: 'EPSG:4326'
7474
},
7575
search: {
7676
url: 'l001url'
@@ -92,7 +92,7 @@ describe('TOC Toolbar', () => {
9292
maxy: 9,
9393
minx: -10,
9494
miny: -9
95-
}, 'EPSG');
95+
}, 'EPSG:4326');
9696

9797
TestUtils.Simulate.click(btn[1]);
9898
expect(spySettings).toHaveBeenCalledWith('l001', 'layers', {opacity: 1 });
@@ -130,7 +130,7 @@ describe('TOC Toolbar', () => {
130130
maxy: 9,
131131
minx: -10,
132132
miny: -9
133-
}, crs: 'EPSG'
133+
}, crs: 'EPSG:4326'
134134
}
135135
}];
136136

@@ -149,7 +149,7 @@ describe('TOC Toolbar', () => {
149149
maxy: 9,
150150
minx: -10,
151151
miny: -9
152-
}, 'EPSG');
152+
}, 'EPSG:4326');
153153

154154
TestUtils.Simulate.click(btn[1]);
155155
expect(spySettings).toHaveBeenCalledWith('l001', 'layers', {opacity: 1 });
@@ -173,7 +173,7 @@ describe('TOC Toolbar', () => {
173173
maxy: 9,
174174
minx: -10,
175175
miny: -9
176-
}, crs: 'EPSG'
176+
}, crs: 'EPSG:4326'
177177
}
178178
}];
179179

@@ -207,7 +207,7 @@ describe('TOC Toolbar', () => {
207207
maxy: 9,
208208
minx: -10,
209209
miny: -9
210-
}, crs: 'EPSG'
210+
}, crs: 'EPSG:4326'
211211
},
212212
search: {
213213
url: 'l001url'
@@ -248,7 +248,7 @@ describe('TOC Toolbar', () => {
248248
maxy: 9,
249249
minx: -10,
250250
miny: -9
251-
}, crs: 'EPSG'
251+
}, crs: 'EPSG:4326'
252252
},
253253
search: {
254254
url: 'l001url'
@@ -263,7 +263,7 @@ describe('TOC Toolbar', () => {
263263
maxy: 29,
264264
minx: 28,
265265
miny: 27
266-
}, crs: 'EPSG'
266+
}, crs: 'EPSG:4326'
267267
},
268268
search: {
269269
url: 'l002url'
@@ -292,7 +292,7 @@ describe('TOC Toolbar', () => {
292292
maxy: 29,
293293
minx: -10,
294294
miny: -9
295-
}, 'EPSG');
295+
}, 'EPSG:4326');
296296

297297
TestUtils.Simulate.click(btn[1]);
298298
expect(spySettings).toHaveBeenCalledWith('g001', 'groups', {});
@@ -313,7 +313,7 @@ describe('TOC Toolbar', () => {
313313
maxy: 9,
314314
minx: -10,
315315
miny: -9
316-
}, crs: 'EPSG'
316+
}, crs: 'EPSG:4326'
317317
},
318318
search: {
319319
url: 'l001url'
@@ -328,7 +328,7 @@ describe('TOC Toolbar', () => {
328328
maxy: 29,
329329
minx: 28,
330330
miny: 27
331-
}, crs: 'EPSG'
331+
}, crs: 'EPSG:4326'
332332
},
333333
search: {
334334
url: 'l002url'
@@ -377,4 +377,29 @@ describe('TOC Toolbar', () => {
377377
expect(removeModal).toExist();
378378
});
379379

380+
it('layer single selection (epsg not supported)', () => {
381+
382+
const selectedLayers = [{
383+
id: 'l001',
384+
title: 'layer001',
385+
name: 'layer001name',
386+
bbox: {
387+
bounds: {
388+
maxx: 10,
389+
maxy: 9,
390+
minx: -10,
391+
miny: -9
392+
}, crs: 'EPSG:3003'
393+
}
394+
}];
395+
396+
const cmp = ReactDOM.render(<Toolbar selectedLayers={selectedLayers} onToolsActions={onToolsActions}/>, document.getElementById("container"));
397+
398+
const el = ReactDOM.findDOMNode(cmp);
399+
expect(el).toExist();
400+
const btn = el.getElementsByClassName('btn');
401+
expect(btn.length).toBe(3);
402+
expect(btn[0].style.cursor).toBe('default');
403+
});
404+
380405
});

web/client/components/catalog/Catalog.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class Catalog extends React.Component {
206206
records={this.props.records}
207207
authkeyParamNames={this.props.authkeyParamNames}
208208
catalogURL={this.isValidServiceSelected() && this.props.services[this.props.selectedService].url || ""}
209-
catalogType={this.props.services[this.props.selectedService].type}
209+
catalogType={this.props.services[this.props.selectedService] && this.props.services[this.props.selectedService].type}
210210
onLayerAdd={this.props.onLayerAdd}
211211
onZoomToExtent={this.props.onZoomToExtent}
212212
zoomToLayer={this.props.zoomToLayer}

web/client/components/catalog/RecordItem.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,15 @@ class RecordItem extends React.Component {
137137

138138
render() {
139139
let record = this.props.record;
140+
const {wms, wmts} = extractOGCServicesReferences(record);
140141
return (
141142
<Panel className="record-item" style={{padding: 0}}>
142143
{this.renderThumb(record && record.thumbnail, record)}
143144
<div>
144145
<h4 className="truncateText">{record && this.getTitle(record.title)}</h4>
145146
<h4 className="truncateText"><small>{record && record.identifier}</small></h4>
146147
<p className="truncateText record-item-description">{this.truncateDescription(this.renderDescription(record), 70)}</p>
148+
{!wms && !wmts && <small className="text-danger"><Message msgId="catalog.missingReference"/></small>}
147149
</div>
148150
{this.renderButtons(record)}
149151
</Panel>

web/client/components/catalog/__tests__/RecordItem-test.jsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,4 +387,31 @@ describe('This test for RecordItem', () => {
387387
expect(titleAndIdentifier.length).toBe(2);
388388
expect(titleAndIdentifier.item(0).innerText).toBe('');
389389
});
390+
391+
it('record without references', () => {
392+
const recordWithoutRef = {
393+
identifier: "test-identifier",
394+
title: "sample title",
395+
tags: ["subject1", "subject2"],
396+
description: "sample abstract",
397+
thumbnail: "img.jpg",
398+
boundingBox: {
399+
extent: [10.686,
400+
44.931,
401+
46.693,
402+
12.54],
403+
crs: "EPSG:4326"
404+
},
405+
references: []
406+
};
407+
408+
const item = ReactDOM.render(<ReactItem record={recordWithoutRef}/>, document.getElementById("container"));
409+
expect(item).toExist();
410+
411+
const itemDom = ReactDOM.findDOMNode(item);
412+
expect(itemDom).toExist();
413+
const dangerText = itemDom.getElementsByClassName('text-danger');
414+
expect(dangerText.length).toBe(1);
415+
});
416+
390417
});

0 commit comments

Comments
 (0)