Skip to content

Commit

Permalink
Merge pull request #2937 from MV88/2922_align_210518
Browse files Browse the repository at this point in the history
2922 align 210518
  • Loading branch information
MV88 authored May 22, 2018
2 parents 5a403ea + 0561169 commit 415b07f
Show file tree
Hide file tree
Showing 72 changed files with 835 additions and 417 deletions.
28 changes: 24 additions & 4 deletions buildConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,25 @@ module.exports = (bundles, themeEntries, paths, extractThemesPlugin, prod, publi
devServer: {
proxy: {
'/rest/geostore': {
target: "https://dev.mapstore2.geo-solutions.it/mapstore",
secure: false
target: "https://dev.mapstore.geo-solutions.it/mapstore",
secure: false,
headers: {
host: "dev.mapstore.geo-solutions.it"
}
},
'/pdf': {
target: "https://dev.mapstore.geo-solutions.it/mapstore",
secure: false,
headers: {
host: "dev.mapstore.geo-solutions.it"
}
},
'/mapstore/pdf': {
target: "https://dev.mapstore.geo-solutions.it",
secure: false,
headers: {
host: "dev.mapstore.geo-solutions.it"
}
},
'/pdf': {
target: "https://dev.mapstore2.geo-solutions.it/mapstore",
Expand All @@ -170,8 +187,11 @@ module.exports = (bundles, themeEntries, paths, extractThemesPlugin, prod, publi
secure: false
},
'/proxy': {
target: "https://dev.mapstore2.geo-solutions.it/mapstore",
secure: false
target: "https://dev.mapstore.geo-solutions.it/mapstore",
secure: false,
headers: {
host: "dev.mapstore.geo-solutions.it"
}
},
'/docs': {
target: "http://localhost:8081",
Expand Down
1 change: 1 addition & 0 deletions docma-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
"web/client/plugins/AutoMapUpdate.jsx",
"web/client/plugins/BackgroundSelector.jsx",
"web/client/plugins/BackgroundSwitcher.jsx",
"web/client/plugins/CreateNewMap.jsx",
"web/client/plugins/DrawerMenu.jsx",
"web/client/plugins/FeatureEditor.jsx",
"web/client/plugins/GlobeViewSwitcher.jsx",
Expand Down
8 changes: 8 additions & 0 deletions web/client/actions/__tests__/maps-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const {
MAP_ERROR, mapError, updatePermissions,
MAP_METADATA_UPDATED, mapMetadataUpdated,
METADATA_CHANGED, metadataChanged,
setShowMapDetails, SHOW_DETAILS,
updateAttribute, saveAll
} = require('../maps');

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

});
it('setShowMapDetails', () => {
const showMapDetails = true;
const action = setShowMapDetails(showMapDetails);
expect(action.type).toBe(SHOW_DETAILS);
expect(action.showMapDetails).toBe(showMapDetails);

});
it('toggleGroupProperties', () => {
const a = toggleGroupProperties();
Expand Down
15 changes: 15 additions & 0 deletions web/client/actions/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const UPDATE_DETAILS = 'MAPS:UPDATE_DETAILS';
const SAVE_DETAILS = 'MAPS:SAVE_DETAILS';
const DELETE_DETAILS = 'MAPS:DELETE_DETAILS';
const SET_DETAILS_CHANGED = 'MAPS:SET_DETAILS_CHANGED';
const SHOW_DETAILS = 'MAPS:SHOW_DETAILS';
const SAVE_RESOURCE_DETAILS = 'MAPS:SAVE_RESOURCE_DETAILS';
const DO_NOTHING = 'MAPS:DO_NOTHING';
const DELETE_MAP = 'MAPS:DELETE_MAP';
Expand Down Expand Up @@ -124,6 +125,19 @@ function mapsLoaded(maps, params, searchText) {
};
}

/**
* shows or hides map details, type `MAPS:SHOW_DETAILS`
* @memberof actions.maps
* @prop {boolean} showMapDetails flag used to trigger the showing/hiding of the map details
* @return {action} type `MAPS:SHOW_DETAILS`
*/
function setShowMapDetails(showMapDetails) {
return {
type: SHOW_DETAILS,
showMapDetails
};
}

/**
* When a error occurred during maps loading
* @memberof actions.maps
Expand Down Expand Up @@ -952,6 +966,7 @@ module.exports = {
detailsSaving, DETAILS_SAVING,
toggleDetailsEditability, TOGGLE_DETAILS_EDITABILITY,
setFeaturedMapsEnabled, FEATURED_MAPS_SET_ENABLED,
setShowMapDetails, SHOW_DETAILS,
metadataChanged,
loadMaps,
mapsLoading,
Expand Down
5 changes: 2 additions & 3 deletions web/client/api/CSW.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ var Api = {
return new Promise((resolve) => {
require.ensure(['../utils/ogc/CSW', '../utils/ogc/Filter'], () => {
const {CSW, marshaller, unmarshaller} = require('../utils/ogc/CSW');

let body = marshaller.marshalString({
name: "csw:GetRecords",
value: CSW.getRecords(startPosition, maxRecords, filter)
Expand Down Expand Up @@ -128,8 +127,8 @@ var Api = {
let uc = el.value.upperCorner;
bbox = [lc[1], lc[0], uc[1], uc[0]];
// TODO parse the extent's crs
let crsCode = el.value && el.value.crs && el.value.crs.split(":::")[1];
if (crsCode === "WGS 1984") {
let crsCode = el.value && el.value.crs && _.last(el.value.crs.split(":"));
if (crsCode === "WGS 1984" || crsCode === "WGS84") {
crs = "EPSG:4326";
} else if (crsCode) {
// TODO check is valid EPSG code
Expand Down
20 changes: 16 additions & 4 deletions web/client/components/TOC/Toolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const ReactCSSTransitionGroup = require('react-addons-css-transition-group');
const {head} = require('lodash');
const ConfirmModal = require('../maps/modals/ConfirmModal');
const LayerMetadataModal = require('./fragments/LayerMetadataModal');
const Proj4js = require('proj4').default;
const Message = require('../I18N/Message');

class Toolbar extends React.Component {

Expand Down Expand Up @@ -137,6 +139,9 @@ class Toolbar extends React.Component {

render() {
const status = this.getStatus();
const currentEPSG = this.checkBbox();
const epsgIsSupported = currentEPSG && Proj4js.defs(currentEPSG);

const layerMetadataModal = (<LayerMetadataModal
key="toollayermetadatamodal"
layerMetadata={this.props.layerMetadata}
Expand All @@ -154,12 +159,19 @@ class Toolbar extends React.Component {
{this.props.text.addLayer}
</Button>
: null}
{this.props.activateTool.activateZoomTool && (status === 'LAYER' || status === 'GROUP' || status === 'LAYERS' || status === 'GROUPS') && this.checkBbox() ?
{this.props.activateTool.activateZoomTool && (status === 'LAYER' || status === 'GROUP' || status === 'LAYERS' || status === 'GROUPS') && currentEPSG ?
<OverlayTrigger
key="zoomTo"
placement="top"
overlay={<Tooltip id="toc-tooltip-zoomTo">{this.props.text.zoomToTooltip[this.props.selectedLayers.length > 1 ? 'LAYERS' : 'LAYER']}</Tooltip>}>
<Button bsStyle="primary" className="square-button-md" onClick={this.zoomTo}>
overlay={<Tooltip id="toc-tooltip-zoomTo">{
epsgIsSupported ? this.props.text.zoomToTooltip[this.props.selectedLayers.length > 1 ? 'LAYERS' : 'LAYER']
: <Message msgId="toc.epsgNotSupported" msgParams={{epsg: currentEPSG || ' '}}/>
}</Tooltip>}>
<Button
bsStyle="primary"
className="square-button-md"
style={epsgIsSupported ? {opacity: 1.0, cursor: 'pointer'} : {opacity: 0.5, cursor: 'default'}}
onClick={epsgIsSupported ? this.zoomTo : () => {}}>
<Glyphicon glyph="zoom-to" />
</Button>
</OverlayTrigger>
Expand Down Expand Up @@ -268,7 +280,7 @@ class Toolbar extends React.Component {
checkBbox = () => {
const layersBbox = this.props.selectedLayers.filter(l => l.bbox).map(l => l.bbox);
const uniqueCRS = layersBbox.length > 0 ? layersBbox.reduce((a, b) => a.crs === b.crs ? a : {crs: 'differentCRS'}) : {crs: 'differentCRS'};
return !!head(layersBbox) && uniqueCRS.crs !== 'differentCRS';
return !!head(layersBbox) && uniqueCRS.crs !== 'differentCRS' && uniqueCRS.crs;
}

zoomTo = () => {
Expand Down
47 changes: 36 additions & 11 deletions web/client/components/TOC/__tests__/Toolbar-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('TOC Toolbar', () => {
maxy: 9,
minx: -10,
miny: -9
}, crs: 'EPSG'
}, crs: 'EPSG:4326'
},
search: {
url: 'l001url'
Expand All @@ -92,7 +92,7 @@ describe('TOC Toolbar', () => {
maxy: 9,
minx: -10,
miny: -9
}, 'EPSG');
}, 'EPSG:4326');

TestUtils.Simulate.click(btn[1]);
expect(spySettings).toHaveBeenCalledWith('l001', 'layers', {opacity: 1 });
Expand Down Expand Up @@ -130,7 +130,7 @@ describe('TOC Toolbar', () => {
maxy: 9,
minx: -10,
miny: -9
}, crs: 'EPSG'
}, crs: 'EPSG:4326'
}
}];

Expand All @@ -149,7 +149,7 @@ describe('TOC Toolbar', () => {
maxy: 9,
minx: -10,
miny: -9
}, 'EPSG');
}, 'EPSG:4326');

TestUtils.Simulate.click(btn[1]);
expect(spySettings).toHaveBeenCalledWith('l001', 'layers', {opacity: 1 });
Expand All @@ -173,7 +173,7 @@ describe('TOC Toolbar', () => {
maxy: 9,
minx: -10,
miny: -9
}, crs: 'EPSG'
}, crs: 'EPSG:4326'
}
}];

Expand Down Expand Up @@ -207,7 +207,7 @@ describe('TOC Toolbar', () => {
maxy: 9,
minx: -10,
miny: -9
}, crs: 'EPSG'
}, crs: 'EPSG:4326'
},
search: {
url: 'l001url'
Expand Down Expand Up @@ -248,7 +248,7 @@ describe('TOC Toolbar', () => {
maxy: 9,
minx: -10,
miny: -9
}, crs: 'EPSG'
}, crs: 'EPSG:4326'
},
search: {
url: 'l001url'
Expand All @@ -263,7 +263,7 @@ describe('TOC Toolbar', () => {
maxy: 29,
minx: 28,
miny: 27
}, crs: 'EPSG'
}, crs: 'EPSG:4326'
},
search: {
url: 'l002url'
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('TOC Toolbar', () => {
maxy: 29,
minx: -10,
miny: -9
}, 'EPSG');
}, 'EPSG:4326');

TestUtils.Simulate.click(btn[1]);
expect(spySettings).toHaveBeenCalledWith('g001', 'groups', {});
Expand All @@ -313,7 +313,7 @@ describe('TOC Toolbar', () => {
maxy: 9,
minx: -10,
miny: -9
}, crs: 'EPSG'
}, crs: 'EPSG:4326'
},
search: {
url: 'l001url'
Expand All @@ -328,7 +328,7 @@ describe('TOC Toolbar', () => {
maxy: 29,
minx: 28,
miny: 27
}, crs: 'EPSG'
}, crs: 'EPSG:4326'
},
search: {
url: 'l002url'
Expand Down Expand Up @@ -377,4 +377,29 @@ describe('TOC Toolbar', () => {
expect(removeModal).toExist();
});

it('layer single selection (epsg not supported)', () => {

const selectedLayers = [{
id: 'l001',
title: 'layer001',
name: 'layer001name',
bbox: {
bounds: {
maxx: 10,
maxy: 9,
minx: -10,
miny: -9
}, crs: 'EPSG:3003'
}
}];

const cmp = ReactDOM.render(<Toolbar selectedLayers={selectedLayers} onToolsActions={onToolsActions}/>, document.getElementById("container"));

const el = ReactDOM.findDOMNode(cmp);
expect(el).toExist();
const btn = el.getElementsByClassName('btn');
expect(btn.length).toBe(3);
expect(btn[0].style.cursor).toBe('default');
});

});
2 changes: 1 addition & 1 deletion web/client/components/catalog/Catalog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class Catalog extends React.Component {
records={this.props.records}
authkeyParamNames={this.props.authkeyParamNames}
catalogURL={this.isValidServiceSelected() && this.props.services[this.props.selectedService].url || ""}
catalogType={this.props.services[this.props.selectedService].type}
catalogType={this.props.services[this.props.selectedService] && this.props.services[this.props.selectedService].type}
onLayerAdd={this.props.onLayerAdd}
onZoomToExtent={this.props.onZoomToExtent}
zoomToLayer={this.props.zoomToLayer}
Expand Down
2 changes: 2 additions & 0 deletions web/client/components/catalog/RecordItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,15 @@ class RecordItem extends React.Component {

render() {
let record = this.props.record;
const {wms, wmts} = extractOGCServicesReferences(record);
return (
<Panel className="record-item" style={{padding: 0}}>
{this.renderThumb(record && record.thumbnail, record)}
<div>
<h4 className="truncateText">{record && this.getTitle(record.title)}</h4>
<h4 className="truncateText"><small>{record && record.identifier}</small></h4>
<p className="truncateText record-item-description">{this.truncateDescription(this.renderDescription(record), 70)}</p>
{!wms && !wmts && <small className="text-danger"><Message msgId="catalog.missingReference"/></small>}
</div>
{this.renderButtons(record)}
</Panel>
Expand Down
27 changes: 27 additions & 0 deletions web/client/components/catalog/__tests__/RecordItem-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,31 @@ describe('This test for RecordItem', () => {
expect(titleAndIdentifier.length).toBe(2);
expect(titleAndIdentifier.item(0).innerText).toBe('');
});

it('record without references', () => {
const recordWithoutRef = {
identifier: "test-identifier",
title: "sample title",
tags: ["subject1", "subject2"],
description: "sample abstract",
thumbnail: "img.jpg",
boundingBox: {
extent: [10.686,
44.931,
46.693,
12.54],
crs: "EPSG:4326"
},
references: []
};

const item = ReactDOM.render(<ReactItem record={recordWithoutRef}/>, document.getElementById("container"));
expect(item).toExist();

const itemDom = ReactDOM.findDOMNode(item);
expect(itemDom).toExist();
const dangerText = itemDom.getElementsByClassName('text-danger');
expect(dangerText.length).toBe(1);
});

});
2 changes: 1 addition & 1 deletion web/client/components/data/download/DownloadDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DownloadDialog extends React.Component {
{name: "native", label: "Native"},
{name: "EPSG:4326", label: "WGS84"}
],
virtualScroll: false
virtualScroll: true
};

componentDidMount() {
Expand Down
4 changes: 3 additions & 1 deletion web/client/components/data/download/DownloadOptions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = class extends React.Component {
wfsFormats: [],
formats: [],
srsList: [],
virtualScroll: false
virtualScroll: true
};

getSelectedFormat = () => {
Expand Down Expand Up @@ -82,6 +82,8 @@ module.exports = class extends React.Component {
value={this.getSelectedSRS()}
onChange={(sel) => this.props.onChange("selectedSrs", sel.value)}
options={this.props.srsList.map(f => ({value: f.name, label: f.label || f.name}))} />

{/* TODO for the future remove the virtualScroll prop since is no longer used*/}
{this.props.virtualScroll ? null : <Checkbox checked={this.props.downloadOptions.singlePage} onChange={() => this.props.onChange("singlePage", !this.props.downloadOptions.singlePage ) }>
<Message msgId="wfsdownload.downloadonlycurrentpage" />
</Checkbox>}
Expand Down
Loading

0 comments on commit 415b07f

Please sign in to comment.