bgruening / galaxy-ipython

:microscope::books: IPython Integration into Galaxy
MIT License
31 stars 14 forks source link

Refreshing the Galaxy history after putting data in it. #3

Open bgruening opened 10 years ago

bgruening commented 10 years ago

It would be nice if we were able to refresh the history after we have transferred some data to it. I'm not aware of any function from bioblend that supports that ...

hexylena commented 10 years ago

That would be really nice, agreed. Howevever since the client is polling the server for history updates, there's no way for the server to tell the client anything ahead of the next scheduled poll.

I bet we could do something like this though: http://stackoverflow.com/questions/7502047/can-scripts-in-iframe-interact-with-scripts-in-the-main-pag

Because the docker and galaxy instances are on the same domain we can probably trigger javascript to click the refresh history button.

We can definitely do that on notebook save. No idea how we'll do it on put() requests though.

hexylena commented 10 years ago

Okay, I've tested this today and cannot get this to work. It may be for any number of reasons (I'm certainly no JS expert, perhaps someone who is will be able to fix this.)

I tested it by opening up a new notebook and running the following in a cell:

from IPython.display import HTML
js = """
<script type="text/javascript>
$("#history-refresh-button").click();
</script>
"""
HTML(js)

In the context of a browser JS console window, this works correctly and reloads the history. In the context of IPython if fails to execute the refresh.

hexylena commented 10 years ago

From IRC, we'll have to have a PubSubHub of some manner running on the notebook image, which can be subscribed to by JS within the mako template. Whenever we receive a notification of a new history item, we can call Galaxy.currHistoryPanel.refreshContents, where var Galaxy = window.parent.Galaxy;

12:27 < ceberhard> So, here's my next guess:
12:27 < ceberhard> You *can* access the Galaxy object from your vis template scripts.
12:27 < ceberhard> "console.debug( 'parent:', window.parent.Galaxy );"
12:27 < esr_> Hmmmmmmmmm
12:27 < ceberhard> (this would only work if it's displayed in the center panel and not if it's in it's own tab).
12:28 < esr_> Oh that gets messy quickly...we could use JS in the template to parse the DOM we've loaded and watch for changes?
12:28 < ceberhard> I would recommend pubsub for that.
12:28 < esr_> Huh. That's a very interesting idea.
12:28 < ceberhard> If you can create a mediator in your mako template between the parent.Galaxy and the template.
12:28 < esr_> bag: mark for v0.2 :P
12:29 < bag> ceberhard, it is in the central panel
12:29 < esr_> yeah
12:29 < esr_> HUH.
12:29 < ceberhard> And then, also have it mediate between your *inner* iframe and it's messages.
12:29 < esr_> That might work
12:29 < esr_> Great suggestion, thanks :)
12:29 < ceberhard> Well - don't thank me yet.
12:29 < bag> esr_, yes nothing for version 0.1 :)
12:29 < ceberhard> Because it's from a different host...
12:30 < ceberhard> the message from your *inner* iframe to the mako template may not be allowed.
12:30 < esr_> ceberhard: well, if we can access galaxy there we can easily pubsub with the remote end for changes, that shouldn't be a problem.