Uploading to history via JavaScript
Essentially, this the similar to a dataset upload where the origin is from a web page when a user clicks on a HTML button. The button is not part of the tool framework but any number of possible I am writing a variety of data editors in JavaScript and it would be convenient to upload the dataset into the user's current history list. of JavaScript actions. I think I should be able to use the regular upload1 (upload.py) machinery. But So far, I have not had success in tricking it with my JavaScript function. I know that I could add web api. But there is a lot hairy code in the history dataset association that looks like it will change. So I'd rather keep it simple. Does anyone have any suggestions? Thanks, Ted function UploadToHistory(name, value) { var payload = { tool_id: "upload1", 'file_type': 'tabular', 'file_name', name, 'dbkey': '?', 'files_0|url_paste': value}; $.ajax( { async: false, type: "POST", url: "/tool_runner/index", data: payload, dataType: "json", success: function(array_obj, status) { console.log("success", array_obj, status); }, failure: function() {console.log("fail");} } ); }
What is the error that you're seeing on the server side? I haven't tried this myself, but Brad Chapman suggested this example payload: -- {"tool_id": "upload1", "history_id": "identifier of history to use", "params": {"file_type": "vcf", "dbkey": "hg19", "files_0|url_paste": http://jbrowse-server.org/path/to/file.vcf", "files_0|NAME": "file_name_for_history.vcf"}} -- Maybe try removing file_type and adding files0|NAME? J. On Nov 12, 2012, at 6:42 PM, Ted Goldstein wrote:
Essentially, this the similar to a dataset upload where the origin is from a web page when a user clicks on a HTML button. The button is not part of the tool framework but any number of possible I am writing a variety of data editors in JavaScript and it would be convenient to upload the dataset into the user's current history list. of JavaScript actions.
I think I should be able to use the regular upload1 (upload.py) machinery. But So far, I have not had success in tricking it with my JavaScript function. I know that I could add web api. But there is a lot hairy code in the history dataset association that looks like it will change. So I'd rather keep it simple.
Does anyone have any suggestions?
Thanks, Ted
function UploadToHistory(name, value) { var payload = { tool_id: "upload1", 'file_type': 'tabular', 'file_name', name, 'dbkey': '?', 'files_0|url_paste': value};
$.ajax( { async: false, type: "POST", url: "/tool_runner/index", data: payload, dataType: "json", success: function(array_obj, status) { console.log("success", array_obj, status); }, failure: function() {console.log("fail");} } ); } ___________________________________________________________ Please keep all replies on the list by using "reply all" in your mail client. To manage your subscriptions to this and other Galaxy lists, please use the interface at:
Thanks Jeremy and Brad. I have made some good progress. The code below works but does not give a newname. It needs this to work: 'runtool_btn': 'Execute', is a required parameter in the various checks (there is also validation code there for a URL origin parameter too). The code below works but the only problem is that the name comes out as Pasted Entry. I see some lines in ./lib/galaxy/tools/parameters/grouping.py:241: if override_name: ./lib/galaxy/tools/parameters/grouping.py:242: dataset_name = override_name That looks like the NAME parameter should do the trick of setting a name instead of Pasted Entry. I've tried tracking through the new_state and I think the problem is that NAME is not a known paremeter Any further advice? function upload(name, value) { var payload = {"tool_id": "upload1", 'file_type': 'auto', 'runtool_btn': 'Execute', 'files_0|url_paste': value, "files_0|NAME": name}; $.ajax( { async: false, type: "POST", url: "/tool_runner/index", data: payload, dataType: "json", success: function(array_obj, status) { console.log("success", array_obj, status); }, failure: function() {console.log("fail");} } ); } Best regards Ted On Nov 12, 2012, at 6:28 PM, Jeremy Goecks wrote:
What is the error that you're seeing on the server side?
I haven't tried this myself, but Brad Chapman suggested this example payload:
-- {"tool_id": "upload1", "history_id": "identifier of history to use", "params": {"file_type": "vcf", "dbkey": "hg19", "files_0|url_paste": http://jbrowse-server.org/path/to/file.vcf", "files_0|NAME": "file_name_for_history.vcf"}} --
Maybe try removing file_type and adding files0|NAME?
J.
On Nov 12, 2012, at 6:42 PM, Ted Goldstein wrote:
Essentially, this the similar to a dataset upload where the origin is from a web page when a user clicks on a HTML button. The button is not part of the tool framework but any number of possible I am writing a variety of data editors in JavaScript and it would be convenient to upload the dataset into the user's current history list. of JavaScript actions.
I think I should be able to use the regular upload1 (upload.py) machinery. But So far, I have not had success in tricking it with my JavaScript function. I know that I could add web api. But there is a lot hairy code in the history dataset association that looks like it will change. So I'd rather keep it simple.
Does anyone have any suggestions?
Thanks, Ted
function UploadToHistory(name, value) { var payload = { tool_id: "upload1", 'file_type': 'tabular', 'file_name', name, 'dbkey': '?', 'files_0|url_paste': value};
$.ajax( { async: false, type: "POST", url: "/tool_runner/index", data: payload, dataType: "json", success: function(array_obj, status) { console.log("success", array_obj, status); }, failure: function() {console.log("fail");} } ); } ___________________________________________________________ Please keep all replies on the list by using "reply all" in your mail client. To manage your subscriptions to this and other Galaxy lists, please use the interface at:
participants (2)
-
Jeremy Goecks
-
Ted Goldstein