-
Notifications
You must be signed in to change notification settings - Fork 234
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
UI activate Server Sent Events #1532
Conversation
- Enabled visual code type checking Signed-off-by: thfries <thomas.fries0@gmail.com>
Signed-off-by: thfries <thomas.fries0@gmail.com>
Hi @thfries . Regarding the eventsource polyfill I am not sure that you really need it. AFAIK you can define "withCredentials" when creating the JS EventSource which sends along the used "Authorization" header for that domain (which was already set if you authenticated against HTTP before). |
I tried that with the standard EventSource and "withCredentials" option. But then the Browser owned modal dialog for username/password appeared. So I don't know how to make the browser aware of the Authorization header that is set in the fetch calls. Do you need a sparate authenticate call for a domain? |
It should work the way we documented in the Ditto docs:
A successfully authenticated to the same domain must be done before being able to open the Eventsource with credentials as far as I know. |
Hi @thjaeckle, |
I see. For updating scalar values (eg a single feature property) you could pass a For the complete thing Json you could do it in a similar way, using the In either way, I think explicitly changing the state of a Form element explicitly to "write" could make sense (vs having always a two way binding and editable form elements). |
- Explicit editing for thing CRUD - Split of thing.js file Signed-off-by: thfries <thomas.fries0@gmail.com>
Hi again, finally here is a proposal. The best solution I found is to introduce a new button that explicitly switches from readonly mode and ends up in a modal like editing mode - while still having kind of in place editing. Currently only implemented on Things CRUD (not feature or other objects yet). Tell me what you think. I totally messed up with the merge of another branch in file searchFilter.js. I need to resolve that later. Currently this branch won't work, sorry. Some issues I observed:
Thomas |
Thanks @thfries Regarding your questions:
That is intended - as a "heartbeat" mechanism to keep the connection open (as e.g. loadbalancers would close HTTP connections after a certain "idle time" without messages).
Different than a "connection" or a websocket session those 2 HTTP calls are already 2 different sources.
This should work. curl --http2 -u ditto:ditto -H 'Accept:text/event-stream' -N https://ditto.eclipseprojects.io/api/2/things/:08672869-0539-44b9-964e-511bbfa1bdbf\?fields\=thingId,attributes,_revision,_modified
data:{"thingId":":08672869-0539-44b9-964e-511bbfa1bdbf","attributes":{"foo":"bar"},"_revision":23,"_modified":"2022-12-19T08:23:58.514052327Z"} |
Signed-off-by: thfries <thomas.fries0@gmail.com>
Thanks, @thjaeckle, the erroneous merge is fixed now. Thanks for clarifying the questions. In your curl example you used |
Ah, that explains it, yes. |
@thfries A tip or two on the SSE API usage:
The syntax you used is beneficial when watching more than one Thing (e.g. all currently visible/fetched Things in the table could also be an option - which would allow to see update to values of many things in the table):
And it may even be omitted:
In this case, you get all modifications for all the things you are allowed to see. -- |
Nice. Thanks for the feedback. Happy that you like the solution. |
- custom web component for CRUD toolbar - API allows to return headers if needed - adapt editors with new toolbar and ETag handling - fixed modified date and revision from SSE - avoid feature editors jumping because of badge in header - fixes some static type checks in utils
Signed-off-by: thfries <thomas.fries0@gmail.com>
I finished a bigger commit that includes a new custom web component for the "new editor style". That caused a lot of changes in the editing codes for things, attributes and features. Next to that, a way to handle the ETag headers was added. Finally optimistic locking works and prevents overwrites of conflicting updates by throwing an error. I'll continue with additional commits to apply the same editor style to all other places. These can be done independently. As this makes the whole UI more consistent, it is appropriate to include them in the same PR? |
Signed-off-by: thfries <thomas.fries0@gmail.com>
I have a question on the optimistic locking: It seems that ditto is responding with a Is it correct, if the PUT request just removes the |
Hi @thfries It seems that "weak entity tags" can never be used in an You could try to remove the |
Sure, I think it is good to do all those changes in this PR. |
- Added new view to see incoming updates for the selected thing - Utils format date had wrong interface description Signed-off-by: thfries <thomas.fries0@gmail.com>
- On feature update also weak ETags are allowed - Improved cleaning up on environment change Signed-off-by: thfries <thomas.fries0@gmail.com>
Added several improvements and also a new view that shows all incoming updates. That creates a bit more transparency what is going on.
|
I took a look at the Policy editors. May we keep the policies as is for now and address this with a separate PR? I am also thinking about the policy imports, that require some additional extensions. So I removed Remaining issues:
|
- Changed CRUD buttons to text and showing dynamically - wrong ETag header on feature/attribute creation - incoming changes now also show attributes Signed-off-by: thfries <thomas.fries0@gmail.com>
Hey @thjaeckle, Found an issue with the If-Match header in case one creates a new feature or new attribute. This is fixed now. Another thing I observed: If you delete a feature or attribute, the SSE does not show the change, so in these cases the UI does not automatically update. |
@thfries had a quick first look at the current state. Very promising 👍 - will have a deeper look at all modifications at a later point. One quick feedback about the ACE editor for the complete thing JSON: I noticed that when not in "Edit" mode you are still able to edit the JSON - which could be confusing (as saving that is not possible). Another thing I noticed is that custom table columns are not updated when a thing is modified (e.g. via "edit" function). Would it be possible to "sync" table and detail view model somehow? |
ACE editor should behave like you expect it. This must be a bug and will be fixed. Update of the table columns is missing, yes. I can add that (at least for the selected thing. May be this can be reused for all things in the search result, may be? |
Signed-off-by: thfries <thomas.fries0@gmail.com>
Then you would have to subscribe on the SSE for all of the thingIds currently shown in the table - this would of course be a great benefit when showing e.g. certain values in the table which update for different things, like e.g. an "Connection state". |
- Update selected thing in search result table Signed-off-by: thfries <thomas.fries0@gmail.com>
Started a quick implementation for the update of the things search table. It is not very complicated so it makes sense to include that. If I extend that to all things in the search result, should we limit that in some way? e.g.
Thanks for your advice. |
The only limiting factor here is probably the total length of the URL caused by the query param "ids" which get longer and longer the more pages are loaded .. I think it does make sense like you proposed it in the second point .. create 2 SSEs, one for the table (where e.g. all the loaded things are included) which uses the columns shown in the table. |
- create a second SSE that listens to all things of the search result - avoid ace editors from creating endless undo histories
- WoT description for feature was referencing old dom field - thing search more button changed SSE to new page and lost 1st page Signed-off-by: thfries <thomas.fries0@gmail.com>
Hi @thjaeckle , I observed that there are messages, that contain only a thingId and nothing else. So I assume the PR is ready from my point of view. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes and UI look good to me 👍
Thanks for that great contribution, @thfries
Together with the new "edit mode" this improves the UI a lot.
Resolves: #1494
First commit is just for preparation and splits things.js into smaller modules
The initial SSE implementation is quite simple, but I needed to introduced 2 new dependencies:
ToDo: