Commit graph

2514 commits

Author SHA1 Message Date
Yohan Boniface
e1a24b6180 chore: fix updaters to use umap instead of map and properties instead of options 2024-11-12 13:27:29 +01:00
Yohan Boniface
b0eb263d93 chore: remove use of L. in umap.js 2024-11-12 11:38:38 +01:00
Yohan Boniface
491d0515cd chore: fix help module not using umap module 2024-11-12 11:31:14 +01:00
Yohan Boniface
55f04a2f10 chore: remove DomEvent import from umap.js 2024-11-12 11:23:18 +01:00
Yohan Boniface
c952fed96a chore: split umap.js in two modules 2024-11-12 10:17:12 +01:00
Yohan Boniface
36efa9c4cc chore: use SAVEMANAGER as a module singleton 2024-10-30 17:14:35 +01:00
Yohan Boniface
488b5882e7 fixup: renaming 2024-10-30 09:43:31 +01:00
Yohan Boniface
7f65b1de57 chore: listen for later _trySave status 2024-10-30 09:42:06 +01:00
Yohan Boniface
ed232e59b8 chore: introduce SaveManager class
The last refactor of the save process (0fdb70ce66)
has introduced a bug: the save flow was not more stopped when a layer fail to save.
This ends with a broken UI, as the map is not dirty anymore, so the save button
is not active anymore, while at least one layer still needs to be saved.

Save can fail in two scenarios:
  - there is a conflict (status 412)
  - the server is down or as an issue (eg. disk is full)

I tried a more modest scenario (listening for status in map.save and
recallign the map save after a conflict), but this ended with calling
map.save uselessly even more.

So I decided to try this refactor, which also totally remove the useless
map.save we were sending at each save until now.
2024-10-28 18:15:18 +01:00
Yohan Boniface
bcea419bfd 2.7.1 2024-10-25 15:44:52 +02:00
Yohan Boniface
b36c03a203 fix: prevent feature.edit to be called twice on polygon/line end edit
When finishing drawing a polygon/line, Leaflet.Editable will send
both `editable:drawing:end` and `editable:drawing:commit`. In normal
flow, we only need to listen to the later, and we only need to
listen for the former in the case of pressing escape while drawing.
2024-10-24 21:07:58 +02:00
Yohan Boniface
71b55e7759 fix: always unset editedFeature on editPanel close
And only this panel.

This was creating a weird bug, steps to reproduce:

- create a marker
- shift-click on the marker to edit the layer (so without explicitly
  closing the panel)
- try to type the layer name: the panel would close

This is also because currently the schema and render() are too
dump, and when any `name` is changed then the `data` reflow is
called, while it should not when editing the datalayer name.

We want to:
- have more targeted schema
- have more specific reflow in render

But that's for other PRs!
2024-10-24 19:22:46 +02:00
Yohan Boniface
023f48ee94
chore: use shutil.move instead of Path.rename to move to purgatory (#2236)
Otherwise it will fail if src and dest are not on the same FS.
2024-10-24 19:18:21 +02:00
Yohan Boniface
bdf0bee156 2.7.0 2024-10-24 18:03:11 +02:00
Yohan Boniface
9fe96a98d1 i18n 2024-10-24 17:51:20 +02:00
Yohan Boniface
bda1984f44
chore: explicitely add geojson extension when downloading a layer (#2228)
This was added by the browser I think, but let's be explicit, just in
case.

cf
https://github.com/umap-project/umap/pull/2224#pullrequestreview-2382243375
2024-10-24 17:47:11 +02:00
Yohan Boniface
2dcd61a96d
Allow to run umap with asgi (#2209)
Follow up of #1701 

cf #2174
2024-10-24 17:46:33 +02:00
Yohan Boniface
455ddd455d
fix: do not try to create legend for non loaded classified layer (#2234)
fix #2232

A classified layer needs to have compiled the data to known its
classes/categories.

This commit review the way we build the legend: instead of creating with
the whole caption panel, we just set a container and we populate it
later. This opens the door for live changing the legend when editing the
layer.

But we have to clarify that "reactive" pattern at some point, as we have
some concurrent pattern laying around: the `render()`, which coupled
with the schema and this is nice, but for now it's a bit rough (changing
the whole UI each time); the `propagate` way, which is more specific,
but not coupled to the schema; the `dataChanged`; and the `onDataLoaded`
now, which is a bit different, as it's about the data being loaded, not
changed/modified, but for the DOM it may at the end be the same. Well,
food for thoughts…
2024-10-24 17:39:12 +02:00
Yohan Boniface
200e12e0d9 chore: apply Biome hints
Co-authored-by: Alexis Métaireau <alexis@notmyidea.org>
2024-10-24 12:39:22 +02:00
Yohan Boniface
3477be99b8 fix: do not try to create legend for non loaded classified layer
fix #2232

A classified layer needs to have compiled the data to known its
classes/categories.

This commit review the way we build the legend: instead of creating
with the whole caption panel, we just set a container and we populate
it later. This opens the door for live changing the legend when
editing the layer.

But we have to clarify that "reactive" pattern at some point, as we
have some concurrent pattern laying around: the `render()`, which
coupled with the schema and this is nice, but for now it's a bit rough
(changing the whole UI each time); the `propagate` way, which is
more specific, but not coupled to the schema; the `dataChanged`; and
the `onDataLoaded` now, which is a bit different, as it's about the
data being loaded, not changed/modified, but for the DOM it may at
the end be the same. Well, food for thoughts…
2024-10-23 18:56:26 +02:00
45f1221d00 Use fake timers on the HLC tests 2024-10-22 13:50:46 +02:00
8eae7990dd Add a fieldInSchema utility function.
Check that fields are present in the schema before calling render
2024-10-22 13:50:46 +02:00
4f0404149e feat(sync): Display the number of connected peers in the interface. 2024-10-22 13:50:46 +02:00
Yohan Boniface
c6c255e216 chore: use shutil.move instead of Path.rename to move to purgatory
Otherwise it will fail if src and dest are not on the same FS.
2024-10-22 12:14:04 +02:00
Yohan Boniface
d2832be6d5
fix: always call propagate at end of save (#2226)
Otherwise the renderEditToolbar will reset name and all.

fix #2225
2024-10-21 16:40:01 +02:00
Yohan Boniface
e0e7e0961c chore: explicitely add geojson extension when downloading a layer
This was added by the browser I think, but let's be explicit, just
in case.
2024-10-21 16:38:08 +02:00
Yohan Boniface
a2af7171d9 chore: call render at end of save
All changes at some point should call render, and render should
become more subtle to update only the needed part according to
the actual changes
2024-10-21 16:25:07 +02:00
Yohan Boniface
132be80a48 chore: remove postsync in captionBar and let map.propagate do its job 2024-10-21 16:05:26 +02:00
Yohan Boniface
ae79daec7e fix: always call propagate at end of save
Otherwise the renderEditToolbar will reset name and all.

fix #2225
2024-10-21 15:41:30 +02:00
Yohan Boniface
e100809d24
fix: use correct icon for layer download advanced action (#2224)
Replace #2221
2024-10-21 12:15:05 +02:00
Yohan Boniface
c74971bc0e chore: move pydantic and websocket in sync dependencies target 2024-10-21 11:50:10 +02:00
Yohan Boniface
9520a99d11 feat: add importer for French cadastre 2024-10-21 11:28:15 +02:00
Yohan Boniface
a1a4904f02 fix: use correct icon for layer download advanced action 2024-10-21 10:41:41 +02:00
Yohan Boniface
e0da3163ec fix: fix dispeared icons from panel titles 2024-10-18 12:08:28 +02:00
Yohan Boniface
0b23f1acd1 2.7.0b3 2024-10-16 19:55:32 +02:00
Yohan Boniface
0b6c66a841 i18n 2024-10-16 19:51:20 +02:00
Yohan Boniface
ab703e081b
feat: add a global toolbox in browser (#2160)
fix #2097
cf #1500


![image](https://github.com/user-attachments/assets/2c8b96e4-8cf7-4d5f-afed-11adf73e98a8)

This is an alternative proposal for #2097:

- adding the button near the "Filter" toggle was a bit ugly, CSS/HTML
talking, because this "Filters" box is a details/summary
- I thought that other needs could live in the same place: a link to
download the filtered/visible data, and a button to show the map data
extent

The "toggle all" button works this way:
- if one or more layers are shown, it will hide those layers
- otherwise it will show all layers

I've preferred not to change the button icon according to map state,
because I didn't find a reliable way to do so, thus I'm afraid to have
inconsistency, but I can't try harder if needed.

Related: I'm thinking of adding a "Download" button for each layers, as
it's a request that comes quite often.

@Aurelie-Jallut could you have a look ? :)
2024-10-16 19:45:56 +02:00
Yohan Boniface
47364904bd
chore: simplify contextmenu items (#2216)
Do not show generic map items when clicking on a feature.

cf #2109

Click on map:


![image](https://github.com/user-attachments/assets/b3717d4a-6f6c-4976-a86b-f97bd1239cea)

Click on feature:


![image](https://github.com/user-attachments/assets/c7f75afb-4a8a-446a-b7f4-a4a790c148c3)
2024-10-16 19:25:06 +02:00
Yohan Boniface
f8e53e7c48
feat: only add visible markers (and tooltips) to DOM (#2204) 2024-10-16 19:20:05 +02:00
Yohan Boniface
d8383dafba fix: do not show browser counter when layer is empty or not loaded
fix #2215
2024-10-16 09:48:03 +02:00
Yohan Boniface
61c3be59a8 chore: use colorbrewer as ES module 2024-10-16 09:01:31 +02:00
Yohan Boniface
8daf4cd652 chore: bump and pin front facing JS deps 2024-10-15 11:28:39 +02:00
Yohan Boniface
966c74b85b chore: simplify contextmenu items
Do not show generic map items when clicking on a feature.

cf #2109
2024-10-15 10:32:07 +02:00
Yohan Boniface
b3e88b6096 chore: make daphne/asgi optional for now 2024-10-14 12:10:13 +02:00
aa246aaf05 WIP: Add an async route for WS 2024-10-14 12:04:46 +02:00
71943c0ab3 chore: use asgi rather than wsgi
By relying on Django Channels and Daphne.
This requires a change in how the application is deployed to take that into account.
2024-10-14 12:04:44 +02:00
Yohan Boniface
a2b8145cde
fix: make sure maps of demo instances of uMap are no indexed (#2203)
fix #2201
2024-10-10 21:00:27 +02:00
Yohan Boniface
ca3451ce14 chore: do not try to remove an icon not in DOM
This occurs when using cluster, which already add/remove markers
2024-10-10 19:50:40 +02:00
Yohan Boniface
c6da1f91cf feat: only add visible markers (and tooltips) to DOM 2024-10-10 19:50:40 +02:00
Yohan Boniface
8635ebf330
chore: use pytest-rerunfailed (#2205)
I first thought about marking test as flaky one by one, but my
impression is mainly all playwright test can become flacky, and we
actually only see some as their appear in the list.
2024-10-10 19:48:54 +02:00
Yohan Boniface
7aa445f01b Update umap/templates/umap/map_detail.html
Co-authored-by: David Larlet <3556+davidbgk@users.noreply.github.com>
2024-10-10 11:00:46 +02:00
Yohan Boniface
60c2b07f9b fix: honour carriage returns in permanent credits
fix #2197
2024-10-10 10:33:12 +02:00
Yohan Boniface
1be7c8d3a9 chore: use pytest-rerunfailed 2024-10-10 10:31:25 +02:00
Yohan Boniface
97d2ebae34 fix: make sure maps of demo instances of uMap are no indexed
fix #2201
2024-10-09 10:15:54 +02:00
Yohan Boniface
b7ee50980f
chore: deactivate contextmenu and shortcuts in map preview (#2199)
Contextmenu and keyboard shortcuts open controls, which are not fully
initiated when in mode `noControl`, which is the case for preview.
2024-10-07 22:28:30 +02:00
David Larlet
76ebe1c0ea
tests: use at.least to compare dates on the hlc tests. (#2196)
Should fix [this
error](https://github.com/umap-project/umap/actions/runs/11165503827/job/31037336947?pr=2188)
2024-10-07 08:20:58 -04:00
Yohan Boniface
e7ed14f216 chore: deactivate contextmenu and shortcuts in map preview
Contextmenu and keyboard shortcuts open controls, which are not
fully initiated when in mode `noControl`, which is the case for
preview.
2024-10-07 12:27:33 +02:00
Yohan Boniface
4b66e0fa83 chore: add border top to browser toolbox 2024-10-07 11:57:37 +02:00
Yohan Boniface
36afe0ead5 chore: open dropdown on download click in browser
Instead of switching context and opening the share panel.
2024-10-07 11:46:01 +02:00
Yohan Boniface
2923e1ca51 feat: add a global toolbox in browser
fix #2097
cf #1500
2024-10-07 10:20:17 +02:00
Yohan Boniface
2ca6ffd5ca 2.7.0b2 2024-10-06 10:20:18 +02:00
Yohan Boniface
581ec242b8 chore: always insert contextmenu on map container parent
offsetParent will return whatever positionned parent element, so
when clicking on a marker it will be the marker container.
And we cannot add the contextmenu inside the map container, as it
the focusout element will be sent before the click action happen
on any item of the contextmenu.
2024-10-06 09:46:23 +02:00
37ffea97a9
FIXUP: adapt the tests to a slow CI 2024-10-05 21:16:45 +02:00
Yohan Boniface
3c0d2b79ef fix: allow to call contextmenu with given positions 2024-10-05 11:26:05 +02:00
Yohan Boniface
c844e1c03d chore: use position: fixed for contextmenu 2024-10-05 11:22:02 +02:00
Yohan Boniface
70f06e7852 fix: insert contextmenu in the offsetParent
Otherwise when parent is a dialog, if the the contextemenu is in
the body, it will be below the dialog forever
2024-10-05 11:08:50 +02:00
Yohan Boniface
89c13a3b7e fix: window.offsetHeight does not means anything 2024-10-05 11:08:36 +02:00
Yohan Boniface
42e7fb8dae chore: pass event to ContextMenu.open 2024-10-05 10:41:33 +02:00
Yohan Boniface
c4b80afb15 fix: simpler way to deal with positionning contextmenu
Use pageX/Y from the begginning instead of recomputing it later.
2024-10-05 10:38:51 +02:00
Yohan Boniface
cba0af96f6 fix: fix contextmenu positionning when map is not full screen 2024-10-05 10:02:41 +02:00
Yohan Boniface
c90618a248 fix: do not show separator in contextmenu when nothing before 2024-10-05 09:09:30 +02:00
979d34f3fa
tests: use at.least to compare dates on the hlc tests. 2024-10-04 22:46:33 +02:00
Yohan Boniface
16b759973b 2.7.0b1 2024-10-04 19:31:57 +02:00
Yohan Boniface
8788f97791 2.7.0b0 2024-10-04 19:18:07 +02:00
Yohan Boniface
a8d04a6abb i18n 2024-10-04 18:38:00 +02:00
Yohan Boniface
f9cf923684
feat: add a profile drop-down menu (#2194)
fix #2115
2024-10-04 18:26:49 +02:00
Yohan Boniface
8d59220d05
fix: make sure anonymous is owner at create (#2189)
The tricky thing is that the Map.is_owner() method check for cookies on
the request, but at create this cookie is not set yet on the request, so
we have to deal with an exception here.

fix #2176
2024-10-04 17:55:29 +02:00
Yohan Boniface
21be2e4fd0 fix: hide "my profile" from dropdown menu if ALLOW_EDIT_PROFILE=False 2024-10-04 17:54:13 +02:00
Yohan Boniface
6876bb1ba5 fix: listen just once for escape key in contextmenu 2024-10-04 17:44:50 +02:00
Yohan Boniface
1029c2655e wip: add a profile drop-down menu
fix #2113
2024-10-04 17:44:50 +02:00
Yohan Boniface
de93446af2
clean: remove zoom in and out from contextmenu (#2195)
Let's make it smaller (unless proven otherwise!).
2024-10-04 17:43:23 +02:00
Yohan Boniface
03ae31c18b chore: remove map.dirty_datalayers
Let's try to make it simpler.
map.datalayers stores all datalayers
map.datalayers_index the non deleted ones sorted
2024-10-04 17:35:35 +02:00
Yohan Boniface
a35b37f423 chore: use map getter instead of getMap in permissions 2024-10-04 17:35:35 +02:00
Yohan Boniface
0d7c6e451d chore: new strategy to update map name when editing it
Also propagate share_status (this may be moved to permissions)
2024-10-04 17:35:33 +02:00
Yohan Boniface
0fdb70ce66 chore: review save strategy
All is now orchestrated from a single method, instead of chaining
calls.
2024-10-04 17:34:59 +02:00
Yohan Boniface
73c83cfa86 chore: always return user infos on map save 2024-10-04 17:34:59 +02:00
Yohan Boniface
13a7a2257d fix: do not fail in autocomplete if on_unselect is undefined 2024-10-04 17:34:59 +02:00
Yohan Boniface
ff5195a787 fix: make sure anonymous is owner at create
The tricky thing is that the Map.is_owner() method check for cookies
on the request, but at create this cookie is not set yet on the
request, so we have to deal with an exception here.

fix #2176
2024-10-04 17:34:59 +02:00
Yohan Boniface
ebd3896e91 chore: replace native confirm by our styled ones 2024-10-04 17:34:20 +02:00
Yohan Boniface
9b29b705da clean: remove zoom in and out from contextmenu
Let's make it smaller (unless proven otherwise!).
2024-10-04 17:32:39 +02:00
Yohan Boniface
4940f6c329 test: fix playwright selector 2024-10-04 17:31:05 +02:00
Yohan Boniface
c8ffe4273f
fix: allow to draw new proprotional circles and to drag them (#2172)
The main issue was because we overrided the `getLatLngs` function in our
PointMixin class, so I changed the way feature get the latlngs from the
UI classes. Plus getting CircleMarker to inherit more from Marker,
through PointMixin.

fix #2171
2024-10-04 16:43:49 +02:00
Yohan Boniface
4b4546991a
chore: display user maps in admin and add in csv export (#2169)
maps are owned maps + maps as editor

cf https://github.com/umap-project/umap/pull/2131#discussion_r1772775039
2024-10-04 16:42:53 +02:00
Yohan Boniface
5d5be52337
feat: delete datalayer's files on delete (#2158)
Until now, uMap was not deleting files on delete, which can increase
file storage a lot after some time.

The files are not deleted, but moved to a "purgatory" folder, from where
they can be deleted after some time.
2024-10-04 16:41:11 +02:00
Yohan Boniface
91800d104d
fix: polygon with interactive=false was still interactive (#2151)
This bug has been introduced when spliting features, as we now only set
the Leaflet Polygon options with setStyle, will the `interactive` option
is only used in the init by Leaflet.

See https://github.com/Leaflet/Leaflet/pull/9475
2024-10-04 16:36:21 +02:00
Yohan Boniface
d95f06abab
chore: use our own contextmenu (#2109)
Let's start from here to clean the contextmenu items.

Current status:

### Some entries are generic, and always present:

In preview mode:


![image](https://github.com/user-attachments/assets/ea5cf2d3-f8f7-4d6a-8bf5-4c0334334bbc)

In edit mode:


![image](https://github.com/user-attachments/assets/2d2fa5c1-a275-4037-8780-d18a5e31949b)

### Some entries are specific to a clicked feature

In preview mode (Marker):


![image](https://github.com/user-attachments/assets/2d03f640-fb62-4be8-893d-d1ffc09d66f1)

In edit mode (Marker):


![image](https://github.com/user-attachments/assets/3f5ede89-fe3e-41a0-ac9a-575ef04e7a41)

In preview mode (Polygon):


![image](https://github.com/user-attachments/assets/fa88b13a-ac53-4bdd-896c-ada025640c35)

In edit mode (Polygon):


![image](https://github.com/user-attachments/assets/c2b46f2a-4f6d-4660-9654-d4f775386898)

In preview mode (Line):


![image](https://github.com/user-attachments/assets/74cd5c21-ad17-4592-b3da-f82f12c60baf)

In edit mode (Line):


![image](https://github.com/user-attachments/assets/4c9f89c6-a30e-4f40-84fe-3fff306358aa)


@Aurelie-Jallut Do you want to make suggestion on what to show or not in
this menu, depending on the context (feature or not, preview or edit
mode) ?
2024-10-04 16:34:06 +02:00
Yohan Boniface
f1619579a4 feat: allow to search by code INSEE in communes importer 2024-10-03 18:03:43 +02:00
Yohan Boniface
c2833987b7 fix: remoteData helpEntries were not on the right format
Should be now an array (not guessing anymore).
2024-10-01 08:55:58 +02:00
0a1d98b146 ci: Skip intermittent-failing tests when on the CI.
A few tests have been failing randomly, leading to developers not having
a lot of trust in the CI, and having to retrigger the runs.

Here is the list of tests:

- `test_should_honor_toZoom`
- `test_default_view_locate`
- `test_umap_import_from_textarea`

This skips these tests when running in the CI, by looking at the `CI`
environment variable, set by Github Actions [0]

[0] https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
2024-09-27 18:26:47 +02:00
5485fb99ab feat(sync): Send remote operations to peers when they join.
- Operations are now stored locally in memory. All operations are tied
  to an HLC (Hybrid Logical Clock), making it possible to order them
  concistently.

- Messages are handled in their `on*` methods, leading to a clearer
  implementation.

- When a new peer joins, it asks a random peer for the list of
  operations, and re-apply them locally.

- Messages types names have been updated to follow CamelCase, and to be
  similar across the client and the server.

- Pass `sync=False` to `makeFeature` in the updaters, to avoid
  generating duplicate operations on message retrieval.
2024-09-27 18:26:47 +02:00