Skip to content

Commit

Permalink
Merge branch 'master' into query-bool
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap committed May 3, 2017
2 parents 6dc6bce + 5359643 commit 1788c9c
Show file tree
Hide file tree
Showing 41 changed files with 803 additions and 203 deletions.
8 changes: 8 additions & 0 deletions docma-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"framework" : [
"web/client/components/index.jsdoc",
"web/client/components/buttons/FullScreenButton.jsx",
"web/client/components/buttons/GlobeViewSwitcherButton.jsx",
"web/client/components/buttons/GoFullButton.jsx",
"web/client/components/mapcontrols/search/SearchBar.jsx",
"web/client/components/buttons/ToggleButton.jsx",
Expand All @@ -116,16 +117,22 @@
"web/client/actions/index.jsdoc",
"web/client/actions/controls.js",
"web/client/actions/fullscreen.js",
"web/client/actions/globeswitcher.js",
"web/client/actions/maps.js",
"web/client/actions/maptype.js",
"web/client/actions/search.js",

"web/client/reducers/index.jsdoc",
"web/client/reducers/controls.js",
"web/client/reducers/globeswitcher.js",
"web/client/reducers/maps.js",
"web/client/reducers/maptype.js",
"web/client/reducers/search.js",

"web/client/epics/index.jsdoc",
"web/client/epics/fullscreen.js",
"web/client/epics/globeswitcher.js",
"web/client/epics/maptype.js",
"web/client/epics/search.js",

"web/client/utils/index.jsdoc",
Expand All @@ -137,6 +144,7 @@
"web/client/plugins/index.jsdoc",
"web/client/plugins/BackgroundSwitcher.jsx",
"web/client/plugins/DrawerMenu.jsx",
"web/client/plugins/GlobeViewSwitcher.jsx",
"web/client/plugins/GoFull.jsx",
"web/client/plugins/Map.jsx",
"web/client/plugins/FullScreen.jsx",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
"react-dom": "15.4.2",
"react-draggable": "2.2.3",
"react-dropzone": "3.4.0",
"react-input-autosize": "1.1.0",
"react-intl": "2.2.3",
"react-joyride": "1.10.1",
"react-nouislider": "1.11.0",
Expand Down
31 changes: 31 additions & 0 deletions web/client/actions/__tests__/globeswitcher-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2017, 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.
*/

const expect = require('expect');
const {
toggle3d,
updateLast2dMapType,
TOGGLE_3D,
UPDATE_LAST_2D_MAPTYPE
} = require('../globeswitcher');

describe('Test correctness of the maptype actions', () => {

it('toggle3d', () => {
const retVal = toggle3d(true);
expect(retVal).toExist();
expect(retVal.type).toBe(TOGGLE_3D);
expect(retVal.enable).toBe(true);
});
it('updateLast2dMapType', () => {
const retVal = updateLast2dMapType("leaflet");
expect(retVal).toExist();
expect(retVal.type).toBe(UPDATE_LAST_2D_MAPTYPE);
expect(retVal.mapType).toBe('leaflet');
});
});
23 changes: 23 additions & 0 deletions web/client/actions/__tests__/maptype-test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2017, 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.
*/

const expect = require('expect');
const {
MAP_TYPE_CHANGED,
changeMapType
} = require('../maptype');

describe('Test correctness of the maptype actions', () => {

it('changeMapType', () => {
const retVal = changeMapType('maptype');
expect(retVal).toExist();
expect(retVal.type).toBe(MAP_TYPE_CHANGED);
expect(retVal.mapType).toBe('maptype');
});
});
2 changes: 1 addition & 1 deletion web/client/actions/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function textSearch(format, url, startPosition, maxRecords, text, options) {
function addLayerAndDescribe(layer) {
return (dispatch, getState) => {
const state = getState();
const layers = state && state.layers;
const layers = state && state.layers && state.layers.flat;
const id = LayersUtils.getLayerId(layer, layers || []);
dispatch(addLayer({...layer, id}));
if (layer.type === 'wms') {
Expand Down
58 changes: 58 additions & 0 deletions web/client/actions/globeswitcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2017, 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.
*/


const TOGGLE_3D = "TOGGLE_3D";
const UPDATE_LAST_2D_MAPTYPE = "UPDATE_LAST_2D_MAPTYPE";
/**
* Emitted when 3d map have to be toggled
* @memberof actions.globeswitcher
* @param {boolean} enable true for enable, false for disable
* @return {action} the action of type `TOGGLE_FULLSCREEN` with enable flag and element selector.
* ```
* {
* type: TOGGLE_3D,
* enable
* }
* ```
*/
function toggle3d(enable, originalMapType) {
return {
type: TOGGLE_3D,
enable,
originalMapType
};
}
/**
* Saves the last 2d map
* @memberof actions.globeswitcher
* @param {string} mapType last maptype
* @return {object} action
* ```
* {
* type: MAPTYPE_2D_SELECTED,
* mapType
* }
* ```
*/
function updateLast2dMapType(mapType) {
return {
type: UPDATE_LAST_2D_MAPTYPE,
mapType
};
}
/**
* Actions for Globe Switcher Plugin.
* @name actions.globeswitcher
*/
module.exports = {
toggle3d,
updateLast2dMapType,
UPDATE_LAST_2D_MAPTYPE,
TOGGLE_3D
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016, GeoSolutions Sas.
/*
* Copyright 2017, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
Expand All @@ -8,11 +8,20 @@

const MAP_TYPE_CHANGED = 'MAP_TYPE_CHANGED';

/**
* changes the map type
* @memberof actions.maptype
* @param {string} mapType the mapType.
* @return {action} the action of type `MAP_TYPE_CHANGED` with mapType
*/
function changeMapType(mapType) {
return {
type: MAP_TYPE_CHANGED,
mapType
};
}

/**
* Actions for map type management.Allow to manage the default map type.
* @name actions.maptype
*/
module.exports = {MAP_TYPE_CHANGED, changeMapType};
11 changes: 10 additions & 1 deletion web/client/actions/queryform.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const EXPAND_ATTRIBUTE_PANEL = 'EXPAND_ATTRIBUTE_PANEL';
const EXPAND_SPATIAL_PANEL = 'EXPAND_SPATIAL_PANEL';
const SELECT_SPATIAL_METHOD = 'SELECT_SPATIAL_METHOD';
const SELECT_SPATIAL_OPERATION = 'SELECT_SPATIAL_OPERATION';
const CHANGE_SPATIAL_ATTRIBUTE = 'CHANGE_SPATIAL_ATTRIBUTE';
const REMOVE_SPATIAL_SELECT = 'REMOVE_SPATIAL_SELECT';
const SHOW_SPATIAL_DETAILS = 'SHOW_SPATIAL_DETAILS';
// const QUERY_FORM_SEARCH = 'QUERY_FORM_SEARCH';
Expand Down Expand Up @@ -133,6 +134,13 @@ function selectSpatialOperation(operation, fieldName) {
};
}

function changeSpatialAttribute(attribute) {
return {
type: CHANGE_SPATIAL_ATTRIBUTE,
attribute
};
}

function removeSpatialSelection() {
return {
type: REMOVE_SPATIAL_SELECT
Expand All @@ -159,7 +167,6 @@ function changeDwithinValue(distance) {
response: response
};
}
function wfsLoadError(e) {
return {
type: WFS_LOAD_ERROR,
Expand Down Expand Up @@ -297,6 +304,7 @@ module.exports = {
EXPAND_SPATIAL_PANEL,
SELECT_SPATIAL_METHOD,
SELECT_SPATIAL_OPERATION,
CHANGE_SPATIAL_ATTRIBUTE,
REMOVE_SPATIAL_SELECT,
SHOW_SPATIAL_DETAILS,
// QUERY_FORM_SEARCH,
Expand Down Expand Up @@ -333,6 +341,7 @@ module.exports = {
expandSpatialFilterPanel,
selectSpatialMethod,
selectSpatialOperation,
changeSpatialAttribute,
removeSpatialSelection,
showSpatialSelectionDetails,
query,
Expand Down
23 changes: 2 additions & 21 deletions web/client/actions/wfsquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,6 @@ function queryError(error) {
};
}

function describeFeatureType(baseUrl, typeName) {
return (dispatch) => {
return axios.get(baseUrl + '?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=' + typeName + '&outputFormat=application/json').then((response) => {
if (typeof response.data === 'object') {
dispatch(featureTypeLoaded(typeName, response.data));
} else {
try {
JSON.parse(response.data);
} catch(e) {
dispatch(featureTypeError(typeName, 'Error from WFS: ' + e.message));
}

}

}).catch((e) => {
dispatch(featureTypeError(typeName, e));
});
};
}

function loadFeature(baseUrl, typeName) {
return (dispatch) => {
return axios.get(baseUrl + '?service=WFS&version=1.1.0&request=GetFeature&typeName=' + typeName + '&outputFormat=application/json').then((response) => {
Expand Down Expand Up @@ -196,7 +176,8 @@ module.exports = {
QUERY_ERROR,
RESET_QUERY,
featureTypeSelected,
describeFeatureType,
featureTypeLoaded,
featureTypeError,
loadFeature,
createQuery,
query,
Expand Down
89 changes: 89 additions & 0 deletions web/client/components/buttons/GlobeViewSwitcherButton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright 2017, 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.
*/

const React = require('react');

const ToggleButton = require('./ToggleButton');
const {Tooltip} = require('react-bootstrap');
const Message = require('../I18N/Message');
/**
* Toggle button for 3d. Wraps {@link #components.buttons.ToggleButton} with some defaults
* @memberof components.buttons
* @class
* @prop {string} [id] an id for the html component
* @prop {object} [btnConfig] the configuration to pass to the bootstrap button
* @prop {object} [options] the options to send when toggle is clicked
* @prop {string|element} [text] the text to disaplay
* @prop {string|element} [help] the help text
* @prop {string} glyphicon the icon name
* @prop {bool} active the status of the button
* @prop {function} onClick. The method to call when clicked. the method will return as parameter the toggled `pressed` prop and the `options` object
* @prop {node} [activeTooltip] the tooltip to use on mouse hover
* @prop {node} [notActiveTooltip] the tooltip to use on mouse hover when the button is active
* @prop {string} [tooltipPlace] positon of the tooltip, one of: 'top', 'right', 'bottom', 'left'
* @prop {object} css style object for the component
* @prop {btnType} [btnType] one of 'normal', 'image'
* @prop {string} image if type is 'image', the src of the image
* @prop {string} pressedStyle the bootstrap style for pressedStyle
* @prop {string} defaultStyle the bootstrap style when not pressed
*
*/
const GlobeViewSwitcherButton = React.createClass({
propTypes: {
id: React.PropTypes.string,
btnConfig: React.PropTypes.object,
options: React.PropTypes.object,
text: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]),
help: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]),
glyphicon: React.PropTypes.string,
active: React.PropTypes.bool,
onClick: React.PropTypes.func,
activeTooltip: React.PropTypes.string,
notActiveTooltip: React.PropTypes.string,
tooltipPlace: React.PropTypes.string,
style: React.PropTypes.object,
btnType: React.PropTypes.oneOf(['normal', 'image']),
image: React.PropTypes.string,
pressedStyle: React.PropTypes.string,
defaultStyle: React.PropTypes.string
},
getDefaultProps() {
return {
id: 'globeviewswitcher-btn',
activeTooltip: 'globeswitcher.tooltipDeactivate',
notActiveTooltip: 'globeswitcher.tooltipActivate',
tooltipPlace: 'left',
defaultStyle: 'primary',
pressedStyle: 'success',
glyphicon: 'globe',
btnConfig: {
className: "square-button"
}
};
},
getButtonProperties() {
return ['id',
'btnConfig',
'options',
'text',
'glyphicon',
'onClick',
'tooltipPlace',
'style',
'btnType',
'image',
'pressedStyle',
'defaultStyle'
].reduce((result, key) => { result[key] = this.props[key]; return result; }, {});
},
render() {
return <ToggleButton {...this.getButtonProperties()} pressed={this.props.active} tooltip={<Tooltip><Message msgId={this.props.active ? this.props.activeTooltip : this.props.notActiveTooltip}/></Tooltip>} />;
}
});

module.exports = GlobeViewSwitcherButton;
Loading

0 comments on commit 1788c9c

Please sign in to comment.