4 <& /util/import_javascript.mas, classes => ['jquery.dataTables-buttons-min', 'jquery.iframe-post-form', 'jszip-min','buttons.bootstrap-min', 'buttons.html5-min', 'buttons.print-min'] &>
6 <div class="modal fade" id="upload_locations_dialog" name="upload_locations_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadLocationsDialog">
7 <div class="modal-dialog modal-lg" role="document">
8 <div class="modal-content">
9 <div class="modal-header">
10 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
11 <h4 class="modal-title" id="uploadLocationsDialog">Upload Locations</h4>
13 <div class="modal-body">
14 <div class="container-fluid">
16 The first row (header) must contain the following:
18 <table class="table table-bordered table-hover">
30 <td>NOAA Station ID</td>
34 <b>Required values:</b><br>
35 <b>Name:</b> must not conflict with an existing location name<br>
36 <b>Abbreviation:</b> used in the map and in uploads, must not conflict with an existing abbreviation<br>
37 <b>Country Code:</b> must be an <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3">ISO Alpha-3 country code</a><br>
38 <b>Country Name:</b> must be an uppercase english short name from the <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3">ISO standard</a><br>
39 <b>Program:</b> must be an exisiting Breeding Program in the database, or multiple breeding programs separated by '&'<br>
40 <b>Type:</b> must be one of the following: Town, Farm, Field, Greenhouse, Screenhouse, Lab, Storage, Other<br>
41 <b>Latitude:</b> (in degrees) must be a number between 90 and -90.<br>
42 <b>Longitude:</b> (in degrees) must be a number between 180 and -180.<br>
43 <b>Elevation:</b> (in meters) must be a number between -418 (Dead Sea) and 8,848 (Mt. Everest).<br>
44 <br><b>Optional values:</b><br>
45 <b>NOAA Station ID:</b> The NOAA Station ID that is nearest and most relevant to the location. <a href="https://www.ncdc.noaa.gov/cdo-web/search" target="_blank">Search Here</a><br>
47 <& /help/file_upload_type.mas, type => "Locations" , optional_column => 1 &>
48 <form method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="upload_locations_form" name="upload_locations_form">
49 <label for="locations_upload_file" style="display: inline-block;">Location File:</label>
50 <input type="file" name="locations_upload_file" id="locations_upload_file" encoding="multipart/form-data" />
54 <div class="modal-footer">
55 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
56 <button type="button" class="btn btn-primary" name="upload_locations_dialog_submit" id="upload_locations_dialog_submit">Upload</button>
62 <div class="modal fade" id="locations_result_dialog" tabindex="-1" role="dialog" aria-labelledby="locationsResultDialog">
63 <div class="modal-dialog modal-lg" role="document">
64 <div class="modal-content ui-front">
65 <div class="modal-header text-center">
66 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
67 <h4 class="modal-title" id="locationsResultDialog">Results</h4>
69 <div id="locations_result_body" class="container-fluid">
71 <div class="modal-footer">
72 <button id="locations_result_close_button" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
78 <script defer="defer">
80 jQuery(document).ready(function() {
82 jQuery('#upload_locations_link').click( function() {
83 jQuery('#upload_locations_dialog').modal("show");
86 jQuery('#upload_locations_dialog_submit').click( function() {
87 var uploadFile = jQuery("#locations_upload_file").val();
88 jQuery('#upload_locations_form').attr("action", "/ajax/locations/upload");
89 if (uploadFile === '') {
90 alert("Please select a file");
93 jQuery("#upload_locations_form").submit();
96 jQuery('#upload_locations_form').iframePostForm({
99 jQuery('#working_modal').modal("show");
101 complete: function (r) {
102 r = r.replace('<pre>', '');
103 r = r.replace('</pre>', '');
104 var response = JSON.parse(r);
106 jQuery('#working_modal').modal("hide");
107 //console.log(response);
108 if (response.error) {
110 for (i = 0; i < response.error.length; i++) {
111 errors.push( '<p>'+response.error[i]+'</p>');
113 var html = '<br><center><b>Upload failed.</b><br><b>Please fix the following errors in </b>'+response.filename+'<b> and try again:</b></center><br>';
114 html += errors.join('') + '<br>';
115 document.getElementById('locations_result_body').innerHTML = html;
116 jQuery('#locations_result_dialog').modal("show");
119 jQuery('#upload_locations_dialog').modal("hide");
120 var saved_locations = [];
121 for (var key in response) {
122 saved_locations.push( '<p>'+key+': '+response[key]+'</p>');
124 var html = '<br><center>'+saved_locations.join('')+'</center>';
125 document.getElementById('locations_result_body').innerHTML = html;
126 jQuery('#locations_result_dialog').modal("show");
127 jQuery('#locations_result_close_button').click( function() {
132 error: function(response) {
133 jQuery('#working_modal').modal("hide");
134 alert("An error occurred");