Changed trials-in-common page to use a single database query to get analyses. Changed...
[sgn.git] / mason / breeders_toolbox / view_file.mas
blob93060795fa14d59a5cf4222d46795adef9decce2
2 <%args>
3 $file_content => undef
4 $filename => undef
5 </%args>
7 <%perl>
9 sub n2a {
10   my ($n) = @_;
11   my @a;
12   while ($n > 0) {
13     unshift @a, ($n-1) % 26;
14     $n = int(($n-1)/26); #Edited for failing corner case
15   }
16   join '', map chr(ord('A') + $_), @a;
19 </%perl>
21 <center>
22 <br/>
23 <h1>File Viewer</h1>
24 <br/>
25 </center>
27 <div class="panel panel-info">
28         <div class="panel-heading">
29                 <h3>File Info</h3>
30         </div>
31         <div class="panel-body">
32                 <table class="table">
33                 <thead>
34                 <tr>
35                 <th>Filename</th>
36                 <th>File Type</th>
37                 <th>Number of Sheets</th>
38                 <th>Parser</th>
39                 </tr>
40                 </thead>
41                 <tbody>
42                 <tr>
43                 <td><% $filename %></td>
44                 <td><% @$file_content[0]->[0]->{type} %></td>
45                 <td><% @$file_content[0]->[0]->{sheets} %></td>
46                 <td><% @$file_content[0]->[0]->{parser} %> (<% @$file_content[0]->[0]->{version} %>)</td>
47                 </tr>
48                 </tbody>
49                 </table>
50         </div>
51 </div>
53 % my $num_sheets = @$file_content[0]->[0]->{sheets};
55 <div class="panel panel-info">
56         <div class="panel-heading">
57                 <h3>File Contents</h3>
58         </div>
59         <div class="panel-body">
61         <ul class="nav nav-tabs" role="tablist">
63 % for ( my $s=1; $s<=$num_sheets; $s++) {
64         
65 % my $sheet_label = @$file_content[0]->[$s]->{label};
66 % $sheet_label =~ s/\s+//g;
68 % if ($s ==1 ){
69                 <li role="presentation" class="active"><a href="#<% $sheet_label %>" aria-controls="<% $sheet_label %>" role="tab" data-toggle="tab"><% $sheet_label %></a></li>
70 % } else {
71                 <li role="presentation"><a href="#<% $sheet_label %>" aria-controls="<% $sheet_label %>" role="tab" data-toggle="tab"><% $sheet_label %></a></li>
72 % }
74 % }
76         </ul>
78         <div class="tab-content">
80 % for (my $i=1; $i<=$num_sheets; $i++) {
82 % my $max_row = @$file_content[0]->[$i]->{maxrow};
83 % my $max_col = @$file_content[0]->[$i]->{maxcol};
85 % my $sheet_label = @$file_content[0]->[$i]->{label};
86 % $sheet_label =~ s/\s+//g;
88 % if ($i == 1) {
89                 <div role="tabpanel" class="tab-pane fade in active" id="<% $sheet_label %>">
90 % } else {
91                 <div role="tabpanel" class="tab-pane fade" id="<% $sheet_label %>">
92 % }
94                         <table class="table table-hover table-bordered">
95                                 <thead>
96                                 <tr>
98 % my $max_aa = n2a(@$file_content[0]->[$i]->{maxcol});
99 % foreach ('A'..$max_aa) {
100                                 <th><% @$file_content[0]->[$i]->{$_.'1'} %></th>
101 % }
102                                 </tr>
103                                 </thead>
104                                 <tbody>
106 % for (my $j=2; $j<=$max_row; $j++) {
108                                 <tr>
110 % foreach ('A'..$max_aa) {
111         
112                                 <td><% @$file_content[0]->[$i]->{$_.$j} %></td>
114 % }
115                                 </tr>
117 % }
119                                 </tbody>
120                         </table>
121                 </div>
122 % }
124         </div>
126 </div>
127 </div>