[879b32]: / qiita_pet / templates / upload.html

Download this file

301 lines (274 with data), 13.6 kB

  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
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
{% extends sitebase.html %}
{% block head %}
<script type="text/javascript">
function validate_file() {
var ssh_key = $("#ssh-key")[0].files[0];
if (ssh_key.size > 4000) {
alert("Your input file is too large to be a valid key, please try again.");
$("#ssh-key").val("");
}
}
function validate_form() {
// modified from https://gist.github.com/dperini/729294#gistcomment-15527
var re_weburl = new RegExp(
// protocol identifier
"(?:(?:scp?)://)" +
// user:pass authentication
"(?:\\S+(?::\\S*)?@)?" +
"(?:" +
// IP address exclusion
// private & local networks
"(?!(?:10|127)(?:\\.\\d{1,3}){3})" +
"(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" +
"(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})" +
// IP address dotted notation octets
// excludes loopback network 0.0.0.0
// excludes reserved space >= 224.0.0.0
// excludes network & broacast addresses
// (first & last IP address of each class)
"(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
"(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
"(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
"|" +
// host name
"(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)" +
// domain name
"(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*" +
// TLD identifier
"(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))" +
// sorry, ignore TLD ending with dot
// "\\.?" +
")" +
// port number
"(?::\\d{2,5})?" +
// resource path, excluding a trailing punctuation mark
"(?:[/?#](?:\\S*[^\\s!\"'()*,-.:;<>?\\[\\]_`{|}~]|))?"
, "gi"
);
var valid_protocol = false;
var url = $("#inputURL").val();
var ssh_key = $("#ssh-key")[0].files[0];
if (url === '' || ssh_key === '' || ssh_key === undefined){
alert("URL and SSH key can't be empty")
} else {
if(re_weburl.test(url)) {
valid_protocol = true;
} else {
alert('Not a valid URL: ' + url);
}
}
return valid_protocol;
}
function connect_to_remote_server(method) {
$('#remote-request-type').val(method);
var formData = new FormData($('#remote-form')[0]);
if (validate_form()) {
$.ajax({
url:'{% raw qiita_config.portal_dir %}/study/upload/remote/' + {{study_id}},
type:'POST',
data:formData,
contentType:false,
processData:false,
cache:false,
success: function(data) {
window.location.reload(1);
},
error: function (object, status, error_msg) {
bootstrapAlert("Error: " + error_msg, "danger")
}
});
}
}
{% if level == 'info' and 'Retrieving remote files:' in message %}
setTimeout(function(){
window.location.reload(1);
}, 5000);
{% end %}
</script>
{% end %}
{% block content %}
{% if level != 'info' or 'Retrieving remote files:' not in message or not message %}
<div class="container">
<div class="row">
<b>Uploading files for: {{study_title}} ({{study_info['study_alias']}})</b>
<br/><br/>
Currently we can process (<b>{{extensions.replace(',',', ')}}</b>):
<ul>
<li>Note that '.zip' files can not be processed.</li>
<li>Note that '.fasta' and '.fna' files require '.qual' files for submission.</li>
<li>Note that '.txt.' files must be tab separated and require the extension .txt.</li>
</ul>
Per our Terms of Condition for use, you certify that the files you are uploading do not contain:
<ul>
<li>protected health information within the meaning of 45 Code of Federal Regulations part 160 and part 164, subparts A and E; <a target="_blank" href="http://cmi.ucsd.edu/PHIChecklist">see checklist</a></li>
<li>whole genome sequencing data for any human subject; <a target="_blank" href="https://www.hmpdacc.org/hmp/doc/HumanSequenceRemoval_SOP.pdf">HMP human sequence removal protocol</a></li>
<li>any data that is copyrighted, protected by trade secret, or otherwise subject to third party proprietary rights, including privacy and publicity rights, unless you are the owner of such rights or have permission from the rightful owner(s) to transfer the data and grant it to Qiita, on behalf of the Regents of the University of California, <a target="_blank" href="https://qiita.ucsd.edu/iframe/?iframe=qiita-terms">all of the license rights granted in our Terms.</li>
</ul>
</div>
<div class="row" align="center">
<a href="{% raw qiita_config.portal_dir %}/study/description/{{study_id}}">&lt;&lt; Go to study description</a>
</div>
<div class="row">
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
Upload via Local Machine
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse {%if not remote_files and not remote_url %} in {% end %}">
<div class="row" align="center">
<b>Upload files locally (max file size: {% if max_upload_size/1000==0 %} {{max_upload_size}} GB{% else %} {{max_upload_size/1000.0}} TB{% end %})</b>
</div>
<div style="height: 150px; width: 100%; background-color:lightgrey; border: 2px solid; border-radius: 25px;" class="resumable-drop-metadata" ondragenter="jQuery(this).addClass('resumable-dragover');" ondragend="jQuery(this).removeClass('resumable-dragover');" ondrop="jQuery(this).removeClass('resumable-dragover');">
<div align="center">
<p style="vertical-align: middle;">Drop files here to upload or <a class="resumable-browse-metadata"><u>select from your computer</u></a></p>
</div>
</div>
<div class="progress-metadata" style="display:none;">
<table>
<tr>
<td width="100%"><div class="progress-container"><div class="progress-bar"></div></div></td>
<td class="progress-text" nowrap="nowrap"></td>
<td class="progress-pause" nowrap="nowrap">
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#" onclick="uploader.resumable.upload(); $('#uploader_status').html('~~ Uploading ~~'); return(false);" class="progress-resume-link"><span class="glyphicon glyphicon-play"></span></a>
<a href="#" onclick="uploader.resumable.pause(); $('#uploader_status').html('~~ Paused ~~'); return(false);" class="progress-pause-link"><span class="glyphicon glyphicon-pause"></span></a>
</td>
</tr>
<tr>
<td colspan="3">
<div class="blinking-message">
<div id="uploader_status"></div>
Keep track of your upload or pause/resume it! <span class="glyphicon glyphicon-arrow-up"></span>
<br/>
<small>Your upload won't be interrupted if you change networks or you close your computer, just make sure you don't leave this page. </small>
</div>
</td>
<tr>
</table>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
Upload via Remote Server (ADVANCED)
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse {%if remote_files and remote_url %} in {% end %}">
<div class="container">
{%if remote_files and remote_url %}
<div class="row">
<button class="btn btn-default" data-toggle="collapse" data-target="#remote-files">
<span class="glyphicon glyphicon-eye-open"></span>
Files
</button> in {{remote_url}}
<div id="remote-files" class="collapse in" style="padding: 10px 10px 10px 10px; border-radius: 10px; background: #EEE;">
{{', '.join(remote_files)}}
</div>
</div>
<br/>
{% end %}
<div class="row">
<button class="btn btn-default" data-toggle="collapse" data-target="#remote-file-instructions">
<span class="glyphicon glyphicon-eye-open"></span>
Instructions
</button>
<div id="remote-file-instructions" class="collapse" style="padding: 10px 10px 10px 10px; border-radius: 10px; background: #EEE;">
<ol>
<li>Currently we only support ftp and scp.</li>
<li>Prepare study files by storing them in one folder on your fileserver.</li>
<li>Generate a new key by running: <code>ssh-keygen -t rsa -C "ssh test key" -f ~/.ssh/qiita-key -P ""</code> in your remote server.</li>
<li>Allow access using the new key: <code>cat ~/.ssh/qiita-key.pub >> ~/.ssh/authorized_keys</code>. Note that erasing that line will remove access.</li>
<li>Obtain your new generated private <code>qiita-key</code> and use it in the Key option</li>
<li>Press 'List Files' to test the connection and verify the list of study files.</li>
<li>If the connection is made and files are correct, press 'Transfer Files' to initiate the transfer.</li>
</ol>
</div>
<br/><br/>
</div>
<div class="row">
<form class="form-horizontal" name="remote-form" id="remote-form" enctype="multipart/form-data">
<input type="hidden" id="remote-request-type" name="remote-request-type">
<div class="form-group">
<label class="col-md-1 control-label">URL</label>
<div class="col-md-6">
<input type="text" class="form-control" name="inputURL" id="inputURL" placeholder="scp://user@server.com:/folders/">
</div>
<label for="inputURL" class="col-md-1 control-label">Key</label>
<div class="col-md-2">
<input type="file" name="ssh-key" id="ssh-key" onchange="validate_file();">
</div>
</div>
<div class="form-group">
<div class="col-md-2"></div>
<div class="col-md-1">
<button type="button" class="btn btn-default" onclick="connect_to_remote_server('list');">List Files</button>
</div>
<div class="col-md-1">
<button type="button" class="btn btn-default" onclick="connect_to_remote_server('transfer');">Transfer Files</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<hr>
<div class="row" align="center">
<h3><u>Files</u></h3>
<table align="center" border="0">
<tr>
<td>
<button type="button" class="btn btn-default" onclick="$('input[name*=\'files_to_erase\']').prop('checked', true);">Select All</button>
</td>
<td width="30px">&nbsp;</td>
<td>
<button type="button" class="btn btn-default" onclick="$('input[name*=\'files_to_erase\']').removeAttr('checked');">Unselect All</button>
</td>
</tr>
</table>
</div>
<div class="row", align="center">
<form method="post" id="delete-files-form">
<div class="uploader-list" style="display:none;">
</div>
</form>
<div class="file-edit-container" style="display:none;">
</div>
&nbsp;
<button type="button" class="btn btn-danger" onclick="if(confirm('Are you sure you want to delete the selected files? You can not undo this action')) { $('#delete-files-form').submit() }">
<span class="glyphicon glyphicon-trash"></span> Delete selected files
</button>
</div>
</div>
<div style='width:inherit;text-align:center;padding-top:30px'>
<small><a href="{% raw qiita_config.portal_dir %}/study/description/{{study_id}}">&lt;&lt; Go to study description</a></small>
</div>
<!-- Upload required files and JS code -->
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/resumable.js"></script>
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/resumable-uploader.js"></script>
<script>
var meta = { fileType: [] };
var maxFileSize = {{max_upload_size}}; // in GB
uploader = (function($){
return (new ResumableUploader(meta, $('.resumable-browse-metadata'),
$('.resumable-drop-metadata'), $('.progress-metadata'),
$('.uploader-list'), $('.file-edit-container'),
maxFileSize, "{{study_id}}", "{{extensions}}",
"{% raw qiita_config.portal_dir %}", '{{is_admin}}'=='True',
'{% raw qiita_config.portal_dir %}/download_upload/{{study_id}}/'));
})(jQuery);
{% for dirid, filename, size in files %}
uploader.addFile({ "dirid": "{{dirid}}", "fileName": "{{filename}}", "size": "{{size}}", "uploaded": "True" });
{% end %}
</script>
{% end %}
{% end %}