2 import '../legacy/jquery.js';
3 import '../legacy/jquery/dataTables.js';
4 import '../legacy/CXGN/Login.js';
6 export function init(main_div, stock_id, stockprop_id) {
8 if (!(main_div instanceof HTMLElement)) {
9 main_div = document.getElementById(
10 main_div.startsWith("#") ? main_div.slice(1) : main_div
14 jQuery(document).ready(function () {
16 if (stock_id !== undefined && stock_id !== null) {
17 stock_param = "/" + stock_id;
18 jQuery('#sequenced_stocks_table').DataTable({
19 "ajax": '/ajax/genomes/sequenced_stocks' + stock_param
23 jQuery('#sequenced_stocks_table').DataTable({
24 "ajax": '/ajax/genomes/sequenced_stocks'
29 jQuery('#sequencing_info_form').submit(function (event) {
31 event.preventDefault();
33 var formdata = jQuery("#sequencing_info_form").serialize();
36 url: '/ajax/genomes/store_sequencing_info?' + formdata,
37 success: function (r) {
38 if (r.error) { alert(r.error + r); }
40 alert("The entry has been saved. Thank you!");
41 jQuery('#edit_sequencing_info_dialog').modal('toggle');
42 clear_dialog_entries();
43 jQuery('#sequenced_stocks_table').DataTable().ajax.reload();
46 error: function (r, e) {
47 alert("An error occurred. (" + r.responseText + ")");
48 var err = eval("(" + r.responseText + ")");
53 jQuery('#dismiss_sequencing_info_dialog').click(function () {
54 jQuery('#edit_sequencing_info_dialog').modal('toggle');
55 clear_dialog_entries();
60 function clear_dialog_entries() {
61 jQuery('#organization').val(undefined);
62 jQuery('#website').val(undefined);
63 jQuery('#genbank_accession').val(undefined);
64 jQuery('#funded_by').val(undefined);
65 jQuery('#funder_project_id').val(undefined);
66 jQuery('#contact_email').val(undefined);
67 jQuery('#sequencing_year').val(undefined);
68 jQuery('#publication').val(undefined);
69 jQuery('#jbrowse_link').val(undefined);
70 jQuery('#blast_db_id').val(undefined);
71 jQuery('#ftp_link').val(undefined);
72 jQuery('#ncbi_link').val(undefined);
73 jQuery('#stockprop_id').val(undefined);
74 jQuery('#website').val(undefined);
77 export function delete_sequencing_info(stockprop_id) {
78 var answer = confirm("Are you sure you want to delete this entry? (stockprop_id= " + stockprop_id + "). This action cannot be undone.");
81 url: '/ajax/genomes/sequencing_info/delete/' + stockprop_id,
82 success: function (r) {
83 if (r.error) { alert(r.error); }
85 alert("The entry has been deleted.");
86 jQuery('#sequenced_stocks_table').DataTable().ajax.reload();
90 alert("An error occurred. The entry was not deleted.");
96 export function edit_sequencing_info(stockprop_id) {
97 //alert(stockprop_id);
99 url: '/ajax/genomes/sequencing_info/' + stockprop_id,
100 success: function (r) {
101 if (r.error) { alert(r.error); }
103 //alert(JSON.stringify(r));
104 jQuery('#organization').val(r.data.organization);
105 jQuery('#website').val(r.data.website);
106 jQuery('#genbank_accession').val(r.data.genbank_accession);
107 jQuery('#funded_by').val(r.data.funded_by);
108 jQuery('#funder_project_id').val(r.data.funder_project_id);
109 jQuery('#contact_email').val(r.data.contact_email);
110 jQuery('#sequencing_year').val(r.data.sequencing_year);
111 jQuery('#publication').val(r.data.publication);
112 jQuery('#jbrowse_link').val(r.data.jbrowse_link);
113 jQuery('#blast_db_id').val(r.data.blast_db_id);
114 jQuery('#ftp_link').val(r.data.ftp_link);
115 jQuery('#ncbi_link').val(r.data.ncbi_link);
116 jQuery('#stockprop_id').val(r.data.stockprop_id);
117 jQuery('#sequencing_status_stock_id').val(r.data.stock_id);
118 jQuery('#website').val(r.data.website);
119 jQuery('#edit_sequencing_info_dialog').modal("show");
122 error: function (r) { alert("an error occurred"); }