diff --git a/assets/conf/environment.cfg b/assets/conf/environment.cfg
index 2127b6d6..bb2c8026 100755
--- a/assets/conf/environment.cfg
+++ b/assets/conf/environment.cfg
@@ -1,4 +1,4 @@
-{"environment_name":"mcl",
+{"environment_name":"edrn",
"environment":"https://labcas-dev.jpl.nasa.gov",
"environment_url":"https://edrn.nci.nih.gov/",
"leadpi_url":"https://edrn.nci.nih.gov/sites/",
@@ -37,6 +37,7 @@
"ksdb_institution_site_api":"https://mcl.jpl.nasa.gov/ksdb/publishhtml/?rdftype=institutionsite",
"ksdb_person_api":"https://mcl.jpl.nasa.gov/ksdb/publishhtml/?rdftype=person",
"ksdb_labcas_search_name_api":"https://mcl.jpl.nasa.gov/ksdb/publishhtml/?rdftype=labcas_search_names&filterval=",
+"ksdb_labcas_dicom_state_name_api":"https://mcl.jpl.nasa.gov/ksdb/publishhtml/?rdftype=labcas_dicom_state_names&filterval=",
"ksdb_labcas_search_protocol_api":"https://mcl.jpl.nasa.gov/ksdb/publishhtml/?rdftype=labcas_search_protocol&filterval=",
"ksdb_labcas_search_profile_api":"https://mcl.jpl.nasa.gov/ksdb/publishhtml/?rdftype=labcas_search_profile&filterval=",
"ksdb_labcas_search_profile_save":"https://mcl.jpl.nasa.gov/ksdb/save_labcas_search_input/",
diff --git a/assets/img/I0.dcm b/assets/img/I0.dcm
new file mode 100644
index 00000000..99db5dd3
Binary files /dev/null and b/assets/img/I0.dcm differ
diff --git a/assets/img/thumbnails b/assets/img/thumbnails
new file mode 120000
index 00000000..cfdbb7a1
--- /dev/null
+++ b/assets/img/thumbnails
@@ -0,0 +1 @@
+/labcas-data/labcas-backend/thumbnails
\ No newline at end of file
diff --git a/assets/js/labcas/.utils.js.swj b/assets/js/labcas/.utils.js.swj
new file mode 100644
index 00000000..7669011b
Binary files /dev/null and b/assets/js/labcas/.utils.js.swj differ
diff --git a/assets/js/labcas/authentication.js b/assets/js/labcas/authentication.js
index d4c7129d..5bcadd98 100755
--- a/assets/js/labcas/authentication.js
+++ b/assets/js/labcas/authentication.js
@@ -16,394 +16,7 @@ Array.prototype.unique = function() {
}
return arr;
}
-function initiate_search(){
- var get_var = get_url_vars();
- console.log(localStorage.getItem("search"));
- if(localStorage.getItem("search") && get_var["search"]){
- localStorage.setItem("search", get_var["search"].replace("&","%26"));
- console.log("Search not clearned");
- }else{
- localStorage.setItem("search", "*");
- console.log("Search cleared");
- }
- $.each(localStorage.getItem("filters").split(","), function(ind, head) {
- var divs = localStorage.getItem(head+"_filters_div").split(",");
- $.each(divs, function(i, divhead) {
- if (!localStorage.getItem($.trim(divhead))){
- localStorage.setItem($.trim(divhead), "");
- }
- if(divhead.includes("_num_")){
- if (!localStorage.getItem($.trim(divhead)+"_0")){
- localStorage.setItem($.trim(divhead)+"_0","");
- localStorage.setItem($.trim(divhead)+"_1","");
- localStorage.setItem($.trim(divhead)+"_max_0","");
- localStorage.setItem($.trim(divhead)+"_max_1","");
- }
- }else{
- if (!localStorage.getItem($.trim(divhead)+"_val")){
- localStorage.setItem($.trim(divhead)+"_val", "");
- }
- }
- });
- });
-
- setup_labcas_search(localStorage.getItem("search"), "all", 0);
- $("#collection_favorites_len").html(user_data['FavoriteFiles'].length+user_data['FavoriteDatasets'].length+user_data['FavoriteCollections'].length);
-}
-
-function fill_collections_public_data(data){
- //data.response.docs.sort(dataset_compare_sort);
- $.each(data.response.docs, function(index, obj) {
- if ((!obj.QAState) || (obj.QAState && !obj.QAState.includes("Private"))){
- var color = "btn-info";
- if(user_data["FavoriteCollections"].includes(obj.id)){
- color = "btn-success";
- }
-
-
- var institutions = obj.Institution? obj.Institution.join(",") : "";
- var pis = obj.LeadPI? obj.LeadPI.join(",") : "";
- var orgs = obj.Organ? obj.Organ.join(",") : "";
-
- if (localStorage.getItem('environment').includes("edrn-labcas")){
- var obj_arr = generate_edrn_links(obj);
- protocols = obj_arr[3].join(",");
- orgs = obj_arr[2].join(",");
- }else if(localStorage.getItem('environment').includes("mcl-labcas") || localStorage.getItem('environment').includes("labcas-dev")){
- var obj_arr = generate_mcl_links(obj);
- protocols = obj_arr[3].join(",");
- orgs = obj_arr[2].join(",");
- }
- $("#collection-table tbody").append(
- "
"+
- " | "+
- ""+
- obj.CollectionName+" | "+
- ""+orgs+" | "+
- ""+obj.Discipline+" | "+
- ""+institutions+" | "+
- ""+pis+" | "+
- ""+
- ""+
- " | "+
- "
");
- }
- });
- $('#loading').hide(500);
- $table.bootstrapTable({
- toolbar: ".toolbar",
- clickToSelect: true,
- showRefresh: true,
- search: true,
- showToggle: true,
- showColumns: true,
- pagination: true,
- searchAlign: 'left',
- pageSize: 50,
- clickToSelect: false,
- pageList: [8, 10, 25, 50, 100],
-
- formatShowingRows: function(pageFrom, pageTo, totalRows) {
- //do nothing here, we don't want to show the text "showing x of y from..."
- },
- formatRecordsPerPage: function(pageNumber) {
- return pageNumber + " rows visible";
- },
- icons: {
- refresh: 'fa fa-refresh',
- toggle: 'fa fa-th-list',
- columns: 'fa fa-columns',
- detailOpen: 'fa fa-plus-circle',
- detailClose: 'fa fa-minus-circle'
- }
- });
-
- //activate the tooltips after the data table is initialized
- $('[rel="tooltip"]').tooltip();
-
- $(window).resize(function() {
- $table.bootstrapTable('resetView');
- });
-}
-function fill_collections_data(data){
- //data.response.docs.sort(dataset_compare_sort);
- $.each(data.response.docs, function(index, obj) {
- var color = "btn-info";
- if(user_data["FavoriteCollections"].includes(obj.id)){
- color = "btn-success";
- }
-
-
- var institutions = obj.Institution? obj.Institution.join(", ") : "";
- var pis = obj.LeadPI? obj.LeadPI.join(", ") : "";
- var orgs = obj.Organ? obj.Organ.join(", ") : "";
- var protocols = obj.ProtocolName? obj.ProtocolName.join(", ") : "";
-
- if (localStorage.getItem('environment').includes("edrn-labcas")){
- var obj_arr = generate_edrn_links(obj);
- protocols = obj_arr[3].join(", ");
- orgs = obj_arr[2].join(", ");
- }else if(localStorage.getItem('environment').includes("mcl-labcas") || localStorage.getItem('environment').includes("labcas-dev")){
- var obj_arr = generate_mcl_links(obj);
- protocols = obj_arr[3].join(", ");
- orgs = obj_arr[2].join(", ");
- }
- if (!protocols){
- protocols = "";
- }
-
- $("#collection-table tbody").append(
- ""+
- " | "+
- ""+
- obj.CollectionName+" | "+
- ""+orgs+" | "+
- ""+obj.Discipline+" | "+
- ""+institutions+" | "+
- ""+pis+" | "+
- ""+
- ""+
- " | "+
- "
");
- });
- $('#loading').hide(500);
- $table.bootstrapTable({
- toolbar: ".toolbar",
- clickToSelect: true,
- showRefresh: true,
- search: false,
- showToggle: true,
- showColumns: true,
- pagination: true,
- pageSize: 50,
- clickToSelect: false,
- pageList: [8, 10, 25, 50, 100],
-
- formatShowingRows: function(pageFrom, pageTo, totalRows) {
- //do nothing here, we don't want to show the text "showing x of y from..."
- },
- formatRecordsPerPage: function(pageNumber) {
- return pageNumber + " rows visible";
- },
- icons: {
- refresh: 'fa fa-refresh',
- toggle: 'fa fa-th-list',
- columns: 'fa fa-columns',
- detailOpen: 'fa fa-plus-circle',
- detailClose: 'fa fa-minus-circle'
- }
- });
-
- //activate the tooltips after the data table is initialized
- $('[rel="tooltip"]').tooltip();
-
- $(window).resize(function() {
- $table.bootstrapTable('resetView');
- });
-}
-function fill_collection_details_data(data){
- console.log("Fill collection details");
- //console.log(data);
- if(!data.response.docs[0]){
- if(!Cookies.get("token") || Cookies.get("token") == "None"){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- redirect_to_login();
- }
- }
- var collectioname = data.response.docs[0].CollectionName;
- console.log("WHAT5");
- if (collectioname.length > 35){
- collectioname = collectioname.slice(0,35);
- }
- $("#collection_name").html(collectioname);
- var obj = data.response.docs[0];
- var institutions = obj.Institution? obj.Institution.join(", ") : "";
- var pis = obj.LeadPI? obj.LeadPI.join(", ") : "";
- var orgs = obj.Organ? obj.Organ.join(", ") : "";
- var proids = [];
- if (localStorage.getItem('environment').includes("edrn-labcas")){
- var obj_arr = generate_edrn_links(obj);
- protocols = obj_arr[3].join(",");
- orgs = obj_arr[2].join(", ");
- var proids = obj.ProtocolId? obj.ProtocolId : [];
- $.each(proids, function(ind, pid) {
- get_protocol_info("2", pid, "shortname", populate_collection_details_protocol_shortname);
- });
- }else if(localStorage.getItem('environment').includes("mcl-labcas") || localStorage.getItem('environment').includes("labcas-dev")){
- var obj_arr = generate_mcl_links(obj);
- protocols = obj_arr[3].join(",");
- institutions = obj_arr[0].join(", ");
- pis = obj_arr[1].join(", ");
- orgs = obj_arr[2].join(", ");
- }
-
- obj.Institution = institutions;
- obj.LeadPI = pis;
- obj.Organ = orgs;
- obj.ProtocolName = protocols;
- obj.Consortium = obj.Consortium? ""+obj.Consortium+"" : "";
-
- var extended_headers = [];
- if (localStorage.getItem('collection_header_extend_'+obj.id)){
- extended_headers = localStorage.getItem('collection_header_extend_'+obj.id).split(',');
- }
- var show_headers = localStorage.getItem('collection_header_order').split(',');
- var collapse_headers = localStorage.getItem('collapsible_headers').split(',');
- var collection_id_append = localStorage.getItem('collection_id_append').split(',');
-
- $.each(show_headers, function(ind, head) {
- var value = obj[head];
- if (typeof value === "undefined") {
- value = "";
- }
- //console.log(value);
- if ($.isArray(value)){
- value = value.join(",");
- }
- if (typeof value == "string"){
- value = value.replace(/% /g,'_labcasPercent_');
- value = decodeURIComponent(value);
- value = value.replace(/\+/g," ").replace(/_labcasPercent_/g,'% ');
- }
- if (collection_id_append.includes(head)){
- value += " ("+obj[head+"Id"]+")";
- }else if (collapse_headers.includes(head)){
- if (value && value.length > 20){
- value = ""+value.substring(0, 20) + "... More" + value.substring(20) + "
Less ";
- }
- }
- $("#collectiondetails-table tbody").append(
- ""+
- ""+head.replace( /([a-z])([A-Z])/g, "$1 $2" )+": | "+
- ""+
- value+
- " | "+
- "
");
- });
- $.each(obj, function(key, value) {
- if (show_headers.includes(key) || !extended_headers.includes(key)){
- return;
- }
- if (typeof value === "undefined") {
- value = "";
- }
- if ($.isArray(value)){
- value = value.join(",");
- }
- if (typeof value == "string"){
- value = value.replace(/% /g,'_labcasPercent_');
- value = decodeURIComponent(value);
- value = value.replace(/\+/g," ").replace(/_labcasPercent_/g,'% ');
- }
- if (collapse_headers.includes(key)){
- if (value.length > 20){
- value = ""+value.substring(0, 20) + "... More" + value.substring(20) + "
Less ";
- }
- }
- $("#collectiondetails-table tbody").append(
- ""+
- ""+key.replace( /([a-z])([A-Z])/g, "$1 $2" )+": | "+
- ""+
- value+
- " | "+
- "
");
-
- });
- $('#loading_collection').hide(500);
- $("#collectiontitle").html(collectioname);
-
-
-}
-function fill_dataset_details_data(data){
- var datasetname = data.response.docs[0].DatasetName;
- $("#datasettitle").html(datasetname);
- if (datasetname.length > 25){
- datasetname = datasetname.slice(0,25);
- }
- console.log("WH1");
- setTimeout(function() {
- $("#collection_datasets_len").html(datasetname);
- }, 2000);
-
- var collectionid = data.response.docs[0].CollectionId;
- var collectionname = data.response.docs[0].CollectionName;
- $("#collection_name").html(""+collectionname+"");
-
- var extended_headers = [];
- if (localStorage.getItem('dataset_header_extend_'+collectionid)){
- extended_headers = localStorage.getItem('dataset_header_extend_'+collectionid).split(',');
- }
- var show_headers = localStorage.getItem('dataset_header_order').split(',');
- var collection_id_append = localStorage.getItem('dataset_id_append').split(',');
-
- $.each(show_headers, function(ind, head) {
- var value = data.response.docs[0][head];
- if (typeof value === "undefined") {
- value = "";
- }
- if (!value){
- return;
- }
-
- if ($.isArray(value)){
- value = value.join(",");
- }
- if (typeof value == "string"){
- value = value.replace(/% /g,'_labcasPercent_');
- value = decodeURIComponent(value);
- value = value.replace(/\+/g," ").replace(/_labcasPercent_/g,'% ');
- }
- if (collection_id_append.includes(head)){
- value += " ("+data.response.docs[0][head+"Id"]+")";
- }
- $("#datasetdetails-table tbody").append(
- ""+
- ""+head.replace( /([a-z])([A-Z])/g, "$1 $2" )+": | "+
- ""+
- value+
- " | "+
- "
");
-
- });
-
- $.each(data.response.docs[0], function(key, value) {
- if (show_headers.includes(key) || !extended_headers.includes(key)){
- return;
- }
- if (typeof value === "undefined") {
- value = "";
- }
- if ($.isArray(value)){
- value = value.join(",");
- }
- if (typeof value == "string"){
- value = value.replace(/% /g,'_labcasPercent_');
- try {
- value = decodeURIComponent(value);
- } catch(e) {
- console.error(e);
- }
- value = value.replace(/\+/g," ").replace(/_labcasPercent_/g,'% ');
- }
-
- $("#datasetdetails-table tbody").append(
- ""+
- ""+key.replace( /([a-z:])([A-Z])/g, "$1 $2" )+": | "+
- ""+
- value+
- " | "+
- "
");
-
- });
-}
function fill_ksdb_info(type, id){
$.ajax({
url: localStorage.getItem(type),
@@ -425,6 +38,7 @@ function fill_ksdb_info(type, id){
}
function fill_file_details_data(data){
$("#filetitle").html(data.response.docs[0].FileName);
+ if (data.response.docs[0].id)
var html_safe_id = encodeURI(escapeRegExp(data.response.docs[0].id)).replace("&","%26");
var fileurl = "";
if (data.response.docs[0].FileUrl){
@@ -477,10 +91,15 @@ function fill_file_details_data(data){
var version = data.response.docs[0].DatasetVersion ? data.response.docs[0].DatasetVersion : "";
var fileloc = data.response.docs[0].FileLocation ? data.response.docs[0].FileLocation : "";
if ('ThumbnailRelativePath' in data.response.docs[0]){
- thumb = "";
+ thumb = "";
$("#viewer_wrapper").html(thumb);
$("#viewer_wrapper").attr("onclick","submitSingleImageData('"+html_safe_id+"','"+fileloc+"','"+filename+"','"+version+"');");
- }else{
+ }else if ('ThumbnailPath' in data.response.docs[0] && data.response.docs[0].ThumbnailPath.startsWith("/labcas-data/labcas-backend/thumbnails")){
+ thumb = "";
+ $("#viewer_wrapper").html(thumb);
+ $("#viewer_wrapper").attr("onclick","submitSingleImageData('"+html_safe_id+"','"+fileloc+"','"+filename+"','"+version+"');");
+
+ }else{
$("#viewer_icon").attr("onclick","submitSingleImageData('"+html_safe_id+"','"+fileloc+"','"+filename+"','"+version+"');");
}
if (check_image_filtered_dataset(html_safe_id)){
@@ -504,7 +123,6 @@ function fill_file_image_viewer_data(data){
filesize = humanFileSize(data.response.docs[0].FileSize, true);
}
//$("#download_icon").attr("onclick","download_file('"+html_safe_id+"','single');");
- console.log("GOTHERE");
if (accepted_image_check(data.response.docs[0].FileName)){
var filename = data.response.docs[0].FileName ? data.response.docs[0].FileName : "";
var version = data.response.docs[0].DatasetVersion ? data.response.docs[0].DatasetVersion : "";
@@ -519,7 +137,7 @@ function fill_file_image_viewer_data(data){
if (h_list){
histomics_list = JSON.parse(h_list);
}
- if (filename.endsWith(".dcm") || filename.endsWith(".dicom")){
+ if (filename.endsWith(".dcm") || filename.endsWith(".dicom") || filename.endsWith(".DCM")){
image_type = "dicoms";
}
@@ -538,520 +156,6 @@ function fill_file_image_viewer_data(data){
-function fill_datasets_children(data){
- data.response.docs.sort(dataset_compare_sort);
- var dataset_html = "";
- var flag = "";
- var dataset_count = 0;
- $.each(data.response.docs, function(key, value) {
- if (flag == ""){
- flag = true;
- return;
- }
- var color = "#0000FF";
- if(user_data["FavoriteDatasets"].includes(value.id)){
- color = "#87CB16 !important";
- }
- value.DatasetName = " ".repeat(value.id.split("/").length - 2)+"•"+value.DatasetName;
-
- var html_safe_id = encodeURI(escapeRegExp(value.id));
- var id_safe_id = html_safe_id.replace(/\//g,"-labsep-");
- var image_div = "";
- if (value.contains_image){
- image_div = "";
- }
-
- dataset_html += ""+
- "
"+
- "
"+
- "
"+
- image_div+
- ""+
- "
"+
- "
";
- dataset_count += 1;
- });
- if ( dataset_html != ""){
- $("#children-datasets").show();
- $( "#dataset_stat_template" ).load("/labcas-ui/templates.html #dataset_stat_template");
- console.log("OKOK1");
- setTimeout(function() {
- $("#collection_datasets_len").html(dataset_count);
- }, 2000);
- }else{
- $( "#dataset_stat_template" ).load("/labcas-ui/templates.html?version=2.3.2 #dataset_name_template");
- }
- $("#children-datasets-section").append(dataset_html);
-}
-function fill_collection_level_files(data){
- console.log("Metadata size");
- var size = data.response.numFound;
- console.log(size);
- var cpage = data.response.start;
- load_pagination("collectionfiles",size,cpage);
- $("#files-table tbody").empty();
- var download_list = JSON.parse(localStorage.getItem("download_list"));
- var cart_list = JSON.parse(localStorage.getItem("cart_list"));
- $.each(data.response.docs, function(key, value) {
-
- var color = "btn-info";
- if(user_data["FavoriteFiles"].includes(value.id)){
- color = "btn-success";
- }
-
- var thumb = "";
- var filetype = value.FileType ? value.FileType.join(",") : "";
- var filename = value.FileName ? value.FileName : "";
- var version = value.DatasetVersion ? value.DatasetVersion : "";
- var fileloc = value.FileLocation ? value.FileLocation : "";
- var site = value.Institution ? value.Institution.join(",") : "";
- var description = value.Description? value.Description.join(",") : "";
- if ('ThumbnailRelativePath' in value){
- thumb = "";
- }
- var html_safe_id = encodeURI(escapeRegExp(value.id));
- var filesize = "";
- var filesizenum = 0;
- if (value.FileSize){
- filesize = humanFileSize(value.FileSize, true);
- filesizenum = value.FileSize;
- }
- var checked = "";
- if ( (download_list && html_safe_id in download_list) || (cart_list && html_safe_id in cart_list)){
- checked = "checked";
- }
- $("#files-table tbody").append(
- ""+
- " | "+
- ""+
- ""+
- value.FileName+
- ""+
- " | "+
- ""+
- site +
- " | "+
- ""+
- filetype +
- " | "+
- ""+
- description +
- " | "+
- ""+
- thumb+
- " | "+
- ""+
- filesize+
- " | "+
- ""+
- ""+
- ""+
- " | "+
- "
");
- });
- if (size > 0){
- $("#children-files").show();
- }
- $('#loading_file').hide(500);
- init_file_checkboxes("files-table");
-}
-function fill_collection_metadata(data){
-
- var dataset_metadata_html = '";
- $('#loading_metadata').hide(500);
- $('#metadata_div').html(dataset_metadata_html);
-}
-function fill_datasets_data(data){
-
- data.response.docs.sort(dataset_compare_sort);
- var collapse_dict = {};
- var image_check_datasets = {};
- var prev_dataset_id = "";
- var dataset_html = "";
- var dataset_attr ="";
- var collapse_button = "";
-
- var get_var = get_url_vars();
- var metadata_exists = false;
- var collection_file_exists = false;
-
-
- $.each(data.response.docs, function(key, value) {
- if (value.id.split(/\//)[1] == get_var["collection_id"]){
- query_labcas_api(localStorage.getItem('environment')+"/data-access-api/files/select?q=DatasetId:"+value.id+"&wt=json&sort=FileName%20asc&indent=true", fill_collection_level_files);
- collection_file_exists = true;
- return;
- }
- else if(value.id.split(/\//)[1].toLowerCase() == "documentation"){
- query_labcas_api(localStorage.getItem('environment')+"/data-access-api/files/select?q=DatasetId:"+value.id+"&wt=json&sort=FileName%20asc&indent=true", fill_collection_metadata);
- metadata_exists = true;
- return;
- }
- var html_safe_id = encodeURI(escapeRegExp(value.id));
- var id_safe_id = html_safe_id.replace(/\//g,"-labsep-");
-
- var color = "#0000FF";
-
- var image_div = "";
- if (value.contains_image){
- image_div = "";
- }
-
- if(user_data["FavoriteDatasets"].includes(value.id)){
- color = "#87CB16 !important";
- }
- if (value.id.split("/").length - 2 > 0){
- if (collapse_dict[prev_dataset_id] == 1){
- dataset_html += "";
- collapse_dict[prev_dataset_id] += 1;
- }
- value.DatasetName = " ".repeat(value.id.split("/").length - 2)+"•"+value.DatasetName;
- collapse_button = "";
- }else{
- if (prev_dataset_id != ""){
- dataset_html += "
";
- }
- prev_dataset_id = value.id.replace(/[\/,\.]/g,"_");
- collapse_button = '';
- collapse_dict[prev_dataset_id] = 1;
- }
- dataset_html += ""+
- "
"+collapse_button+"
"+
- "
"+
- "
"+
- ""+
- image_div +
- ""+
- "
"+
- "
";
- });
- if (!metadata_exists){
- $('#collection_level_files').hide();
- }
- if (!collection_file_exists){
- $('#children-files').hide();
- }
- if ( dataset_html == "" ){
- $('#datasets_in_collection').hide();
- }
- if (prev_dataset_id != ""){
- dataset_html += "";
- }
-
- $("#datasets-table").append(dataset_html);
- $.each(collapse_dict, function(key, value) {
- if (value == 1){
- $('#'+key+'_button').hide();
- }
- });
- /*$.each(image_check_datasets, function(key, value) {
- //console.log(localStorage.getItem('environment')+"/data-access-api/files/select?q=DatasetId:"+key+"AND"+generate_accepted_image_solr_filters()+"&wt=json&sort=FileName%20asc&indent=true");
- query_labcas_api(localStorage.getItem('environment')+"/data-access-api/files/select?q=DatasetId:"+key+"AND"+generate_accepted_image_solr_filters()+"&wt=json&sort=FileName%20asc&indent=true", checkDatasetContainsDicom.bind(null, key, value));
- });*/
- $("#collection_datasets_len").html(data.response.numFound);
- $("#collection_favorites_len").html(user_data['FavoriteFiles'].length+user_data['FavoriteDatasets'].length+user_data['FavoriteCollections'].length);
- $('#loading_dataset').hide(500);
- $('#loading_metadata').hide(500);
-
-}
-function fill_files_data(data){
- var size = data.response.numFound;
- var cpage = data.response.start;
- load_pagination("files",size,cpage);
- $("#files-table tbody").empty();
- var download_list = JSON.parse(localStorage.getItem("download_list"));
- var cart_list = JSON.parse(localStorage.getItem("cart_list"));
- $.each(data.response.docs, function(key, value) {
-
- var color = "btn-info";
- if(user_data["FavoriteFiles"].includes(value.id)){
- color = "btn-success";
- }
-
- var thumb = "";
- var filetype = value.FileType ? value.FileType.join(",") : "";
- var filename = value.FileName ? value.FileName : "";
- var version = value.DatasetVersion ? value.DatasetVersion : "";
- var fileloc = value.FileLocation ? value.FileLocation : "";
- var site = value.Institution ? value.Institution.join(",") : "";
- var parID = value.participantID ? value.participantID.join(",") : "";
- var speID = value.specimen_id ? value.specimen_id.join(",") : "";
- var description = value.Description? value.Description.join(",") : "";
- if ('ThumbnailRelativePath' in value){
- thumb = "";
- }
- var html_safe_id = encodeURI(escapeRegExp(value.id)).replace("&","%26");
- var filesize = "";
- var filesizenum = 0;
- if (value.FileSize){
- filesize = humanFileSize(value.FileSize, true);
- filesizenum = value.FileSize;
- }
- var checked = "";
- if ( (download_list && html_safe_id in download_list) || (cart_list && html_safe_id in cart_list)){
- checked = "checked";
- }
- $("#files-table tbody").append(
- ""+
- " | "+
- ""+
- ""+
- value.FileName+
- ""+
- " | "+
- ""+
- parID +
- " | "+
- ""+
- speID +
- " | "+
- ""+
- site +
- " | "+
- ""+
- filetype +
- " | "+
- ""+
- description +
- " | "+
- ""+
- thumb+
- " | "+
- ""+
- filesize+
- " | "+
- ""+
- ""+
- ""+
- " | "+
- "
");
- });
- $("#collection_files_len").html(size);
- $("#collection_favorites_len").html(user_data['FavoriteFiles'].length+user_data['FavoriteDatasets'].length+user_data['FavoriteCollections'].length);
- $('#loading_file').hide(500);
- if (size > 0){
- $("#children-files").show();
- }
- init_file_checkboxes("files-table");
-}
-
-function setup_labcas_data(datatype, query, dataset_query){
- $.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/collections/select?q="+query+"&wt=json&indent=true&rows=10000&sort=id%20asc",
- beforeSend: function(xhr) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- type: 'GET',
- dataType: 'json',
- success: function (data) {
- if (datatype == "collections"){
- fill_collections_data(data);
- }else if (datatype == "collections_public"){
- fill_collections_public_data(data);
- }else if (datatype == "collectiondatasets"){
- fill_collection_details_data(data);
- $.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/files/select?q="+dataset_query+"&wt=json&sort=FileName%20asc&indent=true",
- beforeSend: function(xhr) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- type: 'GET',
- dataType: 'json',
- processData: false,
- success: function (data) {
- $("#collection_files_len").html(data.response.numFound);
- },
- error: function(e){
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- redirect_to_login();
- }
- });
- }
- },
- error: function(e){
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- redirect_to_login();
- }
- });
- if (datatype == "collectiondatasets"){
- console.log(localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+dataset_query+"&wt=json&indent=true&rows=20000");
- $.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+dataset_query+"&wt=json&indent=true&rows=20000",
- beforeSend: function(xhr) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- type: 'GET',
- dataType: 'json',
- processData: false,
- success: function (data) {
- fill_datasets_data(data);
- },
- error: function(e){
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- redirect_to_login();
- }
- });
- }
-}
-function populate_dataset_children(query){
- query = query.replace(/id:/,'DatasetParentId')+"%5C%2A";
- console.log(localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+query+"&wt=json&indent=true&rows=20000&sort=id%20asc");
- $.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+query+"&wt=json&indent=true&rows=20000&sort=id%20asc",
- xhrFields: {
- withCredentials: true
- },
- beforeSend: function(xhr, settings) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- dataType: 'json',
- success: function (data) {
- fill_datasets_children(data);
-
- },
- error: function(e){
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- redirect_to_login();
-
- }
- });
- $('#loading_dataset').hide(500);
-}
-function setup_labcas_dataset_data(datatype, query, file_query, cpage){
- if (cpage == 0){ //if this isn't a pagination request and a default load
- console.log(localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+query+"&wt=json&indent=true");
- $.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+query+"&wt=json&indent=true",
- xhrFields: {
- withCredentials: true
- },
- beforeSend: function(xhr, settings) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- dataType: 'json',
- success: function (data) {
- try{
- fill_dataset_details_data(data);
- populate_dataset_children(query);
- } catch (ex) {
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- redirect_to_login();
- }
-
- },
- error: function(e){
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- redirect_to_login();
-
- }
- });
- }
- //Set dataset size
-
- console.log(localStorage.getItem('environment')+"/data-access-api/files/select?q="+file_query+"&wt=json&indent=true&sort=FileName%20asc&start="+cpage*10);
- $.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/files/select?q="+file_query+"&wt=json&indent=true&sort=FileName%20asc&start="+cpage*10,
- xhrFields: {
- withCredentials: true
- },
- beforeSend: function(xhr, settings) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- dataType: 'json',
- success: function (data) {
- fill_files_data(data);
- },
- error: function(e){
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- redirect_to_login();
-
- }
- });
-}
function setup_labcas_file_data(datatype, query, file_query){
console.log("QUERY");
@@ -1103,773 +207,3 @@ function setup_labcas_file_data(datatype, query, file_query){
});
}
-
-
-
-/*Search Section*/
-
-function fill_datasets_facets(data){
- //console.log("Data_facets_output");
- //console.log(data);
-}
-
-function fill_datasets_search(data){
- var size = data.response.numFound;
- var cpage = data.response.start;
- load_pagination("datasets_search",size,cpage);
- //console.log("datasets");
- //console.log(data);
- $("#search-dataset-table tbody").empty();
-
- //console.log(data);
- $.each(data.response.docs, function(key, obj) {
- var color = "btn-info";
- if(user_data["FavoriteDatasets"].includes(obj.id)){
- color = "btn-success";
- }
- var html_safe_id = encodeURI(escapeRegExp(obj.id));
- var id_safe_id = html_safe_id.replace(/\//g,"-labsep-");
- var image_div = "";
- if (obj.contains_image){
- image_div = "";
- }
-
-
- $("#search-dataset-table tbody").append(
- ""+
- ""+
- ""+
- obj.DatasetName+" | "+
- ""+
- obj.CollectionName+" | "+
- ""+
- ""+
- image_div+
- ""+
- " | "+
- "
");
- });
-
- $("#collection_datasets_len").html(size);
- $('#loading_dataset').hide(500);
-}
-
-function fill_files_facets(data){
-
-}
-function fill_files_search(data){
- var size = data.response.numFound;
- var cpage = data.response.start;
- load_pagination("files_search",size,cpage);
- $("#search-file-table tbody").empty();
- $.each(data.response.docs, function(key, obj) {
- var color = "btn-info";
- if(user_data["FavoriteFiles"].includes(obj.id)){
- color = "btn-success";
- }
-
- var thumb = "";
- var filetype = obj.FileType ? obj.FileType.join(",") : "";
- var filename = obj.FileName ? obj.FileName : "";
- var version = obj.DatasetVersion ? obj.DatasetVersion : "";
- var fileloc = obj.FileLocation ? obj.FileLocation : "";
-
- var site = obj.Institution ? obj.Institution.join(",") : "";
- var description = obj.Description? obj.Description.join(",") : "";
- if ('ThumbnailRelativePath' in obj){
- thumb = "";
- }
- var filesize = "";
- var filesizenum = 0;
- if (obj.FileSize){
- filesize = humanFileSize(obj.FileSize, true);
- filesizenum += parseInt(obj.FileSize);
- }
- var html_safe_id = encodeURI(escapeRegExp(obj.id)).replace("&","%26");
- var checked = "";
- var download_list = JSON.parse(localStorage.getItem("download_list"));
- var cart_list = JSON.parse(localStorage.getItem("cart_list"));
- //console.log(html_safe_id);
- //console.log(download_list);
- if ( (download_list && html_safe_id in download_list) || (cart_list && html_safe_id in cart_list)){
- checked = "checked";
- }
-
- $("#search-file-table tbody").append(
- ""+
- " | "+
- ""+
- ""+
- obj.FileName+
- ""+
- " | "+
- ""+
- filetype +
- " | "+
- ""+
- site +
- " | "+
- ""+
- description +
- " | "+
- ""+
- thumb+
- " | "+
- ""+
- filesize+
- " | "+
- ""+
- ""+
- " | "+
- "
");
- });
- $("#collection_files_len").html(size);
- $('#loading_file').hide(500);
- //Init shopping cart
- init_file_checkboxes("search-file-table");
-}
-function generate_filters(field_type, placeholder, data, display, head){
- var filters = [];
- var counts = [];
-
- $("#filter_options").append(
- ''+
- ''+
- ''+
- '
'
- );
-
- $("#"+placeholder).html("");
-
- //console.log(data);
- if (placeholder.includes("_num_")){
- var min = 100000000;
- var max = -1;
- var left = 0;
- var right = 100;
- var sum = 0;
- var addflag = false;
- $.each(data, function(key, obj) {
- if (Number.isInteger(obj)){
- if(addflag){
- sum += obj;
- }
- }else{
- if(!isNaN(obj)){
- if(min > +obj){
- min = +obj;
- }
- if (max < +obj){
- max = +obj;
- }
- if(((localStorage.getItem(placeholder+"_0") && localStorage.getItem(placeholder+"_0") <= +obj) || (!localStorage.getItem(placeholder+"_0")))
- && (localStorage.getItem(placeholder+"_1") && localStorage.getItem(placeholder+"_1") >= +obj) || (!localStorage.getItem(placeholder+"_1"))){
- addflag = true;
- }else{
- addflag = false;
- }
- }
- }
- });
- if (min != 100000000 && max != -1){
- if (localStorage.getItem(placeholder+"_max_0")){
- min = localStorage.getItem(placeholder+"_max_0");
- }else{
- localStorage.setItem(placeholder+"_max_0", Math.floor(min));
- left = min;
- }
- if (localStorage.getItem(placeholder+"_max_1")){
- max = localStorage.getItem(placeholder+"_max_1");
- }else{
- localStorage.setItem(placeholder+"_max_1", Math.floor(max));
- right = max;
- }
- if (localStorage.getItem(placeholder+"_0")){
- left = localStorage.getItem(placeholder+"_0");
- }else{
- localStorage.setItem(placeholder+"_0", Math.floor(min));
- left = min;
- }
- if (localStorage.getItem(placeholder+"_1")){
- right = localStorage.getItem(placeholder+"_1");
- }else{
- localStorage.setItem(placeholder+"_1", Math.floor(max));
- right = max;
- }
- $("#"+placeholder).append($(''));
-
- var slider = document.getElementById(placeholder+'_slider');
-
- var slider_left = document.getElementById(placeholder+'_0');
- var slider_right = document.getElementById(placeholder+'_1');
- noUiSlider.create(slider, {
- start: [left, right],
- connect: true,
- range: {
- min: +min,
- max: +max
- },
- step: 1
- });
- document.getElementById(placeholder+'_count').innerHTML = "("+sum+")";
- slider.noUiSlider.on('update', function (values, handle) {
- if (handle == 0){
- slider_left.innerHTML = Math.floor(values[handle]);
- }else if(handle == 1){
- slider_right.innerHTML = Math.floor(values[handle]);
- }
- });
- slider.noUiSlider.on('end', function (values, handle) {
- if (handle == 0){
- localStorage.setItem(placeholder+"_0", Math.floor(values[handle]));
- }else if(handle == 1){
- localStorage.setItem(placeholder+"_1", Math.floor(values[handle]));
- }
-
- var str_field_val = encodeURI("["+localStorage.getItem(placeholder+"_0")+" TO "+localStorage.getItem(placeholder+"_1")+"]");
- var field_search = "&fq="+encodeURI(escapeRegExp(field_type)).replace(/:/g,'%3A')+":"+str_field_val;
- if (localStorage.getItem(placeholder+"_0") == localStorage.getItem(placeholder+"_max_0") && localStorage.getItem(placeholder+"_1") == localStorage.getItem(placeholder+"_max_1")){
- field_search = "";
- }
- localStorage.setItem(placeholder, field_search);
- localStorage.setItem("search_filter", "on");
- setup_labcas_search(localStorage.getItem('search').replace("&","%26"), "all", 0);
- });
- $('#'+placeholder+'_card').css("height","100px");
- }
-
- }else{
- $.each(data, function(key, obj) {
- if (Number.isInteger(obj)){
- counts.push(obj);
- }else{
- filters.push(obj);
- }
- });
- var filter_count = 0;
- $.each(filters, function(i, o){
- if (localStorage.getItem(placeholder+"_val") && localStorage.getItem(placeholder+"_val") != ""){
- }
- if (counts[i] > 0){
- var checked = "";
- if (localStorage.getItem(placeholder+"_val") && localStorage.getItem(placeholder+"_val").includes($.trim(o))){
- checked = "checked";
- }
- $("#"+placeholder).append($(' '));
- filter_count += 1;
- }
- });
- var filter_height = filter_count*50;
- if (filter_height > 100){
- filter_height = 100;
- }
- $('#'+placeholder+'_card').css("height",filter_height.toString()+"px");
-
- $('input[name="'+placeholder+'[]"]').change(function() {
- var field_val = [];
- $("input[name='"+placeholder+"[]']").each(function (index, obj) {
- if(this.checked) {
- field_val.push(this.value);
- }
- });
- var field_search = "";
- if (field_val.length > 0){
- var str_field_val = field_val.map(x => encodeURI(escapeRegExp(String(x))));
-
- field_search = "&fq=("+encodeURI(escapeRegExp(field_type)).replace(/:/g,'%3A')+":"+str_field_val.join(" OR "+encodeURI(escapeRegExp(field_type))+":")+")";
- }
- localStorage.setItem(placeholder, field_search);
- localStorage.setItem(placeholder+"_val",field_val);
- localStorage.setItem("search_filter", "on");
- setup_labcas_search(localStorage.getItem('search').replace("&","%26"), "all", 0);
- });
- }
-}
-
-function generate_categories(field_id, data){
- $('#'+field_id).empty();
- $("#filter_options").empty();
- $.each(localStorage.getItem("filters").split(","), function(ind, head) {
- if (localStorage.getItem("faceted_categories_selected") == head){
- $('#'+field_id).append("");
- }else{
- $('#'+field_id).append("");
- }
- var ids = localStorage.getItem(head+"_filters_id").split(",");
- var displays = localStorage.getItem(head+"_filters_display").split(",");
- var divs = localStorage.getItem(head+"_filters_div").split(",");
- $.each(ids, function(i, idhead) {
- generate_filters(idhead,$.trim(divs[i]), data.facet_counts.facet_fields[idhead], $.trim(displays[i]), $.trim(head));
- });
- });
-}
-
-//Recursive function to loop through collection, dataset, file hierachy to get filters
-function add_labcas_api_facets(querytypes, query, filters, facets, newdata, callback){
- if (querytypes.length < 1){
- callback(newdata);
- }else{
- var querytype = querytypes.pop();
- $.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/"+querytype+"/select?q="+query+""+filters+"&facet=true&facet.limit=-1&facet.field="+facets.join("&facet.field=")+"&wt=json",
- beforeSend: function(xhr) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- type: 'GET',
- dataType: 'json',
- success: function (data) {
- //join existing data with newdata
- if (newdata.facet_counts){
- console.log(localStorage.getItem('environment')+"/data-access-api/"+querytype+"/select?q="+query+""+filters+"&facet=true&facet.limit=-1&facet.field="+facets.join("&facet.field=")+"&wt=json");
- console.log(newdata.facet_counts);
- console.log(newdata.facet_counts.facet_fields.length);
- }
- if (newdata && newdata.facet_counts && newdata.facet_counts.facet_fields && Object.keys(newdata.facet_counts.facet_fields).length > 0){
- console.log("pass1");
- if (data && data.facet_counts && data.facet_counts.facet_fields && Object.keys(data.facet_counts.facet_fields).length > 0){
- console.log("pass2");
- $.each(data.facet_counts.facet_fields, function(i, facet_vals) {
- if (facet_vals && facet_vals.length > 0){
- if (newdata.facet_counts.facet_fields[i]){
- newdata.facet_counts.facet_fields[i] = facet_vals.concat(newdata.facet_counts.facet_fields[i].filter((item) => facet_vals.indexOf(item) < 0));
- }
- }
- });
- }
- }else{
- console.log("didn't pass");
- newdata = data;
- }
- console.log(newdata);
- add_labcas_api_facets(querytypes, query, filters, facets, newdata, callback);
- },
- error: function (xhr, ajaxOptions, thrownError) {
- console.log(xhr.responseText);
- console.log(xhr.status);
- console.log(thrownError);
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- redirect_to_login();
- }
- });
- }
-}
-
-function fill_collections_facets(data){
- console.log(data);
-
- if (localStorage.getItem("search_filter") == "on" || (localStorage.getItem("search") && localStorage.getItem("search") != "*")){
- $('#filter_reset').show();
- }else{
- $('#filter_reset').hide();
- }
- generate_categories("faceted_categories", data);
- $("#faceted_categories").change(function(){
- $.each(localStorage.getItem("filters").split(","), function(ind, head) {
- $("."+head+"_card").hide();
- });
- $(".Core_card").show();
- $(this).find("option:selected").each(function(){
- var optionValue = $(this).attr("value");
- localStorage.setItem("faceted_categories_selected", optionValue);
- $("."+optionValue+"_card").show();
- });
- reset_search_filters();
- setup_labcas_search("*", "all", 0);
- });
- $.each(localStorage.getItem("filters").split(","), function(ind, head) {
- $("."+head+"_card").hide();
- });
- $(".Core_card").show();
- $("."+localStorage.getItem("faceted_categories_selected")+"_card").show();
-}
-function fill_collections_search(data){
- var size = data.response.numFound;
- var cpage = data.response.start;
- load_pagination("collections_search",size,cpage);
- $("#search-collection-table tbody").empty();
- //data.response.docs.sort(dataset_compare_sort);
- $.each(data.response.docs, function(key, obj) {
- var color = "btn-info";
- if(user_data["FavoriteCollections"].includes(obj.id)){
- color = "btn-success";
- }
- $("#search-collection-table tbody").append(
- ""+
- ""+
- ""+
- obj.CollectionName+" | "+
- ""+obj.Organ+" | "+
- ""+obj.Discipline+" | "+
- ""+obj.Institution+" | "+
- ""+obj.LeadPI+" | "+
- ""+
- ""+
- " | "+
- "
");
- });
- $("#collection_name").html(size);
- $('#loading_collection').hide(500);
-}
-
-
-function setup_labcas_search(query, divid, cpage){
- console.log("Searching...");
- if (query != "*"){
- query = '"'+query+'"';
- }
- var collection_filters = "";
- var collection_facets = [];
- $.each(localStorage.getItem("filters").split(","), function(ind, head) {
- var divs = localStorage.getItem(head+"_filters_div").split(",");
- $.each(divs, function(i, divhead) {
- collection_filters += localStorage.getItem($.trim(divhead));
- });
- collection_facets = collection_facets.concat(localStorage.getItem(head+"_filters_id").split(","));
- });
- var data_filters = "";
- if (divid == "collections_search" || divid == "all"){
- console.log(localStorage.getItem('environment')+"/data-access-api/collections/select?q="+query+""+collection_filters+"&wt=json&indent=true&start="+cpage*10);
- $.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/collections/select?q="+query+""+collection_filters+"&wt=json&indent=true&sort=id%20asc&start="+cpage*10,
- beforeSend: function(xhr) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- type: 'GET',
- dataType: 'json',
- success: function (data) {
- fill_collections_search(data);
- },
- error: function(e){
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- redirect_to_login();
- }
- });
- //console.log(localStorage.getItem('environment')+"/data-access-api/files/select?q="+query+""+collection_filters+"&facet=true&facet.limit=-1&facet.field="+collection_facets.join("&facet.field=")+"&wt=json&rows=0&sort=FileName%20asc");
- var querytypes = ["collections","datasets","files"];
- add_labcas_api_facets(querytypes, query, collection_filters, collection_facets, {}, fill_collections_facets);
- /*$.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/files/select?q="+query+""+collection_filters+"&facet=true&facet.limit=-1&facet.field="+collection_facets.join("&facet.field=")+"&wt=json&rows=0&sort=FileName%20asc",
- beforeSend: function(xhr) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- type: 'GET',
- dataType: 'json',
- success: function (data) {
- console.log("GOT HERE");
- fill_collections_facets(data);
- },
- error: function (xhr, ajaxOptions, thrownError) {
- console.log("RIGHTY");
- console.log(xhr.responseText);
- console.log(xhr.status);
- console.log(thrownError);
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- redirect_to_login();
- }
- });*/
- }
- if (divid == "datasets_search" || divid == "all"){
- wait(1000);
- console.log(localStorage.getItem('environment')+"/data-access-api/datasets/select?q=*:*"+collection_filters+"&facet=true&facet.limit=-1&facet.field="+collection_facets.join("&facet.field=")+"&wt=json&rows=0&sort=DatasetName%20asc");
- $.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+query+""+collection_filters+"&wt=json&sort=DatasetName%20asc&indent=true&start="+cpage*10,
- beforeSend: function(xhr) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- type: 'GET',
- dataType: 'json',
- processData: false,
- success: function (data) {
- fill_datasets_search(data);
- },
- error: function(e){
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- redirect_to_login();
- }
- });
- }
- if (divid == "files_search" || divid == "all"){
- console.log("Files search");
- console.log(localStorage.getItem('environment')+"/data-access-api/files/select?q="+query+""+collection_filters+"&wt=json&indent=true&sort=FileName%20asc&start="+cpage*10);
- wait(1000);
- $.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/files/select?q="+query+""+collection_filters+"&wt=json&indent=true&sort=FileName%20asc&start="+cpage*10,
- xhrFields: {
- withCredentials: true
- },
- beforeSend: function(xhr, settings) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- dataType: 'json',
- success: function (data) {
- fill_files_search(data);
- setup_labcas_analytics(query, collection_filters);
- },
- error: function(e){
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- redirect_to_login();
-
- }
- });
-
- }
-}
-/* End Search Section */
-
-
-/*Starred Section*/
-function fill_datasets_starred(data){
- var size = data.response.numFound;
- var cpage = data.response.start;
- $("#starred-dataset-table tbody").empty();
- $.each(data.response.docs, function(key, obj) {
- if(user_data["FavoriteDatasets"].includes(obj.id)){
- var color = "btn-success";
-
-
- $("#starred-dataset-table tbody").append(
- ""+
- " | "+
- ""+
- obj.DatasetName+" | "+
- ""+
- obj.CollectionName+" | "+
- ""+
- ""+
- " | "+
- "
");
- }
- });
- $("#datasets_len").html(size);
-}
-function fill_files_starred(data){
- var size = data.response.numFound;
- var cpage = data.response.start;
- $("#starred-file-table tbody").empty();
- $.each(data.response.docs, function(key, obj) {
- var color = "btn-success";
-
- var filetype = obj.FileType ? obj.FileType.join(",") : "";
- var description = obj.Description? obj.Description.join(",") : "";
- var thumb = "";
- if ('ThumbnailRelativePath' in obj){
- thumb = "";
- }
- var filesize = "";
- if (obj.FileSize){
- filesize = humanFileSize(obj.FileSize, true);
- }
- $("#starred-file-table tbody").append(
- ""+
- " | "+
- ""+
- ""+
- obj.FileName+
- ""+
- " | "+
- ""+
- filetype +
- " | "+
- ""+
- description +
- " | "+
- ""+
- thumb+
- " | "+
- ""+
- filesize+
- " | "+
- ""+
- ""+
- " | "+
- "
");
- });
- $("#files_len").html(size);
-}
-
-function fill_collections_starred(data){
- var size = data.response.numFound;
- var cpage = data.response.start;
- $("#starred-collection-table tbody").empty();
-
- $.each(data.response.docs, function(key, obj) {
- if(user_data["FavoriteCollections"].includes(obj.id)){
- var color = "btn-success";
-
- $("#starred-collection-table tbody").append(
- ""+
- " | "+
- ""+
- obj.CollectionName+" | "+
- ""+obj.Organ+" | "+
- ""+obj.Discipline+" | "+
- ""+obj.Institution+" | "+
- ""+obj.LeadPI+" | "+
- ""+
- ""+
- " | "+
- "
");
- }
- });
- $("#collections_len").html(size);
- $('#loading').hide(500);
-
-}
-
-function setup_labcas_starred(query, divid, cpage){
- var collection_starred_search = "";
- if (user_data["FavoriteCollections"].length > 0){
- collection_starred_search = "&fq=(id:"+user_data["FavoriteCollections"].map(x => encodeURI(escapeRegExp(String(x)))).join(" OR id:")+")";
- }
- var dataset_starred_search = "";
- if (user_data["FavoriteDatasets"].length > 0){
- dataset_starred_search = "&fq=(id:"+user_data["FavoriteDatasets"].map(x => encodeURI(escapeRegExp(String(x)))).join(" OR id:")+")";
- }
- var file_starred_search = "";
- if (user_data["FavoriteFiles"].length > 0){
- var tmp_files_search = user_data["FavoriteFiles"].map(x => encodeURI(escapeRegExp(String(x)))).join(" OR id:").replace(/ *\([^)]*\) */g, "*");
- file_starred_search = "&fq=(id:"+tmp_files_search+")";
- }
- //console.log("Loading data...");
- if (divid == "collections_starred" || divid == "all"){
- console.log(localStorage.getItem('environment')+"/data-access-api/collections/select?q=*"+collection_starred_search+"&wt=json&indent=true&start="+cpage*10);
- $.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/collections/select?q=*"+collection_starred_search+"&wt=json&indent=true&sort=id%20asc&start="+cpage*10,
- beforeSend: function(xhr) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- type: 'GET',
- dataType: 'json',
- success: function (data) {
- fill_collections_starred(data);
- },
- error: function(e){
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- redirect_to_login();
- }
- });
- }
- if (divid == "datasets_starred" || divid == "all"){
- $.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/datasets/select?q=*"+dataset_starred_search+"&wt=json&indent=true&start="+cpage*10,
- beforeSend: function(xhr) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- type: 'GET',
- dataType: 'json',
- processData: false,
- success: function (data) {
- fill_datasets_starred(data);
- },
- error: function(e){
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
- }
- });
- }
-
- if (divid == "files_starred" || divid == "all"){
- console.log(localStorage.getItem('environment')+"/data-access-api/files/select?q=*"+file_starred_search+"&wt=json&indent=true&sort=FileName%20asc&start="+cpage*10);
-
- $.ajax({
- url: localStorage.getItem('environment')+"/data-access-api/files/select?q=*"+file_starred_search+"&wt=json&sort=FileName%20asc&indent=true&start="+cpage*10,
- xhrFields: {
- withCredentials: true
- },
- beforeSend: function(xhr, settings) {
- if(Cookies.get('token') && Cookies.get('token') != "None"){
- xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
- }
- },
- dataType: 'json',
- success: function (data) {
- fill_files_starred(data);
- },
- error: function(e){
- if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
- localStorage.setItem("logout_alert","On");
- alert("You are currently logged out. Redirecting you to log in.");
- }
-
- }
- });
- }
- $("#favorites_len").html(user_data['FavoriteFiles'].length+user_data['FavoriteDatasets'].length+user_data['FavoriteCollections'].length);
-}
-
-/* Starred Section End */
diff --git a/assets/js/labcas/collections.js b/assets/js/labcas/collections.js
new file mode 100644
index 00000000..83a7420f
--- /dev/null
+++ b/assets/js/labcas/collections.js
@@ -0,0 +1,547 @@
+function fill_collection_level_files(data){
+ console.log("Metadata size");
+ var size = data.response.numFound;
+ console.log(size);
+ var cpage = data.response.start;
+ load_pagination("collectionfiles",size,cpage);
+ $("#files-table tbody").empty();
+ var download_list = JSON.parse(localStorage.getItem("download_list"));
+ var cart_list = JSON.parse(localStorage.getItem("cart_list"));
+ $.each(data.response.docs, function(key, value) {
+
+ var color = "btn-info";
+ if(user_data["FavoriteFiles"].includes(value.id)){
+ color = "btn-success";
+ }
+
+ var thumb = "";
+ var filetype = value.FileType ? value.FileType.join(",") : "";
+ var filename = value.FileName ? value.FileName : "";
+ var version = value.DatasetVersion ? value.DatasetVersion : "";
+ var fileloc = value.FileLocation ? value.FileLocation : "";
+ var site = value.Institution ? value.Institution.join(",") : "";
+ var description = value.Description? value.Description.join(",") : "";
+ if ('ThumbnailRelativePath' in value){
+ thumb = "";
+ }
+ var html_safe_id = encodeURI(escapeRegExp(value.id));
+ var filesize = "";
+ var filesizenum = 0;
+ if (value.FileSize){
+ filesize = humanFileSize(value.FileSize, true);
+ filesizenum = value.FileSize;
+ }
+ var checked = "";
+ if ( (download_list && html_safe_id in download_list) || (cart_list && html_safe_id in cart_list)){
+ checked = "checked";
+ }
+ $("#files-table tbody").append(
+ ""+
+ " | "+
+ ""+
+ ""+
+ value.FileName+
+ ""+
+ " | "+
+ ""+
+ site +
+ " | "+
+ ""+
+ filetype +
+ " | "+
+ ""+
+ description +
+ " | "+
+ ""+
+ thumb+
+ " | "+
+ ""+
+ filesize+
+ " | "+
+ ""+
+ ""+
+ ""+
+ " | "+
+ "
");
+ });
+ if (size > 0){
+ $("#children-files").show();
+ }
+ $('#loading_file').hide(500);
+ init_file_checkboxes("files-table");
+}
+
+function fill_collection_metadata(data){
+
+ var dataset_metadata_html = '";
+ $('#loading_metadata').hide(500);
+ $('#metadata_div').html(dataset_metadata_html);
+}
+function fill_collection_details_data(data){
+ console.log("Fill collection details");
+ if(!data.response.docs[0]){
+ if(!Cookies.get("token") || Cookies.get("token") == "None"){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ redirect_to_login();
+ }
+ }
+ var collectioname = data.response.docs[0].CollectionName;
+ console.log("WHAT5");
+ if (collectioname.length > 35){
+ collectioname = collectioname.slice(0,35);
+ }
+ $("#collection_name").html(collectioname);
+ var obj = data.response.docs[0];
+ var institutions = obj.Institution? obj.Institution.join(", ") : "";
+ var pis = obj.LeadPI? obj.LeadPI.join(", ") : "";
+ var orgs = obj.Organ? obj.Organ.join(", ") : "";
+ var proids = [];
+ if (localStorage.getItem('environment').includes("edrn-labcas")){
+ var obj_arr = generate_edrn_links(obj);
+ protocols = obj_arr[3].join(",");
+ orgs = obj_arr[2].join(", ");
+ var proids = obj.ProtocolId? obj.ProtocolId : [];
+ $.each(proids, function(ind, pid) {
+ get_protocol_info("2", pid, "shortname", populate_collection_details_protocol_shortname);
+ });
+ }else if(localStorage.getItem('environment').includes("mcl-labcas") || localStorage.getItem('environment').includes("labcas-dev")){
+ var obj_arr = generate_mcl_links(obj);
+ protocols = obj_arr[3].join(",");
+ institutions = obj_arr[0].join(", ");
+ pis = obj_arr[1].join(", ");
+ orgs = obj_arr[2].join(", ");
+ }
+
+ obj.Institution = institutions;
+ obj.LeadPI = pis;
+ obj.Organ = orgs;
+ obj.ProtocolName = protocols;
+ obj.Consortium = obj.Consortium? ""+obj.Consortium+"" : "";
+
+ var extended_headers = [];
+ if (localStorage.getItem('collection_header_extend_'+obj.id)){
+ extended_headers = localStorage.getItem('collection_header_extend_'+obj.id).split(',');
+ }
+ var show_headers = localStorage.getItem('collection_header_order').split(',');
+ var collapse_headers = localStorage.getItem('collapsible_headers').split(',');
+ var collection_id_append = localStorage.getItem('collection_id_append').split(',');
+
+ $.each(show_headers, function(ind, head) {
+ var value = obj[head];
+ if (typeof value === "undefined") {
+ value = "";
+ }
+ if ($.isArray(value)){
+ value = value.join(",");
+ }
+ if (typeof value == "string"){
+ value = value.replace(/% /g,'_labcasPercent_');
+ value = decodeURIComponent(value);
+ value = value.replace(/\+/g," ").replace(/_labcasPercent_/g,'% ');
+ }
+ if (collection_id_append.includes(head)){
+ value += " ("+obj[head+"Id"]+")";
+ }else if (collapse_headers.includes(head)){
+ if (value && value.length > 20){
+ value = ""+value.substring(0, 20) + "... More" + value.substring(20) + "
Less ";
+ }
+ }
+ $("#collectiondetails-table tbody").append(
+ ""+
+ ""+head.replace( /([a-z])([A-Z])/g, "$1 $2" )+": | "+
+ ""+
+ value+
+ " | "+
+ "
");
+ });
+ $.each(obj, function(key, value) {
+ if (show_headers.includes(key) || !extended_headers.includes(key)){
+ return;
+ }
+ if (typeof value === "undefined") {
+ value = "";
+ }
+ if ($.isArray(value)){
+ value = value.join(",");
+ }
+ if (typeof value == "string"){
+ value = value.replace(/% /g,'_labcasPercent_');
+ value = decodeURIComponent(value);
+ value = value.replace(/\+/g," ").replace(/_labcasPercent_/g,'% ');
+ }
+ if (collapse_headers.includes(key)){
+ if (value.length > 20){
+ value = ""+value.substring(0, 20) + "... More" + value.substring(20) + "
Less ";
+ }
+ }
+ $("#collectiondetails-table tbody").append(
+ ""+
+ ""+key.replace( /([a-z])([A-Z])/g, "$1 $2" )+": | "+
+ ""+
+ value+
+ " | "+
+ "
");
+
+ });
+
+ $('#loading_collection').hide(500);
+ $("#collectiontitle").html(collectioname);
+
+
+}
+
+function fill_collections_public_data(data){
+ $.each(data.response.docs, function(index, obj) {
+ if ((!obj.OwnerPrincipal) || (obj.OwnerPrincipal && obj.OwnerPrincipal.includes("All Users"))){
+ var color = "btn-info";
+ if(user_data["FavoriteCollections"].includes(obj.id)){
+ color = "btn-success";
+ }
+
+
+ var institutions = obj.Institution? obj.Institution.join(",") : "";
+ var pis = obj.LeadPI? obj.LeadPI.join(",") : "";
+ var orgs = obj.Organ? obj.Organ.join(",") : "";
+
+ if (localStorage.getItem('environment').includes("edrn-labcas")){
+ var obj_arr = generate_edrn_links(obj);
+ protocols = obj_arr[3].join(",");
+ orgs = obj_arr[2].join(",");
+ }else if(localStorage.getItem('environment').includes("mcl-labcas") || localStorage.getItem('environment').includes("labcas-dev")){
+ var obj_arr = generate_mcl_links(obj);
+ protocols = obj_arr[3].join(",");
+ orgs = obj_arr[2].join(",");
+ }
+ $("#collection-table tbody").append(
+ ""+
+ " | "+
+ ""+
+ obj.CollectionName+" | "+
+ ""+orgs+" | "+
+ ""+obj.Discipline+" | "+
+ ""+institutions+" | "+
+ ""+pis+" | "+
+ ""+
+ ""+
+ " | "+
+ "
");
+ }
+ });
+ $('#loading').hide(500);
+ $table.bootstrapTable({
+ toolbar: ".toolbar",
+ clickToSelect: true,
+ showRefresh: true,
+ search: true,
+ showToggle: true,
+ showColumns: true,
+ pagination: true,
+ searchAlign: 'left',
+ pageSize: 50,
+ clickToSelect: false,
+ pageList: [8, 10, 25, 50, 100],
+
+ formatShowingRows: function(pageFrom, pageTo, totalRows) {
+ },
+ formatRecordsPerPage: function(pageNumber) {
+ return pageNumber + " rows visible";
+ },
+ icons: {
+ refresh: 'fa fa-refresh',
+ toggle: 'fa fa-th-list',
+ columns: 'fa fa-columns',
+ detailOpen: 'fa fa-plus-circle',
+ detailClose: 'fa fa-minus-circle'
+ }
+ });
+ //activate the tooltips after the data table is initialized
+ $('[rel="tooltip"]').tooltip();
+
+ $(window).resize(function() {
+ $table.bootstrapTable('resetView');
+ });
+}
+
+
+function fill_collections_data(data){
+ $.each(data.response.docs, function(index, obj) {
+ var color = "btn-info";
+ if(user_data["FavoriteCollections"].includes(obj.id)){
+ color = "btn-success";
+ }
+
+
+ var institutions = obj.Institution? obj.Institution.join(", ") : "";
+ var pis = obj.LeadPI? obj.LeadPI.join(", ") : "";
+ var orgs = obj.Organ? obj.Organ.join(", ") : "";
+ var protocols = obj.ProtocolName? obj.ProtocolName.join(", ") : "";
+
+ if (localStorage.getItem('environment').includes("edrn-labcas")){
+ var obj_arr = generate_edrn_links(obj);
+ protocols = obj_arr[3].join(", ");
+ orgs = obj_arr[2].join(", ");
+ }else if(localStorage.getItem('environment').includes("mcl-labcas") || localStorage.getItem('environment').includes("labcas-dev")){
+ var obj_arr = generate_mcl_links(obj);
+ protocols = obj_arr[3].join(", ");
+ orgs = obj_arr[2].join(", ");
+ }
+ if (!protocols){
+ protocols = "";
+ }
+
+ $("#collection-table tbody").append(
+ ""+
+ " | "+
+ ""+
+ obj.CollectionName+" | "+
+ ""+orgs+" | "+
+ ""+obj.Discipline+" | "+
+ ""+institutions+" | "+
+ ""+pis+" | "+
+ ""+
+ ""+
+ " | "+
+ "
");
+ });
+ $('#loading').hide(500);
+ $table.bootstrapTable({
+ toolbar: ".toolbar",
+ clickToSelect: true,
+ showRefresh: true,
+ search: false,
+ showToggle: true,
+ showColumns: true,
+ pagination: true,
+ pageSize: 50,
+ clickToSelect: false,
+ pageList: [8, 10, 25, 50, 100],
+
+ formatShowingRows: function(pageFrom, pageTo, totalRows) {
+ },
+ formatRecordsPerPage: function(pageNumber) {
+ return pageNumber + " rows visible";
+ },
+ icons: {
+ refresh: 'fa fa-refresh',
+ toggle: 'fa fa-th-list',
+ columns: 'fa fa-columns',
+ detailOpen: 'fa fa-plus-circle',
+ detailClose: 'fa fa-minus-circle'
+ }
+ });
+
+ //activate the tooltips after the data table is initialized
+ $('[rel="tooltip"]').tooltip();
+
+ $(window).resize(function() {
+ $table.bootstrapTable('resetView');
+ });
+}
+
+function fill_datasets_data(data){
+
+ data.response.docs.sort(dataset_compare_sort);
+ var collapse_dict = {};
+ var image_check_datasets = {};
+ var prev_dataset_id = "";
+ var dataset_html = "";
+ var dataset_attr ="";
+ var collapse_button = "";
+
+ var get_var = get_url_vars();
+ var metadata_exists = false;
+ var collection_file_exists = false;
+
+
+ $.each(data.response.docs, function(key, value) {
+ if (value.id.split(/\//)[1] == get_var["collection_id"]){
+ query_labcas_api(localStorage.getItem('environment')+"/data-access-api/files/select?q=DatasetId:"+value.id+"&wt=json&sort=FileName%20asc&indent=true", fill_collection_level_files);
+ collection_file_exists = true;
+ return;
+ }
+ else if(value.id.split(/\//)[1].toLowerCase() == "documentation"){
+ query_labcas_api(localStorage.getItem('environment')+"/data-access-api/files/select?q=DatasetId:"+value.id+"&wt=json&sort=FileName%20asc&indent=true", fill_collection_metadata);
+ metadata_exists = true;
+ return;
+ }
+ var html_safe_id = encodeURI(escapeRegExp(value.id));
+ var id_safe_id = html_safe_id.replace(/\//g,"-labsep-");
+
+ var color = "#0000FF";
+
+ var image_div = "";
+ if (value.contains_image){
+ image_div = "";
+ }
+
+ if(user_data["FavoriteDatasets"].includes(value.id)){
+ color = "#87CB16 !important";
+ }
+ if (value.id.split("/").length - 2 > 0){
+ if (collapse_dict[prev_dataset_id] == 1){
+ dataset_html += "";
+ collapse_dict[prev_dataset_id] += 1;
+ }
+ value.DatasetName = " ".repeat(value.id.split("/").length - 2)+"•"+value.DatasetName;
+ collapse_button = "";
+ }else{
+ if (prev_dataset_id != ""){
+ dataset_html += "
";
+ }
+ prev_dataset_id = value.id.replace(/[\/,\.]/g,"_");
+ collapse_button = '';
+ collapse_dict[prev_dataset_id] = 1;
+ }
+
+ dataset_html += ""+
+ "
"+collapse_button+"
"+
+ "
"+
+ "
"+
+ ""+
+ image_div +
+ ""+
+ "
"+
+ "
";
+ });
+ if (!metadata_exists){
+ $('#collection_level_files').hide();
+ }
+ if (!collection_file_exists){
+ $('#children-files').hide();
+ }
+ if ( dataset_html == "" ){
+ $('#datasets_in_collection').hide();
+ }
+ if (prev_dataset_id != ""){
+ dataset_html += "";
+ }
+
+ $("#datasets-table").append(dataset_html);
+ $.each(collapse_dict, function(key, value) {
+ if (value == 1){
+ $('#'+key+'_button').hide();
+ }
+ });
+ $("#collection_datasets_len").html(data.response.numFound);
+ $("#collection_favorites_len").html(user_data['FavoriteFiles'].length+user_data['FavoriteDatasets'].length+user_data['FavoriteCollections'].length);
+ $('#loading_dataset').hide(500);
+ $('#loading_metadata').hide(500);
+
+}
+function setup_labcas_data(datatype, query, dataset_query){
+ console.log(localStorage.getItem('environment')+"/data-access-api/collections/select?q="+query+"&wt=json&indent=true&rows=10000&sort=id%20asc");
+ $.ajax({
+ url: localStorage.getItem('environment')+"/data-access-api/collections/select?q="+query+"&wt=json&indent=true&rows=10000&sort=id%20asc",
+ beforeSend: function(xhr) {
+ if(Cookies.get('token') && Cookies.get('token') != "None"){
+ xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
+ }
+ },
+ type: 'GET',
+ dataType: 'json',
+ success: function (data) {
+ if (datatype == "collections"){
+ fill_collections_data(data);
+ }else if (datatype == "collections_public"){
+ console.log("publiccollection");
+ console.log(data);
+
+ fill_collections_public_data(data);
+ }else if (datatype == "collectiondatasets"){
+ fill_collection_details_data(data);
+ $.ajax({
+ url: localStorage.getItem('environment')+"/data-access-api/files/select?q="+dataset_query+"&wt=json&sort=FileName%20asc&indent=true",
+ beforeSend: function(xhr) {
+ if(Cookies.get('token') && Cookies.get('token') != "None"){
+ xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
+ }
+ },
+ type: 'GET',
+ dataType: 'json',
+ processData: false,
+ success: function (data) {
+ $("#collection_files_len").html(data.response.numFound);
+ },
+ error: function(e){
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+ redirect_to_login();
+ }
+ });
+ }
+ },
+ error: function(e){
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+ redirect_to_login();
+ }
+ });
+ if (datatype == "collectiondatasets"){
+ console.log(localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+dataset_query+"&wt=json&indent=true&rows=20000");
+ $.ajax({
+ url: localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+dataset_query+"&wt=json&indent=true&rows=20000",
+ beforeSend: function(xhr) {
+ if(Cookies.get('token') && Cookies.get('token') != "None"){
+ xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
+ }
+ },
+ type: 'GET',
+ dataType: 'json',
+ processData: false,
+ success: function (data) {
+ fill_datasets_data(data);
+ },
+ error: function(e){
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+ redirect_to_login();
+ }
+ });
+ }
+}
+
diff --git a/assets/js/labcas/datasets.js b/assets/js/labcas/datasets.js
new file mode 100644
index 00000000..154fcb84
--- /dev/null
+++ b/assets/js/labcas/datasets.js
@@ -0,0 +1,324 @@
+function fill_files_data(data){
+ var size = data.response.numFound;
+ var cpage = data.response.start;
+ load_pagination("files",size,cpage);
+ $("#files-table tbody").empty();
+ var download_list = JSON.parse(localStorage.getItem("download_list"));
+ var cart_list = JSON.parse(localStorage.getItem("cart_list"));
+ $.each(data.response.docs, function(key, value) {
+
+ var color = "btn-info";
+ if(user_data["FavoriteFiles"].includes(value.id)){
+ color = "btn-success";
+ }
+
+ var thumb = "";
+ var filetype = value.FileType ? value.FileType.join(",") : "";
+ var filename = value.FileName ? value.FileName : "";
+ var version = value.DatasetVersion ? value.DatasetVersion : "";
+ var fileloc = value.RealFileLocation ? value.RealFileLocation : "";
+ var site = value.Institution ? value.Institution.join(",") : "";
+ var parID = value.participantID ? value.participantID.join(",") : "";
+ var speID = value.specimen_id ? value.specimen_id.join(",") : "";
+ var description = value.Description? value.Description.join(",") : "";
+ if ('ThumbnailRelativePath' in value){
+ thumb = "";
+ }
+ var html_safe_id = encodeURI(escapeRegExp(value.id)).replace("&","%26");
+ var filesize = "";
+ var filesizenum = 0;
+ if (value.FileSize){
+ filesize = humanFileSize(value.FileSize, true);
+ filesizenum = value.FileSize;
+ }
+ var checked = "";
+ if ( (download_list && html_safe_id in download_list) || (cart_list && html_safe_id in cart_list)){
+ checked = "checked";
+ }
+ $("#files-table tbody").append(
+ ""+
+ " | "+
+ ""+
+ ""+
+ value.FileName+
+ ""+
+ " | "+
+ ""+
+ parID +
+ " | "+
+ ""+
+ speID +
+ " | "+
+ ""+
+ site +
+ " | "+
+ ""+
+ filetype +
+ " | "+
+ ""+
+ description +
+ " | "+
+ ""+
+ thumb+
+ " | "+
+ ""+
+ filesize+
+ " | "+
+ ""+
+ ""+
+ ""+
+ " | "+
+ "
");
+ });
+ $("#collection_files_len").html(size);
+ $("#collection_favorites_len").html(user_data['FavoriteFiles'].length+user_data['FavoriteDatasets'].length+user_data['FavoriteCollections'].length);
+ $('#loading_file').hide(500);
+ if (size > 0){
+ $("#children-files").show();
+ }
+ init_file_checkboxes("files-table");
+}
+
+function fill_datasets_children(data){
+ data.response.docs.sort(dataset_compare_sort);
+ var dataset_html = "";
+ var flag = "";
+ var dataset_count = 0;
+ $.each(data.response.docs, function(key, value) {
+ if (flag == ""){
+ flag = true;
+ return;
+ }
+ var color = "#0000FF";
+ if(user_data["FavoriteDatasets"].includes(value.id)){
+ color = "#87CB16 !important";
+ }
+ value.DatasetName = " ".repeat(value.id.split("/").length - 2)+"•"+value.DatasetName;
+
+ var html_safe_id = encodeURI(escapeRegExp(value.id));
+ var id_safe_id = html_safe_id.replace(/\//g,"-labsep-");
+ var image_div = "";
+ if (value.contains_image){
+ image_div = "";
+ }
+
+ dataset_html += ""+
+ "
"+
+ "
"+
+ "
"+
+ image_div+
+ ""+
+ "
"+
+ "
";
+ dataset_count += 1;
+ });
+ if ( dataset_html != ""){
+ $("#children-datasets").show();
+ $( "#dataset_stat_template" ).load("/labcas-ui/templates.html #dataset_stat_template");
+ console.log("OKOK1");
+ setTimeout(function() {
+ $("#collection_datasets_len").html(dataset_count);
+ }, 2000);
+ }else{
+ $( "#dataset_stat_template" ).load("/labcas-ui/templates.html?version=2.3.2 #dataset_name_template");
+ }
+ $("#children-datasets-section").append(dataset_html);
+}
+
+function populate_dataset_children(query){
+ query = query.replace(/id:/,'DatasetParentId')+"%5C%2A";
+ console.log(localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+query+"&wt=json&indent=true&rows=20000&sort=id%20asc");
+ $.ajax({
+ url: localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+query+"&wt=json&indent=true&rows=20000&sort=id%20asc",
+ xhrFields: {
+ withCredentials: true
+ },
+ beforeSend: function(xhr, settings) {
+ if(Cookies.get('token') && Cookies.get('token') != "None"){
+ xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
+ }
+ },
+ dataType: 'json',
+ success: function (data) {
+ fill_datasets_children(data);
+
+ },
+ error: function(e){
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+ redirect_to_login();
+
+ }
+ });
+ $('#loading_dataset').hide(500);
+}
+
+function fill_dataset_details_data(data){
+ var datasetname = data.response.docs[0].DatasetName;
+ $("#datasettitle").html(datasetname);
+ if (datasetname.length > 25){
+ datasetname = datasetname.slice(0,25);
+ }
+ console.log("WH1");
+ setTimeout(function() {
+ $("#collection_datasets_len").html(datasetname);
+ }, 2000);
+
+ var collectionid = data.response.docs[0].CollectionId;
+ var collectionname = data.response.docs[0].CollectionName;
+ $("#collection_name").html(""+collectionname+"");
+
+ var extended_headers = [];
+ if (localStorage.getItem('dataset_header_extend_'+collectionid)){
+ extended_headers = localStorage.getItem('dataset_header_extend_'+collectionid).split(',');
+ }
+ var show_headers = localStorage.getItem('dataset_header_order').split(',');
+ var collection_id_append = localStorage.getItem('dataset_id_append').split(',');
+
+ $.each(show_headers, function(ind, head) {
+ var value = data.response.docs[0][head];
+ if (typeof value === "undefined") {
+ value = "";
+ }
+ if (!value){
+ return;
+ }
+
+ if ($.isArray(value)){
+ value = value.join(",");
+ }
+ if (typeof value == "string"){
+ value = value.replace(/% /g,'_labcasPercent_');
+ value = decodeURIComponent(value);
+ value = value.replace(/\+/g," ").replace(/_labcasPercent_/g,'% ');
+ }
+ if (collection_id_append.includes(head)){
+ value += " ("+data.response.docs[0][head+"Id"]+")";
+ }
+ $("#datasetdetails-table tbody").append(
+ ""+
+ ""+head.replace( /([a-z])([A-Z])/g, "$1 $2" )+": | "+
+ ""+
+ value+
+ " | "+
+ "
");
+
+ });
+
+ $.each(data.response.docs[0], function(key, value) {
+ if (show_headers.includes(key) || !extended_headers.includes(key)){
+ return;
+ }
+ if (typeof value === "undefined") {
+ value = "";
+ }
+ if ($.isArray(value)){
+ value = value.join(",");
+ }
+ if (typeof value == "string"){
+ value = value.replace(/% /g,'_labcasPercent_');
+ try {
+ value = decodeURIComponent(value);
+ } catch(e) {
+ console.error(e);
+ }
+ value = value.replace(/\+/g," ").replace(/_labcasPercent_/g,'% ');
+ }
+
+ $("#datasetdetails-table tbody").append(
+ ""+
+ ""+key.replace( /([a-z:])([A-Z])/g, "$1 $2" )+": | "+
+ ""+
+ value+
+ " | "+
+ "
");
+
+ });
+}
+
+function setup_labcas_dataset_data(datatype, query, file_query, cpage){
+ if (cpage == 0){ //if this isn't a pagination request and a default load
+ console.log(localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+query+"&wt=json&indent=true");
+ $.ajax({
+ url: localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+query+"&wt=json&indent=true",
+ xhrFields: {
+ withCredentials: true
+ },
+ beforeSend: function(xhr, settings) {
+ if(Cookies.get('token') && Cookies.get('token') != "None"){
+ xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
+ }
+ },
+ dataType: 'json',
+ success: function (data) {
+ try{
+ fill_dataset_details_data(data);
+ populate_dataset_children(query);
+ } catch (ex) {
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+ redirect_to_login();
+ }
+
+ },
+ error: function(e){
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+ redirect_to_login();
+
+ }
+ });
+ }
+ //Set dataset size
+
+ console.log(localStorage.getItem('environment')+"/data-access-api/files/select?q="+file_query+"&wt=json&indent=true&sort=FileName%20asc&start="+cpage*10);
+ $.ajax({
+ url: localStorage.getItem('environment')+"/data-access-api/files/select?q="+file_query+"&wt=json&indent=true&sort=FileName%20asc&start="+cpage*10,
+ xhrFields: {
+ withCredentials: true
+ },
+ beforeSend: function(xhr, settings) {
+ if(Cookies.get('token') && Cookies.get('token') != "None"){
+ xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
+ }
+ },
+ dataType: 'json',
+ success: function (data) {
+ fill_files_data(data);
+ },
+ error: function(e){
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+ redirect_to_login();
+
+ }
+ });
+}
+
diff --git a/assets/js/labcas/hierarchy_filter_utils.js b/assets/js/labcas/hierarchy_filter_utils.js
index be04497b..60708ed3 100644
--- a/assets/js/labcas/hierarchy_filter_utils.js
+++ b/assets/js/labcas/hierarchy_filter_utils.js
@@ -29,10 +29,29 @@ function collection_hierarchy_fill(data){
});
console.log(hierarchy_list);
console.log("Done");
+
+ //Make sure hierarchy default is populated #-tagged #defaulthierarchy
+ if (localStorage.getItem("hierarchy_tags") != ""){
+ var valid_tags_check = false;
+ var hierarchy_tags = localStorage.getItem("hierarchy_tags").split(",");
+ var elt = $('#view_tags');
+ $.each(hierarchy_tags, function( key, val ) {
+ if (val in collection_facets.facet_counts.facet_fields){
+ elt.tagsinput('add', { "value": val});
+ valid_tags_check = true;
+ }
+ });
+ //if tag exist as a key in the files under this collection, show the hierarchy built by the hierarchy tag combination
+ if (valid_tags_check){
+ $('#datasets-table').hide();
+ $('#hierarchy_').show();
+ }
+ }
+
}
function collection_hierarchy_get(collection_id){
- var facets = "&facet.field=participantID&facet.field=SubmittingInvestigatorID&facet.field=contains_image&facet.field=DatasetName&facet.field=AssayType&facet.field=ContentType&facet.field=library_strategy";
+ var facets = "&facet.field=participantID&facet.field=SubmittingInvestigatorID&facet.field=contains_image&facet.field=dicom_StudyInstanceUID&facet.field=dicom_AccessionNumber&facet.field=dicom_PatientID&facet.field=dicom_StudyDate&facet.field=n&facet.field=dicom_Modality&facet.field=dicom_SeriesDescription&facet.field=dicom_StudyDescription&facet.field=dicom_SeriesInstanceUID&facet.field=DatasetName&facet.field=AssayType&facet.field=ContentType&facet.field=library_strategy";
url = localStorage.getItem('environment')+"/data-access-api/files/select?q=CollectionId:"+collection_id+"&facet=true&facet.limit=-1&facet.mincount=1"+facets+"&wt=json&rows=0";
query_labcas_api(url, collection_hierarchy_fill);
}
@@ -51,27 +70,24 @@ function get_hierarchy_selected(idx){
return -1;
}
}
-
+function toggle_child_elements(idx, show){
+ if (show == "true"){
+ $('div[id^="hierarchy_'+idx+'_"]').show();
+ $('#toggle_'+idx).html("");
+ }else{
+ $('div[id^="hierarchy_'+idx+'_"]').hide();
+ $('#toggle_'+idx).html("");
+ }
+}
function fill_hierarchy_data(data, collection_id, path, pathval, idx){
var collection_file_facets = data.facet_counts.facet_fields;
- console.log("recursion");
- console.log(data);
- console.log(path);
- console.log(idx);
collection_file_f = get_hierarchy_selected(idx);
- console.log(collection_file_facets);
- console.log("recursion_end");
if (collection_file_facets != -1){
- console.log("loop");
- console.log(collection_file_facets);
- console.log(collection_file_facets[collection_file_f]);
- console.log("loop_end");
idx += 1;
var prev = 1;
var prev_v = 0;
$.each(collection_file_facets[collection_file_f], function(k, v) {
- console.log("loop_sub_sub");
if (prev == 1){
prev_v = v;
prev = 0;
@@ -80,17 +96,22 @@ function fill_hierarchy_data(data, collection_id, path, pathval, idx){
if (v != 0 && $.trim(prev_v) != ''){
var pathval_child = pathval.slice();
var path_child = path.slice();
+ var pathval_parent = pathval.slice();
pathval_child.push(prev_v);
path_child.push(collection_file_f);
- console.log("Path2");
- console.log(path_child);
- console.log(pathval_child);
var mapped_path = replaceRegExp(pathval.join("_"), "_");
var mapped_path_child = replaceRegExp(pathval_child.join("_"), "_");
+ var mapped_path_parent = replaceRegExp(pathval_parent.join("_"), "_");
collection_facets_alias[mapped_path_child] = [path_child, pathval_child];
- console.log("Mapped");
- console.log(mapped_path_child);
- $('#hierarchy_'+mapped_path).append("
");
+ var visibility = "";
+ var checkbox = "";
+ if (idx > 1){
+ visibility = "style='display:none'";
+ checkbox = "";
+ }
+ $('#toggle_'+mapped_path_parent+'_').css("visibility", "visible");
+ $('#toggle_'+mapped_path_parent).css("visibility", "visible");
+ $('#hierarchy_'+mapped_path).append("");
collection_file_f_child = get_hierarchy_selected(idx);
if (collection_file_f_child == -1){
return;
@@ -107,8 +128,6 @@ function fill_hierarchy_data(data, collection_id, path, pathval, idx){
filter_field = "&"+filters.join("&");
}
url = localStorage.getItem('environment')+"/data-access-api/files/select?q=CollectionId:"+collection_id+filter_field+"&facet=true&facet.limit=-1&facet.mincount=1"+facets+"&wt=json&rows=0";
- console.log("url1");
- console.log(url);
$.ajax({
url: url,
beforeSend: function(xhr) {
@@ -120,7 +139,6 @@ function fill_hierarchy_data(data, collection_id, path, pathval, idx){
dataType: 'json',
processData: false,
success: function (filedata) {
- console.log(filedata);
fill_hierarchy_data(filedata, collection_id, path_child, pathval_child, idx);
},error: function(e){
if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
diff --git a/assets/js/labcas/search.js b/assets/js/labcas/search.js
index 264e8ddb..eec4406d 100755
--- a/assets/js/labcas/search.js
+++ b/assets/js/labcas/search.js
@@ -14,3 +14,546 @@ function search(){
console.log("Set search");
window.location.href = "/labcas-ui/s/index.html?search="+search_text.replace("&","%26");
}
+
+function fill_datasets_search(data){
+ var size = data.response.numFound;
+ var cpage = data.response.start;
+ load_pagination("datasets_search",size,cpage);
+ $("#search-dataset-table tbody").empty();
+
+ $.each(data.response.docs, function(key, obj) {
+ var color = "btn-info";
+ if(user_data["FavoriteDatasets"].includes(obj.id)){
+ color = "btn-success";
+ }
+ var html_safe_id = encodeURI(escapeRegExp(obj.id));
+ var id_safe_id = html_safe_id.replace(/\//g,"-labsep-");
+ var image_div = "";
+ if (obj.contains_image){
+ image_div = "";
+ }
+
+
+ $("#search-dataset-table tbody").append(
+ ""+
+ ""+
+ ""+
+ obj.DatasetName+" | "+
+ ""+
+ obj.CollectionName+" | "+
+ ""+
+ ""+
+ image_div+
+ ""+
+ " | "+
+ "
");
+ });
+
+ $("#collection_datasets_len").html(size);
+ $('#loading_dataset').hide(500);
+}
+
+function generate_categories(field_id, data){
+ $('#'+field_id).empty();
+ $("#filter_options").empty();
+ $.each(localStorage.getItem("filters").split(","), function(ind, head) {
+ if (localStorage.getItem("faceted_categories_selected") == head){
+ $('#'+field_id).append("");
+ }else{
+ $('#'+field_id).append("");
+ }
+ var ids = localStorage.getItem(head+"_filters_id").split(",");
+ var displays = localStorage.getItem(head+"_filters_display").split(",");
+ var divs = localStorage.getItem(head+"_filters_div").split(",");
+ $.each(ids, function(i, idhead) {
+ generate_filters(idhead,$.trim(divs[i]), data.facet_counts.facet_fields[idhead], $.trim(displays[i]), $.trim(head));
+ });
+ });
+}
+function fill_files_search(data){
+ var size = data.response.numFound;
+ var cpage = data.response.start;
+ load_pagination("files_search",size,cpage);
+ $("#search-file-table tbody").empty();
+ $.each(data.response.docs, function(key, obj) {
+ var color = "btn-info";
+ if(user_data["FavoriteFiles"].includes(obj.id)){
+ color = "btn-success";
+ }
+
+ var thumb = "";
+ var filetype = obj.FileType ? obj.FileType.join(",") : "";
+ var filename = obj.FileName ? obj.FileName : "";
+ var version = obj.DatasetVersion ? obj.DatasetVersion : "";
+ var fileloc = obj.RealFileLocation ? obj.RealFileLocation : "";
+
+ var site = obj.Institution ? obj.Institution.join(",") : "";
+ var description = obj.Description? obj.Description.join(",") : "";
+ if ('ThumbnailRelativePath' in obj){
+ thumb = "";
+ }
+ var filesize = "";
+ var filesizenum = 0;
+ if (obj.FileSize){
+ filesize = humanFileSize(obj.FileSize, true);
+ filesizenum += parseInt(obj.FileSize);
+ }
+ var html_safe_id = encodeURI(escapeRegExp(obj.id)).replace("&","%26");
+ var checked = "";
+ var download_list = JSON.parse(localStorage.getItem("download_list"));
+ var cart_list = JSON.parse(localStorage.getItem("cart_list"));
+ if ( (download_list && html_safe_id in download_list) || (cart_list && html_safe_id in cart_list)){
+ checked = "checked";
+ }
+
+ $("#search-file-table tbody").append(
+ ""+
+ " | "+
+ ""+
+ ""+
+ obj.FileName+
+ ""+
+ " | "+
+ ""+
+ filetype +
+ " | "+
+ ""+
+ site +
+ " | "+
+ ""+
+ description +
+ " | "+
+ ""+
+ thumb+
+ " | "+
+ ""+
+ filesize+
+ " | "+
+ ""+
+ ""+
+ " | "+
+ "
");
+ });
+ $("#collection_files_len").html(size);
+ $('#loading_file').hide(500);
+ //Init shopping cart
+ init_file_checkboxes("search-file-table");
+}
+function generate_filters(field_type, placeholder, data, display, head){
+ var filters = [];
+ var counts = [];
+
+ $("#filter_options").append(
+ ''+
+ ''+
+ ''+
+ '
'
+ );
+
+ $("#"+placeholder).html("");
+
+ if (placeholder.includes("_num_")){
+ var min = 100000000;
+ var max = -1;
+ var left = 0;
+ var right = 100;
+ var sum = 0;
+ var addflag = false;
+ $.each(data, function(key, obj) {
+ if (Number.isInteger(obj)){
+ if(addflag){
+ sum += obj;
+ }
+ }else{
+ if(!isNaN(obj)){
+ if(min > +obj){
+ min = +obj;
+ }
+ if (max < +obj){
+ max = +obj;
+ }
+ if(((localStorage.getItem(placeholder+"_0") && localStorage.getItem(placeholder+"_0") <= +obj) || (!localStorage.getItem(placeholder+"_0")))
+ && (localStorage.getItem(placeholder+"_1") && localStorage.getItem(placeholder+"_1") >= +obj) || (!localStorage.getItem(placeholder+"_1"))){
+ addflag = true;
+ }else{
+ addflag = false;
+ }
+ }
+ }
+ });
+ if (min != 100000000 && max != -1){
+ if (localStorage.getItem(placeholder+"_max_0")){
+ min = localStorage.getItem(placeholder+"_max_0");
+ }else{
+ localStorage.setItem(placeholder+"_max_0", Math.floor(min));
+ left = min;
+ }
+ if (localStorage.getItem(placeholder+"_max_1")){
+ max = localStorage.getItem(placeholder+"_max_1");
+ }else{
+ localStorage.setItem(placeholder+"_max_1", Math.floor(max));
+ right = max;
+ }
+ if (localStorage.getItem(placeholder+"_0")){
+ left = localStorage.getItem(placeholder+"_0");
+ }else{
+ localStorage.setItem(placeholder+"_0", Math.floor(min));
+ left = min;
+ }
+ if (localStorage.getItem(placeholder+"_1")){
+ right = localStorage.getItem(placeholder+"_1");
+ }else{
+ localStorage.setItem(placeholder+"_1", Math.floor(max));
+ right = max;
+ }
+ $("#"+placeholder).append($(''));
+
+ var slider = document.getElementById(placeholder+'_slider');
+
+ var slider_left = document.getElementById(placeholder+'_0');
+ var slider_right = document.getElementById(placeholder+'_1');
+ noUiSlider.create(slider, {
+ start: [left, right],
+ connect: true,
+ range: {
+ min: +min,
+ max: +max
+ },
+ step: 1
+ });
+ document.getElementById(placeholder+'_count').innerHTML = "("+sum+")";
+ slider.noUiSlider.on('update', function (values, handle) {
+ if (handle == 0){
+ slider_left.innerHTML = Math.floor(values[handle]);
+ }else if(handle == 1){
+ slider_right.innerHTML = Math.floor(values[handle]);
+ }
+ });
+ slider.noUiSlider.on('end', function (values, handle) {
+ if (handle == 0){
+ localStorage.setItem(placeholder+"_0", Math.floor(values[handle]));
+ }else if(handle == 1){
+ localStorage.setItem(placeholder+"_1", Math.floor(values[handle]));
+ }
+
+ var str_field_val = encodeURI("["+localStorage.getItem(placeholder+"_0")+" TO "+localStorage.getItem(placeholder+"_1")+"]");
+ var field_search = "&fq="+encodeURI(escapeRegExp(field_type)).replace(/:/g,'%3A')+":"+str_field_val;
+ if (localStorage.getItem(placeholder+"_0") == localStorage.getItem(placeholder+"_max_0") && localStorage.getItem(placeholder+"_1") == localStorage.getItem(placeholder+"_max_1")){
+ field_search = "";
+ }
+ localStorage.setItem(placeholder, field_search);
+ localStorage.setItem("search_filter", "on");
+ setup_labcas_search(localStorage.getItem('search').replace("&","%26"), "all", 0);
+ });
+ $('#'+placeholder+'_card').css("height","100px");
+ }
+
+ }else{
+ $.each(data, function(key, obj) {
+ if (Number.isInteger(obj)){
+ counts.push(obj);
+ }else{
+ filters.push(obj);
+ }
+ });
+ var filter_count = 0;
+ $.each(filters, function(i, o){
+ if (localStorage.getItem(placeholder+"_val") && localStorage.getItem(placeholder+"_val") != ""){
+ }
+ if (counts[i] > 0){
+ var checked = "";
+ if (localStorage.getItem(placeholder+"_val") && localStorage.getItem(placeholder+"_val").includes($.trim(o))){
+ checked = "checked";
+ }
+ $("#"+placeholder).append($(' '));
+ filter_count += 1;
+ }
+ });
+ var filter_height = filter_count*50;
+ if (filter_height > 100){
+ filter_height = 100;
+ }
+ $('#'+placeholder+'_card').css("height",filter_height.toString()+"px");
+
+ $('input[name="'+placeholder+'[]"]').change(function() {
+ var field_val = [];
+ $("input[name='"+placeholder+"[]']").each(function (index, obj) {
+ if(this.checked) {
+ field_val.push(this.value);
+ }
+ });
+ var field_search = "";
+ if (field_val.length > 0){
+ var str_field_val = field_val.map(x => encodeURI(escapeRegExp(String(x))));
+
+ field_search = "&fq=("+encodeURI(escapeRegExp(field_type)).replace(/:/g,'%3A')+":"+str_field_val.join(" OR "+encodeURI(escapeRegExp(field_type))+":")+")";
+ }
+ localStorage.setItem(placeholder, field_search);
+ localStorage.setItem(placeholder+"_val",field_val);
+ localStorage.setItem("search_filter", "on");
+ setup_labcas_search(localStorage.getItem('search').replace("&","%26"), "all", 0);
+ });
+ }
+}
+
+
+//Recursive function to loop through collection, dataset, file hierachy to get filters
+function add_labcas_api_facets(querytypes, query, filters, facets, newdata, callback){
+ if (querytypes.length < 1){
+ callback(newdata);
+ }else{
+ var querytype = querytypes.pop();
+ $.ajax({
+ url: localStorage.getItem('environment')+"/data-access-api/"+querytype+"/select?q="+query+""+filters+"&facet=true&facet.limit=-1&facet.field="+facets.join("&facet.field=")+"&wt=json",
+ beforeSend: function(xhr) {
+ if(Cookies.get('token') && Cookies.get('token') != "None"){
+ xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
+ }
+ },
+ type: 'GET',
+ dataType: 'json',
+ success: function (data) {
+ //join existing data with newdata
+ if (newdata.facet_counts){
+ console.log(localStorage.getItem('environment')+"/data-access-api/"+querytype+"/select?q="+query+""+filters+"&facet=true&facet.limit=-1&facet.field="+facets.join("&facet.field=")+"&wt=json");
+ console.log(newdata.facet_counts);
+ console.log(newdata.facet_counts.facet_fields.length);
+ }
+ if (newdata && newdata.facet_counts && newdata.facet_counts.facet_fields && Object.keys(newdata.facet_counts.facet_fields).length > 0){
+ console.log("pass1");
+ if (data && data.facet_counts && data.facet_counts.facet_fields && Object.keys(data.facet_counts.facet_fields).length > 0){
+ console.log("pass2");
+ $.each(data.facet_counts.facet_fields, function(i, facet_vals) {
+ if (facet_vals && facet_vals.length > 0){
+ if (newdata.facet_counts.facet_fields[i]){
+ newdata.facet_counts.facet_fields[i] = facet_vals.concat(newdata.facet_counts.facet_fields[i].filter((item) => facet_vals.indexOf(item) < 0));
+ }
+ }
+ });
+ }
+ }else{
+ console.log("didn't pass");
+ newdata = data;
+ }
+ console.log(newdata);
+ add_labcas_api_facets(querytypes, query, filters, facets, newdata, callback);
+ },
+ error: function (xhr, ajaxOptions, thrownError) {
+ console.log(xhr.responseText);
+ console.log(xhr.status);
+ console.log(thrownError);
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+ redirect_to_login();
+ }
+ });
+ }
+}
+
+function fill_collections_search(data){
+ var size = data.response.numFound;
+ var cpage = data.response.start;
+ load_pagination("collections_search",size,cpage);
+ $("#search-collection-table tbody").empty();
+ $.each(data.response.docs, function(key, obj) {
+ var color = "btn-info";
+ if(user_data["FavoriteCollections"].includes(obj.id)){
+ color = "btn-success";
+ }
+ $("#search-collection-table tbody").append(
+ ""+
+ ""+
+ ""+
+ obj.CollectionName+" | "+
+ ""+obj.Organ+" | "+
+ ""+obj.Discipline+" | "+
+ ""+obj.Institution+" | "+
+ ""+obj.LeadPI+" | "+
+ ""+
+ ""+
+ " | "+
+ "
");
+ });
+ $("#collection_name").html(size);
+ $('#loading_collection').hide(500);
+}
+function fill_collections_facets(data){
+ console.log(data);
+
+ if (localStorage.getItem("search_filter") == "on" || (localStorage.getItem("search") && localStorage.getItem("search") != "*")){
+ $('#filter_reset').show();
+ }else{
+ $('#filter_reset').hide();
+ }
+ generate_categories("faceted_categories", data);
+ $("#faceted_categories").change(function(){
+ $.each(localStorage.getItem("filters").split(","), function(ind, head) {
+ $("."+head+"_card").hide();
+ });
+ $(".Core_card").show();
+ $(this).find("option:selected").each(function(){
+ var optionValue = $(this).attr("value");
+ localStorage.setItem("faceted_categories_selected", optionValue);
+ $("."+optionValue+"_card").show();
+ });
+ reset_search_filters();
+ setup_labcas_search("*", "all", 0);
+ });
+ $.each(localStorage.getItem("filters").split(","), function(ind, head) {
+ $("."+head+"_card").hide();
+ });
+ $(".Core_card").show();
+ $("."+localStorage.getItem("faceted_categories_selected")+"_card").show();
+}
+
+
+function setup_labcas_search(query, divid, cpage){
+ console.log("Searching...");
+ if (query != "*"){
+ query = '"'+query+'"';
+ }
+ var collection_filters = "";
+ var collection_facets = [];
+ $.each(localStorage.getItem("filters").split(","), function(ind, head) {
+ var divs = localStorage.getItem(head+"_filters_div").split(",");
+ $.each(divs, function(i, divhead) {
+ collection_filters += localStorage.getItem($.trim(divhead));
+ });
+ collection_facets = collection_facets.concat(localStorage.getItem(head+"_filters_id").split(","));
+ });
+ var data_filters = "";
+ if (divid == "collections_search" || divid == "all"){
+ console.log(localStorage.getItem('environment')+"/data-access-api/collections/select?q="+query+""+collection_filters+"&wt=json&indent=true&start="+cpage*10);
+ $.ajax({
+ url: localStorage.getItem('environment')+"/data-access-api/collections/select?q="+query+""+collection_filters+"&wt=json&indent=true&sort=id%20asc&start="+cpage*10,
+ beforeSend: function(xhr) {
+ if(Cookies.get('token') && Cookies.get('token') != "None"){
+ xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
+ }
+ },
+ type: 'GET',
+ dataType: 'json',
+ success: function (data) {
+ fill_collections_search(data);
+ },
+ error: function(e){
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+ redirect_to_login();
+ }
+ });
+ var querytypes = ["collections","datasets","files"];
+ add_labcas_api_facets(querytypes, query, collection_filters, collection_facets, {}, fill_collections_facets);
+ if (divid == "datasets_search" || divid == "all"){
+ wait(1000);
+ console.log(localStorage.getItem('environment')+"/data-access-api/datasets/select?q=*:*"+collection_filters+"&facet=true&facet.limit=-1&facet.field="+collection_facets.join("&facet.field=")+"&wt=json&rows=0&sort=DatasetName%20asc");
+ $.ajax({
+ url: localStorage.getItem('environment')+"/data-access-api/datasets/select?q="+query+""+collection_filters+"&wt=json&sort=DatasetName%20asc&indent=true&start="+cpage*10,
+ beforeSend: function(xhr) {
+ if(Cookies.get('token') && Cookies.get('token') != "None"){
+ xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
+ }
+ },
+ type: 'GET',
+ dataType: 'json',
+ processData: false,
+ success: function (data) {
+ fill_datasets_search(data);
+ },
+ error: function(e){
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+ redirect_to_login();
+ }
+ });
+ }
+ if (divid == "files_search" || divid == "all"){
+ console.log("Files search");
+ console.log(localStorage.getItem('environment')+"/data-access-api/files/select?q="+query+""+collection_filters+"&wt=json&indent=true&sort=FileName%20asc&start="+cpage*10);
+ wait(1000);
+ $.ajax({
+ url: localStorage.getItem('environment')+"/data-access-api/files/select?q="+query+""+collection_filters+"&wt=json&indent=true&sort=FileName%20asc&start="+cpage*10,
+ xhrFields: {
+ withCredentials: true
+ },
+ beforeSend: function(xhr, settings) {
+ if(Cookies.get('token') && Cookies.get('token') != "None"){
+ xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
+ }
+ },
+ dataType: 'json',
+ success: function (data) {
+ fill_files_search(data);
+ setup_labcas_analytics(query, collection_filters);
+ },
+ error: function(e){
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+ redirect_to_login();
+
+ }
+ });
+
+ }
+}
+}
+
+function initiate_search(){
+ var get_var = get_url_vars();
+ console.log(localStorage.getItem("search"));
+ if(localStorage.getItem("search") && get_var["search"]){
+ localStorage.setItem("search", get_var["search"].replace("&","%26"));
+ console.log("Search not clearned");
+ }else{
+ localStorage.setItem("search", "*");
+ console.log("Search cleared");
+ }
+ $.each(localStorage.getItem("filters").split(","), function(ind, head) {
+ var divs = localStorage.getItem(head+"_filters_div").split(",");
+ $.each(divs, function(i, divhead) {
+ if (!localStorage.getItem($.trim(divhead))){
+ localStorage.setItem($.trim(divhead), "");
+ }
+ if(divhead.includes("_num_")){
+ if (!localStorage.getItem($.trim(divhead)+"_0")){
+ localStorage.setItem($.trim(divhead)+"_0","");
+ localStorage.setItem($.trim(divhead)+"_1","");
+ localStorage.setItem($.trim(divhead)+"_max_0","");
+ localStorage.setItem($.trim(divhead)+"_max_1","");
+ }
+ }else{
+ if (!localStorage.getItem($.trim(divhead)+"_val")){
+ localStorage.setItem($.trim(divhead)+"_val", "");
+ }
+ }
+ });
+ });
+
+ setup_labcas_search(localStorage.getItem("search"), "all", 0);
+ $("#collection_favorites_len").html(user_data['FavoriteFiles'].length+user_data['FavoriteDatasets'].length+user_data['FavoriteCollections'].length);
+}
+
diff --git a/assets/js/labcas/starred.js b/assets/js/labcas/starred.js
new file mode 100644
index 00000000..eed2ee8b
--- /dev/null
+++ b/assets/js/labcas/starred.js
@@ -0,0 +1,211 @@
+function fill_files_starred(data){
+ var size = data.response.numFound;
+ var cpage = data.response.start;
+ $("#starred-file-table tbody").empty();
+ $.each(data.response.docs, function(key, obj) {
+ var color = "btn-success";
+
+ var filetype = obj.FileType ? obj.FileType.join(",") : "";
+ var description = obj.Description? obj.Description.join(",") : "";
+ var thumb = "";
+ if ('ThumbnailRelativePath' in obj){
+ thumb = "";
+ }
+ var filesize = "";
+ if (obj.FileSize){
+ filesize = humanFileSize(obj.FileSize, true);
+ }
+ $("#starred-file-table tbody").append(
+ ""+
+ " | "+
+ ""+
+ ""+
+ obj.FileName+
+ ""+
+ " | "+
+ ""+
+ filetype +
+ " | "+
+ ""+
+ description +
+ " | "+
+ ""+
+ thumb+
+ " | "+
+ ""+
+ filesize+
+ " | "+
+ ""+
+ ""+
+ " | "+
+ "
");
+ });
+ $("#files_len").html(size);
+}
+
+function fill_collections_starred(data){
+ var size = data.response.numFound;
+ var cpage = data.response.start;
+ $("#starred-collection-table tbody").empty();
+
+ $.each(data.response.docs, function(key, obj) {
+ if(user_data["FavoriteCollections"].includes(obj.id)){
+ var color = "btn-success";
+
+ $("#starred-collection-table tbody").append(
+ ""+
+ " | "+
+ ""+
+ obj.CollectionName+" | "+
+ ""+obj.Organ+" | "+
+ ""+obj.Discipline+" | "+
+ ""+obj.Institution+" | "+
+ ""+obj.LeadPI+" | "+
+ ""+
+ ""+
+ " | "+
+ "
");
+ }
+ });
+ $("#collections_len").html(size);
+ $('#loading').hide(500);
+
+}
+
+function fill_datasets_starred(data){
+ var size = data.response.numFound;
+ var cpage = data.response.start;
+ $("#starred-dataset-table tbody").empty();
+ $.each(data.response.docs, function(key, obj) {
+ if(user_data["FavoriteDatasets"].includes(obj.id)){
+ var color = "btn-success";
+
+
+ $("#starred-dataset-table tbody").append(
+ ""+
+ " | "+
+ ""+
+ obj.DatasetName+" | "+
+ ""+
+ obj.CollectionName+" | "+
+ ""+
+ ""+
+ " | "+
+ "
");
+ }
+ });
+ $("#datasets_len").html(size);
+}
+function setup_labcas_starred(query, divid, cpage){
+ var collection_starred_search = "";
+ if (user_data["FavoriteCollections"].length > 0){
+ collection_starred_search = "&fq=(id:"+user_data["FavoriteCollections"].map(x => encodeURI(escapeRegExp(String(x)))).join(" OR id:")+")";
+ }
+ var dataset_starred_search = "";
+ if (user_data["FavoriteDatasets"].length > 0){
+ dataset_starred_search = "&fq=(id:"+user_data["FavoriteDatasets"].map(x => encodeURI(escapeRegExp(String(x)))).join(" OR id:")+")";
+ }
+ var file_starred_search = "";
+ if (user_data["FavoriteFiles"].length > 0){
+ var tmp_files_search = user_data["FavoriteFiles"].map(x => encodeURI(escapeRegExp(String(x)))).join(" OR id:").replace(/ *\([^)]*\) */g, "*");
+ file_starred_search = "&fq=(id:"+tmp_files_search+")";
+ }
+ if (divid == "collections_starred" || divid == "all"){
+ console.log(localStorage.getItem('environment')+"/data-access-api/collections/select?q=*"+collection_starred_search+"&wt=json&indent=true&start="+cpage*10);
+ $.ajax({
+ url: localStorage.getItem('environment')+"/data-access-api/collections/select?q=*"+collection_starred_search+"&wt=json&indent=true&sort=id%20asc&start="+cpage*10,
+ beforeSend: function(xhr) {
+ if(Cookies.get('token') && Cookies.get('token') != "None"){
+ xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
+ }
+ },
+ type: 'GET',
+ dataType: 'json',
+ success: function (data) {
+ fill_collections_starred(data);
+ },
+ error: function(e){
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+ redirect_to_login();
+ }
+ });
+ }
+ if (divid == "datasets_starred" || divid == "all"){
+ $.ajax({
+ url: localStorage.getItem('environment')+"/data-access-api/datasets/select?q=*"+dataset_starred_search+"&wt=json&indent=true&start="+cpage*10,
+ beforeSend: function(xhr) {
+ if(Cookies.get('token') && Cookies.get('token') != "None"){
+ xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
+ }
+ },
+ type: 'GET',
+ dataType: 'json',
+ processData: false,
+ success: function (data) {
+ fill_datasets_starred(data);
+ },
+ error: function(e){
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+ }
+ });
+ }
+ if (divid == "files_starred" || divid == "all"){
+ console.log(localStorage.getItem('environment')+"/data-access-api/files/select?q=*"+file_starred_search+"&wt=json&indent=true&sort=FileName%20asc&start="+cpage*10);
+
+ $.ajax({
+ url: localStorage.getItem('environment')+"/data-access-api/files/select?q=*"+file_starred_search+"&wt=json&sort=FileName%20asc&indent=true&start="+cpage*10,
+ xhrFields: {
+ withCredentials: true
+ },
+ beforeSend: function(xhr, settings) {
+ if(Cookies.get('token') && Cookies.get('token') != "None"){
+ xhr.setRequestHeader("Authorization", "Bearer " + Cookies.get('token'));
+ }
+ },
+ dataType: 'json',
+ success: function (data) {
+ fill_files_starred(data);
+ },
+ error: function(e){
+ if (!(localStorage.getItem("logout_alert") && localStorage.getItem("logout_alert") == "On")){
+ localStorage.setItem("logout_alert","On");
+ alert("You are currently logged out. Redirecting you to log in.");
+ }
+
+ }
+ });
+ }
+ $("#favorites_len").html(user_data['FavoriteFiles'].length+user_data['FavoriteDatasets'].length+user_data['FavoriteCollections'].length);
+}
+
diff --git a/assets/js/labcas/utils.js b/assets/js/labcas/utils.js
index cb5fa178..55881f58 100755
--- a/assets/js/labcas/utils.js
+++ b/assets/js/labcas/utils.js
@@ -29,7 +29,9 @@ $().ready(function() {
//initiate clinical-ui-link
setTimeout(function(){
if (!(location.href.includes("/labcas-ui/index.html") || location.href.endsWith("/labcas-ui/") || location.href.endsWith("/labcas-ui") || location.href.includes("/labcas-ui/o/index.html"))){
- console.log("2");
+ if(!localStorage.getItem('environment')){
+ localStorage.setItem("environment","https://"+location.hostname.split(/\//)[0]);
+ }
query_labcas_api(localStorage.getItem('environment')+"/data-access-api/collections/select?q=*&facet=true&facet.limit=-1&wt=json&rows=0",get_labcas_collection_stats);
query_labcas_api(localStorage.getItem('environment')+"/data-access-api/datasets/select?q=*&facet=true&facet.limit=-1&wt=json&rows=0",get_labcas_dataset_stats);
query_labcas_api(localStorage.getItem('environment')+"/data-access-api/files/select?q=*&facet=true&facet.limit=-1&wt=json&rows=0",get_labcas_file_stats);
@@ -445,11 +447,10 @@ function paginate(divid, cpage){
}
}
function escapeRegExp(string) {
- console.log("replace!");
return string.replace(/[\*\?\^\$\{\}\(\)\|\[\]\\~&!":]/g, '\\$&'); // $& means the whole matched string
}
function replaceRegExp(string, replace) {
- return string.replace(/[\*\?\^\$\{\}\(\)\|\[\]\\~&! ":]/g, replace); // $& means the whole matched string
+ return string.replace(/[\*\?\^\$\{\}\(\)\|\[\]\\~&!;\.\/ ":]/g, replace); // $& means the whole matched string
}
function formatTimeOfDay(millisSinceEpoch) {
@@ -938,7 +939,7 @@ function introWizard(check_first_time){
}
function accepted_image_check(f){
- var img_ext = [".svs",".jpg",".gif",".jpeg",".dcm",".dicom",".png",".tif",".tiff",".scm",".scn",".qptiff"];
+ var img_ext = [".svs",".jpg",".gif",".jpeg",".dcm",".DCM",".dicom",".png",".tif",".tiff",".scm",".scn",".qptiff"];
var pass_flag = false;
$.each(img_ext, function(key,value){
if (f.toLowerCase().endsWith(value)){
@@ -961,7 +962,7 @@ function acepted_omero_check(f){
}
function generate_accepted_image_solr_filters(){
- var img_ext = [".svs",".jpg",".gif",".jpeg",".dcm",".dicom",".png",".tif",".tiff",".scm",".scn",".qptiff"];
+ var img_ext = [".svs",".jpg",".gif",".jpeg",".dcm",".DCM",".dicom",".png",".tif",".tiff",".scm",".scn",".qptiff"];
var fq = "(id:*"+img_ext.join("%20AND%20id:*")+")";
return fq;
}
@@ -1003,11 +1004,14 @@ function generate_image_file_list(data){
var image_type = "image";
console.log(data);
$.each(data.response.docs, function(key, value) {
+ console.log("Here");
console.log(key);
console.log(value.id);
- if ( accepted_image_check(value.id) ){
+ if ( accepted_image_check(value.id) || accepted_image_check(value.FileName)){
var html_safe_id = encodeURI(escapeRegExp(value.id));
- if (value.id.toLowerCase().endsWith(".dcm") || value.id.toLowerCase().endsWith(".dicom")){
+ if (value.id.toLowerCase().endsWith(".dcm") || value.id.toLowerCase().endsWith(".dicom") || value.id.toLowerCase().endsWith(".DCM")
+ || value.FileName.toLowerCase().endsWith(".dcm") || value.FileName.toLowerCase().endsWith(".dicom") || value.FileName.toLowerCase().endsWith(".DCM")
+ ){
image_type = "dicoms";
}else if(acepted_omero_check(value.id)){
image_type = "omeros";
@@ -1060,16 +1064,22 @@ function checkDatasetContainsDicom(dataset_id, safe_dataset_id, data){
function submitImage(formname, dataset){
if ( $('#check_all:checked').length || dataset){
- console.log("GOT HERE");
- console.log(dataset);
+ console.log("GOT HERE");
+ console.log(dataset);
var get_var = get_url_vars();
if (dataset){
- dataset = dataset.replace("%5C%20","%20").replace("%20","%5C%20").replace(" ","%5C%20");
- console.log(localStorage.getItem('environment')+"/data-access-api/files/select?q=DatasetId:"+dataset+"&wt=json&indent=true&rows=10000");
- query_labcas_api(localStorage.getItem('environment')+"/data-access-api/files/select?q=DatasetId:"+dataset+"&wt=json&indent=true&rows=10000", generate_image_file_list);
+ url = "";
+ if (dataset == "hierarchy_query" && localStorage.getItem("hierarchy_file_query")){
+ var file_query = localStorage.getItem("hierarchy_file_query");
+ url = localStorage.getItem('environment')+"/data-access-api/files/select?q=*"+file_query+"&wt=json&indent=true&rows=2147483647";
+ }else{
+ dataset = dataset.replace("%5C%20","%20").replace("%20","%5C%20").replace(" ","%5C%20");
+ url = localStorage.getItem('environment')+"/data-access-api/files/select?q=DatasetId:"+dataset+"&wt=json&indent=true&rows=10000";
+ }
+ console.log(url);
+ query_labcas_api(url, generate_image_file_list);
}
- //submitDicom('files-table','all',dataset_id)
return;
}else{
submitImageData(formname);
@@ -1083,10 +1093,10 @@ function submitSingleImageData(image, loc, name, version){
var image_type = "image";
image_list.push(localStorage.getItem('environment')+"/data-access-api/download?id="+image);
histomics_list.push([loc,name,version, image]);
- if (image.endsWith(".dcm") || image.endsWith(".dicom")){
+ if (name.endsWith(".dcm") || name.endsWith(".dicom") || name.endsWith(".DCM")){
image_type = "dicoms";
}
- else if (acepted_omero_check(image)){
+ else if (acepted_omero_check(name)){
image_type = "omeros";
}else{
localStorage.setItem("image_data",JSON.stringify(histomics_list));
@@ -1147,19 +1157,26 @@ function submitImageData(formname, dicom){
}else{}
//custom code for qptiff
+ //
+
+ console.log("Got HERE1");
if (dicom){
+ console.log("Got HERE2");
dicoms_list.push(localStorage.getItem('environment')+"/data-access-api/download?id="+$(dicom).val());
- if ($(dicom).val().endsWith(".dcm") || $(dicom).val().endsWith(".dicom")){
+ if ($(dicom).val().endsWith(".dcm") || $(dicom).val().endsWith(".dicom") || $(dicom).val().endsWith(".DCM")){
image_type = "dicoms";
}
}else{
+ console.log("Got HERE3");
if (formname.startsWith("cart_")){
if (localStorage.getItem('cart_list')){
+ console.log("HERE2");
download_list = JSON.parse(localStorage.getItem('cart_list'));
$.each(download_list, function( key, val ) {
+ //check_image_filtered_dataset should be key, not val[1] since key is the full labcasId and contains dataset name within, while val[1] is just the filename itself.
if (check_image_filtered_dataset(key)){
- if (accepted_image_check(key) && (key.endsWith(".dcm") || key.endsWith(".dicom"))){
+ if (accepted_image_check(val[1]) && (val[1].endsWith(".dcm") || val[1].endsWith(".dicom") || val[1].endsWith(".DCM"))){
dicoms_list.push(localStorage.getItem('environment')+"/data-access-api/download?id="+key);
}else if(acepted_omero_check(key)){
omero_list.push([val[0],val[1],val[2], key]);
@@ -1171,11 +1188,17 @@ function submitImageData(formname, dicom){
});
}
}else{
+ console.log("Got HERE4.0");
$('#' + formname + ' input[type="checkbox"]').each(function() {
- if ($(this).is(":checked") && accepted_image_check($(this).val())) {
-
- if ($(this).val().endsWith(".dcm") || $(this).val().endsWith(".dicom")){
+ console.log("Got HERE4.1");
+ console.log(formname);
+ if ($(this).is(":checked") && accepted_image_check($(this).data("name"))) {
+ console.log($(this).val());
+ console.log($(this).data("name"));
+ if ($(this).val().endsWith(".dcm") || $(this).val().endsWith(".dicom") || $(this).val().endsWith(".DCM") ||
+ $(this).data("name").endsWith(".dcm") || $(this).data("name").endsWith(".dicom") || $(this).data("name").endsWith(".DCM")
+ ){
image_type = "dicoms";
dicoms_list.push(localStorage.getItem('environment')+"/data-access-api/download?id="+$(this).val());
}else if(acepted_omero_check($(this).val())){
@@ -1192,6 +1215,7 @@ function submitImageData(formname, dicom){
}
}
+ console.log("Got HERE5");
localStorage.setItem("image",JSON.stringify(image_list));
localStorage.setItem("dicoms",JSON.stringify(dicoms_list));
localStorage.setItem("image_data",JSON.stringify(histomics_list));
@@ -1512,7 +1536,7 @@ function set_cart_status (){
console.log(check_image_filtered_dataset(key));
if (check_image_filtered_dataset(key)){
console.log("IN");
- if (val[1] && accepted_image_check(val[1]) && (val[1].endsWith(".dicom") || val[1].endsWith(".dcm"))){
+ if (val[1] && accepted_image_check(val[1]) && (val[1].endsWith(".dicom") || val[1].endsWith(".dcm") || val[1].endsWith(".DCM"))){
dicomsize += 1;
}else if(val[1] && acepted_omero_check(val[1])){
omerosize += 1;
diff --git a/assets/sass/state.json b/assets/sass/state.json
new file mode 100644
index 00000000..f03909de
--- /dev/null
+++ b/assets/sass/state.json
@@ -0,0 +1 @@
+{"version":"0.3","window-center":307,"window-width":650,"position":{"i":0,"j":0,"k":1},"scale":1,"scaleCenter":{"x":0,"y":0},"translation":{"x":0,"y":0},"drawings":{"attrs":{"listening":true,"visible":true},"className":"Layer","children":[{"attrs":{"name":"position-group","id":"slice-1_frame-0","visible":true},"className":"Group","children":[{"attrs":{"name":"ruler-group","visible":true,"id":"684thmq504b","draggable":true},"className":"Group","children":[{"attrs":{"points":[61,185,67,242],"stroke":"#ffff80","strokeWidth":0.8034433285509326,"name":"shape"},"className":"Line"},{"attrs":{"points":[59.00242807160693,185.21027072930454,62.99757192839307,184.7897292706955],"stroke":"#ffff80","strokeWidth":0.20086083213773315,"name":"shape-tick0"},"className":"Line"},{"attrs":{"points":[65.00242807160693,242.21027072930454,68.99757192839307,241.78972927069546],"stroke":"#ffff80","strokeWidth":0.20086083213773315,"name":"shape-tick1"},"className":"Line"},{"attrs":{"x":42,"y":249.5,"name":"label"},"className":"Label","children":[{"attrs":{"fontSize":4.820659971305595,"fontFamily":"Verdana","fill":"#ffff80","name":"text","text":"52.10 mm"},"className":"Text"},{"attrs":{"width":25.081329345703125,"height":4.820659971305595},"className":"Tag"}]}]},{"attrs":{"name":"ruler-group","visible":true,"id":"axdp22ex6ui","draggable":true},"className":"Group","children":[{"attrs":{"points":[173,158,177,205],"stroke":"#ffff80","strokeWidth":0.8034433285509326,"name":"shape"},"className":"Line"},{"attrs":{"points":[170.99862667132228,158.17032964499384,175.00137332867772,157.82967035500613],"stroke":"#ffff80","strokeWidth":0.20086083213773315,"name":"shape-tick0"},"className":"Line"},{"attrs":{"points":[174.99862667132228,205.17032964499387,179.00137332867772,204.82967035500616],"stroke":"#ffff80","strokeWidth":0.20086083213773315,"name":"shape-tick1"},"className":"Line"},{"attrs":{"x":152,"y":212.5,"name":"label"},"className":"Label","children":[{"attrs":{"fontSize":4.820659971305595,"fontFamily":"Verdana","fill":"#ffff80","name":"text","text":"42.88 mm"},"className":"Text"},{"attrs":{"width":25.081329345703125,"height":4.820659971305595},"className":"Tag"}]}]}]}]},"drawingsDetails":{"684thmq504b":{"textExpr":"{length}","longText":"","quant":{"length":{"value":52.10499333893058,"unit":"mm"}}},"axdp22ex6ui":{"textExpr":"{length}","longText":"","quant":{"length":{"value":42.88216123576329,"unit":"mm"}}}}}
\ No newline at end of file
diff --git a/c/index.html b/c/index.html
index 1bf6c4ed..95a66936 100755
--- a/c/index.html
+++ b/c/index.html
@@ -199,6 +199,7 @@ Files in this Collection
+
diff --git a/cd/.index.html.swn b/cd/.index.html.swn
new file mode 100644
index 00000000..95f9fed5
Binary files /dev/null and b/cd/.index.html.swn differ
diff --git a/cd/index.html b/cd/index.html
index c6086252..34c5c75d 100755
--- a/cd/index.html
+++ b/cd/index.html
@@ -71,12 +71,9 @@ Files in this hierarchy
@@ -170,7 +167,6 @@
Files in this hierarchy
+
+
+\
+