@@ -11,9 +11,7 @@ const assign = require('object-assign');
1111
1212const ConfigUtils = require ( '../../utils/ConfigUtils' ) ;
1313const EMPTY_RULE = {
14- constraints : {
15- allowedStyles : { style : [ ] }
16- } ,
14+ constraints : { } ,
1715 ipaddress : "" ,
1816 layer : "" ,
1917 request : "" ,
@@ -25,14 +23,24 @@ const EMPTY_RULE = {
2523const 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} ;
3436var 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 }
0 commit comments