-
Notifications
You must be signed in to change notification settings - Fork 80
Websockets on cart page #1058
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
Websockets on cart page #1058
Conversation
…ebsockets-on-cart-page
Ready for review |
Changes Unknown when pulling 795c748 on squirrelo:websockets-on-cart-page into * on biocore:cart-branch*. |
argh, conflicts, can you pull from upstream master and upstream cart-branch. |
Done, tests running now. |
@biocore/qiita-dev Tests pass, ready for review! |
Ok, now I'm reviewing this one. |
# parse into JSON | ||
msginfo = loads(msg) | ||
default = Analysis(self.current_user.default_analysis) | ||
if 'samples' not in msginfo: |
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 think you can simplify this if/else block by using msginfo.get('samples'), which would return a None
when 'samples'
is not part of the dictionary. And perhaps, this is the way both arguments should be retrieved such that in case nothing was sent remove_samples would raise an exception (QiitaIncompetentDeveloper, I think).
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.
if the object sent over the line always includes samples
then the message is consistent. In this branch, the message would just need to have samples
associated with []
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.
or None
This looks great!! Such an awesome improvement overall, a few things:
File "/Users/yoshikivazquezbaeza/.virtualenvs/qiita/lib/python2.7/site-package
s/tornado/web.py", line 1141, in _when_complete
callback()
File "/Users/yoshikivazquezbaeza/.virtualenvs/qiita/lib/python2.7/site-package
s/tornado/web.py", line 1162, in _execute_method
self._when_complete(method(*self.path_args, **self.path_kwargs),
File "/Users/yoshikivazquezbaeza/.virtualenvs/qiita/lib/python2.7/site-package
s/tornado/web.py", line 2297, in wrapper
return method(self, *args, **kwargs)
File "/Users/yoshikivazquezbaeza/git_sw/qiita/qiita_pet/handlers/analysis_hand
lers.py", line 220, in get
proc_info=proc_data_info)
File "/Users/yoshikivazquezbaeza/.virtualenvs/qiita/lib/python2.7/site-packages/tornado/web.py", line 538, in render
html = self.render_string(template_name, **kwargs)
File "/Users/yoshikivazquezbaeza/.virtualenvs/qiita/lib/python2.7/site-packages/tornado/web.py", line 645, in render_string
return t.generate(**namespace)
File "/Users/yoshikivazquezbaeza/.virtualenvs/qiita/lib/python2.7/site-packages/tornado/template.py", line 273, in generate
return execute()
File "analysis_selected_html.generated.py", line 276, in _tt_execute
for pid in proc_datas: # analysis_selected.html:79 (via sitebase.html:192)
UnboundLocalError: local variable 'proc_datas' referenced before assignment |
@@ -63,6 +72,10 @@ | |||
</div> | |||
{% end %} | |||
|
|||
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#create-analysis-modal-view"> |
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.
This button would be better ( I think ) at the top.
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.
And probably colored in "green"
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 have it at the bottom to force people to look at what they selected before hitting create. I can make it green though.
When I select a few samples and try to create the analysis, I get a 405 error. |
Last thing, now that I've been able to list several studies under the "/selected/" handler, I think it would be better if the studies were presented inside a data table. And the table shouldn't use the full width of the window, it looks weird. |
@@ -1,8 +1,15 @@ | |||
{% extends sitebase.html %} | |||
{% block head %} | |||
<script type="text/javascript"> | |||
var ws = new WebSocket('ws://' + window.location.host + '/analysis/selected/socket/'); |
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.
It would be really nice if it were possible to reuse the moi init here since it is already doing browser checking.
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.
Can do.
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.
Added an init_websocket
function for taking care of boilerplate code.
I've not gone over the code but I was testing this branch as @squirrelo suggested that this is the last PR on this branch. One of the things that act weirdly is that I can select samples, go to the "View selected samples" page; and, when I go back to the study listing page, I have no feedback of which samples have been already selected. I would suggest that the checkbox should be checked if you've already chosen those samples. Alternatively, I would suggest changing the checkbox to a |
Also, I cannot create an analysis. I added a new study, completely processed it, I only choose it's samples. When I click create analysis on the modal that appears, nothing happens... As a note, nothing in my terminal or javascript console, so no clue on what is going on. |
Fixed the issue with creation of new analyses, the modal was submitting to the wrong page. As for previously selected samples, I agree that something needs to be done, but it's something that needs a lot of discussion and thought. For now, I think what we have will work, and it can be expanded upon when we come to a conclusion for how previously selected samples are shown. The big issue is that you aren't selecting by sample, but by processed data. |
Thanks for the comments @squirrelo |
This is good to go as is for now though, since it's still on it's own branch. In light of that, can we get this a final review and merge? |
As @ElDeveloper suggests, I will be more comfortable if @wasade can review this, as he has more experience with websockets and he already had some comments on this PR. |
This only changed a single number, so the tests will pass fine. It's good to review. |
var ws = init_websocket(window.location.host + '/analysis/selected/socket/'); | ||
ws.onmessage = function(evt) { if(evt.data != 'true') {ws.close();} }; | ||
ws.onerror = function(evt) { $('#ws-error').html("<b>Server communication error. Sample removal will not be recorded. Please try again later.</b>"); }; | ||
ws.onclose = function(evt) { $('#ws-error').html("<b>Server communication error. Sample removal will not be recorded. Please try again later.</b>"); }; |
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.
Closing a web socket should be a normal operation, right? Why is this considered an error?
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.
n this case, it should stay open until you leave the page in order to capture sample removals. If it closes prematurely that’s bad and should be treated as an error.
On Apr 22, 2015, at 7:20 AM, Daniel McDonald notifications@github.com wrote:
In qiita_pet/templates/analysis_selected.html #1058 (comment):
@@ -1,8 +1,15 @@
<script type="text/javascript"> +var ws = init_websocket(window.location.host + '/analysis/selected/socket/'); +ws.onmessage = function(evt) { if(evt.data != 'true') {ws.close();} }; +ws.onerror = function(evt) { $('#ws-error').html("Server communication error. Sample removal will not be recorded. Please try again later."); }; +ws.onclose = function(evt) { $('#ws-error').html("Server communication error. Sample removal will not be recorded. Please try again later."); }; Closing a web socket should be a normal operation, right? Why is this considered an error?
{% extends sitebase.html %}
{% block head %}—
Reply to this email directly or view it on GitHub https://github.com/biocore/qiita/pull/1058/files#r28876200.
What is the reason for not reusing the moi client-side websocket code? It would require only a minor modification to moi.js (allow specifying an onerror method at construction, and the specific handler the websocket should use). This is an opportunity to reduce js code replication and centralize websocket handling client-side. |
The MOI.js is specific to what MOI is doing. I can make it generalizable, but then it’s no longe the same asr MOI.js in the MOI repo and the changes will need to get moved there as well. This is a fast solution that allows us to have qiita-specific websocket code and MOI specific web socket code coexist.
|
It really isn't specific. Is a PR for the minor changes against moi not possible? It literally does the exact same thing, is just more flexible. That argument is analogous to writing a custom fasta parser every time we need to parse a fasta file. It's quick, allows for special casing whatever random garbage is in the comment field, but hurts us in the long run. |
Ok, broke out the web socket initialization and in the process may have fixed #993. If the MOI code looks good I’ll open a pull request to add it directly into MOI.
|
Great, thank you
|
This is now fully MOI-ified so it should be ready for merge. I will add the cart info stuff to the top corner in a subsequent pull request, since this one is already growing rather large. |
👍 |
~~Requires #1041 so merge that first.~~Merged
Depends on #1056 so merge that firstMergedThis adds websocket-based removal of samples and processed data on the selected samples cart page. It also moves the analysis creation to that page as well.