Merge pull request #5069 from solgenomics/topic/accession_upload_file
[sgn.git] / mason / fieldbook / home.mas
blobeb811a1f7da6aa814cd3fe1682bace1905daab16
2 <%args>
3 @projects => undef
4 $programs => undef
5 @file_metadata => ()
6 $user_id => undef
7 @layout_files => undef
8 @trait_files => undef
9 @phenotype_files => undef
10 @removed_phenotype_files => undef
11 @roles => ()
12 </%args>
14 <& /util/import_javascript.mas, classes => [ 'jquery', 'jqueryui', 'jquery.iframe-post-form','CXGN.List','CXGN.BreedersToolbox.FieldBook', 'CXGN.BreedersToolbox.HTMLSelect'] &>
16 <& /page/page_title.mas, title=>'Field Book Tools' &>
18 <div class="container-fluid">
20 <&| /page/explanation.mas, title=>'Field Layout Files', collapsible=>1, collapsed=>0, &>
21   <p>
22     <em><b>Field Book</b></em> is an app for collecting phenotypic data on field research plots using an android tablet computer.
23     <br/><br/>
24     <a href="https://play.google.com/store/apps/details?id=com.fieldbook.tracker"> Field Book Software</a>
25     <br/><br/>
26     To use Fieldbook you need a Field Layout File and a Trait File; both can be created on this page. <br/>Once you have created and downloaded your Field Layout and Trait files, move them onto your mobile device into the Fieldbook directories (generally /fieldbook/import_field/ for your Field Layout Files and /fieldbook/traits/ for your trait files.)
27     <br/><br/>
28     By using Fieldbook with the Field Layout and Trait Files created here, you can be sure that your traits are properly defined and your experimental units, whether they are plots or plants or tissue samples, are also properly defined.
29   </p>
30 </&>
32 <& /fieldbook/create_fieldbook_dialog.mas &>
34 <&| /page/info_section.mas, title=>'Field Layout Files', empty_message=>'', collapsible=>1, collapsed=>0, subtitle=>'[<a name="create_fieldbook_link">New</a>]' &>
35 <%perl>
36 #my @breeding_programs = @{$programs};
37 #foreach my $prog (@breeding_programs) {
38 #  print @$prog[0].@$prog[1]."</br>";
40 foreach my $file (@file_metadata) {
41    my @trial_array = @{$file};
42    my $file_name = $trial_array[1];
43    my $trial_layout_download = '[<a href="/fieldbook/trial_download/'.$trial_array[2].'">Download File</a>]  |   [<a id="delete_fieldbook_layout_link" href="/fieldbook/delete_file/'.$trial_array[2].'">Delete File</a>]';
44    print $trial_array[1]."$trial_layout_download<br>";
45    #print $trial_array[2]."</br>";
47 </%perl>
48 </&>
50 <& /fieldbook/create_trait_file_dialog.mas &>
52 <&| /page/info_section.mas, title=>'Trait Files', empty_message=>'', collapsible=>1, collapsed=>0, subtitle=>'[<a id="create_new_trait_file_link">New</a>]' &>
53   <%perl>
54   foreach my $trait_ref (@trait_files) {
55     my @trait_array = @{$trait_ref};
56     my $trait_file_name = $trait_array[0];
57     my $trait_file_download = '[<a href="/fieldbook/trait_file_download/'.$trait_array[1].'">Download File</a>] |   [<a id="delete_trait_file_link" href="/fieldbook/delete_file/'.$trait_array[1].'">Delete File</a>]';
58     print $trait_array[0]."$trait_file_download<br>";
59     #print $trial_array[4]."</br>";
60   }
61   </%perl>
62 </&>
64 <&| /page/info_section.mas, title=>'Uploaded Phenotype Files', collapsible=>1, collapsed=>0, subtitle=>'[<a id="upload_fieldbook_phenotypes_link">Upload</a>]' &>
65   <%perl>
66   if (scalar(@phenotype_files)>0) {
67     print qq { <br/><div class="well well-sm"><table class="table fieldbook_phenotype_datatables"><thead><tr><th>Filename</th><th>Delete</th></tr></thead><tbody> };
69     foreach my $phenotype_ref (@phenotype_files) {
70       my @phenotype_array = @{$phenotype_ref};
71       my $phenotype_file_name = $phenotype_array[0];
72       #my $phenotype_file_download = '[<a href="/fieldbook/trait_file_download/'.$trait_array[1].'">Download</a>]';
73       #print $phenotype_array[0]."$trait_file_download<br>";
74       print qq { <tr><td>$phenotype_array[0]</td><td><a href="javascript:remove_phenotype_data($phenotype_array[1])"><b>X</b></a></td></tr> };
75     }
77     print qq { </tbody></table></div> };
78   }
79   </%perl>
81 </&>
83 <& /fieldbook/upload_phenotype_fieldbook.mas &>
85 <&| /page/info_section.mas, title=>'Removed Phenotype Files', collapsible=>1, collapsed=>1 &>
86   <%perl>
87   foreach my $phenotype_ref (@removed_phenotype_files) {
88     my @phenotype_array = @{$phenotype_ref};
89     my $phenotype_file_name = $phenotype_array[0];
90     #my $phenotype_file_download = '[<a href="/fieldbook/trait_file_download/'.$trait_array[1].'">Download</a>]';
91     #print $phenotype_array[0]."$trait_file_download<br>";
92     print qq { $phenotype_array[0]  <button disabled="1" id="re-upload" >re-upload</button><br /> };
93   }
94   </%perl>
95 </&>
97 </div>
100 <script>
102 jQuery(document).ready(function() {
103     jQuery('.fieldbook_phenotype_datatables').DataTable();
104 } );
106   function remove_phenotype_data(file_id) {
107     var yes = confirm("Do you really want to remove all data associated with this file (id="+file_id+")");
108     jQuery.ajax( {
109       beforeSend: function() { jQuery('#working_modal').modal("show"); },
110       url: '/breeders/trial/delete/file/'+file_id,
111       success: function(response) {
112          jQuery('#working_modal').modal("hide");
113          if (response.error) {
114            alert(response.error);
115          }
116          else {
117             alert("SUCCESS!");
118             location.reload();
119          }
120       },
121       error: function(response) {
122          jQuery('#working_modal').modal("hide");
123          alert("An error occurred!");
124       }
125     });
126   }
127 </script>