Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 2x 3x 3x 3x 3x 3x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 1x 3x 3x 3x 3x 3x 2x 1x 1x 2x 2x 2x 2x 2x 2x 1x 1x | /*EE * Copyright 2020, GeoSolutions Sas. * All rights reserved.E * * This source code is licensed under the BSID-style license found in the * LICENSE file in the root directory of this source tree. */ import { Observable } from 'rxjs'; import { mapSelector } from '@mapstore/framework/selectors/map'; import { layersSelector, groupsSelector } from '@mapstore/framework/selectors/layers'; import { backgroundListSelector } from '@mapstore/framework/selectors/backgroundselector'; import { mapOptionsToSaveSelector } from '@mapstore/framework/selectors/mapsave'; import { bookmarkSearchConfigSelector,E textSearchConfigSelector } from '@mapstore/framework/selectors/sEearchconfig'; import { saveMapConfiguration } from '@mapstore/framework/utils/MapUtils'; import { getConfigProp } from '@mapstore/framework/utils/ConfigUtils'; import { creatMapStoreMap, updateMapStoreMap } from '@js/api/geonode/adapter'; import { SAVE_CONTENT, UPDATE_RESOURCE_BEFORE_SAVE, saveSuccess, saveError, savingResource } from '@js/actions/gnsave'; import { resourceLoading, setResource, resourceError, updateResourceProperties } from '@js/actions/gnresource'; import { getResourceByPk } from '@js/api/geonode/v1'; import { parseDevHostname } from '@js/utils/APIUtils'; const SaveAPI = { map: (state, id, metadata, reload) => { const map = mapSelector(state) || {}; const layers = layersSelector(state); const groups = groupsSelector(state); const backgrounds = backgroundListSelector(state); const textSearchConfig = textSearchConfigSelector(state); const bookmarkSearchConfig = bookmarkSearchConfigSelector(state); const additionalOptions = mapOptionsToSaveSelector(state); const data = saveMapConfiguration( map, layers, groups, backgrounds, textSearchConfig, bookmarkSearchConfig, additionalOptions ); const name = metadata.name; const description = metadata.description; const thumbnail = metadata.thumbnail; const body = { name, data, attributes: [{ type: 'string', name: 'title', value: name, label: 'Title' }, { type: 'string', name: 'abstract', I value: description, label: 'Abstract' }, ...(thumbnail ? [{ type: 'string', name: 'thumbnail', value: thumbnail, label: 'Thumbnail' }] : []) ] }; return id ? updateMapStoreMap(id, { ...body, id }) : creatMapStoreMap(body) .then((response) => { if (reload) { window.location.href = parseDevHostname(`${getConfigProp('geonode_url')}maps/${response.id}/edit`); } return response.data; }); } }; export const gnSaveContent = (action$, store) => action$.ofType(SAVE_CONTENT) .switchMap((action) => { const state = store.getState(); const contentType = state.gnresource?.type || 'map'; return Observable.defer(() => SaveAPI[contentType](state, action.id, action.metadata, action.reload)) .switchMap((response) => { return Observable.of( saveSuccess(response), I updateResourceProperties({ 'title': action.metadata.name, 'abstract': action.metadata.description, 'thumbnail_url': action.metadata.thumbnail }) ); }) .catch((error) => { return Observable.of(saveError(error.data || error.message)); }) .startWith(savingResource()); }); export const gnUpdateResource = (action$, store) => action$.ofType(UPDATE_RESOURCE_BEFORE_SAVE) .switchMap((action) => { const state = store.getState(); const currentResource = state.gnresource?.data || {}; if ( !action.id || currentResource.pk && action.id && currentResource.pk + '' === action.id + '') { return Observable.empty(); } return Observable.defer(() => getResourceByPk(action.id)) .switchMap((resource) => { return Observable.of(setResource(resource)); }) .catch((error) => { return Observable.of(resourceError(error.data || error.message)); }) .startWith(resourceLoading()); }); export default { gnSaveContent, gnUpdateResource }; |