From 4a76d2af0fcd6df3e4f0d5190be1dd6dc1a19124 Mon Sep 17 00:00:00 2001 From: stefanocudini Date: Tue, 17 Nov 2026 17:04:46 +0100 Subject: [PATCH 1/5] fix action longprofile --- web/client/actions/longitudinalProfile.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web/client/actions/longitudinalProfile.js b/web/client/actions/longitudinalProfile.js index b275b2f293..22e72a36f3 100644 --- a/web/client/actions/longitudinalProfile.js +++ b/web/client/actions/longitudinalProfile.js @@ -197,14 +197,22 @@ export const toggleMode = (mode) => ({ export const setup = (config) => { return (dispatch, getState) => { dispatch(setupPlugin(config)); - const { referentials, distances, defaultDistance, defaultReferentialName } = config || configSelector(getState()); + const { + referentials = [], + distances = [], + defaultDistance, + defaultReferentialName + } = configSelector(getState()) || {}; + if (!referentials.length) { + dispatch(error({ title: "Error", message: "longitudinalProfile.errors.loadingError", autoDismiss: 10 })); + } const defaultReferential = referentials.find(el => el.layerName === defaultReferentialName); if (defaultReferentialName && !defaultReferential) { dispatch(error({ title: "Error", message: "longitudinalProfile.errors.defaultReferentialNotFound", autoDismiss: 10 })); } dispatch(updateDockPanelsList(CONTROL_DOCK_NAME, "add", "right")); - dispatch(changeReferential(defaultReferentialName ?? referentials[0].layerName)); + dispatch(changeReferential(defaultReferentialName || referentials[0]?.layerName)); dispatch(changeDistance(defaultDistance ?? distances[0])); dispatch(updateAdditionalLayer( LONGITUDINAL_VECTOR_LAYER_ID, From 9e2ccaebd4e1f6c0f41f6d903e74877e598b537f Mon Sep 17 00:00:00 2001 From: stefanocudini Date: Tue, 17 Nov 2026 17:18:25 +0100 Subject: [PATCH 2/5] update jsdoc, fix also distances --- web/client/actions/longitudinalProfile.js | 3 ++- web/client/plugins/LongitudinalProfileTool.jsx | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/web/client/actions/longitudinalProfile.js b/web/client/actions/longitudinalProfile.js index 22e72a36f3..23327e1165 100644 --- a/web/client/actions/longitudinalProfile.js +++ b/web/client/actions/longitudinalProfile.js @@ -12,6 +12,7 @@ import { } from "../actions/maplayout"; import {error} from "../actions/notifications"; import { + LONGITUDINAL_DISTANCES, CONTROL_DOCK_NAME, LONGITUDINAL_OWNER, LONGITUDINAL_VECTOR_LAYER_ID, @@ -199,7 +200,7 @@ export const setup = (config) => { dispatch(setupPlugin(config)); const { referentials = [], - distances = [], + distances = LONGITUDINAL_DISTANCES, defaultDistance, defaultReferentialName } = configSelector(getState()) || {}; diff --git a/web/client/plugins/LongitudinalProfileTool.jsx b/web/client/plugins/LongitudinalProfileTool.jsx index 1321874ae2..66dccde05d 100644 --- a/web/client/plugins/LongitudinalProfileTool.jsx +++ b/web/client/plugins/LongitudinalProfileTool.jsx @@ -71,10 +71,10 @@ import { createPlugin } from '../utils/PluginsUtils'; * @prop {Object} cfg.config the plugin configuration * @prop {string} cfg.config.wpsurl optional, the geoserver url the the wps endpoint to use. It can be an absolute url. default is "/geoserver/wps". * @prop {string} cfg.config.chartTitle the default title of the chart - * @prop {number} cfg.config.noDataThreshold the number that beyond it will exclude data - * @prop {number} cfg.config.defaultDistance the default distance value in meters + * @prop {number} cfg.config.noDataThreshold the number that beyond it will exclude data. Default is 999999 + * @prop {number} cfg.config.defaultDistance optional, the initial value of the distance (in meters) shown in the settings and used by the WPS process. Default is 100 * @prop {string} cfg.config.identifier the profile to use in the wps request, defaulted to gs:LongitudinalProfile - * @prop {string} cfg.config.defaultReferentialName the default referential name + * @prop {string} cfg.config.defaultReferentialName optional, the default referential name. If not set, the first item of `referentials` is used * @prop {Object[]} cfg.config.referentials (required) the layers that can be used as referentials * @prop {string[]} cfg.filterAllowedCRS the allowed crs to be proposed when dropping a DXF file, (needs to be supported by mapstore) * @prop {Object} cfg.additionalCRS the crs object that allow to define also a label From 2fa24664d90f5b248ee9bab5094cd9701e3a5297 Mon Sep 17 00:00:00 2001 From: stefanocudini Date: Tue, 17 Nov 2026 17:50:09 +0100 Subject: [PATCH 3/5] added some tests --- .../__tests__/longitudinalPfofile-test.js | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/web/client/actions/__tests__/longitudinalPfofile-test.js b/web/client/actions/__tests__/longitudinalPfofile-test.js index 86522b2f0b..17e94cd14c 100644 --- a/web/client/actions/__tests__/longitudinalPfofile-test.js +++ b/web/client/actions/__tests__/longitudinalPfofile-test.js @@ -7,7 +7,7 @@ */ import expect from "expect"; -import {CONTROL_DOCK_NAME} from '../../plugins/longitudinalProfile/constants'; +import {CONTROL_DOCK_NAME, LONGITUDINAL_DISTANCES} from '../../plugins/longitudinalProfile/constants'; import {SET_CONTROL_PROPERTY} from "../controls"; import { ADD_PROFILE_DATA, @@ -24,6 +24,7 @@ import { loading, LOADING, openDock, + setup, setupPlugin, SETUP, TEAR_DOWN, @@ -33,6 +34,22 @@ import { toggleMaximize, toggleMode } from "../longitudinalProfile"; +import longitudinalProfile from '../../reducers/longitudinalProfile'; + +/** + * runs the setup thunk against the real reducer and returns the dispatched actions + */ +const runSetup = (config) => { + let state = { longitudinalProfile: longitudinalProfile(undefined, {}) }; + const actions = []; + const dispatch = (action) => { + actions.push(action); + state = { longitudinalProfile: longitudinalProfile(state.longitudinalProfile, action) }; + }; + setup(config)(dispatch, () => state); + return { actions, state }; +}; +const REFERENTIALS = [{ layerName: "sfdem", title: "sfdem" }]; describe('Test correctness of the actions', () => { it('setup', () => { @@ -137,3 +154,26 @@ describe('Test correctness of the actions', () => { expect(action.type).toBe(TOGGLE_MAXIMIZE); }); }); + +describe('Test setup thunk (defaultDistance / distances)', () => { + it('setup without defaultDistance and distances uses the default distance', () => { + const { actions, state } = runSetup({ referentials: REFERENTIALS }); + const distanceAction = actions.find(a => a.type === CHANGE_DISTANCE); + expect(distanceAction).toExist(); + expect(distanceAction.distance).toBe(100); + expect(state.longitudinalProfile.config.distances).toEqual(LONGITUDINAL_DISTANCES); + expect(actions[actions.length - 1].type).toBe(INITIALIZED); + }); + it('setup with defaultDistance uses the configured value', () => { + const { actions } = runSetup({ referentials: REFERENTIALS, defaultDistance: 75 }); + expect(actions.find(a => a.type === CHANGE_DISTANCE).distance).toBe(75); + }); + it('setup with distances only keeps the default distance', () => { + const { actions } = runSetup({ referentials: REFERENTIALS, distances: [20, 40] }); + expect(actions.find(a => a.type === CHANGE_DISTANCE).distance).toBe(100); + }); + it('setup with defaultDistance null falls back to the first of distances', () => { + const { actions } = runSetup({ referentials: REFERENTIALS, defaultDistance: null, distances: [20, 40] }); + expect(actions.find(a => a.type === CHANGE_DISTANCE).distance).toBe(20); + }); +}); From b5552454772367497214e8bd983c5fa1a7755356 Mon Sep 17 00:00:00 2001 From: stefanocudini Date: Tue, 17 Nov 2026 18:09:05 +0100 Subject: [PATCH 4/5] fix profile message colors --- web/client/themes/default/less/longitudinal-profile.less | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/client/themes/default/less/longitudinal-profile.less b/web/client/themes/default/less/longitudinal-profile.less index 1e3600229d..1433b6232e 100644 --- a/web/client/themes/default/less/longitudinal-profile.less +++ b/web/client/themes/default/less/longitudinal-profile.less @@ -13,6 +13,7 @@ .longitude-help { .background-color-var(@theme-vars[mask-bg]); .color-var(@theme-vars[main-bg]); + .border-color-var(@theme-vars[main-border-color]); } .longitudinal-tool-container { .background-color-var(@theme-vars[main-bg]); @@ -75,6 +76,11 @@ top: 45px; width: 300px; border-radius: 3px; + // keep the message visible on light basemaps: border + shadow around the box, + // dark text-shadow around the light (main-bg) text + border: 1px solid; + .shadow(); + text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); z-index: 1; padding: 10px; opacity: 0.8; From 0ccecb7f9657fcc3fc75f6415dba267cfa24cedf Mon Sep 17 00:00:00 2001 From: stefanocudini Date: Wed, 18 Nov 2026 16:38:04 +0100 Subject: [PATCH 5/5] fix menu orientation --- web/client/plugins/longitudinalProfile/Menu.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/client/plugins/longitudinalProfile/Menu.jsx b/web/client/plugins/longitudinalProfile/Menu.jsx index 2b9c61a688..1a597e1128 100644 --- a/web/client/plugins/longitudinalProfile/Menu.jsx +++ b/web/client/plugins/longitudinalProfile/Menu.jsx @@ -56,7 +56,8 @@ const Menu = ({ const ButtonElement = document.getElementById("longitudinal-tool"); const offsetTop = getOffsetTop(ButtonElement); const offsetBottom = getOffsetBottom(ButtonElement); - const dropUpVal = offsetTop > 130 || offsetBottom < 130; + const MAX_OFFSET_TOP = 140; // this value is tested both for Mapstore and GeoNode layout (DON'T reduce it) + const dropUpVal = offsetTop > MAX_OFFSET_TOP || offsetBottom < MAX_OFFSET_TOP; setDropUp(dropUpVal); }, []); const [open, setMenuOpen ] = useState(false);