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

Commits on May 15, 2024

  1. feat(settings): Expose settings as a dict.

    This makes it possible to use them in standalone scripts, when using
    `django.settings.configure(**settings_dict)`.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    d2e3148 View commit details
    Browse the repository at this point in the history
  2. WIP

    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    b10b1ed View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    fd98170 View commit details
    Browse the repository at this point in the history
  4. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    d11451a View commit details
    Browse the repository at this point in the history
  5. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    6122b2b View commit details
    Browse the repository at this point in the history
  6. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    4de4907 View commit details
    Browse the repository at this point in the history
  7. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    4474f06 View commit details
    Browse the repository at this point in the history
  8. feat(sync): sync map properties over websocket

    All keystrokes are currently sent, which is not ideal because it will
    use a lot of bandwidth.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    cd09cac View commit details
    Browse the repository at this point in the history
  9. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    8a4c50d View commit details
    Browse the repository at this point in the history
  10. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    2bd96d2 View commit details
    Browse the repository at this point in the history
  11. feat(sync): initialize datalayers internal objects in the constructor.

    Otherwise, an event can come from the websocket, trying to update an
    `undefined` property.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    1ed4784 View commit details
    Browse the repository at this point in the history
  12. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    c4db041 View commit details
    Browse the repository at this point in the history
  13. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    33108a9 View commit details
    Browse the repository at this point in the history
  14. 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)
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    346391b View commit details
    Browse the repository at this point in the history
  15. feat(sync): Only sync when on edit mode

    The is done to save server resources, for accessed maps which
    aren't currently being edited.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    f964bff View commit details
    Browse the repository at this point in the history
  16. fix(sync): Keep features IDs for Polygons and Lines

    It wasn't passed previously, so objects where duplicated.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    23d1c3b View commit details
    Browse the repository at this point in the history
  17. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    99e24d9 View commit details
    Browse the repository at this point in the history
  18. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    5a32a3d View commit details
    Browse the repository at this point in the history
  19. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    0bddba2 View commit details
    Browse the repository at this point in the history
  20. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    1c1dd4a View commit details
    Browse the repository at this point in the history
  21. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    bfd7613 View commit details
    Browse the repository at this point in the history
  22. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    1aad901 View commit details
    Browse the repository at this point in the history
  23. fix(sync): Initialize tilelayerand remoteData earlier.

    It makes it possible to set these values on a remote peer.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    1d2cf98 View commit details
    Browse the repository at this point in the history
  24. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    a491a7c View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    1f07826 View commit details
    Browse the repository at this point in the history
  26. fix(sync): intialize the sync engine before entering edit mode.

    Otherwise `this.sync` is not defined.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    cbdcfba View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    81554d1 View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    57355eb View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    61d8ccb View commit details
    Browse the repository at this point in the history
  30. fix(sync): allow features geometries to be synced

    By defining the `geometry` property in the schema.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    178eb2a View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    47070d1 View commit details
    Browse the repository at this point in the history
  32. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    190c353 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    90e85f1 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    b85ee40 View commit details
    Browse the repository at this point in the history
  35. chore(sync) make the test pass

    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    124b727 View commit details
    Browse the repository at this point in the history
  36. 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.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    991add9 View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    d95d8d4 View commit details
    Browse the repository at this point in the history
  38. feat(sync): Add JS unittests for updateObjectValue, and refactor.

    The new implementation uses `reduce`, in the hopes of producing a more
    readable version than old-style loops and reassignment of object values.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    6618f38 View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    c0212ee View commit details
    Browse the repository at this point in the history
  40. chore(tests): Rename "collaboration" tests to "optimistic merge"

    As "collaboration" can be mistaken between "websocket" and
    "server-merge". This naming makes it explicit.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    fff2235 View commit details
    Browse the repository at this point in the history
  41. tests(sync): Test that marker sync works properly

    This commit handles the start and stop of the websocket server during
    the tests, using the xprocess library
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    2c9b823 View commit details
    Browse the repository at this point in the history
  42. Configuration menu
    Copy the full SHA
    4c6e0a8 View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    98c3849 View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    550a43c View commit details
    Browse the repository at this point in the history
  45. test(sync): Ensure map properties are synced

    This tests that the name of the map, and that zoom-control visibility is
    properly synced over websockets.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    2ca27c3 View commit details
    Browse the repository at this point in the history
  46. Configuration menu
    Copy the full SHA
    35c51a8 View commit details
    Browse the repository at this point in the history
  47. Configuration menu
    Copy the full SHA
    ea66e6a View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    0bc5af2 View commit details
    Browse the repository at this point in the history
  49. chore(sync): use sync=false everywhere to stop propagation

    In some cases, you want to stop the propagation of events. The previous
    code was using `fromSync=true` and `sync=false` interchangeably. This
    makes it use `sync=false` everywhere.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    bfdc87a View commit details
    Browse the repository at this point in the history
  50. chore(sync): Sync engine now retrieves auth token

    It's now it's responsability to get the authentication token from
    the http server and pass it to the websocket server, it will make it
    possible to redo the roundtrip when getting disconnected.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    a646909 View commit details
    Browse the repository at this point in the history
  51. chore(sync): relax some validation logic on the websocket server

    Messages are now checked for conformity with the procol we defined, but
    stop at the `operation` boundary. Values aren't checked.
    almet committed May 15, 2024
    Configuration menu
    Copy the full SHA
    d897bb5 View commit details
    Browse the repository at this point in the history

Commits on May 16, 2024

  1. chore(test): fix a typo

    (but I would really like to see what web socker would look like)
    almet committed May 16, 2024
    Configuration menu
    Copy the full SHA
    81b2bba View commit details
    Browse the repository at this point in the history
  2. chore(test): remove empty test

    almet committed May 16, 2024
    Configuration menu
    Copy the full SHA
    cb54cbb View commit details
    Browse the repository at this point in the history
  3. test(sync): WIP

    almet committed May 16, 2024
    Configuration menu
    Copy the full SHA
    f115e75 View commit details
    Browse the repository at this point in the history
  4. chore(sync): remove belongsTo for now

    As it requires more discussion, it will happen in a separate
    pull-request.
    almet committed May 16, 2024
    Configuration menu
    Copy the full SHA
    56244cf View commit details
    Browse the repository at this point in the history
  5. feat(sync) Add a belongsTo property in the schema

    This new property allows to know what's the relation with the schema
    property and the different object types (map, datalayer, feature).
    
    This serves two goals:
    
    1. Check that the incoming messages make sense (it's possible to change
       this property in this object)
    2. Document where the property is used in practice. Because there is a
       lot of properties, it's hard to keep track of where they are used.
       This makes it explicit.
    almet committed May 16, 2024
    Configuration menu
    Copy the full SHA
    82abfeb View commit details
    Browse the repository at this point in the history