forked from geosolutions-it/MapStore2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…ons-it#274 remove widget (geosolutions-it#275) * Fix geosolutions-it#271 AutoResourceUpdate implementation * Update context as well and others * updating epics logic for ignoring execution based on options * Update pr with changes to plugin config * update revision including fix for geosolutions-it#10622
- Loading branch information
Showing
17 changed files
with
434 additions
and
28 deletions.
There are no files selected for viewing
Submodule MapStore2
updated
9 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright 2024, 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. | ||
*/ | ||
|
||
export const START_UPDATING_RESOURCE = "AUTO_RESOURCE_UPDATE:START_UPDATING_RESOURCE"; | ||
|
||
export const startUpdatingResource = (options) => { | ||
return { | ||
type: START_UPDATING_RESOURCE, | ||
options | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
import AutoResourceUpdate from './plugins/AutoResourceUpdate'; | ||
import pluginsDef from '../MapStore2/web/client/product/apiPlugins'; | ||
const { plugins, requires } = pluginsDef; | ||
|
||
export default { | ||
plugins: { | ||
...plugins, | ||
AutoResourceUpdatePlugin: AutoResourceUpdate | ||
}, | ||
requires: { | ||
...requires | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/* | ||
* Copyright 2024, 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 Rx from 'rxjs'; | ||
import { isEmpty } from 'lodash'; | ||
|
||
import { MAP_CONFIG_LOADED, MAP_INFO_LOADED } from '../../MapStore2/web/client/actions/config'; | ||
import { warning } from '../../MapStore2/web/client/actions/notifications'; | ||
import { updateCatalogServices } from '../../MapStore2/web/client/actions/catalog'; | ||
import { replaceLayers } from '../../MapStore2/web/client/actions/layers'; | ||
import { isUserAllowedSelectorCreator } from '../../MapStore2/web/client/selectors/security'; | ||
import { DASHBOARD_LOADED, dashboardLoaded } from '../../MapStore2/web/client/actions/dashboard'; | ||
import { SET_CURRENT_STORY, setCurrentStory } from '../../MapStore2/web/client/actions/geostory'; | ||
|
||
import { START_UPDATING_RESOURCE } from '@js/actions/autoResourceUpdate'; | ||
import { getConfigProp } from '../../MapStore2/web/client/utils/ConfigUtils'; | ||
import { migrateAllUrls } from '../utils/AutoResourceUpdateUtils'; | ||
|
||
/** | ||
* Epics for update old map | ||
* @name epics.autoresourceupdate | ||
* @type {Object} | ||
*/ | ||
|
||
|
||
/** | ||
* When map has been loaded, it sends a notification if the version is less than 2 and users has write permission. | ||
* @param {external:Observable} action$ manages `MAP_CONFIG_LOADED` and `MAP_INFO_LOADED`. | ||
* @memberof epics.autoresourceupdate | ||
* @return {external:Observable} | ||
*/ | ||
export const manageAutoMapUpdateEpic = (action$, store) => | ||
action$.ofType(START_UPDATING_RESOURCE) | ||
.switchMap(() => | ||
action$.ofType(MAP_CONFIG_LOADED) | ||
.switchMap((mapConfigLoaded) => | ||
action$.ofType(MAP_INFO_LOADED) | ||
.take(1) | ||
.switchMap(() => { | ||
const state = store.getState(); | ||
const options = getConfigProp('AutoResourceUpdateOptions'); | ||
const showNotification = options?.showNotificationForRoles?.length && isUserAllowedSelectorCreator({ | ||
allowedRoles: options.showNotificationForRoles | ||
})(state); | ||
const layers = mapConfigLoaded?.config?.map?.layers || []; | ||
const newLayers = migrateAllUrls(layers, options.urlsToReplace); | ||
const services = mapConfigLoaded?.config?.catalogServices?.services; | ||
const newServices = migrateAllUrls(services, options.urlsToReplace); | ||
let actions = []; | ||
if (showNotification) { | ||
// show only for allowed roles, do not show it by default | ||
actions.push(warning({ | ||
title: "notification.warning", | ||
message: "notification.updateOldResource", | ||
autoDismiss: options.autoDismiss, | ||
position: "tc" | ||
})); | ||
} | ||
actions.push(updateCatalogServices(newServices)); | ||
actions.push(replaceLayers(newLayers)); | ||
if (isEmpty(options)) { | ||
return Rx.Observable.empty(); | ||
} | ||
return Rx.Observable.from(actions); | ||
}) | ||
)); | ||
|
||
/** | ||
* When map has been loaded, it sends a notification if the version is less than 2 and users has write permission. | ||
* @param {external:Observable} action$ manages `MAP_CONFIG_LOADED` and `MAP_INFO_LOADED`. | ||
* @memberof epics.autoresourceupdate | ||
* @return {external:Observable} | ||
*/ | ||
export const manageAutoDashboardUpdateEpic = (action$, store) => | ||
action$.ofType(START_UPDATING_RESOURCE) | ||
.switchMap(() => | ||
action$.ofType(DASHBOARD_LOADED) | ||
.take(1) | ||
.switchMap(({resource, data}) => { | ||
const state = store.getState(); | ||
const options = getConfigProp('AutoResourceUpdateOptions'); | ||
const showNotification = options?.showNotificationForRoles?.length && isUserAllowedSelectorCreator({ | ||
allowedRoles: options.showNotificationForRoles | ||
})(state); | ||
|
||
const newData = migrateAllUrls(data, options.urlsToReplace); | ||
let actions = []; | ||
if (showNotification) { | ||
// show only for allowed roles, do not show it by default | ||
actions.push(warning({ | ||
title: "notification.warning", | ||
message: "notification.updateOldResource", | ||
autoDismiss: options.autoDismiss, | ||
position: "tc" | ||
})); | ||
} | ||
actions.push(dashboardLoaded(resource, newData)); | ||
if (isEmpty(options)) { | ||
return Rx.Observable.empty(); | ||
} | ||
return Rx.Observable.from(actions); | ||
}) | ||
); | ||
|
||
|
||
/** | ||
* when a story is loaded a check is done and all urls are replaced | ||
* @param {external:Observable} action$ manages `START_UPDATING_RESOURCE` and `SET_CURRENT_STORY`. | ||
* @memberof epics.autoresourceupdate | ||
* @return {external:Observable} | ||
*/ | ||
export const manageAutoGeostoryUpdateEpic = (action$, store) => | ||
action$.ofType(START_UPDATING_RESOURCE) | ||
.switchMap(() => | ||
action$.ofType(SET_CURRENT_STORY) | ||
.filter(({story}) => !isEmpty(story)) | ||
.switchMap(({story}) => { | ||
const state = store.getState(); | ||
const options = getConfigProp('AutoResourceUpdateOptions'); | ||
const showNotification = options?.showNotificationForRoles?.length && isUserAllowedSelectorCreator({ | ||
allowedRoles: options.showNotificationForRoles | ||
})(state); | ||
|
||
const newStory = migrateAllUrls(story, options.urlsToReplace); | ||
let actions = []; | ||
if (showNotification) { | ||
// show only for allowed roles, do not show it by default | ||
actions.push(warning({ | ||
title: "notification.warning", | ||
message: "notification.updateOldResource", | ||
autoDismiss: options.autoDismiss, | ||
position: "tc" | ||
})); | ||
} | ||
actions.push(setCurrentStory(newStory)); | ||
if (isEmpty(options)) { | ||
return Rx.Observable.empty(); | ||
} | ||
return Rx.Observable.from(actions); | ||
}) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2024, 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 Rx from 'rxjs'; | ||
import {isEmpty} from 'lodash'; | ||
|
||
import { LOAD_MAP_CONFIG, MAP_CONFIG_LOADED } from '../../MapStore2/web/client/actions/config'; | ||
import { warning } from '../../MapStore2/web/client/actions/notifications'; | ||
import { updateCatalogServices } from '../../MapStore2/web/client/actions/catalog'; | ||
import { isUserAllowedSelectorCreator } from '../../MapStore2/web/client/selectors/security'; | ||
import { replaceLayers } from '../../MapStore2/web/client/actions/layers'; | ||
|
||
import { getConfigProp } from '../../MapStore2/web/client/utils/ConfigUtils'; | ||
import { migrateAllUrls } from '../utils/AutoResourceUpdateUtils'; | ||
|
||
|
||
/** | ||
* When map has been loaded, it sends a notification if the version is less than 2 and users has write permission. | ||
* @param {external:Observable} action$ manages `MAP_CONFIG_LOADED` and `MAP_INFO_LOADED`. | ||
* @memberof epics.autoresourceupdate | ||
* @return {external:Observable} | ||
*/ | ||
export const manageAutoContextUpdateEpic = (action$, store) => | ||
action$.ofType(LOAD_MAP_CONFIG) | ||
.switchMap(() => | ||
action$.ofType(MAP_CONFIG_LOADED) | ||
.take(1) | ||
.switchMap((mapConfigLoaded) => { | ||
const state = store.getState(); | ||
const options = getConfigProp('AutoResourceUpdateOptions'); | ||
const showNotification = options?.showNotificationForRoles?.length && isUserAllowedSelectorCreator({ | ||
allowedRoles: options.showNotificationForRoles | ||
})(state); | ||
const layers = mapConfigLoaded?.config?.map?.layers || []; | ||
const newLayers = migrateAllUrls(layers, options.urlsToReplace); | ||
const services = mapConfigLoaded?.config?.catalogServices?.services; | ||
const newServices = migrateAllUrls(services, options.urlsToReplace); | ||
let actions = []; | ||
if (showNotification) { | ||
// show only for allowed roles, do not show it by default | ||
actions.push(warning({ | ||
title: "notification.warning", | ||
message: "notification.updateOldResource", | ||
autoDismiss: options.autoDismiss, | ||
position: "tc" | ||
})); | ||
} | ||
actions.push(updateCatalogServices(newServices)); | ||
actions.push(replaceLayers(newLayers)); | ||
if (isEmpty(options)) { | ||
return Rx.Observable.empty(); | ||
} | ||
return Rx.Observable.from(actions); | ||
}) | ||
); |
Oops, something went wrong.