Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sync) Add a belongsTo property in the schema #1828

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
d2e3148
feat(settings): Expose settings as a dict.
almet Apr 16, 2024
b10b1ed
WIP
almet Apr 8, 2024
fd98170
doc: update cookie-related comment
almet Apr 16, 2024
d11451a
feat(WebSockets): Features a WebSocket server.
almet Apr 16, 2024
6122b2b
feat(websockets): First SyncEngine appearance
almet Apr 19, 2024
4de4907
feat(websockets): Authenticate with signed tokens.
almet Apr 19, 2024
4474f06
feat(sync): sync features and map properties
almet Apr 19, 2024
cd09cac
feat(sync): sync map properties over websocket
almet Apr 19, 2024
8a4c50d
feat(sync): Sync features over websockets
almet Apr 19, 2024
2bd96d2
feat(sync): sync layer's properties.
almet Apr 29, 2024
1ed4784
feat(sync): initialize datalayers internal objects in the constructor.
almet Apr 29, 2024
c4db041
feat(sync): Add a `enableSync` option.
almet Apr 30, 2024
33108a9
feat(sync): Add WebSocket specific settings
almet Apr 30, 2024
346391b
chore(sync): Move the sync flag in the options
almet May 7, 2024
f964bff
feat(sync): Only sync when on edit mode
almet May 7, 2024
23d1c3b
fix(sync): Keep features IDs for Polygons and Lines
almet May 7, 2024
99e24d9
fix(sync): Import the data when syncing GeoJSON objects.
almet May 8, 2024
5a32a3d
feat(sync): Sync only when the edition of a feature is over.
almet May 8, 2024
0bddba2
fix(sync): Allow cloning of features
almet May 9, 2024
1c1dd4a
chore(schema): Add a `belongsTo` field in the schema.
almet May 9, 2024
bfd7613
chore(sync): Ensure properties can be updated before doing it.
almet May 9, 2024
1aad901
fix(sync): Allow overlays to sync
almet May 9, 2024
1d2cf98
fix(sync): Initialize `tilelayer`and `remoteData` earlier.
almet May 9, 2024
a491a7c
feat(sync): Avoid syncing remote datalayers' features
almet May 9, 2024
1f07826
feat(sync): handle syncing of map limitbounds.
almet May 9, 2024
cbdcfba
fix(sync): intialize the sync engine before entering edit mode.
almet May 9, 2024
81554d1
feat(settings): allow reading socket-related settings from ENV variables
almet May 9, 2024
57355eb
chore(sync): remove useless dependencies from ws.py
almet May 9, 2024
61d8ccb
chore(docker): run the websocket server as a separate command
almet May 9, 2024
178eb2a
fix(sync): allow features geometries to be synced
almet May 9, 2024
47070d1
feat(sync): Allow the sync of datalayer creation
almet May 13, 2024
190c353
fix(sync): do not call `getSyncMetadata` if it doesn't exist
almet May 13, 2024
90e85f1
fix(sync) only send datalayer options
almet May 13, 2024
b85ee40
chore(docker) remove ws.py for now
almet May 13, 2024
124b727
chore(sync) make the test pass
almet May 13, 2024
991add9
refactor(sync): Remove unnecessary complexity
almet May 13, 2024
d95d8d4
feat(sync): add tests for the websocket token view
almet May 13, 2024
6618f38
feat(sync): Add JS unittests for `updateObjectValue`, and refactor.
almet May 14, 2024
c0212ee
chore(sync): Add message-dispatcher unit tests
almet May 14, 2024
fff2235
chore(tests): Rename "collaboration" tests to "optimistic merge"
almet May 14, 2024
2c9b823
tests(sync): Test that marker sync works properly
almet May 14, 2024
4c6e0a8
test(sync): Marker drag-n-drop and delete are synced
almet May 15, 2024
98c3849
test(sync): Ensure polygons and their edits can be synced
almet May 15, 2024
550a43c
test(sync): ensure polygon drag-n-drop is synced
almet May 15, 2024
2ca27c3
test(sync): Ensure map properties are synced
almet May 15, 2024
35c51a8
test(sync): Ensure datalayer properties are synced
almet May 15, 2024
ea66e6a
fix(schema): dashArray belongs to features as well
almet May 15, 2024
0bc5af2
chore(utils): remove `console.log` calls
almet May 15, 2024
bfdc87a
chore(sync): use `sync=false` everywhere to stop propagation
almet May 15, 2024
a646909
chore(sync): Sync engine now retrieves auth token
almet May 15, 2024
d897bb5
chore(sync): relax some validation logic on the websocket server
almet May 15, 2024
81b2bba
chore(test): fix a typo
almet May 16, 2024
cb54cbb
chore(test): remove empty test
almet May 16, 2024
f115e75
test(sync): WIP
almet May 16, 2024
56244cf
chore(sync): remove `belongsTo` for now
almet May 16, 2024
82abfeb
feat(sync) Add a `belongsTo` property in the schema
almet May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ dependencies = [
"django-probes==1.7.0",
"Pillow==10.3.0",
"psycopg==3.1.18",
"pydantic==2.7.0",
"requests==2.31.0",
"rcssmin==1.1.2",
"rjsmin==1.2.2",
"social-auth-core==4.5.4",
"social-auth-app-django==5.4.1",
"websockets==12.0",
]

[project.optional-dependencies]
Expand All @@ -60,6 +62,7 @@ test = [
"pytest-django==4.8.0",
"pytest-playwright==0.5.0",
"pytest-xdist>=3.5.0,<4",
"pytest-xprocess>=1.0.1",
]
docker = [
"uwsgi==2.0.25.1",
Expand Down
7 changes: 6 additions & 1 deletion umap/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,14 @@ def get_anonymous_edit_url(self):
path = reverse("map_anonymous_edit_url", kwargs={"signature": signature})
return settings.SITE_URL + path

def is_owner(self, user=None, request=None):
if user and self.owner == user:
return True
return self.is_anonymous_owner(request)

def is_anonymous_owner(self, request):
if not request or self.owner:
# edit cookies are only valid while map hasn't owner
# edit cookies are only valid while the map doesn't have owner
return False
key, value = self.signed_cookie_elements
try:
Expand Down
3 changes: 3 additions & 0 deletions umap/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@
globals()["STATICFILES_DIRS"].insert(0, value)
else:
globals()[key] = value

# Expose these settings for consumption by e.g. django.settings.configure.
settings_as_dict = {k: v for k, v in globals().items() if k.isupper()}
7 changes: 7 additions & 0 deletions umap/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,10 @@
},
},
}

# WebSocket configuration

WEBSOCKET_ENABLED = env.bool("WEBSOCKET_ENABLED", default=False)
WEBSOCKET_HOST = env("WEBSOCKET_HOST", default="localhost")
WEBSOCKET_PORT = env.int("WEBSOCKET_PORT", default=8001)
WEBSOCKET_URI = env("WEBSOCKET_URI", default="ws://localhost:8001")
26 changes: 14 additions & 12 deletions umap/static/umap/js/modules/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,26 @@ import * as Utils from './utils.js'
import { SCHEMA } from './schema.js'
import { Request, ServerRequest, RequestError, HTTPError, NOKError } from './request.js'
import Orderable from './orderable.js'

import { SyncEngine } from './sync/engine.js'
// Import modules and export them to the global scope.
// For the not yet module-compatible JS out there.

// By alphabetic order
window.U = {
URLs,
Request,
ServerRequest,
RequestError,
HTTPError,
NOKError,
Browser,
Facets,
Panel,
Caption,
EditPanel,
Facets,
FullPanel,
Utils,
SCHEMA,
HTTPError,
NOKError,
Orderable,
Caption,
Panel,
Request,
RequestError,
SCHEMA,
ServerRequest,
SyncEngine,
URLs,
Utils,
}
Loading