[879b32]: / qiita_pet / templates / study_ajax / prep_summary.html

Download this file

636 lines (599 with data), 23.9 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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
{% from qiita_core.qiita_settings import qiita_config %}
<script type="text/javascript">
/*
* Function to update the prep information contents
*
* This function executes an AJAX query to modify the contents of the
* prep information and updates the interface accordingly
*
*/
function update_prep_information() {
var fp = $("#file-selector").val();
$.ajax({
url: '{% raw qiita_config.portal_dir %}/prep_template/',
type: 'PATCH',
data: {'op': 'replace', 'path': '/{{prep_id}}/data', 'value': fp},
success: function(data) {
if(data.status == 'error') {
bootstrapAlert(data.message, "danger");
}
else {
populate_main_div('{% raw qiita_config.portal_dir %}/study/description/prep_template/', { prep_id: {{prep_id}}, study_id: {{study_id}} });
}
}
});
}
/*
*
* Function to create a new ENA investigation type term and update the template
*
* This function executes an AJAX query to add a new user-defined term to the
* ENA ontology, then updates the current prep information to have the newly
* added term and it updates the interface accordingly
*
*/
function add_new_investigation_type_term_and_update() {
var new_val = $("#new-ontology").val();
if (!new_val.match(/^[0-9a-zA-Z ]+$/)) {
bootstrapAlert("Only alphanumeric characters and space are allowed.", "danger");
}
else {
$.ajax({
url: '{% raw qiita_config.portal_dir %}/ontology/',
type: 'PATCH',
data: {'op': 'add', 'path': '/ENA/', 'value': new_val},
success: function(data) {
if(data.status == 'error') {
bootstrapAlert(data.message, "danger");
}
else {
// Add the new term to the user defined list, mark it as selected,
// clean the text box and hide it
var v = $("#new-ontology").val();
$('#user-ontology option').last().before($('<option>').attr({'value': v}).text(v));
$('#user-ontology').val(v);
$('#new-ontology').val('');
$("#new-ena-info").hide();
update_investigation_type(v);
}
}
});
}
}
/*
*
* Updates the investigation type of the prep information
*
* @param value string with the new investigation type value
*
* This function executes an AJAX call to update the investigation type
* of the current prep information
*
*/
function update_investigation_type(value) {
// Once we update the investigation_type we can't put it back to undefined
// so remove the empty values
$("#ena-ontology option[value='']").remove();
$("#user-ena-info option[value='']").remove();
$.ajax({
url: '{% raw qiita_config.portal_dir %}/prep_template/',
type: 'PATCH',
data: {'op': 'replace', 'path': '/{{prep_id}}/investigation_type', 'value': value},
success: function(data) {
if(data.status == 'error') {
bootstrapAlert(data.message, "danger");
}
}
});
}
/*
*
* Deletes a sample from the prep template
*
* @param prep_id the prep template id
*
* This function executes an AJAX call to remove the given sample from the
* prep information
*
*/
function delete_prep_sample(prep_id) {
var sample_names = Array();
var message = '';
$('.prep-sample-delete:checkbox:checked').each(function(){
sample_names.push($(this).val());
});
if (sample_names.length == 0) {
alert('No samples selected');
return false;
}
if (sample_names.length > 10) {
message = sample_names.length + ' samples';
} else {
message = "'" + sample_names.join(', ') + "'";
}
if(confirm("Are you sure you want to delete " + message + "?")) {
sample_names = sample_names.join(',')
$.ajax({
url: '{% raw qiita_config.portal_dir %}/prep_template/',
type: 'PATCH',
data: {'op': 'remove', 'path': '/' + prep_id + '/1/samples/' + sample_names},
success: function(data) {
if(data.status == 'error') {
bootstrapAlert(data.message, "danger");
}
else {
populate_main_div('{% raw qiita_config.portal_dir %}/study/description/prep_template/', { prep_id: prep_id, study_id: {{study_id}} });
}
}
});
}
}
/*
*
* Updates deprecated flag in the prep information <fieldset>
*
* @param prep_id the prep template id
* @param new_value the new deprecate value
*
* This function executes an AJAX call to update the deprecated flag
*
*/
function deprecate_preparation(prep_id, new_value) {
var status = 'deprecate';
if (!new_value){
status = 'DE-deprecate'
}
if(confirm("Are you sure you want to " + status + " this preparation?")) {
$.ajax({
url: '{% raw qiita_config.portal_dir %}/prep_template/',
type: 'PATCH',
data: {'op': 'update-deprecated', 'path': '/' + prep_id + '/' + new_value},
success: function(data) {
if(data.status == 'error') {
bootstrapAlert(data.message, "danger");
}
else {
populate_main_div('{% raw qiita_config.portal_dir %}/study/description/prep_template/', { prep_id: prep_id, study_id: {{study_id}} });
}
}
});
}
}
/*
*
* Deletes a column from the prep template
*
* @param prep_id the prep template id
* @param column_name string with the column to be removed
*
* This function executes an AJAX call to remove the given column from the
* prep information
*
*/
function delete_prep_column(prep_id, column_name, row_id) {
if(confirm("Are you sure you want to delete '" + column_name + "' information?")) {
$.ajax({
url: '{% raw qiita_config.portal_dir %}/prep_template/',
type: 'PATCH',
data: {'op': 'remove', 'path': '/' + prep_id + '/' + row_id + '/columns/' + column_name},
success: function(data) {
if(data.status == 'error') {
bootstrapAlert(data.message, "danger");
}
else {
populate_main_div('{% raw qiita_config.portal_dir %}/study/description/prep_template/', { prep_id: prep_id, study_id: {{study_id}}, row_id: row_id });
}
}
});
}
}
/*
* Toggle the graph view
*
* Show/hide the graph div and update GUI accordingly
*
*/
function toggle_graphs() {
if($("#graph-network-div").css('display') == 'none' ) {
$("#graph-network-div").show();
$("#show-hide-btn").text("-");
} else {
$("#graph-network-div").hide();
$("#show-hide-btn").text("+");
}
}
/**
*
* Load the interface to add an artifact to the prep information
*
* This function executes an AJAX call to populate the given target div
* with the interface needed to add a new artifact to the prep information
*
* @param target string The name of the target div
*
**/
function load_new_artifact(target, errors) {
show_loading(target);
if (errors !== undefined && errors !== "") {
bootstrapAlert(errors.split('\n').join('<br/>'), "danger");
}
// If it can be edited, show the page to upload a new artifact
$.get("{% raw qiita_config.portal_dir %}/study/new_artifact/", {"study_id": {{study_id}}, "prep_template_id": {{prep_id}} })
.done(function(data) {
$("#" + target).html(data);
});
}
/*
*
* Load the prep information summary table
*
* This function executes an AJAX call to populate the prep-artifact-summary-div
* with a table containing a summary of the prep information
*/
function load_information_summary() {
show_loading("prep-artifact-summary-div");
$.get('{% raw qiita_config.portal_dir %}/study/description/prep_summary/', {'prep_id': {{prep_id}} })
.done(function ( data ) {
$("#prep-artifact-summary-div").html(data);
});
}
/*
* Delete a prep template from the system
*
* @param prep_id The prep template id
*
* This function executes an AJAX call to delete the provided prep template
* and updates the interface accordingly
*
*/
function delete_prep_info(prep_id) {
if(confirm("Are you sure you want to delete prep template " + prep_id + "?")) {
// Perform the AJAX call to delete
$.ajax({
url: '{% raw qiita_config.portal_dir %}/prep_template/?prep-template-id=' + prep_id,
type: 'DELETE',
success: function(data) {
if(data.status == 'error') {
bootstrapAlert(data.message, "danger");
}
else {
// If success, populate the main div with the study info
// and regenerate the data type menu div (there is one prep less)
populate_main_div("{% raw qiita_config.portal_dir %}/study/description/baseinfo/", { study_id: {{study_id}} });
populate_data_type_menu_div();
}
}
});
}
}
/*
* Autoscroll prep info list
*
* This is a helper function so we can scroll once the prep table is ready
*/
function autoscroll_prep_list() {
// taken from: http://stackoverflow.com/a/2906009
if ({{row_id}} > 1) {
var container = $("html, body"), scrollTo = $("#row_{{row_id}}");
container.animate({
scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop()
});
}
}
/**
**/
function validate_new_prep_name() {
$("#update-prep-name-btn").prop('disabled', $("#new-prep-name").val().replace(/ /g,'') === "");
};
/**
*
* Function to update the name of a prep information
*/
function change_prep_name() {
$.ajax({
url: '{% raw qiita_config.portal_dir %}/prep_template/',
type: 'PATCH',
data: {'op': 'replace', 'path': '/{{prep_id}}/name', 'value': $('#new-prep-name').val()},
success: function(data) {
if(data.status == 'error') {
bootstrapAlert(data.message, "danger");
} else {
// Hide the modal to change the prep name
$("#update-prep-name").modal('hide');
// Update the name of the artifact in the GUI
$("#prep-name-span").text($('#new-prep-name').val());
// Reset the value in the modal to an empty string
$('#new-prep-name').val("");
// Update the data type menu so it shows the new name
populate_data_type_menu_div();
}
}
});
}
$(document).ready(function () {
if("{{investigation_type}}" !== "None") {
// The prep information already has an investigation type
// Delete the entries from the select that correspond to no values
$("#ena-ontology option[value='']").remove();
$("#user-ena-info option[value='']").remove();
// Update the selects to point to the correct value
var v = $("#ena-ontology option[value='{{investigation_type}}']");
if (v.length == 1) {
// Set the value
$("#ena-ontology").val('{{investigation_type}}');
}
else {
// It is a user defined value
$("#user-ena-info").show();
$("#ena-ontology").val('Other');
$("#user-ontology").val('{{investigation_type}}');
}
}
load_information_summary();
// Initialize the graph object. If the template already have an artifact
// attached, it will load the artifact graph, otherwise it will load the
// page to add a new artifact
newProcessingNetworkVue("#processing-graph-vue");
// If the file-selector select changes, check if we need to show the update button
$("#file-selector").change(function ( event ) {
if ( $("#file-selector").val() === "" ) {
$("#update-button-div").hide();
}
else {
$("#update-button-div").show();
}
});
// If the ena-ontology select changes, check if we need to show the user list
$("#ena-ontology").change(function ( event ) {
var value = $("#ena-ontology").val();
if( value == "Other" ) {
$("#user-ena-info").show();
$("#user-ena-info").trigger('change');
}
else {
$("#user-ena-info").hide();
$("#new-ena-info").hide();
update_investigation_type(value);
}
});
// If the user-ena-info select changes, check if we need to show the input box
$("#user-ena-info").change(function ( event ) {
var value = $("#user-ontology").val();
if( value == "New Type" ) {
$("#new-ena-info").show();
}
else {
$("#new-ena-info").hide();
if( value !== "" ) {
update_investigation_type(value);
}
}
});
$('#processing-tab-btn').on('shown.bs.tab', function (e) {
processingNetwork.$refs.procGraph.resetZoom();
});
{% if alert_type != 'success' and alert_message != '' %}
bootstrapAlert(decodeURIComponent("{% raw alert_message %}").replace(/\+/g,' '), "{{alert_type}}");
{% else %}
$('#alert-message').alert('close');
{% end %}
// Set the focus on the text input when the modal to change the artifact
// name is shown
$('#update-prep-name').on('shown.bs.modal', function() {
$('#new-prep-name').val($("#prep-name-span").text());
$('#new-prep-name').focus();
$('#new-prep-name').select();
});
qiita_websocket.init(window.location.host + '{% raw qiita_config.portal_dir %}/study/list/socket/', error, error);
qiita_websocket.add_callback('sel', show_alert);
});
function toggleCheckboxes(element){
$('.prep-sample-delete').each(function(){
$(this).prop('checked', element.checked);
});
}
</script>
<!-- Prep template title and buttons -->
<div class="row">
<div class="col-md-12">
{% if other_filepaths is not None and other_filepaths %}
<h6>Last update: {{ other_filepaths[0].split('_')[-1] }}</h6>
{% end %}
<h4>
{% if deprecated %}
<span class="label label-danger">This Preparation Information has been DEPRECATED</span>
<br/><br/>
{% end %}
<span id="prep-name-span">{{name}}</span> - ID {{prep_id}} ({{data_type}})
{% if user_level in ('admin', 'wet-lab admin') and creation_job is not None %}
<a class="btn btn-default" download="{{creation_job_filename}}" href="data:text/plain;charset=utf-8,{{creation_job_filename_body}}"><span class="glyphicon glyphicon-download-alt"></span> SampleSheet</a>
{% if creation_job_artifact_summary is not None %}
<a class="btn btn-default" target="_blank" href="{% raw qiita_config.portal_dir %}/artifact/html_summary/{{creation_job_artifact_summary}}"><span class="glyphicon glyphicon-download-alt"></span> Creation Job Output</a>
{% end %}
{% end %}
<a class="btn btn-default" data-toggle="modal" data-target="#update-prep-name"><span class="glyphicon glyphicon-pencil"></span> Edit name</a>
<a class="btn btn-default" href="{% raw qiita_config.portal_dir %}/download/{{download_prep_id}}"><span class="glyphicon glyphicon-download-alt"></span> Prep info</a>
<a class="btn btn-default" href="{% raw qiita_config.portal_dir %}/download_sample_info_per_prep/{{prep_id}}"><span class="glyphicon glyphicon-download-alt"></span> Sample info (only this prep)</a>
{% if is_submitted_to_ebi %}
<a class="btn btn-default" href="{% raw qiita_config.portal_dir %}/download_ebi_accessions/experiments/{{prep_id}}"><span class="glyphicon glyphicon-download-alt"></span> EBI experiment accessions</a>
{% end %}
{% if editable %}
<br/>
{% if user_level in ('admin', 'wet-lab admin') and data_type in {'Metagenomic', 'Metatranscriptomic'} %}
<button class="btn btn-info" onclick="this.disabled=true; window.location='{% raw qiita_config.portal_dir %}/download_data_release_from_prep/{{prep_id}}';">
<span class="glyphicon glyphicon-download-alt"></span> Download Data Release
</button>
{% end %}
{% if deprecated %}
<a class="btn btn-warning" onclick="deprecate_preparation({{prep_id}}, false);"><span class="glyphicon glyphicon-pushpin"></span> Remove Deprecation</a>
{% else%}
<a class="btn btn-warning" onclick="deprecate_preparation({{prep_id}}, true);"><span class="glyphicon glyphicon-pushpin"></span> Deprecate</a>
{% end %}
<a class="btn btn-danger" onclick="delete_prep_info({{prep_id}});"><span class="glyphicon glyphicon-trash"></span> Delete</a>
{% end %}
{% if prep_restrictions %}
<h5>
<div class="alert alert-warning" role="alert">
{{prep_restrictions}}
</div>
</h5>
{% end %}
</h4>
</div>
</div>
<div class="row">
<div class="col-md-12">
{% if human_reads_filter_method is not None %}
<h7> The raw data of this preparation was pre-processed via: <b>{{ human_reads_filter_method }}</b></h7>
{% end %}
<ul class="nav nav-pills">
<li style="border: 1px solid #428bca; border-radius: 5px"><a data-toggle="tab" href="#sample-listing-tab-div">Sample Listing</a></li>
<li style="border: 1px solid #428bca; border-radius: 5px"><a data-toggle="tab" href="#summary-tab-div">Summary</a></li>
<li style="border: 1px solid #428bca; border-radius: 5px" class="active"><a data-toggle="tab" href="#processing-graph-vue" id="processing-tab-btn" number-samples={{num_samples}}>Processing</a></li>
<li style="border: 1px solid #428bca; border-radius: 5px"><a data-toggle="tab" href="#archived-artifacts-tab-div">Archived Artifacts</a></li>
</ul>
<div class="tab-content">
<div id="sample-listing-tab-div" class="tab-pane fade">
<div class="panel panel-default">
{% if not artifact_attached %}
<button class="btn btn-danger st-interactive" onclick="delete_prep_sample({{prep_id}});">
<span class="glyphicon glyphicon-trash"></span> Delete Selected
</button>
{% end %}
<div>
<table class="table">
<thead>
<tr>
{% if not artifact_attached %}
<th><input type="checkbox" onchange="toggleCheckboxes(this)"></th>
{% end %}
<th>Samples</th>
</tr>
</thead>
{% for sid in samples %}
<tr>
{% if not artifact_attached %}
<td>
<input type="checkbox" class="prep-sample-delete" value="{{sid}}">
</td>
{% end %}
<td>{{sid}}</td>
</tr>
{% end %}
</table>
</div>
</div>
</div>
<div id="summary-tab-div" class="tab-pane fade">
<b>Number of samples: </b>{{num_samples}}<br/>
<b>Number of columns: </b>{{num_columns}}<br/>
{% if editable %}
<!-- Update prep template -->
<div class="row">
<div class="col-md-12">
<b>Update prep information:</b>
<select id="file-selector">
<option value="">Choose file...</option>
{% for fp in files %}
<option value="{{fp}}">{{fp}}</option>
{% end %}
</select>
<div id="update-button-div" hidden>
<button class="btn btn-info btn-sm" onclick="update_prep_information();" hidden>Update</button>
</div>
</div>
</div>
<!-- Investigation type info -->
<div class="row">
<!-- Ena ontology selector -->
<div class="col-md-6">
<b>Select Investigation Type:</b> <small>Unsure? <a href="https://www.ebi.ac.uk/submission/#" target="_blank">Check</a></small>
<select id="ena-ontology" name="ena-ontology" value="ena-ontology">
<option value=""></option>
{% for o in ontology['ENA'] %}
<option value="{{o}}">{{o}}</option>
{% end %}
</select>
</div>
<div class="col-md-3">
</div>
<!-- user-defined selector -->
<div class="col-md-4" id="user-ena-info" hidden> User defined investigation type:
<select id="user-ontology" name="user-ontology" value="user-ontology">
<option value=""></option>
{% for o in ontology['User'] %}
<option value="{{o}}">{{o}}</option>
{% end %}
<option value="New Type">New Type</option>
</select>
</div>
<!-- new user-defined input -->
<div class="col-md-4" id="new-ena-info" hidden> New user defined term:
<input type="textbox" id="new-ontology" name="new-ontology">
<button class="btn btn-info btn-sm" onclick="add_new_investigation_type_term_and_update();">Add</button>
</div>
</div>
{% end %}
{% if other_filepaths %}
<button class="btn btn-secondary" data-toggle="collapse" data-target="#other-filepaths"><b>Show older files</b></button>
{% end %}
<div id="other-filepaths" class="collapse">
<small>
{% raw '<br/>'.join(other_filepaths[1:]) %}
</small>
</div>
<div id="prep-artifact-summary-div" class="tab-pane fade in active">
</div>
</div>
<div id="archived-artifacts-tab-div" class="tab-pane fade">
<div>
<table class="table">
<thead>
<tr>
<th>Add to Analysis</th>
<th>Artifact</th>
<th>Creation time</th>
<th>Merging scheme</th>
</tr>
</thead>
{% for artifact in archived_artifacts %}
<tr>
<td>
<input type="button" id="send-button-{{artifact.id}}" class="btn btn-sm" value="Add" onclick="send_samples_to_analysis(this, [{{artifact.id}}])">
</td>
<td>
{{artifact.name}} ({{artifact.id}})
</td>
<td>{{artifact.timestamp}}</td>
<td>
{{artifact.merging_scheme[0]}}
</td>
</tr>
{% end %}
</table>
</div>
</div>
<div id="processing-graph-vue" class="tab-pane fade in active">
<processing-graph ref="procGraph" v-bind:is-analysis-pipeline='false' v-bind:no-init-jobs-callback="load_new_artifact" portal="{% raw qiita_config.portal_dir %}" graph-endpoint="/prep_template/{{prep_id}}/graph/" jobs-endpoint="/prep_template/{{prep_id}}/jobs/" element-id="{{prep_id}}"></processing-graph>
</div>
</div>
</div>
</div>
<!-- Modal to update the prep name -->
<div class="modal fade update-artifact-name" tabindex="-1" role="dialog" id="update-prep-name">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Updating prep information {{prep_id}} name</h3>
</div>
<div class="modal-body">
Introduce the new name:<br/>
<input type="text" name="new-prep-name" id="new-prep-name" onkeyup="validate_new_prep_name();">
<button id="update-prep-name-btn" class="btn btn-default" onclick="change_prep_name();" disabled>Update</button>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>