Skip to content

Commit

Permalink
Add Upload2 support through the browser.
Browse files Browse the repository at this point in the history
Minor refactoring of Upload1 to pull the URIs out into v1 and v2 files
to avoid cloning a bunch of .js files.
  • Loading branch information
tomkraljevic committed Dec 8, 2013
1 parent dca1e35 commit a5cdeb4
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/resources/jquery.fileupload/js/api_v1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var H2O_POSTFILE_URI = '/PostFile.json';
var H2O_PARSE_URI = 'Parse.query';
2 changes: 2 additions & 0 deletions lib/resources/jquery.fileupload/js/api_v2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var H2O_POSTFILE_URI = '/2/PostFile.json';
var H2O_PARSE_URI = '2/Parse2.query';
4 changes: 2 additions & 2 deletions lib/resources/jquery.fileupload/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $(function () {
$('#UploadBtn').unbind('click').click(function(e) {
e.preventDefault();
$(this).prop("disabled",true);
uri = '/PostFile.json?key=' + $("table #key").val();
uri = H2O_POSTFILE_URI + '?key=' + $("table #key").val();
data.url = uri;
data.submit();
});
Expand All @@ -51,7 +51,7 @@ $(function () {
result = $.parseJSON(result);
}
if(result.response.status == "done") {
window.location.href='Parse.query?source_key=' + $("table #key").val();
window.location.href = H2O_PARSE_URI + '?source_key=' + $("table #key").val();
return;
}
failedUpload("callback done(), but the response is wrong: " + result, data);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/water/api/RequestServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,14 @@ public static HashMap<String,Request> requests() {
} else {
Request.addToNavbar(registerRequest(new ImportFiles2()), "Import Files2", "Beta (FluidVecs!)");
Request.addToNavbar(registerRequest(new Parse2()), "Parse2", "Beta (FluidVecs!)");
Request.addToNavbar(registerRequest(new Upload2()), "Upload2", "Beta (FluidVecs!)");
Request.addToNavbar(registerRequest(new Inspect2()), "Inspect2", "Beta (FluidVecs!)");
Request.addToNavbar(registerRequest(new hex.LR2()), "Linear Regression2", "Beta (FluidVecs!)");
Request.addToNavbar(registerRequest(new SummaryPage2()), "Summary2", "Beta (FluidVecs!)");
Request.addToNavbar(registerRequest(new Console()), "Console", "Beta (FluidVecs!)");
Request.addToNavbar(registerRequest(new ExportModel()), "Export Model", "Beta (FluidVecs!)");
Request.addToNavbar(registerRequest(new ImportModel()), "Import Model", "Beta (FluidVecs!)");
}
}

// internal handlers
//registerRequest(new StaticHTMLPage("/h2o/CoefficientChart.html","chart"));
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/water/api/Upload.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
public class Upload extends HTMLOnlyRequest {
@Override
protected String build(Response response) {
return "<script type='text/javascript' src='jquery.fileupload/js/vendor/jquery.ui.widget.js'></script>"
return ""
+ "<script type='text/javascript' src='jquery.fileupload/js/api_v1.js'></script>"
+ "<script type='text/javascript' src='jquery.fileupload/js/vendor/jquery.ui.widget.js'></script>"
+ "<script type='text/javascript' src='jquery.fileupload/js/jquery.iframe-transport.js'></script>"
+ "<script type='text/javascript' src='jquery.fileupload/js/jquery.fileupload.js'></script>"
+ "<script type='text/javascript' src='jquery.fileupload/js/main.js'></script>"
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/water/api/Upload2.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
public class Upload2 extends HTMLOnlyRequest {
@Override
protected String build(Response response) {
return "<script type='text/javascript' src='jquery.fileupload/js/vendor/jquery.ui.widget.js'></script>"
return ""
+ "<script type='text/javascript' src='jquery.fileupload/js/api_v2.js'></script>"
+ "<script type='text/javascript' src='jquery.fileupload/js/vendor/jquery.ui.widget.js'></script>"
+ "<script type='text/javascript' src='jquery.fileupload/js/jquery.iframe-transport.js'></script>"
+ "<script type='text/javascript' src='jquery.fileupload/js/jquery.fileupload.js'></script>"
+ "<script type='text/javascript' src='jquery.fileupload/js/main.js'></script>"
Expand Down

0 comments on commit a5cdeb4

Please sign in to comment.