From 498ad82d2cc8582d3139bf69a0fe333d6b425668 Mon Sep 17 00:00:00 2001 From: gebele Date: Thu, 8 Aug 2019 12:44:29 +0000 Subject: ensure dataset parser errors not hidden in a task; check upload by first header; remove_task_data, tasks, prediction dataset, training dataset; js code refinement --- views/upload.haml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 views/upload.haml (limited to 'views/upload.haml') diff --git a/views/upload.haml b/views/upload.haml new file mode 100644 index 0000000..159f7a5 --- /dev/null +++ b/views/upload.haml @@ -0,0 +1,28 @@ +%div.card + %a.btn.btn-outline-info{:href => "//#{ENV['VIRTUAL_HOST']}/predict"} + %span.fa.fa-caret-left{:aria=>{:hidden=>"true"}} + New Prediction +%div.card.bg-light{:id=>"uploadDataset"} + %div.card-body + %h3.card-title="Processing file #{@filename} to dataset." + %img.h2{:src=>"/images/wait30trans.gif", :id=>"circle_upload", :class=>"circle", :alt=>"processing"} + :javascript + $(document).ready(function() { + var aClient = new HttpClient(); + aClient.post('//#{ENV['VIRTUAL_HOST']}/predict', 'models=#{@models}&batchfile=#{@filename}', function(res1) { + var contentType = res1.getResponseHeader('content-type'); + if (contentType == "application/json"){ + var response = JSON.parse(res1.responseText); + } else { + var response = res1.responseText; + } + if (res1.status == 200 && response['models'] && response['dataset_id']){ + aClient.post('//#{ENV['VIRTUAL_HOST']}/predict', 'models='+response['models']+'&dataset_id='+response['dataset_id'], function(res2) { + $("body").html(res2.responseText); + }); + } + if (res1.status == 200 && contentType == "text/html"){ + $("body").html(response); + } + }); + }); -- cgit v1.2.3 From 270bddf5081671cd1905d6cce6eb3659159f573a Mon Sep 17 00:00:00 2001 From: gebele Date: Fri, 16 Aug 2019 09:49:53 +0000 Subject: change hostname method --- views/upload.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'views/upload.haml') diff --git a/views/upload.haml b/views/upload.haml index 159f7a5..54faa5c 100644 --- a/views/upload.haml +++ b/views/upload.haml @@ -1,5 +1,5 @@ %div.card - %a.btn.btn-outline-info{:href => "//#{ENV['VIRTUAL_HOST']}/predict"} + %a.btn.btn-outline-info{:href => "//#{$host_with_port}/predict"} %span.fa.fa-caret-left{:aria=>{:hidden=>"true"}} New Prediction %div.card.bg-light{:id=>"uploadDataset"} @@ -9,7 +9,7 @@ :javascript $(document).ready(function() { var aClient = new HttpClient(); - aClient.post('//#{ENV['VIRTUAL_HOST']}/predict', 'models=#{@models}&batchfile=#{@filename}', function(res1) { + aClient.post('//#{$host_with_port}/predict', 'models=#{@models}&batchfile=#{@filename}', function(res1) { var contentType = res1.getResponseHeader('content-type'); if (contentType == "application/json"){ var response = JSON.parse(res1.responseText); @@ -17,7 +17,7 @@ var response = res1.responseText; } if (res1.status == 200 && response['models'] && response['dataset_id']){ - aClient.post('//#{ENV['VIRTUAL_HOST']}/predict', 'models='+response['models']+'&dataset_id='+response['dataset_id'], function(res2) { + aClient.post('//#{$host_with_port}/predict', 'models='+response['models']+'&dataset_id='+response['dataset_id'], function(res2) { $("body").html(res2.responseText); }); } -- cgit v1.2.3