-
Notifications
You must be signed in to change notification settings - Fork 42
Prevent negative clicks during manual centering and display a UI message #1649
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
Prevent negative clicks during manual centering and display a UI message #1649
Conversation
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.
I'm surprised we hadn't caught this bug sooner. 😱 Good catch! 🎣 It could explain why we were having issues with this in the Cypress tests...
As before, as a safeguard, I would prefer if the back-end returned a 4xx error to the front-end (which would then display that error via showErrorPanel
). Then, to improve the user experience, I would find a way to not dispatch the click action while the 3-click centring process is in progress. As you hinted at, this would require a WebSocket message, a Redux action, and a new flag in the state.
Very nice :), it would be great with error from the backend as well as @axelboc pointed out. |
What you suggest is very nice and I think you did an excellent work wit this PR :)
You mean, instead of returning or raising an exception to send a signal and websocket with the result instead ? That could also work very well. I'm not sure it would make much of a difference for this kind of short interaction. |
Yeah, you're right, it'd probably be a bit over-engineered. So keeping the 4xx error response in mind, I think that means basically catching the error and showing that "Please wait" message instead of dispatching |
Yes, thats what I thought |
I guess this would also need the necessary changes to |
Actually I tried only with |
Thanks @alessandro-olivo. The best thing would be if you could add the lock code to the two other diffractometer classes It would otherwise be nice if you could test without the changes to Thanks again for the super nice work ! |
Right now, the "lock logic" is only implemented in our In any case, I’ll try to implement this logic in both
I've already tested these changes with the |
Ok, sounds perfect @alessandro-olivo. So ill merge this for now then ! |
Ah, @alessandro-olivo, could you re-base and then merge please ;) |
…feature-diffr_is_moving" in the mxcubecore repository is mandatory for this commit)
…notification in the UI
7120fa8
to
9df2aa2
Compare
Done! I think this week I should be able to give a try to the aforementioned changes |
The feature/fix allows handling user clicks that happen while a manual centering step is still in progress. A message is shown on the UI to inform the user.
The issue
After the first manual centering click, if the user clicks again before the first step is completed, a message appears on the UI and the number of available clicks is reduced by one. If the user keeps clicking, the click count can go negative, as shown in the screenshot:

This behavior can be tested adding a
time.sleep(3)
in themanual_centring
method of theDiffractometerMockup
HWOdef manual_centring(self): """ Descript. : """ for click in range(3): self.user_clicked_event = AsyncResult() #self.waiting_for_click = True x, y = self.user_clicked_event.get() if click < 2: + time.sleep(3) self.motor_hwobj_dict["phi"].set_value_relative(90) self.last_centred_position[0] = x self.last_centred_position[1] = y centred_pos_dir = self._get_random_centring_position() return centred_pos_dir
The proposed change
In
mxcubeweb/core/components/sampleview.py
The change allows, raising an Exception from

.imageClicked(...)
, to inform the frontend that the centering step is still in progress. If the frontend receives a negative click (i.e. "-1") it will show the following message:Test the feature:
Just apply the following changes in the
DiffractometerMockup
:Thoughts