[879b32]: / qiita_pet / static / js / sampleTemplateVue.js

Download this file

667 lines (611 with data), 25.2 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
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
var sampleTemplatePage = null;
// taken from https://stackoverflow.com/a/19963011
function unique(array) {
return $.grep(array, function(el, index) {
return index == $.inArray(el, array);
});
}
function get_column_summary(study_id, portal, column, numSamples){
var row = $('.' + column + 'collapsed');
if (row.is(":hidden")) {
var cell = $(row.children()[0]);
cell.html('<img src="' + portal + '/static/img/waiting.gif" style="display:block;margin-left: auto;margin-right: auto"/>');
$.get(portal + '/study/description/sample_template/columns/', {study_id: study_id, column: column}, function(data) {
cell.html('');
var values = data['values'];
var uniques = unique(values);
var table = $('<table>').addClass('table').appendTo(cell);
if (uniques.length === 1) {
var tr = $('<tr>').appendTo(table);
var td = $('<td>').append(uniques[0] + ' is repeated in all rows.').appendTo(tr);
} else if (uniques.length === numSamples) {
var tr = $('<tr>').appendTo(table);
var td = $('<td>').append('All the values in this category are different').appendTo(tr);
} else {
var counts = {};
for (let u of uniques) { counts[u] = 0; }
for (let v of values) { counts[v]++; }
for (let u of uniques) {
var tr = $('<tr>').appendTo(table);
var td = $('<td>').append(u).appendTo(tr);
var td = $('<td>').append(counts[u]).appendTo(tr);
}
}
})
}
}
Vue.component('sample-template-page', {
template: '<div id="sample-template-main-div">' +
// Title div
'<div class="row">' +
'<div class="col-md-12">' +
'<h3>Sample Information<span id="title-h3"></span></h3>' +
'<h6>Last update: <span id="current-sample-info"></span></h6>' +
'</div>' +
'</div>' +
// Processing div
'<div class="row" id="st-processsing-div" style="border-radius: 10px; background: #EEE;">' +
'<div class="col-md-12">' +
'<h4>We are processing your request via job "<span id="job-id-span"></span>". Status: "<span id="job-status-span"></span>"</h4>' +
'</div>' +
'</div>' +
'</br>' +
// Content div
'<div class="row">' +
'<div class="col-md-12" id="sample-template-contents">' +
'</div>' +
'</div>' +
'</div>',
props: ['portal', 'study-id'],
maxDirectUploadSize: 10485760,
methods: {
/**
*
* Checks the status of the job performing some task over the sample
* information
*
**/
checkJob: function() {
let vm = this;
$.get(vm.portal + '/study/process/job/', {job_id: vm.job}, function(data) {
var jobStatus;
jobStatus = data['job_status'];
$('#job-id-span').text(data['job_id']);
$('#job-status-span').text(jobStatus);
if (jobStatus === 'error' || jobStatus === 'success') {
vm.stopJobCheckInterval();
// Hide the processing div
$('#st-processsing-div').hide();
// Enable interaction bits
$('#update-st-div').show();
$('.st-interactive').prop('disabled', false);
if (jobStatus === 'error') {
// The job errored - show the error
bootstrapAlert(data['job_error'], "danger");
} else {
// The job succeeded - reload the interface to show changes
if (vm.refresh) {
vm.refresh = false;
location.reload();
} else {
vm.updateSampleTemplateOverview();
}
}
}
})
.fail(function(object, status, error_msg) {
bootstrapAlert("Error checking the job status: " + object.statusText, "danger");
});
},
/**
*
* Starts the interval that checks the status of the job.
*
**/
startJobCheckInterval: function(jobId) {
let vm = this;
vm.job = jobId;
// Hide the current error message (if any)
$('#alert-message').alert('close');
// Show the processing div
$('#st-processsing-div').show();
// Disable interaction bits
$('.st-interactive').prop('disabled', true);
$('#update-st-div').hide();
// Force the first check to happen now
vm.checkJob();
// Set the interval for further checking - this jobs tend to be way faster
// hence setting the interval every 2 seconds.
vm.interval = setInterval(vm.checkJob, 2000);
},
/**
*
* Stops the interval checking the status of the job
*
**/
stopJobCheckInterval: function() {
let vm = this;
clearInterval(vm.interval);
},
/**
*
* Performs a call to the server API to create a new sample template
*
**/
createSampleTemplate: function() {
let vm = this;
var fp = $('#file-select').val();
var dtype = $('#data-type-select').val();
var file = $('#st-direct-upload')[0].files[0];
var fd = new FormData();
fd.append('study_id', vm.studyId);
fd.append('filepath', fp);
fd.append('data_type', dtype);
if (file !== undefined) {
fd.append('direct_upload', true);
fd.append('theFile', file);
}
$.ajax({
url: vm.portal + '/study/description/sample_template/',
type: 'POST',
processData: false,
contentType: false,
data: fd,
success: function(data) {
vm.startJobCheckInterval(data['job']);
},
error: function (object, status, error_msg) {
bootstrapAlert("Error updating sample template: " + error_msg, "danger")
}
});
},
/**
*
* Performs a call to the server API to udpate the sample information
*
**/
updateSampleTemplate: function() {
let vm = this;
var file = $('#st-direct-upload')[0].files[0];
var fd = new FormData();
fd.append('op', 'replace');
fd.append('path', vm.studyId + '/data/');
if (file !== undefined) {
fd.append('direct_upload', true);
fd.append('value', file);
} else {
fd.append('value', $('#file-select').val());
}
$.ajax({
url: vm.portal + '/study/description/sample_template/',
type: 'PATCH',
processData: false,
contentType: false,
data: fd,
success: function(data) {
vm.startJobCheckInterval(data['job']);
},
error: function (object, status, error_msg) {
bootstrapAlert("Error updating sample template: " + error_msg, "danger")
}
});
},
/**
*
* Performs a call to the server API to delete a column from the sample template
*
* @param category str The category to be removed
* @param rowId int The row number where this category was placed
*
**/
deleteColumn: function(category, rowId) {
let vm = this;
$.ajax({
url: vm.portal + '/study/description/sample_template/',
type: 'PATCH',
data: {'op': 'remove', 'path': vm.studyId + '/columns/' + category},
success: function(data) {
vm.rowId = rowId;
vm.rowType = 'column';
vm.startJobCheckInterval(data['job']);
},
error: function (object, status, error_msg) {
bootstrapAlert("Error deleting column: " + error_msg, "danger")
}
});
},
/**
*
* Performs a call to the server API to delete a sample from the sample template
*
* @param sample str The sample to be removed
* @param rowId int The row number where this sample was placed
*
**/
deleteSamples: function(samples) {
let vm = this;
var total_samples = samples.length;
if (total_samples === 0){
alert('No samples selected!');
} else {
if (confirm('Are you sure you want to delete ' + total_samples + ' samples?')) {
$.ajax({
url: vm.portal + '/study/description/sample_template/',
type: 'PATCH',
data: {'op': 'remove', 'path': vm.studyId + '/samples/' + samples},
success: function(data) {
vm.rowId = 0;
vm.rowType = 'sample';
vm.startJobCheckInterval(data['job']);
},
error: function (object, status, error_msg) {
bootstrapAlert("Error deleting sample: " + error_msg, "danger")
}
});
}
}
},
/**
*
* Performs a call to the server API to delete the sample template
*
**/
deleteSampleTemplate: function() {
let vm = this;
if(confirm("Are you sure you want to delete the sample information?")) {
vm.refresh = true;
$.ajax({
url: vm.portal + '/study/description/sample_template/?study_id=' + vm.studyId,
type: 'DELETE',
success: function(data) {
vm.startJobCheckInterval(data['job']);
},
error: function (object, status, error_msg) {
bootstrapAlert("Error deleting sample information: " + error_msg, "danger")
}
});
}
},
/**
*
* Creates the GUI for the summary table
*
**/
populateSampleInfoTable: function() {
let vm = this;
// Gathering this information is expensive in some studies. By issuing
// a different AJAX call for it, we can keep showing the rest of the interface
// (and interact with it) without having to wait for this information to
// show up - also the creation of the table occurs now in client side
// rather than in server side.
$.get(vm.portal + '/study/description/sample_template/columns/', {study_id: vm.studyId}, function(data) {
var catValues, $tr, $td, rowIdx, collapsedId, $trVal, $div, $btn;
$div = $('<div>').addClass('panel panel-default').appendTo('#sample-info-tab');
$('<div>').addClass('panel-heading').appendTo($div).append('Information summary');
var $mtable = $('<table>').addClass('table').appendTo($div);
var $table = $('<tbody>').appendTo($mtable);
var categories = data['values'];
categories.sort(function(a, b){return a[0].localeCompare(b[0], 'en', {'sensitivity': 'base'});});
rowIdx = 0;
for (var cat of categories) {
$tr = $('<tr>').attr('id', 'col-row-' + rowIdx).appendTo($table);
if (vm.editable && vm.userCanEdit) {
$td = $('<td>').appendTo($tr);
$btn = $('<button>').addClass('btn btn-danger st-interactive').appendTo($td).attr('data-column', cat).attr('data-row-id', rowIdx);
$('<span>').addClass('glyphicon glyphicon-trash').appendTo($btn);
$btn.on('click', function () {
if (confirm('Are you sure you want to delete `' + $(this).attr('data-column') + '`?')) {
vm.deleteColumn($(this).attr('data-column'), $(this).attr('data-row-id'));
}
});
}
rowIdx += 1;
$td = $('<td>').appendTo($tr);
$('<b>').append(cat + ': ').appendTo($td);
$td.append('&nbsp;&nbsp;&nbsp;&nbsp;');
collapsedId = cat + 'collapsed';
fcall = 'get_column_summary(' + vm.studyId + ', "' + vm.portal + '", "' + cat + '", ' + vm.numSamples + ')';
$bt = $('<button>').addClass('btn btn-default').attr('onclick', fcall).attr('data-toggle', 'collapse').attr('data-target', '.' + collapsedId).append('Values').appendTo($td);
$trVal = $('<tr>').addClass('collapse').addClass(collapsedId).appendTo($table);
$('<td>').attr('colspan', '3').append('&nbsp;').appendTo($trVal);
}
// Scroll to the desired row
if(vm.rowType === 'column' && vm.rowId !== null) {
// taken from: http://stackoverflow.com/a/2906009
var container = $('html, body');
var scrollTo = $('#col-row-' + vm.rowId);
container.animate({
scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop()
});
vm.rowId = null;
}
})
.fail(function(object, status, error_msg) {
bootstrapAlert("Error loading sample information: " + object.statusText, "danger");
});
},
/**
*
* Creates the GUI for the Sample-Prep table
*
**/
populateSamplePrepTab: function() {
let vm = this;
show_loading('sample-prep-tab');
$.get(vm.portal + '/study/description/sample_summary/', {study_id: vm.studyId}, function(data) {
$('#sample-prep-tab').html(data);
})
.fail(function(object, status, error_msg) {
bootstrapAlert("Error loading sample-prep information: " + object.statusText, "danger");
});
},
/**
*
* Creates the GUI for the case that a sample template exists
*
**/
populateExistingSampleTemplate: function() {
let vm = this;
var $btn, $div, $small, $row, $col, $ul, $li, $tab;
// Clear the contents of the div
$('#sample-template-contents').empty();
// Add the buttons next to the title
// Download Sample Information button
$('#current-sample-info').append(vm.current_file.split('_')[1].split('.')[0]);
$('#title-h3').append(' ');
$btn = $('<a>').addClass('btn btn-default').attr('href', vm.portal + '/download/' + vm.downloadId).appendTo('#title-h3');
$('<span>').addClass('glyphicon glyphicon-download-alt').appendTo($btn);
$btn.append(' Sample Info');
// Delete button (only if the user can edit)
if (vm.userCanEdit) {
$('#title-h3').append(' ');
$btn = $('<button>').addClass('btn btn-danger st-interactive').on('click', vm.deleteSampleTemplate).appendTo('#title-h3');
$('<span>').addClass('glyphicon glyphicon-trash').appendTo($btn);
$btn.append(' Delete');
}
// Show older files button (only if the sample information has older files)
if (vm.oldFiles.length > 0) {
// Add the button
$('#title-h3').append(' ');
$btn = $('<button>').addClass('btn btn-default').attr('data-toggle', 'collapse').attr('data-target', '#st-old-files').appendTo('#title-h3');
$('<span>').addClass('glyphicon glyphicon-eye-open').appendTo($btn);
$btn.append(' Show old files');
// Add the div that hold the old files
$div = $('<div>').attr('id', 'st-old-files').addClass('collapse').appendTo('#sample-template-contents');
$div.css('padding', '10px 10px 10px 10px').css('border-radius', '10px').css('background', '#EEE');
$small = $('<small>').appendTo($div).append('<label>Old files</label>');
for (var oldFile of vm.oldFiles) {
$small.append('<br/>' + oldFile);
}
}
// Adding the alert for restrictions
if (vm.sample_restrictions !== '') {
$row = $('<div>').addClass('row').appendTo('#sample-template-contents');
$col = $('<h5>').appendTo($row);
$('<div>').addClass('alert').addClass('alert-warning').append(vm.sample_restrictions).appendTo($row)
}
// After adding the buttons we can add the two tabs - one holding the Sample Information
// and the other one holding the Sample and preparation summary
$row = $('<div>').addClass('row').appendTo('#sample-template-contents');
$col = $('<div>').addClass('col-md-12').appendTo($row);
// The two "pills"
$ul = $('<ul>').addClass('nav nav-pills').appendTo($col);
$li = $('<li>').css('border', '1px solid #428bca').css('border-radius', '5px').appendTo($ul);
if (vm.rowType == 'column') {
$li.addClass('active');
}
$('<a>').attr('data-toggle', 'tab').attr('href', '#sample-info-tab').appendTo($li).append('Sample Information');
$li = $('<li>').css('border', '1px solid #428bca').css('border-radius', '5px').appendTo($ul);
if (vm.rowType == 'sample') {
$li.addClass('active');
}
$('<a>').attr('data-toggle', 'tab').attr('href', '#sample-prep-tab').appendTo($li).append('Sample-Prep Summary');
// The two tab divs are contained in a single tab-content div
$div = $('<div>').addClass('tab-content').appendTo($col);
$tab = $('<div>').addClass('tab-pane').attr('id', 'sample-info-tab').appendTo($div);
if (vm.rowType == 'column') {
$tab.addClass('active');
}
// Add the number of samples
$tab.append('<label>Number of samples:</label> ' + vm.numSamples + '</br>')
// Add the number of columns
$tab.append('<label>Number of columns:</label> ' + vm.numColumns + '</br>')
if (vm.userCanEdit) {
// Add the select to update the sample information
$row = $('<div>').attr('id', 'update-st-div').addClass('row form-group').appendTo($tab);
$('<label>').addClass('col-sm-2 col-form-label').append('Update sample information:').appendTo($row);
// Add the direct upload field
$('<label>')
.addClass('btn btn-default')
.append('Direct upload file <small>(< 2MB)</small>')
.appendTo($row)
.append('<input type="file" style="display: none;" id="st-direct-upload">');
$('#st-direct-upload').on('change', function() {
if (this.files.length != 1) {
alert('You can only upload one file.')
return false;
}
if (this.files[0].size > vm.maxDirectUploadSize) {
alert('You can only upload files smaller than 2MB. For larger files please use the "Upload Files" button on the left.');
return false;
}
vm.updateSampleTemplate()
});
$col = $('<div>').addClass('col-sm-3').appendTo($row);
$select = $('<select>').attr('id', 'file-select').addClass('form-control').appendTo($col);
$('<option>').attr('value', "").append('Choose file...').appendTo($select);
for (var opt of vm.uploadedFiles) {
$('<option>').attr('value', opt).append(opt).appendTo($select);
}
// Add the button to trigger the update
$col = $('<div>').addClass('col-sm-2').attr('id', 'update-btn-div').appendTo($row).hide();
$('<button>').addClass('btn btn-success form-control').append('Update').appendTo($col).on('click', vm.updateSampleTemplate);
$('#file-select').on('change', function() {
if (this.value === "") {
$('#update-btn-div').hide()
} else {
$('#update-btn-div').show()
}
});
}
// Populate the sample information table
vm.populateSampleInfoTable();
// Sample-prep tab
$tab = $('<div>').addClass('tab-pane').attr('id', 'sample-prep-tab').appendTo($div);
if (vm.rowType === 'sample') {
$tab.addClass('active');
}
vm.populateSamplePrepTab();
},
/**
*
* Creates the GUI to create a new sample template
*
**/
populateNewSampleTemplateForm: function() {
let vm = this;
var $row, $col, $select;
// Clear the contents of the div
$('#sample-template-contents').empty();
// To avoid code duplication creating the DOM elements, create a list
// with the contents and create the DOM elements in the for loop
var rowContents = [
// First one contains the uploaded files
{label: 'Select sample information file:', selectId: 'file-select', options: vm.uploadedFiles, placeholder: 'Choose file...'},
// Second one contains the data types
{label: 'If uploading a QIIME mapping file, select the data type of the prep information:', selectId: 'data-type-select', options: vm.dataTypes, placeholder: 'Choose a data type...'}]
// Create the DOM elements
for (var rC of rowContents) {
$row = $('<div>').addClass('row form-group').appendTo('#sample-template-contents');
$('<label>').addClass('col-sm-3 col-form-label').append(rC.label).appendTo($row);
$col = $('<div>').addClass('col-sm-3').appendTo($row);
$select = $('<select>').attr('id', rC.selectId).addClass('form-control').appendTo($col);
$('<option>').attr('value', "").append(rC.placeholder).appendTo($select);
for (var opt of rC.options) {
$('<option>').attr('value', opt).append(opt).appendTo($select);
}
if (rC['selectId'] == 'file-select') {
// Add the direct upload field
$('<label>')
.addClass('btn btn-default')
.append('Direct upload file <small>(< 2MB)</small>')
.appendTo($row)
.append('<input type="file" style="display: none;" id="st-direct-upload">');
$('#st-direct-upload').on('change', function() {
if (this.files.length != 1) {
alert('You can only upload one file.')
return false;
}
if (this.files[0].size > vm.maxDirectUploadSize) {
alert('You can only upload files smaller than 2MB. For larger files please use the "Upload Files" button on the left.');
return false;
}
vm.createSampleTemplate()
});
}
}
// Add the button - by default hidden
$row = $('<div>').attr('id', 'create-btn-div').addClass('row form-group').appendTo('#sample-template-contents').hide();
$col = $('<div>').addClass('col-sm-1').appendTo($row);
$('<button>').addClass('btn btn-success form-control st-interactive').append('Create').appendTo($col).on('click', vm.createSampleTemplate);
// Show/hide the button base on the value of the file selector
$('#file-select').on('change', function() {
if (this.value === "") {
$('#create-btn-div').hide()
} else {
$('#create-btn-div').show()
}
});
},
/**
*
* Performs a query to the server to update the sample template overview information
*
**/
updateSampleTemplateOverview: function () {
let vm = this;
$.get(vm.portal + '/study/description/sample_template/overview/', {study_id: vm.studyId}, function(data) {
vm.exists = data['exists'];
vm.dataTypes = data['data_types'];
vm.uploadedFiles = data['uploaded_files'];
vm.userCanEdit = data['user_can_edit'];
vm.job = data['job'];
vm.downloadId = data['download_id'];
vm.current_file = data['st_files'][0];
vm.oldFiles = data['st_files'].slice(1);
vm.numSamples = data['num_samples'];
vm.numColumns = data['num_columns'];
vm.columns = data['columns'];
vm.sample_restrictions = data['sample_restrictions'];
// fixing message for nicer display
if (vm.sample_restrictions !== '') {
vm.sample_restrictions = "Sample Info " + vm.sample_restrictions.split(" ").slice(2).join(" ");
}
// Populate the sample-template-contents
$('#title-h3').empty();
if (!vm.exists) {
vm.populateNewSampleTemplateForm();
} else {
vm.populateExistingSampleTemplate();
}
// Check the job for first time
if (vm.job !== null) {
$.get(vm.portal + '/study/process/job/', {job_id: vm.job}, function(data) {
var jobStatus = data['job_status'];
if (jobStatus === 'error') {
bootstrapAlert(data['job_error'], "danger");
} else if (jobStatus !== 'success') {
vm.startJobCheckInterval(vm.job);
}
})
.fail(function(object, status, error_msg) {
bootstrapAlert("Error checking the job status: " + object.statusText, "danger");
});
}
})
.fail(function(object, status, error_msg) {
bootstrapAlert("Error gathering Sample Information from server: " + object.statusText, "danger");
});
},
/**
*
* Cleans up the current object
*
**/
destroy: function() {
let vm = this;
vm.stopJobCheckInterval()
}
},
/**
*
* This function gets called by Vue once the HTML template is ready in the DOM
*
**/
mounted() {
let vm = this;
vm.interval = null;
vm.job = null;
vm.editable = true;
vm.rowId = null;
vm.rowType = 'column';
vm.refresh = false;
$('#st-processsing-div').hide();
show_loading('sample-template-contents');
// Get the overview information from the server
vm.updateSampleTemplateOverview();
}
});
/**
*
* Creates a new Vue object for the Sample Template in a safe way
*
* @param target str The id of the target div for the new Vue object
*
**/
function newSampleTemplateVue(target) {
if (sampleTemplatePage !== null) {
sampleTemplatePage.$refs.stElem.destroy();
}
sampleTemplatePage = new Vue({el: target});
};