Skip to content

Commit

Permalink
#193: Update to the latest MapStore 2024.02 (#194)
Browse files Browse the repository at this point in the history
* #193: Update to the latest MapStore 2024.02

* fix workflow yaml

* index.html updated

* Update build and tests files to work properly

* Update cadastrapp.yml

---------

Co-authored-by: Lorenzo Natali <[email protected]>
  • Loading branch information
dsuren1 and offtherailz authored Oct 21, 2024
1 parent 5ef8f9f commit a215c29
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 80 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/cadastrapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: "setting up npm"
uses: actions/setup-node@v1
with:
node-version: '12.x'
node-version: '16.x'

- name: "cache node modules"
uses: actions/cache@v1
Expand All @@ -37,19 +37,20 @@ jobs:
run: npm run ext:build

- name: "publish zip as artifact"
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: Cadastrapp-${{ github.sha }}
path: dist/Cadastrapp.zip

- name: "change webpack config to avoid minification"
run: sed -i -e 's/prod: true/prod: false/' build/extension/prod-webpack.config.js
run: |
sed -i -e 's/prod: true/prod: false/' build/extension/prod-webpack.config.js
- name: "build unminified"
run: npm run ext:build

- name: "publish zip as artifact"
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: Cadastrapp-unminified-${{ github.sha }}
path: dist/Cadastrapp.zip
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# add legacy peer dependency flag on npm install
legacy-peer-deps=true
2 changes: 1 addition & 1 deletion MapStore2
Submodule MapStore2 updated 1428 files
11 changes: 10 additions & 1 deletion build/extension/prod-webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ const fileLoader = {
}
}]
};
const urlLoader = {
test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/,
use: [{
loader: 'url-loader',
options: {
mimetype: "application/font-woff"
}
}]
};
const {module: moduleObj, ...extensionConfig} = createExtensionWebpackConfig({ prod: true, name, ...commons, plugins});
// Temp fix to return errors for leaflet
// TODO: wait for a fix on mapstore createExtensionWebpackConfig
Expand All @@ -50,4 +59,4 @@ const rules = [{
}, ...moduleObj.rules[0].use.slice(1)]
}, ...moduleObj.rules.slice(1)];

module.exports = { ...extensionConfig, module: { ...moduleObj, rules: [...rules, fileLoader] } };
module.exports = { ...extensionConfig, module: { ...moduleObj, rules: [...rules, fileLoader, urlLoader] } };
5 changes: 0 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,9 @@
}
</style>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway" type='text/css'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="shortcut icon" type="image/png" href="https://cdn.jslibs.mapstore2.geo-solutions.it/leaflet/favicon.ico" />
<script src="https://maps.google.com/maps/api/js?v=3"></script>
<!--script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.10/proj4.js"></script-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.js"></script>
<!--<script src="https://www.mapquestapi.com/sdk/leaflet/v2.2/mq-map.js?key=__API_KEY_MAPQUEST__"></script>-->

</head>
Expand Down
15 changes: 7 additions & 8 deletions js/extension/epics/__tests__/events-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { testEpic } from "@mapstore/epics/__tests__/epicTestUtils";
import {saveAsAnnotation} from "../../actions/cadastrapp";
import {CADASTRAPP_VECTOR_LAYER_ID} from "@js/extension/constants";
import {cadastrappSaveAsAnnotation} from "@js/extension/epics/events";
import {SET_CONTROL_PROPERTY} from "@mapstore/actions/controls";
import {NEW_ANNOTATION, SET_EDITING_FEATURE} from "@mapstore/actions/annotations";
import { ADD_LAYER } from "@mapstore/actions/layers";
import { EDIT_ANNOTATION } from "@mapstore/plugins/Annotations/actions/annotations";

describe("download Epics", () => {
const state = {
Expand Down Expand Up @@ -86,17 +86,16 @@ describe("download Epics", () => {
it("cadastrappSaveAsAnnotation", done => {
testEpic(
cadastrappSaveAsAnnotation,
3,
2,
saveAsAnnotation(),
actions => {
expect(actions.length).toBe(3);
expect(actions.length).toBe(2);
actions.map(action=>{
switch (action.type) {
case SET_CONTROL_PROPERTY:
case NEW_ANNOTATION:
case ADD_LAYER:
break;
case SET_EDITING_FEATURE:
expect(action.feature.features.length).toBe(2);
case EDIT_ANNOTATION:
expect(action.id).toBeTruthy();
break;
default:
expect(false).toBe(true);
Expand Down
13 changes: 6 additions & 7 deletions js/extension/epics/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {SAVE_AS_ANNOTATION, ZOOM_TO_SELECTION} from '../actions/cadastrapp';
import {getCadastrappVectorLayer, getCurrentPlotFeatures, getSelectedFeatures} from '../selectors/cadastrapp';
import { zoomToExtent } from '@mapstore/actions/map';
import bbox from '@turf/bbox';
import {convertFeaturesToAnnotation} from "@js/extension/utils/download";
import {setControlProperty} from "@mapstore/actions/controls";
import {newAnnotation, setEditingFeature} from "@mapstore/actions/annotations";
import { convertFeaturesToAnnotationLayer } from "@js/extension/utils/download";
import { editAnnotation } from "@mapstore/plugins/Annotations/actions/annotations";
import { addLayer } from '@mapstore/actions/layers';


/**
Expand All @@ -30,11 +30,10 @@ export function cadastrappZoomToSelection(action$, store) {
export function cadastrappSaveAsAnnotation(action$, store) {
return action$.ofType(SAVE_AS_ANNOTATION).switchMap(() => {
const state = store.getState();
const collection = convertFeaturesToAnnotation(getCadastrappVectorLayer(state), state);
const layer = convertFeaturesToAnnotationLayer(getCadastrappVectorLayer(state), state);
return Rx.Observable.of(
setControlProperty('annotations', 'enabled', true),
newAnnotation(),
setEditingFeature(collection)
addLayer(layer),
editAnnotation(layer.id)
);
});
}
Expand Down
8 changes: 5 additions & 3 deletions js/extension/utils/__tests__/download-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import expect from 'expect';
import {convertFeaturesToAnnotation} from "@js/extension/utils/download";
import {convertFeaturesToAnnotationLayer} from "@js/extension/utils/download";
import { ANNOTATIONS } from '@mapstore/utils/LegacyAnnotationsUtils';

describe('download utils', () => {
it("convertFeaturesToAnnotation", () => {
it("convertFeaturesToAnnotationLayer", () => {
const state = {
cadastrapp: {
configuration:
Expand Down Expand Up @@ -67,10 +68,11 @@ describe('download utils', () => {
]
};

const converted = convertFeaturesToAnnotation(layer, state);
const converted = convertFeaturesToAnnotationLayer(layer, state);
expect(converted.features[0].geometry.type).toBe('Polygon');
expect(converted.features[1].geometry.type).toBe(layer.features[1].geometry.type);
expect(converted.features[0].properties.geometryTitle).toBe('SomeTitle');
expect(converted.features[1].properties.geometryTitle).toBe('SomeTitle2');
expect(converted.rowViewer).toBe(ANNOTATIONS);
});
});
71 changes: 36 additions & 35 deletions js/extension/utils/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {validateFeatureCoordinates} from "@mapstore/utils/MeasureUtils";
import {cadastreLayerIdParcelle} from "@js/extension/selectors/cadastrapp";
import {getMessageById} from "@mapstore/utils/LocaleUtils";
import {currentMessagesSelector} from "@mapstore/selectors/locale";
import {ANNOTATIONS, createAnnotationId} from '@mapstore/plugins/Annotations/utils/AnnotationsUtils';

export const toDownload = ({ fileName, mimeType }) => (response) => {
const dataUrl = window.URL.createObjectURL(new Blob([response.data], { type: mimeType }));
Expand Down Expand Up @@ -48,46 +49,46 @@ export function downloadResponse(response, { fileName = 'unknown' } = {}) {
* @param state
* @returns object
*/
export const convertFeaturesToAnnotation = (vectorLayer, state) => {
const id = uuidv1();
export const convertFeaturesToAnnotationLayer = (vectorLayer, state) => {
const id = createAnnotationId(uuidv1());
return {
type: "FeatureCollection",
type: "vector",
features: [
...(vectorLayer?.features ?? []).map(feature => ({
type: 'Feature',
geometry: {
type: feature.geometry.type === 'MultiPolygon' ? 'Polygon' : feature.geometry.type,
coordinates: feature.geometry.type === 'MultiPolygon'
? validateFeatureCoordinates({coordinates: feature.geometry.coordinates[0], type: 'Polygon'})
: validateFeatureCoordinates(feature.geometry),
textLabels: feature.geometry.textLabels
},
properties: {
id: uuidv1(),
isValidFeature: true,
geometryTitle: feature.properties[cadastreLayerIdParcelle(state)],
values: feature.properties?.values || []
},
style: [{
...feature.style,
type: feature.geometry.type,
id: uuidv1(),
geometry: null,
title: `${feature.geometry.type} Style`,
filtering: true
}]
}))
...(vectorLayer?.features ?? []).map(feature => {
const geomType = feature.geometry.type === 'MultiPolygon' ? 'Polygon' : feature.geometry.type;
return {
type: 'Feature',
geometry: {
type: geomType,
coordinates: feature.geometry.type === 'MultiPolygon'
? validateFeatureCoordinates({coordinates: feature.geometry.coordinates[0], type: 'Polygon'})
: validateFeatureCoordinates(feature.geometry),
textLabels: feature.geometry.textLabels
},
properties: {
id: uuidv1(),
isValidFeature: true,
geometryTitle: feature.properties[cadastreLayerIdParcelle(state)],
values: feature.properties?.values || [],
annotationType: geomType,
name: geomType
},
style: [{
...feature.style,
type: feature.geometry.type,
id: uuidv1(),
geometry: null,
title: `${feature.geometry.type} Style`,
filtering: true
}]
};
})
],
properties: {
id,
description: '',
type: 'Cadastrapp',
title: getMessageById(currentMessagesSelector(state), "cadastrapp.result.parcelle.selectedPlots"),
iconGlyph: 'geometry-collection'
},
id,
description: '',
title: getMessageById(currentMessagesSelector(state), "cadastrapp.result.parcelle.selectedPlots"),
style: {},
newFeature: true,
rowViewer: ANNOTATIONS,
visibility: true
};
};
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CadastrappExtension",
"version": "1.0.0",
"version": "2.2.0",
"description": "Cadastrapp plugin for mapstore2",
"main": "index.js",
"eslintConfig": {
Expand Down Expand Up @@ -31,15 +31,16 @@
"@geosolutions/acorn-jsx": "4.0.2",
"@geosolutions/jsdoc": "3.4.4",
"@geosolutions/mocha": "6.2.1-3",
"@mapstore/eslint-config-mapstore": "1.0.3",
"@mapstore/eslint-config-mapstore": "1.0.5",
"@testing-library/react": "12.1.5",
"axios-mock-adapter": "1.16.0",
"babel-loader": "8.0.5",
"babel-plugin-add-module-exports": "0.1.4",
"babel-plugin-istanbul": "6.0.0",
"babel-plugin-object-assign": "1.2.1",
"babel-plugin-react-transform": "2.0.2",
"babel-plugin-transform-imports": "2.0.0",
"copy-webpack-plugin": "^5.1.2",
"copy-webpack-plugin": "5.0.2",
"css-loader": "5.1.2",
"css-minimizer-webpack-plugin": "3.0.2",
"denodeify": "1.2.1",
Expand All @@ -54,8 +55,8 @@
"expect": "1.20.1",
"file-loader": "2.0.0",
"glob": "7.1.1",
"html-loader": "0.5.1",
"html-webpack-plugin": "4.5.0",
"html-loader": "2.0.0",
"html-webpack-plugin": "5.2.0",
"jsdoc-jsx": "0.1.0",
"karma": "6.4.0",
"karma-chrome-launcher": "3.1.1",
Expand All @@ -68,9 +69,10 @@
"karma-mocha": "2.0.1",
"karma-mocha-reporter": "2.2.5",
"karma-sourcemap-loader": "0.3.8",
"karma-webpack": "^5.0.0-alpha.5",
"karma-webpack": "5.0.0",
"less": "4.1.1",
"less-loader": "8.0.0",
"markdownlint-cli": "0.34.0",
"mini-css-extract-plugin": "1.3.9",
"mkdirp": "0.5.1",
"ncp": "2.0.0",
Expand All @@ -92,14 +94,14 @@
"rimraf": "2.5.2",
"simple-git": "2.20.1",
"style-loader": "2.0.0",
"terser": "5.18.1",
"url-loader": "0.5.7",
"vusion-webfonts-generator": "0.4.1",
"webpack": "5.9.0",
"webpack": "5.54.0",
"webpack-bundle-size-analyzer": "2.0.2",
"webpack-cli": "4.10.0",
"webpack-dev-server": "3.11.0",
"zip-webpack-plugin": "^3.0.0",
"git-revision-webpack-plugin": "5.0.0"
"zip-webpack-plugin": "3.0.0"
},
"dependencies": {
"mapstore2": "file:MapStore2"
Expand All @@ -119,4 +121,4 @@
},
"author": "GeoSolutions",
"license": "BSD-2-Clause"
}
}
9 changes: 5 additions & 4 deletions proxyConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const DEV_PROTOCOL = "http";
const DEV_HOST = "localhost:8080";
const cookie = "_hp2_props.2826793817=%7B%22account_state%22%3A%22active%22%7D; _hp2_id.2826793817=%7B%22userId%22%3A%221499114905535127%22%2C%22pageviewId%22%3A%222428177607153135%22%2C%22sessionId%22%3A%222201495479166025%22%2C%22identity%22%3A%223635521%22%2C%22trackerVersion%22%3A%224.0%22%2C%22identityField%22%3Anull%2C%22isIdentified%22%3A1%7D; _ga=GA1.2.418248975.1607951243; JSESSIONID=node0zn0cohqg5jw2qn4nddqynxiw70196.node0";
const cookie = "JSESSIONID=node0fieai9vvjzcv1uhtlkbbmp7jt4043608.node0";
module.exports = {
"/rest": {
target: `${DEV_PROTOCOL}://${DEV_HOST}/mapstore`,
Expand All @@ -26,11 +26,12 @@ module.exports = {
}
},
"/proxy": {
target: `https://dev.mapstore.geo-solutions.it/mapstore`,
target: `${DEV_PROTOCOL}://${DEV_HOST}/mapstore/`,
secure: false
},
"/mapstore/proxy": {
target: `https://dev.mapstore.geo-solutions.it`,
target: `${DEV_PROTOCOL}://${DEV_HOST}`,

secure: false
},
"/geonetwork": {
Expand Down Expand Up @@ -60,4 +61,4 @@ module.exports = {
}

}
};
};
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MapStoreExtension-1.0.0
MapStoreExtension-2.2.0
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ const cfg = buildConfig(
proxyConfig
);
// stream are needed here in code
cfg.resolve.fallback = {timers: false};
cfg.resolve.fallback = {timers: false, http: false, https: false, stream: false, zlib: false};
cfg.devtool = "eval-source-map";
module.exports = cfg;

0 comments on commit a215c29

Please sign in to comment.