summaryrefslogtreecommitdiff
path: root/views/neighbours.haml
blob: ae93aff36832d69698b9b421d704cbb0e81904b1 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/ @@prediction_models and @@predictions defined in POST request '/predict'
/ unpacks multi prediction array ;
/ prepare it for neighbours ;
/ align single prediction to endpoint ;
/ display preordered in table view ;

:javascript
  $(function() {
    $( ".results" ).resizable({
      containment: ".content"
    });
  });
  
.results{:style=>"display:none"}
  - count_m = 0
  / tabs div ;
  #tabs
    %ul
      / each endpoint becomes a tab head ;
      - @@prediction_models.each do |m|
        - count_m += 1
        %li
          %a{:href => "#results_#{count_m}", :id => "link#{m.title}"}
            = m.title
    - count_rs = 0
    / unpack to single arrays
    - @@predictions.each do |pa|
      - count_rs += 1
      #results{:id=>"#{count_rs}"}
        - pa.each do |p|
          / prepare dataset for neighbours table ;
          / delete first array which contains input compound prediction ;
          / keep the following arrays they are the neighbour predictions ;
          - p.data_entries.shift
          - p.compounds.shift
          / call the tablesorter plugin ;
          / presort by similarity ;
          :javascript
            $(document).ready(function(){
              $("table##{count_rs}").tablesorter({
                //debug: true,
                //widgets: ['zebra'],
                headers: {0: {sorter: false}, 3: {sorter: false}},
                sortList: [[2,1]]
              });
            });
          / TODO catch table error if tbody is empty      
          %h2= "Neighbours: "
          %table{:id=>"#{count_rs}", :class=>"tablesorter", :cellspacing=>"1"}
            %thead
              %tr
                %th
                  Compound
                %th
                  Measured Activity
                %th
                  Similarity
                %th
                  Details
            -#%tbody
            - count = 0
            - p.compounds.each do |neighbour_compound|
              %tr
                %td
                  %img{:src=>"#{neighbour_compound.uri}/image", :alt=>"", :width=>"100px"}
                %td{:class => p.data_entries[count][2]}
                  = p.data_entries[count][2]
                %td{:class => p.data_entries[count][2]}
                  = p.data_entries[count][3].round(3)                  
                %td{:class => p.data_entries[count][2]}
                  %a{:href => to("/prediction/#{CGI.escape(neighbour_compound.uri)}/details"), :id=>"link#{count_rs}#{count}", :target=>"details"}
                    %img{:src=>"/images/arrow_right_float.png", :alt=>"arrow"}
                  :javascript
                    $(function() {
                        $("a#link#{count_rs}#{count}").on('click', function(e) {
                            $('#iframe').bPopup();
                        });
                    });
                    
                - count += 1

%iframe{:id=>"iframe", :name=>"details", :height=>"80%", :width=>"80%", :style=>"display:none;border:0px"}