summaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2019-07-11 15:59:13 +0000
committergebele <gebele@in-silico.ch>2019-07-11 15:59:13 +0000
commit5490f6214f3a22216f7980c7d46f6d9fe10a4924 (patch)
tree7da1f991c1f31048b7b55a2dbc5729da7694860d /views
parent5efd8128dc5bdb9ffc0aa4798f8aa303973794e6 (diff)
simplify js code;reorder js code;
Diffstat (limited to 'views')
-rw-r--r--views/batch.haml53
-rw-r--r--views/neighbors.haml2
-rw-r--r--views/prediction.haml12
3 files changed, 32 insertions, 35 deletions
diff --git a/views/batch.haml b/views/batch.haml
index c454ac7..3f54772 100644
--- a/views/batch.haml
+++ b/views/batch.haml
@@ -6,9 +6,20 @@
%div.card-body
%h3.card-title="Batch prediction results for: #{@filename}"
+ // prepare variable values for javascript
+ // increase timer interval for large datasets
+ - ctimer = ((@compounds_size/1000) == 0 ? 1000 : ((@compounds_size/1000)*1000))
+ - approx = {}
+ - sum_approx = 0
+ // process batch predictions
- @models.each_with_index do |model,idx|
- m = Model::Validation.find model
- task = @tasks[idx].id
+ - tasktime = task.generation_time.to_i
+ // assume single compound prediction time: classification=0.1s,regression=0.5s
+ - task_approx = m.classification? ? (tasktime*1000 + @compounds_size*100) : (tasktime*1000 + @compounds_size*500)
+ - approx[idx] = task_approx + sum_approx
+ - sum_approx += (m.classification? ? @compounds_size*100 : @compounds_size*1000)
#result.card.bg-light{:id=>idx}
%div.card-body
%div.row
@@ -26,31 +37,29 @@
%div{:id=>"bar_#{idx}", :style=>"background-color: #4CAF50;width:10px;height:3px;position:absolute;"}
%p{:id=>"est_#{idx}"}
waiting ...
- - # increase interval timer for large datasets
- - ctimer = ((@compounds_size/1000) == 0 ? 1000 : ((@compounds_size/1000)*1000))
:javascript
- var timer = #{ctimer};
- var tasktime = #{task.generation_time.to_i};
- var compoundsSize = #{@compounds_size};
- var task_uri = "#{to("/prediction/task/?turi=#{task}")}";
- $(document).ready(function(){
- // check button class before execute a task
- if (#{idx} > 0){
- markers[#{idx}] = setInterval(function(){
- var button = document.getElementById("detailsbutton_#{idx-1}");
- if(!button.classList.contains('disabled')){
- renderTask(task_uri,'#{model}',#{idx});
- remaining(#{idx},tasktime,#{m.classification?},compoundsSize);
- }
- }, timer );
- }else{
- markers[#{idx}] = setInterval(function(){
- renderTask(task_uri,'#{model}',#{idx});
- remaining(#{idx},tasktime,#{m.classification?},compoundsSize);
- }, timer );
- };
+ $(document).ready(function() {
+ taskProgress('#{idx}','#{ctimer}','#{approx[idx]}','#{to("/prediction/task/?turi=#{task}")}');
});
#data-container.card.d-none.table-responsive{:id=>idx}
+ :javascript
+ taskProgress = function(idx,timer,approximate,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);
+ remaining(idx,approximate);
+ }
+ }, timer );
+ }else{
+ markers[idx] = setInterval(function(){
+ renderTask(task_uri,idx);
+ remaining(idx,approximate);
+ }, timer );
+ };
+ };
%div.modal.fade{:id=>"details", :tabindex=>"-1", :role=>"dialog"}
%div.modal-dialog.modal-lg{:role=>"document"}
%div.modal-content
diff --git a/views/neighbors.haml b/views/neighbors.haml
index 91b5f57..5f3e2bc 100644
--- a/views/neighbors.haml
+++ b/views/neighbors.haml
@@ -8,7 +8,7 @@
/ get predictionFeature type
- m = Model::Lazar.find model.model_id.to_s
%li.nav-item
- %a.nav-link{:class => ("active" if i ==0), :href => "#results_#{i+1}", :id => "linkTab#{i+1}", data: {toggle:"tab"}, :onclick=>"sortTable('#{i+1}');"}
+ %a.nav-link{:class => ("active" if i ==0), :href => "#results_#{i+1}", :id => "linkTab#{i+1}", data: {toggle:"tab"}}
= "#{model.endpoint} (#{model.species})"
%div.tab-content
- @predictions.each_with_index do |prediction,j|
diff --git a/views/prediction.haml b/views/prediction.haml
index bde2397..fe1e487 100644
--- a/views/prediction.haml
+++ b/views/prediction.haml
@@ -1,15 +1,3 @@
-:javascript
- $(document).ready(function(){
- $('[data-toggle="popover"]').popover();
- $('.modal').on('hidden.bs.modal', function () {
- $(this).removeData('bs.modal');
- });
- $('.modal').on('show.bs.modal', function(e){
- var button = $(e.relatedTarget);
- var modal = $(this);
- modal.find('.modal-content').load(button.data("remote"));
- });
- });
%div.card
%a.btn.btn-outline-info{:href => to('/predict')}
%span.fa.fa-caret-left