forked from geosolutions-it/geonode-mapstore-client
-
Notifications
You must be signed in to change notification settings - Fork 101
/
gn-catalogue.js
222 lines (201 loc) · 9.04 KB
/
gn-catalogue.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/*
* Copyright 2021, 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.
*/
import main from '@mapstore/framework/components/app/main';
import Router, { withRoutes } from '@js/components/Router';
import MainLoader from '@js/components/MainLoader';
import { connect } from 'react-redux';
import { getConfigProp, setConfigProp } from '@mapstore/framework/utils/ConfigUtils';
import { loadPrintCapabilities } from '@mapstore/framework/actions/print';
import StandardApp from '@mapstore/framework/components/app/StandardApp';
import geostory from '@mapstore/framework/reducers/geostory';
import withExtensions from '@mapstore/framework/components/app/withExtensions';
// the app needs this epics and reducers from mapstore to correctly initialize some functionalities
import controls from '@mapstore/framework/reducers/controls';
import maptype from '@mapstore/framework/reducers/maptype';
import security from '@mapstore/framework/reducers/security';
import print from '@mapstore/framework/reducers/print';
import {
standardReducers,
standardEpics,
standardRootReducerFunc
} from '@mapstore/framework/stores/defaultOptions';
import timeline from '@mapstore/framework/reducers/timeline';
import dimension from '@mapstore/framework/reducers/dimension';
import playback from '@mapstore/framework/reducers/playback';
import mapPopups from '@mapstore/framework/reducers/mapPopups';
import catalog from '@mapstore/framework/reducers/catalog';
import searchconfig from '@mapstore/framework/reducers/searchconfig';
import widgets from '@mapstore/framework/reducers/widgets';
import context from '@mapstore/framework/reducers/context';
// end
import ViewerRoute from '@js/routes/Viewer';
import UploadDatasetRoute from '@js/routes/UploadDataset';
import UploadDocumentRoute from '@js/routes/UploadDocument';
import CatalogueRoute from '@js/routes/Catalogue';
import MapViewerRoute from '@js/routes/MapViewer';
import gnsearch from '@js/reducers/gnsearch';
import gnresource from '@js/reducers/gnresource';
import resourceservice from '@js/reducers/resourceservice';
import gnsettings from '@js/reducers/gnsettings';
import notifications from '@mapstore/framework/reducers/notifications';
import {
getConfiguration,
getEndpoints,
getAccountInfo
} from '@js/api/geonode/v2';
import {
setupConfiguration,
initializeApp,
getPluginsConfiguration,
getPluginsConfigOverride
} from '@js/utils/AppUtils';
import { CATALOGUE_ROUTES, appRouteComponentTypes } from '@js/utils/AppRoutesUtils';
import { updateGeoNodeSettings } from '@js/actions/gnsettings';
import {
gnCheckSelectedDatasetPermissions,
gnSetDatasetsPermissions,
// to make the current layout work we need this epic
// we should improve the layout to avoid the use of side effect to manage the page structure
updateMapLayoutEpic
} from '@js/epics';
import timelineEpics from '@mapstore/framework/epics/timeline';
import gnresourceEpics from '@js/epics/gnresource';
import resourceServiceEpics from '@js/epics/resourceservice';
import gnsearchEpics from '@js/epics/gnsearch';
import favoriteEpics from '@js/epics/favorite';
import maplayout from '@mapstore/framework/reducers/maplayout';
import pluginsDefinition, { storeEpicsNamesToExclude } from '@js/plugins/index';
import ReactSwipe from 'react-swipeable-views';
import SwipeHeader from '@mapstore/framework/components/data/identify/SwipeHeader';
import { registerMediaAPI } from '@mapstore/framework/api/media';
import * as geoNodeMediaApi from '@js/observables/media/geonode';
registerMediaAPI('geonode', geoNodeMediaApi);
import '@js/observables/persistence';
const requires = {
ReactSwipe,
SwipeHeader
};
const DEFAULT_LOCALE = {};
const ConnectedRouter = connect(
(state) => ({
locale: state?.locale || DEFAULT_LOCALE,
user: state?.security?.user || null
})
)(Router);
const viewers = {
[appRouteComponentTypes.VIEWER]: ViewerRoute,
[appRouteComponentTypes.CATALOGUE]: CatalogueRoute,
[appRouteComponentTypes.DATASET_UPLOAD]: UploadDatasetRoute,
[appRouteComponentTypes.DOCUMENT_UPLOAD]: UploadDocumentRoute,
[appRouteComponentTypes.MAP_VIEWER]: MapViewerRoute
};
const routes = CATALOGUE_ROUTES.map(({ component, ...config }) => ({ ...config, component: viewers[component] }));
initializeApp();
getEndpoints()
.then(()=> Promise.all([
getConfiguration(),
getAccountInfo()
])
.then(([localConfig, user]) => {
setupConfiguration({
localConfig,
user
})
.then(({
securityState,
geoNodeConfiguration,
pluginsConfigKey,
query,
configEpics,
mapType = 'openlayers',
onStoreInit,
targetId = 'ms-container',
settings
}) => {
// get the correct map layout
const mapLayout = getConfigProp('mapLayout') || {};
setConfigProp('mapLayout', mapLayout[query.theme] || mapLayout.viewer);
const appEpics = {
...standardEpics,
...configEpics,
gnCheckSelectedDatasetPermissions,
gnSetDatasetsPermissions,
...pluginsDefinition.epics,
...gnresourceEpics,
...resourceServiceEpics,
...gnsearchEpics,
...favoriteEpics,
updateMapLayoutEpic,
// needed to initialize the correct time range
...timelineEpics
};
storeEpicsNamesToExclude(appEpics);
// register custom arcgis layer
import('@js/map/' + mapType + '/plugins/ArcGisMapServer')
.then(() => {
main({
targetId,
enableExtensions: true,
appComponent: withRoutes(routes)(ConnectedRouter),
loaderComponent: MainLoader,
initialState: {
defaultState: {
...securityState
}
},
themeCfg: null,
pluginsConfig: getPluginsConfigOverride(getPluginsConfiguration(localConfig.plugins, pluginsConfigKey)),
pluginsDef: {
plugins: {
...pluginsDefinition.plugins
},
requires: {
...requires,
...pluginsDefinition.requires
}
},
printEnabled: true,
rootReducerFunc: standardRootReducerFunc,
onStoreInit,
appReducers: {
...standardReducers,
gnresource,
resourceservice,
gnsettings,
security,
maptype,
print,
maplayout,
controls,
timeline,
dimension,
playback,
mapPopups,
catalog,
searchconfig,
widgets,
geostory,
gnsearch,
notifications,
context,
...pluginsDefinition.reducers
},
appEpics,
geoNodeConfiguration,
initialActions: [
// add some settings in the global state to make them accessible in the monitor state
// later we could use expression in localConfig
updateGeoNodeSettings.bind(null, settings),
loadPrintCapabilities.bind(null, getConfigProp('printUrl'))
]
},
withExtensions(StandardApp));
});
});
})
);