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

Backend for the state of the regulation editor #26

Merged
merged 49 commits into from
Jan 26, 2024
Merged

Conversation

ondrej33
Copy link
Member

@ondrej33 ondrej33 commented Dec 14, 2023

This PR implements the backend for tracking and validating the state of the model edited in the regulations editor. It is synchronized with the frontend using events.

The events supported by the main ModelState struct are listed in the src/aeon_events.ts file.

Before reviewing and merging this, finishing at least some of the following things would be nice. However, (except for the first one?), they can be addressed via some subsequent PR.

  • Divide the current ModelState events into "two groups" - (A) those for adding new objects (regulations, variables) and (B) those for modifying/removing the existing objects. This would enable us to fix some issues with paths and payloads. Events of group A would have a more general path, such as ['model', 'regulation', 'add'], and carry a JSON payload fully encoding some prepared structure (such as RegulationData). Events of group B would have more specific paths encoding the specific object, such as ['model', 'regulation', 'regulator_id', 'target_id', 'remove']. The payload of these events could then be just a single value or even be empty sometimes (now, all the IDs are also part of the payload, making it "bloated").
  • Finish some remaining minor events for modifying the ModelState and add tests for the some remaining cases.
  • Update the API src/aeon_events.ts reflecting the previous points.
  • Utilize the front-end event API from the TS code (emit the events to the backend reacting to user inputs and react to backend events adjusting the state).
  • Finish the refresh part of the SessionState API for ModelState. There is a placeholder currently, and all the "getter" events should be added.
  • Refactor the code :)

@daemontus
Copy link
Member

A quick note for me: Currently, most actions that do not directly modify an ObservableState are handled through two objects: one that performs an action, the other that listens to the result. We should probably turn this into a Promise that is returned by the action method instead of having two objects. But this is handled completely on the frontend, the backend should work the same way it is working now.

@ondrej33 ondrej33 marked this pull request as ready for review January 3, 2024 20:54
@daemontus daemontus force-pushed the dev-regulations-state branch from 0f543da to b03a8a0 Compare January 22, 2024 09:44
@daemontus
Copy link
Member

This seems to be working now. There might be a few things that we need to solve down the line, but we'll merge it and work on new stuff in separate PRs.

@daemontus daemontus merged commit 353145f into main Jan 26, 2024
6 checks passed
@daemontus daemontus deleted the dev-regulations-state branch January 26, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants