summaryrefslogtreecommitdiff
path: root/views/upload.haml
blob: 159f7a583371edb71e0402d7a6a1c3aac2cf0e10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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);
          }
        });
      });