Skip to content

Commit afae226

Browse files
sijandh35dsuren1giohappyallyoucanmap
authored
[Fixes #2233 #2234 #2235] Implementation of dynamic request rules (#2244)
--------- Co-authored-by: Suren <[email protected]> Co-authored-by: G.Allegri <[email protected]> Co-authored-by: allyoucanmap <[email protected]>
1 parent c26e3cc commit afae226

File tree

19 files changed

+1105
-9
lines changed

19 files changed

+1105
-9
lines changed

geonode_mapstore_client/apps.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def run_setup_hooks(*args, **kwargs):
8888
),
8989
re_path(r"^metadata/(?P<pk>[^/]*)$", views.metadata, name='metadata'),
9090
re_path(r"^metadata/(?P<pk>[^/]*)/embed$", views.metadata_embed, name='metadata'),
91+
re_path(r"^api/v2/reqrules$", views.RequestConfigurationView.as_view(), name="request-rules"),
9192
# required, otherwise will raise no-lookup errors to be analysed
9293
re_path(r"^api/v2/", include(router.urls)),
9394

@@ -304,6 +305,11 @@ def run_setup_hooks(*args, **kwargs):
304305

305306
setattr(settings, "MAPSTORE_DASHBOARD_CATALOGUE_SELECTED_SERVICE", MAPSTORE_DASHBOARD_CATALOGUE_SELECTED_SERVICE)
306307
setattr(settings, "MAPSTORE_DASHBOARD_CATALOGUE_SERVICES", MAPSTORE_DASHBOARD_CATALOGUE_SERVICES)
308+
handlers = getattr(settings, "REQUEST_CONFIGURATION_RULES_HANDLERS", [])
309+
handlers.extend([
310+
"geonode_mapstore_client.handlers.BaseConfigurationRuleHandler",
311+
])
312+
setattr(settings, "REQUEST_CONFIGURATION_RULES_HANDLERS", handlers)
307313

308314

309315
def connect_geoserver_style_visual_mode_signal():
@@ -324,4 +330,8 @@ def ready(self):
324330
if not apps.ready:
325331
run_setup_hooks()
326332
connect_geoserver_style_visual_mode_signal()
333+
334+
from geonode_mapstore_client.registry import request_configuration_rules_registry
335+
request_configuration_rules_registry.init_registry()
336+
327337
super(AppConfig, self).ready()
Submodule MapStore2 updated 90 files
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright 2025, 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+
export const RULE_EXPIRED = 'GEONODE_SECURITY:RULE_EXPIRED';
10+
11+
export function ruleExpired() {
12+
return {
13+
type: RULE_EXPIRED
14+
};
15+
}

geonode_mapstore_client/client/js/api/geonode/security/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import axios from '@mapstore/framework/libs/ajax';
1010
import WKT from 'ol/format/WKT';
1111
import GeoJSON from 'ol/format/GeoJSON';
1212
import uuid from 'uuid';
13+
import { getEndpointUrl, RULES } from '../v2/constants';
1314

1415
const wktFormat = new WKT();
1516
const geoJSONFormat = new GeoJSON();
@@ -78,3 +79,8 @@ export const deleteGeoLimits = (resourceId, id, type = 'user') => {
7879
return axios.delete(`/security/geolimits/${resourceId}?${type}_id=${id}`)
7980
.then(({ data }) => data);
8081
};
82+
83+
export const getRequestRules = () => {
84+
return axios.get(getEndpointUrl(RULES))
85+
.then(({ data }) => data);
86+
};

geonode_mapstore_client/client/js/api/geonode/v2/constants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ let endpoints = {
3535
'facets': '/api/v2/facets',
3636
'uploads': '/api/v2/uploads',
3737
'metadata': '/api/v2/metadata',
38-
'assets': '/api/v2/assets'
38+
'assets': '/api/v2/assets',
39+
'rules': '/api/v2/reqrules'
3940
};
4041

4142
export const RESOURCES = 'resources';
@@ -51,6 +52,7 @@ export const FACETS = 'facets';
5152
export const UPLOADS = 'uploads';
5253
export const METADATA = 'metadata';
5354
export const ASSETS = 'assets';
55+
export const RULES = 'rules';
5456

5557
export const setEndpoints = (data) => {
5658
endpoints = { ...endpoints, ...data };

geonode_mapstore_client/client/js/apps/gn-catalogue.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import {
7272

7373
import timelineEpics from '@mapstore/framework/epics/timeline';
7474
import gnresourceEpics from '@js/epics/gnresource';
75+
import securityEpics from '@js/epics/security';
7576
import resourceServiceEpics from '@js/epics/resourceservice';
7677
import maplayout from '@mapstore/framework/reducers/maplayout';
7778

@@ -149,7 +150,8 @@ getEndpoints()
149150
...resourceServiceEpics,
150151
updateMapLayoutEpic,
151152
// needed to initialize the correct time range
152-
...timelineEpics
153+
...timelineEpics,
154+
...securityEpics
153155
});
154156

155157
storeEpicsNamesToExclude(appEpics);

geonode_mapstore_client/client/js/apps/gn-components.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { updateGeoNodeSettings } from '@js/actions/gnsettings';
3030
import { COMPONENTS_ROUTES, appRouteComponentTypes } from '@js/utils/AppRoutesUtils';
3131
import gnresourceEpics from '@js/epics/gnresource';
3232
import resourceServiceEpics from '@js/epics/resourceservice';
33+
import securityEpics from '@js/epics/security';
3334

3435
import gnresource from '@js/reducers/gnresource';
3536
import resourceservice from '@js/reducers/resourceservice';
@@ -75,6 +76,7 @@ document.addEventListener('DOMContentLoaded', function() {
7576
...configEpics,
7677
...gnresourceEpics,
7778
...resourceServiceEpics,
79+
...securityEpics,
7880
gnListenToResourcesPendingExecution
7981
});
8082

geonode_mapstore_client/client/js/apps/gn-dashboard.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import ReactSwipe from 'react-swipeable-views';
3737
import SwipeHeader from '@mapstore/framework/components/data/identify/SwipeHeader';
3838
import { requestResourceConfig } from '@js/actions/gnresource';
3939
import gnresourceEpics from '@js/epics/gnresource';
40+
import securityEpics from '@js/epics/security';
4041
const requires = {
4142
ReactSwipe,
4243
SwipeHeader
@@ -81,7 +82,8 @@ document.addEventListener('DOMContentLoaded', function() {
8182

8283
const appEpics = cleanEpics({
8384
...configEpics,
84-
...gnresourceEpics
85+
...gnresourceEpics,
86+
...securityEpics
8587
});
8688

8789
storeEpicsNamesToExclude(appEpics);

geonode_mapstore_client/client/js/apps/gn-document.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import ReactSwipe from 'react-swipeable-views';
3333
import SwipeHeader from '@mapstore/framework/components/data/identify/SwipeHeader';
3434
import { requestResourceConfig } from '@js/actions/gnresource';
3535
import gnresourceEpics from '@js/epics/gnresource';
36+
import securityEpics from '@js/epics/security';
3637
const requires = {
3738
ReactSwipe,
3839
SwipeHeader
@@ -76,7 +77,8 @@ document.addEventListener('DOMContentLoaded', function() {
7677

7778
const appEpics = cleanEpics({
7879
...configEpics,
79-
...gnresourceEpics
80+
...gnresourceEpics,
81+
...securityEpics
8082
});
8183

8284
storeEpicsNamesToExclude(appEpics);

geonode_mapstore_client/client/js/apps/gn-geostory.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
import { updateGeoNodeSettings } from '@js/actions/gnsettings';
2727
import { requestResourceConfig } from '@js/actions/gnresource';
2828
import gnresourceEpics from '@js/epics/gnresource';
29+
import securityEpics from '@js/epics/security';
2930
import {
3031
setupConfiguration,
3132
initializeApp,
@@ -84,7 +85,8 @@ document.addEventListener('DOMContentLoaded', function() {
8485

8586
const appEpics = cleanEpics({
8687
...configEpics,
87-
...gnresourceEpics
88+
...gnresourceEpics,
89+
...securityEpics
8890
});
8991

9092
storeEpicsNamesToExclude(appEpics);

0 commit comments

Comments
 (0)