Skip to content

Commit

Permalink
Merge branch 'master' into temp
Browse files Browse the repository at this point in the history
  • Loading branch information
kappu72 authored Apr 6, 2018
2 parents 2c7336a + 7bdff39 commit 39f2024
Show file tree
Hide file tree
Showing 82 changed files with 3,103 additions and 388 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,4 @@
},
"author": "GeoSolutions",
"license": "BSD-2-Clause"
}
}
16 changes: 12 additions & 4 deletions web/client/actions/__tests__/search-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ var {
TEXT_SEARCH_ITEM_SELECTED,
TEXT_SEARCH_NESTED_SERVICES_SELECTED,
TEXT_SEARCH_CANCEL_ITEM,
UPDATE_RESULTS_STYLE,
searchResultLoaded,
searchTextLoading,
searchResultError,
textSearch,
selectSearchItem,
selectNestedService,
cancelSelectedItem
cancelSelectedItem,
updateResultsStyle
} = require('../search');

describe('Test correctness of the search actions', () => {
Expand Down Expand Up @@ -56,11 +58,12 @@ describe('Test correctness of the search actions', () => {
expect(retval2.append).toBe(true);
});
it('serch item selected', () => {
const retval = selectSearchItem("A", "B");
const retval = selectSearchItem("A", "B", {color: '#ff0000'});
expect(retval).toExist();
expect(retval.type).toBe(TEXT_SEARCH_ITEM_SELECTED);
expect(retval.item).toEqual("A");
expect(retval.mapConfig).toBe("B");
expect(retval.resultsStyle).toEqual({color: '#ff0000'});
});
it('serch item cancelled', () => {
const retval = cancelSelectedItem("ITEM");
Expand All @@ -77,6 +80,11 @@ describe('Test correctness of the search actions', () => {
expect(retval.items).toEqual(items);
expect(retval.services).toEqual(services);
});


it('update results style', () => {
const style = {color: '#ff0000'};
const retval = updateResultsStyle(style);
expect(retval).toExist();
expect(retval.type).toBe(UPDATE_RESULTS_STYLE);
expect(retval.style).toEqual({color: '#ff0000'});
});
});
22 changes: 21 additions & 1 deletion web/client/actions/__tests__/widgets-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const {
OPEN_FILTER_EDITOR,
EXPORT_CSV,
EXPORT_IMAGE,
DEPENDENCY_SELECTOR_KEY,
exportCSV,
exportImage,
openFilterEditor,
Expand All @@ -35,7 +36,9 @@ const {
editNewWidget,
onEditorChange,
changeEditorSetting,
setPage
setPage,
setupDependencySelector,
toggleDependencySelector
} = require('../widgets');

describe('Test correctness of the widgets actions', () => {
Expand Down Expand Up @@ -156,5 +159,22 @@ describe('Test correctness of the widgets actions', () => {
expect(retval.key).toBe("step");
expect(retval.value).toBe(1);
});
it('setupDependencySelector', () => {
const value = { active: true, setup: "setup" };
const retval = setupDependencySelector(value);
expect(retval).toExist();
expect(retval.type).toBe(EDITOR_SETTING_CHANGE);
expect(retval.key).toBe(`${DEPENDENCY_SELECTOR_KEY}`);
expect(retval.value).toBe(value);
});
it('toggleDependencySelector', () => {
const value = { setup: "setup" };
const retval = toggleDependencySelector(true, value);
expect(retval).toExist();
expect(retval.type).toBe(EDITOR_SETTING_CHANGE);
expect(retval.key).toBe(`${DEPENDENCY_SELECTOR_KEY}`);
expect(retval.value.setup).toBe("setup");
expect(retval.value.active).toBe(true);
});

});
5 changes: 4 additions & 1 deletion web/client/actions/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const SET_EDITOR_AVAILABLE = "DASHBOARD:SET_AVAILABLE";
const SET_EDITING = "DASHBOARD:SET_EDITING";
const SHOW_CONNECTIONS = "DASHBOARD:SHOW_CONNECTIONS";
module.exports = {
SET_EDITING,
setEditing: (editing) => ({type: SET_EDITING, editing }),
SET_EDITOR_AVAILABLE,
setEditorAvailable: available => ({type: SET_EDITOR_AVAILABLE, available})
setEditorAvailable: available => ({type: SET_EDITOR_AVAILABLE, available}),
SHOW_CONNECTIONS,
triggerShowConnections: show => ({ type: SHOW_CONNECTIONS, show})
};
24 changes: 21 additions & 3 deletions web/client/actions/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const TEXT_SEARCH_ERROR = 'TEXT_SEARCH_ERROR';
const TEXT_SEARCH_CANCEL_ITEM = 'TEXT_SEARCH_CANCEL_ITEM';
const TEXT_SEARCH_ITEM_SELECTED = 'TEXT_SEARCH_ITEM_SELECTED';
const TEXT_SEARCH_SET_HIGHLIGHTED_FEATURE = 'TEXT_SEARCH_SET_HIGHLIGHTED_FEATURE';
const UPDATE_RESULTS_STYLE = 'UPDATE_RESULTS_STYLE';

/**
* updates the results of the search result loaded
* @memberof actions.search
Expand Down Expand Up @@ -120,12 +122,14 @@ function textSearch(searchText, {services = null} = {}) {
* @memberof actions.search
* @param {object} item the selected item
* @param {object} mapConfig the current map configuration (with size, projection...)
* @param {object} resultsStyle style to apply to results geometries
*/
function selectSearchItem(item, mapConfig) {
function selectSearchItem(item, mapConfig, resultsStyle) {
return {
type: TEXT_SEARCH_ITEM_SELECTED,
item,
mapConfig
mapConfig,
resultsStyle
};

}
Expand Down Expand Up @@ -171,6 +175,18 @@ function setHighlightedFeature(feature) {
};
}

/**
* Change default style of results geometries
* @memberof actions.search
* @param {object} style style of results geometries
*/
function updateResultsStyle(style) {
return {
type: UPDATE_RESULTS_STYLE,
style
};
}

/**
* Actions for search
* @name actions.search
Expand All @@ -189,6 +205,7 @@ module.exports = {
TEXT_SEARCH_NESTED_SERVICES_SELECTED,
TEXT_SEARCH_CANCEL_ITEM,
TEXT_SEARCH_SET_HIGHLIGHTED_FEATURE,
UPDATE_RESULTS_STYLE,
searchTextLoading,
searchResultError,
searchResultLoaded,
Expand All @@ -200,5 +217,6 @@ module.exports = {
selectNestedService,
selectSearchItem,
cancelSelectedItem,
setHighlightedFeature
setHighlightedFeature,
updateResultsStyle
};
60 changes: 58 additions & 2 deletions web/client/actions/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ const ADD_DEPENDENCY = "WIDGETS:ADD_DEPENDENCY";
const REMOVE_DEPENDENCY = "WIDGETS:REMOVE_DEPENDENCY";
const LOAD_DEPENDENCIES = "WIDGETS:LOAD_DEPENDENCIES";
const RESET_DEPENDENCIES = "WIDGETS:RESET_DEPENDENCIES";
const TOGGLE_CONNECTION = "WIDGETS:TOGGLE_CONNECTION";

const OPEN_FILTER_EDITOR = "WIDGETS:OPEN_FILTER_EDITOR";
const EXPORT_CSV = "WIDGETS:EXPORT_CSV";
const EXPORT_IMAGE = "WIDGETS:EXPORT_IMAGE";
const WIDGET_SELECTED = "WIDGETS:WIDGET_SELECTED";
const DEFAULT_TARGET = "floating";
const DEPENDENCY_SELECTOR_KEY = "dependencySelector";
const WIDGETS_REGEX = /^widgets\["?([^"\]]*)"?\]\.?(.*)$/;


/**
Expand Down Expand Up @@ -170,6 +174,20 @@ const loadDependencies = (dependencies) => ({
type: LOAD_DEPENDENCIES,
dependencies
});

/**
* Action triggered to start the connection flow. Typically starts the connection flow
* @param {array} availableDependencies Array of available dependency keys
* @param {object} options a map of connections to apply when the dependencies has been resolved
* @param {string} target target of the connection. If not present we assume is the current editing widget (not yet supported)
*/
const toggleConnection = (active, availableDependencies, options, target) => ({
type: TOGGLE_CONNECTION,
active,
availableDependencies,
options,
target
});
/**
* Change the page setting of the editor
* @param {number} step the page number
Expand All @@ -187,11 +205,40 @@ const exportCSV = ({data= [], title = "export"}) => ({
title
});

const selectWidget = (widget, opts) => ({
type: WIDGET_SELECTED,
widget,
opts
});
const exportImage = ({widgetDivId}) => ({
type: EXPORT_IMAGE,
widgetDivId
});
/**
* Triggers the filter editor opening
*/
const openFilterEditor = () => ({type: OPEN_FILTER_EDITOR});
/**
* Changes the setup of the dependency selector, that allow to select a dependent widget
* @param {object} setup the initial setup of the dependency selector
*/
const setupDependencySelector = (setup) => changeEditorSetting(`${DEPENDENCY_SELECTOR_KEY}`, setup);
/**
* Sets a value in the configuration of the dependency selector
* @param {string} key the configuration of the dependency selector to change
* @param {any} value the value to assign to the key
*/
const changeDependencySelector = (key, value) => changeEditorSetting(`${DEPENDENCY_SELECTOR_KEY}[${key}]`, value);
/**
* Activate/deactivate the dependency selector with an initial setup
* @param {boolean} active active flag of the dependency selector
* @param {object} settings initial setup
*/
const toggleDependencySelector = (active, settings) => setupDependencySelector({
active,
...settings
});

module.exports = {
NEW,
INSERT,
Expand All @@ -208,10 +255,11 @@ module.exports = {
REMOVE_DEPENDENCY,
LOAD_DEPENDENCIES,
RESET_DEPENDENCIES,
DEFAULT_TARGET,
OPEN_FILTER_EDITOR,
EXPORT_CSV,
EXPORT_IMAGE,
TOGGLE_CONNECTION,
WIDGET_SELECTED,
exportCSV,
exportImage,
openFilterEditor,
Expand All @@ -226,9 +274,17 @@ module.exports = {
editNewWidget,
onEditorChange,
changeEditorSetting,
toggleConnection,
selectWidget,
addDependency,
removeDependency,
loadDependencies,
resetDependencies,
setPage
setPage,
changeDependencySelector,
setupDependencySelector,
toggleDependencySelector,
DEPENDENCY_SELECTOR_KEY,
DEFAULT_TARGET,
WIDGETS_REGEX
};
5 changes: 3 additions & 2 deletions web/client/components/charts/Pie.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* LICENSE file in the root directory of this source tree.
*/
const React = require('react');
const {pure} = require('recompose');
const {PieChart, Pie, Cell} = require('recharts');
const {convertToNameValue} = require('./polar');

module.exports = ({isAnimationActive, width = 600, height = 300, data, series =[], xAxis, colorGenerator, ...props, maxCols = 3} = {}) => {
module.exports = pure(({isAnimationActive, width = 600, height = 300, data, series =[], xAxis, colorGenerator, ...props, maxCols = 3} = {}) => {
const seriesArray = Array.isArray(series) ? series : [series];
const cols = Math.min(maxCols, seriesArray.length);
const COLORS = colorGenerator(data.length);
Expand All @@ -33,4 +34,4 @@ module.exports = ({isAnimationActive, width = 600, height = 300, data, series =[
}
{props.children}
</PieChart>);
};
});
2 changes: 1 addition & 1 deletion web/client/components/charts/SimpleChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const AUTOCOLOR_DEFAULTS = {
* @param {String} [type="line"] Type of the chart. One of "line", "pie", "bar", "gauge"
* @param {Object} [tooltip={}] false to disable tooltip. TooltipOptions otherwise
* @param {Object} [legend={}] false to disable legend. Legend options otherwise
* @param {Object} [autoColorOptions] [description] Optiopns to generate colors for the chart
* @param {Object} [autoColorOptions] [description] Options to generate colors for the chart
* @param {[type]} props [description]
*/
const SimpleChart = ({type="line", tooltip = {}, legend = {}, autoColorOptions = AUTOCOLOR_DEFAULTS, colorGenerator, ...props} = {}) => {
Expand Down
12 changes: 9 additions & 3 deletions web/client/components/dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@
* LICENSE file in the root directory of this source tree.
*/
const React = require('react');
const {pure, compose} = require('recompose');
const {pure, compose, defaultProps} = require('recompose');
const Message = require('../I18N/Message');
const emptyState = require('../misc/enhancers/emptyState');
const withSelection = require('../widgets/view/enhancers/withSelection');

module.exports =
compose(
pure,
emptyState(
({widgets = []} = {}) => widgets.length === 0,
() => ({
glyph: "dashboard",
title: <Message msgId="dashboard.emptyTitle" /> // TODO i18n
title: <Message msgId="dashboard.emptyTitle" />
})
)
),
defaultProps({
isWidgetSelectable: ({}) => true
}),
withSelection
)(require('../widgets/view/WidgetsView'));
10 changes: 6 additions & 4 deletions web/client/components/map/leaflet/Feature.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const geometryToLayer = function(geojson, options) {
if (!coords && !geometry) {
return null;
}

const style = options.style && options.style[geometry.type] || options.style;
let layer;
switch (geometry.type) {
case 'Point':
Expand All @@ -71,13 +73,13 @@ const geometryToLayer = function(geojson, options) {

case 'LineString':
latlngs = coordsToLatLngs(coords, geometry.type === 'LineString' ? 0 : 1, coordsToLatLng);
layer = new L.Polyline(latlngs, options.style);
layer = new L.Polyline(latlngs, style);
layer.msId = geojson.id;
return layer;
case 'MultiLineString':
latlngs = coordsToLatLngs(coords, geometry.type === 'LineString' ? 0 : 1, coordsToLatLng);
for (i = 0, len = latlngs.length; i < len; i++) {
layer = new L.Polyline(latlngs[i], options.style);
layer = new L.Polyline(latlngs[i], style);
layer.msId = geojson.id;
if (layer) {
layers.push(layer);
Expand All @@ -86,13 +88,13 @@ const geometryToLayer = function(geojson, options) {
return new L.FeatureGroup(layers);
case 'Polygon':
latlngs = coordsToLatLngs(coords, geometry.type === 'Polygon' ? 1 : 2, coordsToLatLng);
layer = new L.Polygon(latlngs, options.style);
layer = new L.Polygon(latlngs, style);
layer.msId = geojson.id;
return layer;
case 'MultiPolygon':
latlngs = coordsToLatLngs(coords, geometry.type === 'Polygon' ? 1 : 2, coordsToLatLng);
for (i = 0, len = latlngs.length; i < len; i++) {
layer = new L.Polygon(latlngs[i], options.style);
layer = new L.Polygon(latlngs[i], style);
layer.msId = geojson.id;
if (layer) {
layers.push(layer);
Expand Down
Loading

0 comments on commit 39f2024

Please sign in to comment.