Skip to content

Commit bf5ad67

Browse files
kappu72offtherailz
authored andcommitted
Added area editor (#2891)
1 parent 4ca7bad commit bf5ad67

36 files changed

Lines changed: 1184 additions & 110 deletions

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
"url": "0.10.3",
197197
"uuid": "3.0.1",
198198
"w3c-schemas": "1.3.1",
199+
"wellknown": "0.5.0",
199200
"wkt-parser": "https://github.com/geosolutions-it/wkt-parser/tarball/mapstore2_fixes",
200201
"xml2js": "0.4.17"
201202
},

web/client/actions/rulesmanager.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ const EDIT_RULE = "RULES_MANAGER:EDIT_RULE";
2424
const CLEAN_EDITING = "RULES_MANAGER:CLEAN_EDITING";
2525
const SAVE_RULE = "RULES_MANAGER:SAVE_RULE";
2626
const RULE_SAVED = "RULES_MANAGER:RULE_SAVED";
27-
const DELETE_RULES = "RULES_MANAGER: DELETE_RULES";
27+
const DELETE_RULES = "RULES_MANAGER:DELETE_RULES";
28+
const CACHE_CLEAN = "RULES_MANAGER:CACHE_CLEAN";
2829

30+
function onCacheClean() {
31+
return {
32+
type: CACHE_CLEAN
33+
};
34+
}
2935
function delRules(ids) {
3036
return {
3137
type: DELETE_RULES,
@@ -277,5 +283,6 @@ module.exports = {
277283
EDIT_RULE, onEditRule,
278284
CLEAN_EDITING, cleanEditing,
279285
SAVE_RULE, saveRule, RULE_SAVED,
280-
DELETE_RULES, delRules
286+
DELETE_RULES, delRules,
287+
CACHE_CLEAN, onCacheClean
281288
};

web/client/api/WMS.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ const Api = {
189189
},
190190
getBBox: function(record, bounds) {
191191
let layer = record;
192-
let bbox = (layer.EX_GeographicBoundingBox || CoordinatesUtils.getWMSBoundingBox(layer.BoundingBox) || (layer.LatLonBoundingBox && layer.LatLonBoundingBox.$) || layer.latLonBoundingBox);
192+
let bbox = (layer.EX_GeographicBoundingBox || layer.exGeographicBoundingBox || CoordinatesUtils.getWMSBoundingBox(layer.BoundingBox) || (layer.LatLonBoundingBox && layer.LatLonBoundingBox.$) || layer.latLonBoundingBox);
193193
while (!bbox && layer.Layer && layer.Layer.length) {
194194
layer = layer.Layer[0];
195-
bbox = (layer.EX_GeographicBoundingBox || CoordinatesUtils.getWMSBoundingBox(layer.BoundingBox) || (layer.LatLonBoundingBox && layer.LatLonBoundingBox.$) || layer.latLonBoundingBox);
195+
bbox = (layer.EX_GeographicBoundingBox || layer.exGeographicBoundingBox || CoordinatesUtils.getWMSBoundingBox(layer.BoundingBox) || (layer.LatLonBoundingBox && layer.LatLonBoundingBox.$) || layer.latLonBoundingBox);
196196
}
197197
if (!bbox) {
198198
bbox = {

web/client/api/geoserver/GeoFence.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ const assign = require('object-assign');
1111

1212
const ConfigUtils = require('../../utils/ConfigUtils');
1313
const EMPTY_RULE = {
14-
constraints: {
15-
allowedStyles: {style: []}
16-
},
14+
constraints: {},
1715
ipaddress: "",
1816
layer: "",
1917
request: "",
@@ -25,14 +23,24 @@ const EMPTY_RULE = {
2523
const cleanConstraints = (rule) => {
2624
if (!rule.constraints ) {
2725
return rule;
26+
}else if (rule.grant === "DENY") {
27+
const {constraints: omit, ...r} = rule;
28+
return r;
2829
}
2930
let constraints = {...rule.constraints};
3031
constraints.allowedStyles = constraints.allowedStyles && constraints.allowedStyles.style || [];
3132
constraints.attributes = constraints.attributes && constraints.attributes.attribute || [];
33+
constraints.restrictedAreaWkt = constraints.restrictedAreaWkt || "";
3234
return {...rule, constraints};
3335
};
3436
var Api = {
35-
37+
cleanCache: () => {
38+
return axios.get('rest/geofence/ruleCache/invalidate', Api.addBaseUrlGS())
39+
.then(function(response) {
40+
return response.data;
41+
}
42+
);
43+
},
3644
loadRules: function(page, rulesFiltersValues, entries = 10) {
3745
const params = {
3846
page,
@@ -92,9 +100,9 @@ var Api = {
92100

93101
updateRule: function(rule) {
94102
// id, priority and grant aren't updatable
95-
const {id, priority, grant, position, ...others} = rule;
103+
const {id, priority, grant, position, ...others} = cleanConstraints(rule);
96104
const newRule = {...EMPTY_RULE, ...others};
97-
return axios.put(`geofence/rest/rules/id/${id}`, cleanConstraints(newRule), this.addBaseUrl({
105+
return axios.put(`geofence/rest/rules/id/${id}`, newRule, this.addBaseUrl({
98106
'headers': {
99107
'Content': 'application/json'
100108
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
10+
const enhancer = require("./enhancers/Map");
11+
const autoMapType = require('../../map/enhancers/autoMapType');
12+
const mapType = require('../../map/enhancers/mapType');
13+
const autoResize = require('../../map/enhancers/autoResize');
14+
const onMapViewChanges = require('../../map/enhancers/onMapViewChanges');
15+
const withDraw = require("../../map/enhancers/withDraw");
16+
const {compose} = require('recompose');
17+
18+
const MapWitDraw = compose(
19+
enhancer,
20+
onMapViewChanges,
21+
autoResize(0),
22+
autoMapType,
23+
mapType,
24+
withDraw()
25+
)(require('../../map/BaseMap'));
26+
27+
const Portal = require('react-overlays').Portal;
28+
29+
module.exports = ({layer, onMapReady = () => {}}) => {
30+
return (
31+
<Portal container={document.querySelector('.rules-data-gird')}>
32+
<div className="rules-manager-map-modal" style={{position: "absolute", zIndex: 11, top: 0, bottom: 0, width: "100%"}}>
33+
<MapWitDraw
34+
onMapReady={onMapReady}
35+
options={{ style: { margin: 10, height: 'calc(100% - 20px)' }}}
36+
layer={layer}
37+
tools={["draw"]}/>
38+
</div>
39+
</Portal>);
40+
};
41+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 PropTypes = require('prop-types');
11+
const Button = require("../../misc/toolbar/ToolbarButton");
12+
const ContainerDimensions = require('react-container-dimensions').default;
13+
const {Controlled: Codemirror} = require('react-codemirror2');
14+
require('codemirror/lib/codemirror.css');
15+
require('codemirror/mode/sql/sql');
16+
const LocaleUtils = require('../../../utils/LocaleUtils');
17+
18+
19+
class RoiCql extends React.Component {
20+
static propTypes = {
21+
wkt: PropTypes.string,
22+
onChangeFilter: PropTypes.func
23+
};
24+
static contextTypes = {
25+
messages: PropTypes.object
26+
};
27+
constructor(props) {
28+
super(props);
29+
this.state = {cql: props.wkt};
30+
}
31+
componentWillReceiveProps({wkt: nw}) {
32+
if (nw !== this.props.wkt) {
33+
this.setState({cql: nw});
34+
}
35+
}
36+
onChange = (editor, data, value) => {
37+
this.setState(() => ({cql: value}));
38+
}
39+
render() {
40+
return (
41+
<ContainerDimensions>
42+
{({width}) =>
43+
<div style={{width, display: "flex", flexDirection: "column"}}>
44+
<Codemirror
45+
value={this.state.cql}
46+
onBeforeChange={this.onChange}
47+
options={{
48+
mode: {name: "sql"},
49+
lineNumbers: true,
50+
lineWrapping: true
51+
}}/>
52+
<Button disabled={this.props.wkt === this.state.cql} text={LocaleUtils.getMessageById(this.context.messages, "rulesmanager.apply")} onClick={this.apply}/>
53+
</div>}
54+
</ContainerDimensions>);
55+
}
56+
apply = () => {
57+
if (this.props.onChangeFilter) {
58+
this.props.onChangeFilter(this.state.cql);
59+
}
60+
}
61+
}
62+
63+
module.exports = RoiCql;

0 commit comments

Comments
 (0)