Skip to content

Commit

Permalink
include epics needed for timeline at app initialization (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap authored Jan 28, 2022
1 parent 66a0f73 commit 74d9fd6
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 42 deletions.
34 changes: 21 additions & 13 deletions geonode_mapstore_client/client/js/apps/gn-catalogue.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ import {
import {
setupConfiguration,
initializeApp,
getPluginsConfiguration
getPluginsConfiguration,
storeEpicsCache
} from '@js/utils/AppUtils';
import { ResourceTypes } from '@js/utils/ResourceUtils';
import { updateGeoNodeSettings } from '@js/actions/gnsettings';
Expand All @@ -69,6 +70,7 @@ import {
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';
Expand Down Expand Up @@ -224,6 +226,23 @@ Promise.all([
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
};

storeEpicsCache(appEpics);

// register custom arcgis layer
import('@js/map/' + mapType + '/plugins/ArcGisMapServer')
.then(() => {
Expand Down Expand Up @@ -284,18 +303,7 @@ Promise.all([
annotations,
...pluginsDefinition.reducers
},
appEpics: {
...standardEpics,
...configEpics,
gnCheckSelectedDatasetPermissions,
gnSetDatasetsPermissions,
...pluginsDefinition.epics,
...gnresourceEpics,
...resourceServiceEpics,
...gnsearchEpics,
...favoriteEpics,
updateMapLayoutEpic
},
appEpics,
geoNodeConfiguration,
initialActions: [
// add some settings in the global state to make them accessible in the monitor state
Expand Down
16 changes: 11 additions & 5 deletions geonode_mapstore_client/client/js/apps/gn-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import {
import {
setupConfiguration,
initializeApp,
getPluginsConfiguration
getPluginsConfiguration,
storeEpicsCache
} from '@js/utils/AppUtils';
import { ResourceTypes } from '@js/utils/ResourceUtils';
import pluginsDefinition from '@js/plugins/index';
Expand Down Expand Up @@ -79,6 +80,14 @@ document.addEventListener('DOMContentLoaded', function() {
targetId = 'ms-container',
settings
}) => {

const appEpics = {
...configEpics,
...gnresourceEpics
};

storeEpicsCache(appEpics);

import('@js/map/' + mapType + '/plugins/ArcGisMapServer')
.then(() => {
main({
Expand Down Expand Up @@ -113,10 +122,7 @@ document.addEventListener('DOMContentLoaded', function() {
maptype,
widgets
},
appEpics: {
...configEpics,
...gnresourceEpics
},
appEpics,
onStoreInit,
geoNodeConfiguration,
initialActions: [
Expand Down
16 changes: 11 additions & 5 deletions geonode_mapstore_client/client/js/apps/gn-geostory.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import gnresourceEpics from '@js/epics/gnresource';
import {
setupConfiguration,
initializeApp,
getPluginsConfiguration
getPluginsConfiguration,
storeEpicsCache
} from '@js/utils/AppUtils';
import { ResourceTypes } from '@js/utils/ResourceUtils';
import pluginsDefinition from '@js/plugins/index';
Expand Down Expand Up @@ -79,6 +80,14 @@ document.addEventListener('DOMContentLoaded', function() {
targetId = 'ms-container',
settings
}) => {

const appEpics = {
...configEpics,
...gnresourceEpics
};

storeEpicsCache(appEpics);

// register custom arcgis layer
import('@js/map/' + mapType + '/plugins/ArcGisMapServer')
.then(() => {
Expand Down Expand Up @@ -113,10 +122,7 @@ document.addEventListener('DOMContentLoaded', function() {
security,
maptype
},
appEpics: {
...configEpics,
...gnresourceEpics
},
appEpics,
onStoreInit,
geoNodeConfiguration,
initialActions: [
Expand Down
16 changes: 10 additions & 6 deletions geonode_mapstore_client/client/js/apps/gn-home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import {

import {
setupConfiguration,
initializeApp
initializeApp,
storeEpicsCache
} from '@js/utils/AppUtils';

const DEFAULT_LOCALE = {};
Expand Down Expand Up @@ -65,6 +66,13 @@ Promise.all([
securityState,
geoNodeConfiguration
}) => {
const appEpics = {
...gnsearchEpics,
...gnsaveEpics,
...resourceServiceEpics
};

storeEpicsCache(appEpics);
// home app entry point
main({
appComponent: withRoutes(routes)(ConnectedRouter),
Expand All @@ -83,11 +91,7 @@ Promise.all([
security,
controls
},
appEpics: {
...gnsearchEpics,
...gnsaveEpics,
...resourceServiceEpics
},
appEpics,
geoNodeConfiguration
});
});
Expand Down
29 changes: 19 additions & 10 deletions geonode_mapstore_client/client/js/apps/gn-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ import { getConfiguration, getAccountInfo } from '@js/api/geonode/v2';
import {
setupConfiguration,
initializeApp,
getPluginsConfiguration
getPluginsConfiguration,
storeEpicsCache
} from '@js/utils/AppUtils';
import { ResourceTypes } from '@js/utils/ResourceUtils';
import { requestResourceConfig } from '@js/actions/gnresource';
Expand All @@ -57,6 +58,8 @@ import {
gnCheckSelectedDatasetPermissions,
gnSetDatasetsPermissions
} from '@js/epics';

import timelineEpics from '@mapstore/framework/epics/timeline';
import gnresourceEpics from '@js/epics/gnresource';
import maplayout from '@mapstore/framework/reducers/maplayout';
import 'react-widgets/dist/css/react-widgets.css';
Expand Down Expand Up @@ -116,6 +119,20 @@ document.addEventListener('DOMContentLoaded', function() {

const resourceId = geoNodePageConfig.resourceId;

const appEpics = {
...standardEpics,
...configEpics,
updateMapLayoutEpic,
gnCheckSelectedDatasetPermissions,
gnSetDatasetsPermissions,
...gnresourceEpics,
...pluginsDefinition.epics,
// needed to initialize the correct time range
...timelineEpics
};

storeEpicsCache(appEpics);

// register custom arcgis layer
import('@js/map/' + mapType + '/plugins/ArcGisMapServer')
.then(() => {
Expand Down Expand Up @@ -165,15 +182,7 @@ document.addEventListener('DOMContentLoaded', function() {
widgets,
...pluginsDefinition.reducers
},
appEpics: {
...standardEpics,
...configEpics,
updateMapLayoutEpic,
gnCheckSelectedDatasetPermissions,
gnSetDatasetsPermissions,
...gnresourceEpics,
...pluginsDefinition.epics
},
appEpics,
geoNodeConfiguration,
initialActions: [
// add some settings in the global state to make them accessible in the monitor state
Expand Down
6 changes: 3 additions & 3 deletions geonode_mapstore_client/client/js/hooks/useLazyPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import isEmpty from 'lodash/isEmpty';
import { getPlugins, createPlugin, isMapStorePlugin } from '@mapstore/framework/utils/PluginsUtils';
import { augmentStore } from '@mapstore/framework/utils/StateUtils';
import join from 'lodash/join';
import { getEpicCache, setEpicCache } from '@js/utils/AppUtils';

function filterRemoved(registry, removed = []) {
return Object.keys(registry).reduce((acc, p) => {
Expand All @@ -26,7 +27,6 @@ function filterRemoved(registry, removed = []) {

let storedPlugins = {};
const pluginsCache = {};
const epicsCache = {};
const reducersCache = {};

function useLazyPlugins({
Expand Down Expand Up @@ -78,10 +78,10 @@ function useLazyPlugins({
// so we need to filter out the one previously added and include only new one
const filterOutExistingEpics = Object.keys(epics)
.reduce((acc, key) => {
if (epicsCache[key]) {
if (getEpicCache(key)) {
return acc;
}
epicsCache[key] = true;
setEpicCache(key);
return {
...acc,
[key]: epics[key]
Expand Down
10 changes: 10 additions & 0 deletions geonode_mapstore_client/client/js/utils/AppUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import url from 'url';
import axios from '@mapstore/framework/libs/ajax';
import { addLocaleData } from 'react-intl';

let epicsCache = {};
let actionListeners = {};
// Target url here to fix proxy issue
let targetURL = '';
Expand All @@ -48,6 +49,15 @@ const getTargetUrl = () => {
return targetURL;
};

export const storeEpicsCache = (epics) => {
Object.keys(epics).forEach((key) => {
epicsCache[key] = true;
});
};

export const getEpicCache = (name) => epicsCache[name];
export const setEpicCache = (name) => { epicsCache[name] = true; };

export function getVersion() {
if (!__DEVTOOLS__) {
return __MAPSTORE_PROJECT_CONFIG__.version;
Expand Down

0 comments on commit 74d9fd6

Please sign in to comment.