Commit graph

2794 commits

Author SHA1 Message Date
9be613e3ce feat(sync): add tests for the websocket token view 2024-06-07 18:21:30 +02:00
80eaa151de refactor(sync): Remove unnecessary complexity
Because we're relying on the `geoJSONToFeatures` method, we don't need
anymore updaters, the default ones (map, datalayer, feature) are enough.

It also makes the codebase compatible with our eslint configuration.
2024-06-07 18:21:30 +02:00
9e36476abe chore(sync) make the test pass 2024-06-07 18:21:30 +02:00
647f6c3dfe chore(docker) remove ws.py for now 2024-06-07 18:21:30 +02:00
d5bff22081 fix(sync) only send datalayer options 2024-06-07 18:21:30 +02:00
898a3e93b2 fix(sync): do not call getSyncMetadata if it doesn't exist
This can arise when the form isn't bound to a "syncable" object. We
might want to provide an utility to check an object is *syncable*, or a
specific form to not attempt to sync objects which don't need it.
2024-06-07 18:21:30 +02:00
8e5c434988 feat(sync): Allow the sync of datalayer creation 2024-06-07 18:21:30 +02:00
458d68a4bb fix(sync): allow features geometries to be synced
By defining the `geometry` property in the schema.
2024-06-07 18:21:30 +02:00
5b55c80529 chore(docker): run the websocket server as a separate command 2024-06-07 18:21:30 +02:00
1d9b086115 chore(sync): remove useless dependencies from ws.py 2024-06-07 18:21:30 +02:00
def915c561 feat(settings): allow reading socket-related settings from ENV variables 2024-06-07 18:21:30 +02:00
01408254c9 fix(sync): intialize the sync engine before entering edit mode.
Otherwise `this.sync` is not defined.
2024-06-07 18:21:30 +02:00
46207741ff feat(sync): handle syncing of map limitbounds. 2024-06-07 18:21:30 +02:00
9cb87392c0 feat(sync): Avoid syncing remote datalayers' features
They will be synced on their own, and we dont want them to be present
twice on the map.
2024-06-07 18:21:30 +02:00
b99c242648 fix(sync): Initialize tilelayerand remoteData earlier.
It makes it possible to set these values on a remote peer.
2024-06-07 18:21:30 +02:00
059103b66c fix(sync): Allow overlays to sync
`this.options.overlay` is now set during `map.initialize()`, which makes
it possible to be set by incoming websocket operations.
2024-06-07 18:21:30 +02:00
2fafad714e chore(sync): Ensure properties can be updated before doing it.
When receiving a message, this checks the given properties belong to
the "subject" before applying the message.
2024-06-07 18:21:30 +02:00
25ccdde0b0 chore(schema): Add a belongsTo field in the schema.
The goal is to use this as a security measure, to check that the
updated properties belong the the "subject" when receiving sync
operations.
2024-06-07 18:21:30 +02:00
28a359e03f fix(sync): Allow cloning of features
Removing the `id` from the feature when cloning makes it generate a new
one. Without this change, the cloned feature keep the already existing
`id`, and during sync, the original object is lost (replaced by the
clone).

Nobody wants to be replaced by a clone.
2024-06-07 18:21:30 +02:00
e4bcb53c6f feat(sync): Sync only when the edition of a feature is over.
It's less spectacular than sending the position as it changes, but takes
less bandwidth and seems good enough.
2024-06-07 18:21:30 +02:00
ce0f3c9d3e fix(sync): Import the data when syncing GeoJSON objects.
Prior to these changes, the data wasn't transmitted over WebSocket, and
even if present it wasn't taken into account.
2024-06-07 18:21:30 +02:00
e24173eb9f fix(sync): Keep features IDs for Polygons and Lines
It wasn't passed previously, so objects where duplicated.
2024-06-07 18:21:30 +02:00
c6ee25b906 feat(sync): Only sync when on edit mode
The is done to save server resources, for accessed maps which
aren't currently being edited.
2024-06-07 18:21:30 +02:00
66eb90ffd1 chore(sync): Move the sync flag in the options
The goal being for it to be hidden for now.

- Add a `is_owner` method on the map and use it in the view
- Remove duplicated line in `global.js`
- Rename `Datalayer` to `DataLayer` everywhere
- Move the sync flag in the map options (next to slideshow)
2024-06-07 18:21:30 +02:00
32a4f3feda feat(sync): Add WebSocket specific settings
`WEBSOCKET_ENABLED`, `WEBSOCKET_HOST`, `WEBSOCKET_PORT` and
`WEBSOCKET_URI` have been added.

They are being transmitted to the client via the `map.options`.
When `WEBSOCKET_ENABLED` is set to `False`, the client doesn't have
the ability to be synced.
2024-06-07 18:21:30 +02:00
5e692d2280 feat(sync): Add a enableSync option.
This changes how the syncEngine works. At the moment, it's always
instanciated, even if no syncing is configured. It just does nothing.

This is to avoid doing `if (engine) engine.update()` calls everywhere
we use it.

You now need to `start()` and `stop()` it.
2024-06-07 18:21:30 +02:00
9a74cc370c feat(sync): initialize datalayers internal objects in the constructor.
Otherwise, an event can come from the websocket, trying to update an
`undefined` property.
2024-06-07 18:21:30 +02:00
b956101d5d feat(sync): sync layer's properties.
This also changes the interface between the synced classes and the sync
engine.

The sync engines only requires two methods now:

- `getSyncMetadata()` which returns all the metadata needed, including
the `engine`.
- `render()` which renders the object, updating the needed parts.
2024-06-07 18:21:30 +02:00
66105127cb feat(sync): Sync features over websockets
Added a new `geometryToFeature` method in `umap.layer.js` which can
update a given geometry if needed.

A new `id` property can also be passed to the features on creation, to
make it possible to have the same features `id` on different peers.
2024-06-07 18:21:30 +02:00
c9abb15dd1 feat(sync): sync map properties over websocket
All keystrokes are currently sent, which is not ideal because it will
use a lot of bandwidth.
2024-06-07 18:21:30 +02:00
698c926997 feat(sync): sync features and map properties
Synced objects now expose different methods, such as:
- `getSyncEngine` which returns the location of the sync object.
- `getMetadata` which returns the associated metadata with the object.

Hooks have been added when features are created or changed, so the
changes can be synced with other peers.
2024-06-07 18:21:30 +02:00
f255c3c8a5 feat(websockets): Authenticate with signed tokens.
Authentication is now done using a signed token provided by the Django
server, sent by the JS client and checked by the WebSocket server.

The token contains a `permissions` key that's checked to ensure the user
has access to the map "room", where events will be shared by the peers.
2024-06-07 18:21:30 +02:00
e2b9b161e6 feat(websockets): First SyncEngine appearance
A new SyncEngine module has been added to the JavaScript code. It aims
to sync the local changes with remote ones. This first implementation
relies on a websocket connection.
2024-06-07 18:21:30 +02:00
1128348db6 feat(WebSockets): Features a WebSocket server.
There is one "room" per map, and the server relays messages to all the
other connected peers.

Messages are checked for compliance with what's allowed as a security
measure. They should also be checked in the clients to avoid potential
attack vectors.
2024-06-07 18:21:30 +02:00
ee3dbb85ca doc: update cookie-related comment 2024-06-07 18:21:30 +02:00
2daeaf12e0 WIP 2024-06-07 18:21:30 +02:00
c1fe86747b feat(settings): Expose settings as a dict.
This makes it possible to use them in standalone scripts, when using
`django.settings.configure(**settings_dict)`.
2024-06-07 18:21:30 +02:00
Yohan Boniface
de62a92f76 docs: add user docs for keyboard shortcuts 2024-06-06 07:16:02 +02:00
Yohan Boniface
9d211005b1 chore: remove U.Keys, and refactor global shorcuts 2024-06-06 07:15:49 +02:00
Yohan Boniface
ef94389c03
Merge pull request #1881 from umap-project/help-module
chore: move help to a separate module
2024-06-06 06:41:41 +02:00
Yohan Boniface
c70951a994 chore: move help to a separate module 2024-06-05 19:42:15 +02:00
Yohan Boniface
d3599fbe9e
Merge pull request #1879 from umap-project/dependabot/pip/ruff-0.4.7
chore: bump ruff from 0.4.5 to 0.4.7
2024-06-05 11:46:47 +02:00
Yohan Boniface
b7b39fa2f5 i18n 2024-06-05 10:50:21 +02:00
dependabot[bot]
befc9b3ec2
chore: bump ruff from 0.4.5 to 0.4.7
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.4.5 to 0.4.7.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.4.5...v0.4.7)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-05 08:49:29 +00:00
Yohan Boniface
56e401dea5
Merge pull request #1878 from umap-project/dependabot/pip/uwsgi-2.0.26
chore: bump uwsgi from 2.0.25.1 to 2.0.26
2024-06-05 10:48:42 +02:00
Yohan Boniface
2430a43445
Merge pull request #1877 from umap-project/dependabot/pip/requests-2.32.3
chore: bump requests from 2.32.2 to 2.32.3
2024-06-05 10:48:20 +02:00
Yohan Boniface
f256d7a75a
Merge pull request #1880 from umap-project/dependabot/pip/hatch-1.12.0
chore: bump hatch from 1.11.1 to 1.12.0
2024-06-05 10:48:01 +02:00
dependabot[bot]
e3c21151f9
chore: bump hatch from 1.11.1 to 1.12.0
Bumps [hatch](https://github.com/pypa/hatch) from 1.11.1 to 1.12.0.
- [Release notes](https://github.com/pypa/hatch/releases)
- [Commits](https://github.com/pypa/hatch/compare/hatch-v1.11.1...hatch-v1.12.0)

---
updated-dependencies:
- dependency-name: hatch
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-03 17:58:28 +00:00
dependabot[bot]
a037d36ae0
chore: bump uwsgi from 2.0.25.1 to 2.0.26
Bumps [uwsgi](https://uwsgi-docs.readthedocs.io/en/latest/) from 2.0.25.1 to 2.0.26.

---
updated-dependencies:
- dependency-name: uwsgi
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-03 17:58:09 +00:00
dependabot[bot]
a1050be5e8
chore: bump requests from 2.32.2 to 2.32.3
Bumps [requests](https://github.com/psf/requests) from 2.32.2 to 2.32.3.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.32.2...v2.32.3)

---
updated-dependencies:
- dependency-name: requests
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-03 17:58:03 +00:00