summaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2019-08-08 12:44:29 +0000
committergebele <gebele@in-silico.ch>2019-08-08 12:44:29 +0000
commit498ad82d2cc8582d3139bf69a0fe333d6b425668 (patch)
treea660e70ddb709e4e20ff6a70f952f7d07e7c56fe /views
parent185a6df5e09dc89a50f23858e9cb221aacca9327 (diff)
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
Diffstat (limited to 'views')
-rw-r--r--views/batch.haml44
-rw-r--r--views/upload.haml28
2 files changed, 32 insertions, 40 deletions
diff --git a/views/batch.haml b/views/batch.haml
index e0fc573..4e1df05 100644
--- a/views/batch.haml
+++ b/views/batch.haml
@@ -11,22 +11,13 @@
%a.btn.btn-outline-info{:href => "//#{ENV['VIRTUAL_HOST']}/predict?tpid=#{@pid}"}
%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
- uploadInterval = setInterval(function(){
- uploadDataset('//#{ENV['VIRTUAL_HOST']}/prediction/task/?turi=#{@upid}');
- }, 1000 );
-
%div.card.bg-light
%div.card-body
- %h3.card-title="Batch prediction results for: #{@filename}"
+ %h3.card-title="Batch prediction results for: #{@filename}"
// prepare variable values for javascript
// increase timer interval for large datasets
- - ctimer = 10000#((@compounds_size/1000) == 0 ? 1000 : ((@compounds_size/1000)*1000))
+ - timer = 10000#((@compounds_size/1000) == 0 ? 1000 : ((@compounds_size/1000)*1000))
// process batch predictions
- @models.each_with_index do |model,idx|
- m = Model::Validation.find model
@@ -38,7 +29,7 @@
%h5.card-title="#{m.endpoint} (#{m.species})"
#pager{:id=>idx}
%div.col-6
- %a.btn.btn-outline-info.btn-sm.disabled{:id => "detailsbutton_#{idx}", :data=>{:toggle=>"collapse"}, :href=>"javascript:void(0)", :onclick=>"pagePredictions('//#{ENV['VIRTUAL_HOST']}/prediction/task/?predictions=#{task}','#{model}','#{idx}','//#{ENV['VIRTUAL_HOST']}/prediction/task/?turi=#{task}')"}
+ %a.btn.btn-outline-info.btn-sm.disabled{:id => "detailsbutton_#{idx}", :data=>{:toggle=>"collapse"}, :href=>"javascript:void(0)", :onclick=>"pagePredictions('//#{ENV['VIRTUAL_HOST']}/prediction/task/?predictions=#{task}','#{model}','#{idx}','#{@compounds_size}')"}
%span.fa.fa-caret-right
Details
%a.btn.btn-outline-info.btn-sm.disabled{:id => "downbutton_#{idx}", :href=>"//#{ENV['VIRTUAL_HOST']}/predict/batch/download?tid=#{task}", :title=>"download"}
@@ -49,37 +40,10 @@
%img.h2{:src=>"/images/wait30trans.gif", :id=>"circle_#{idx}", :class=>"circle", :alt=>"wait", :style=>"display:none;"}
:javascript
$(document).ready(function() {
- taskProgress('#{idx}','#{ctimer}','//#{ENV['VIRTUAL_HOST']}/prediction/task/?turi=#{task}');
+ taskProgress('#{idx}','#{timer}','//#{ENV['VIRTUAL_HOST']}/prediction/task/?turi=#{task}');
});
#data-container.card.d-none.table-responsive{:id=>idx}
:javascript
- taskProgress = function(idx,timer,task_uri){
- // wait until previous task is completed
- if (idx > 0){
- markers[idx] = setInterval(function(){
- var button = document.getElementById("detailsbutton_"+(idx-1));
- if(!button.classList.contains('disabled')){
- renderTask(task_uri,idx);
- $("#est_"+idx).hide();
- $("#circle_"+idx).show();
- }
- }, timer );
- }else{
- markers[idx] = setInterval(function(){
- // check that dataset parsing is completed
- if (document.getElementById("uploadDataset")){
- $("#est_"+idx).show();
- $("#circle_"+idx).hide();
- } else {
- renderTask(task_uri,idx);
- if ( $("#est_"+idx).is(":visible") ){
- $("#est_"+idx).hide();
- $("#circle_"+idx).show();
- }
- }
- }, timer );
- };
- };
%div.modal.fade{:id=>"details", :tabindex=>"-1", :role=>"dialog"}
%div.modal-dialog.modal-lg{:role=>"document"}
%div.modal-content
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);
+ }
+ });
+ });