
js.dataexplorer-data.min.js Maven / Gradle / Ivy
(function(j,D){D.dataexplorer=D.dataexplorer||{};var t=D.dataexplorer.data=D.dataexplorer.data||{};t.createDataTable=i;t.createGenomeBrowser=F;t.doShowGenomeBrowser=l;t.setGenomeBrowserAttributes=n;t.setGenomeBrowserSettings=H;t.setGenomeBrowserEntities=C;var s=new D.RestClient();var r;var x;var p;var h;var m;var B;var d={};var y={};var c,a;function H(I){d=I}function C(I){x=I}function i(){j.get("/permission/FreemarkerTemplate/read").done(function(I){c=React.render(D.ui.Table({entity:k().name,attrs:g(),query:z(),onRowAdd:A,onRowDelete:A,onRowEdit:A,onRowInspect:q,onRowClick:(l()&&v())?w:null,enableInspect:I,onSort:function(J){a={orders:[{attr:J.attr.name,direction:J.order==="desc"?"DESC":"ASC"}]}}}),j("#data-table-container")[0])})}function A(){j(document).trigger("dataChange.data")}function q(K){var I=K.id;var J=K.name;j("#entityReport").load("dataexplorer/details",{entityName:J,entityId:I},function(){j("#entityReportModal").modal("show")})}function w(I){var J=I[h.name];var K=I[p.name];if(J!==undefined&&J!==""&&K!==undefined&&K!==""){r.setLocation(J,K-50,K+50)}}function f(){j.download(D.getContextUrl()+"/download",{dataRequest:JSON.stringify(o())});j("#downloadModal").modal("hide")}function o(){var I=z();var J={entityName:k().name,attributeNames:[],query:{rules:[I.q]},colNames:j("input[name=colNames]:checked").val(),entityValues:j("input[name=entityValues]:checked").val(),downloadType:j("input[name=downloadTypes]:checked").val()};J.query.sort=a;var K=D.getAtomicAttributes(u(),s);j.each(K,function(){var L=this;J.attributeNames.push(L.name)});return J}function l(){return D.ie9!==true&&p!==undefined&&h!==undefined&&D.dataexplorer.settings.data_genome_browser!==false}function v(){var I=D.dataexplorer.getSelectedAttributes();return(I.indexOf(h)!=-1)&&(I.indexOf(p)!=-1)}function G(L){var I;var J=k().attributes;var M=L.split(",");for(var K in M){I=J[M[K]];if(I!==undefined){break}}return I}function F(L){var M=false;if(L!==null){M=L.showHighlight}var K=j.extend(true,{},d,L||{});j("#genomebrowser").css("display","block");j("#genomebrowser").css("visibility","visible");var J=k();var I={name:J.label||J.name,uri:"/das/molgenis/dasdataset_"+J.name+"/",desc:J.description,stylesheet_uri:"/css/selected_dataset-track.xml"};K.sources.push(I);j.each(x,function(O,P){if(P.name!==J.name){var N={name:P.label||P.name,uri:"/das/molgenis/dasdataset_"+P.name+"/",desc:P.description,stylesheet_uri:"/css/selected_dataset-track.xml"};K.sources.push(N)}});K.registry="https://www.dasregistry.org/das/sources";K.prefix="https://www.biodalliance.org/release-0.13/";r=new Browser(K);if(M===true){r.highlightRegion(r.chr,(r.viewStart+9990),(r.viewEnd-9990))}r.addFeatureInfoPlugin(function(N,O){E(N,O,J)});return r}function E(M,O,L){if(y.hasOwnProperty(O.tier.dasSource.name+M.id+M.label)){j.each(y[O.tier.dasSource.name+M.id+M.label].sections,function(Q){O.sections.push(y[O.tier.dasSource.name+M.id+M.label].sections[Q])})}else{var K=M.notes.indexOf("source:MOLGENIS");if(O.feature.score==="0.0"){O.feature.score=undefined}if(O.feature.method==="not_recorded"){O.feature.method=undefined}var P=false;if(K!==-1){j.each(M.notes,function(U){var V=M.notes[U].indexOf("patient:");var T=M.notes[U].split("~");var S;var W=M.notes[U].indexOf("track:");if(W!==-1){S=M.notes[U].substr(W+6);if(L.name===S){P=true}}if(V!==-1){var Q=M.notes[U].substr(V+8);if(P){var R=j(''+Q+"");R.click(function(){j.each(u(),function(X,Y){if(Y===B){e(Y,undefined,undefined,Q)}})});O.add("Filter on patient:",R[0])}}else{if(T.length===2){O.add(T[0],T[1])}}});if(P){var J=j(''+M.id+"");var I;j.each(u(),function(Q,R){if(R.name===L.idAttribute){I=R}});J.click(function(){e(I,undefined,undefined,M.id)});if(M.id!=="-"&&I!==undefined){if(I.visible){O.setTitle(M.id);O.add("Filter on mutation:",J[0])}}else{O.setTitle("Chromosome:"+M.segment+" Position:"+M.min)}var N=j('Show details');N.click(function(){q({id:M.id,name:k().name})});O.add("",N[0])}}y[O.tier.dasSource.name+M.id+M.label]=O}O.feature.notes=[]}function b(){j.each(u(),function(I,J){if(J===p){e(J,Math.floor(r.viewStart).toString(),Math.floor(r.viewEnd).toString())}else{if(J===h){e(J,undefined,undefined,r.chr)}}})}function n(L,I,K,J){p=G(L);h=G(I);m=G(K);B=G(J)}function k(){return D.dataexplorer.getSelectedEntityMeta()}function u(){return D.dataexplorer.getSelectedAttributes()}function g(){return D.dataexplorer.getSelectedAttributesTree()}function z(){return D.dataexplorer.getEntityQuery()}function e(N,O,J,K){var I=new D.dataexplorer.filter.SimpleFilter(N,O,J,K);var M=new D.dataexplorer.filter.ComplexFilter(N);var L=new D.dataexplorer.filter.ComplexFilterElement(N);L.simpleFilter=I;L.operator=undefined;M.addComplexFilterElement(L);j(document).trigger("updateAttributeFilters",{filters:[M]})}j(function(){j(document).off(".data");j(document).on("changeModule.data",function(J,I){if(I==="data"){D.dataexplorer.data.createDataTable()}});j(document).on("changeAttributeSelection.data",function(L,J){if(c&&c.isMounted()&&(D.dataexplorer.getSelectedModule()=="data")){var M=c.state.attrs;var K=J.attributesTree;for(var I in K){if(M[I]!==undefined&&M[I]!==null){if(M[I].hasOwnProperty("*")&&K.hasOwnProperty(I)){K[I]=M[I]}}}c.setProps({attrs:K,onRowClick:(l()&&v())?w:null})}});j(document).on("updateAttributeFilters.data",function(K,J){function I(N,O,L){var M=999999999;if(N){O=O&&O>0?O:1;L=L&&L>0?L:O+M;r.setLocation(N,O,L)}}if(D.dataexplorer.getSelectedModule()=="data"){if(D.dataexplorer.settings.genomebrowser!=="false"){j.each(J.filters,function(){if(this.getComplexFilterElements&&this.getComplexFilterElements()[0]){if(this.attribute===p){I(r.chr,parseInt(this.getComplexFilterElements()[0].simpleFilter.fromValue),parseInt(this.getComplexFilterElements()[0].simpleFilter.toValue))}else{if(this.attribute===h){I(this.getComplexFilterElements()[0].simpleFilter.getValues()[0],r.viewStart,r.viewEnd)}}}})}}});j(document).on("changeQuery.data",function(J,I){if(c&&c.isMounted()&&(D.dataexplorer.getSelectedModule()=="data")){c.setProps({query:I})}});j("#download-button").click(function(){f()});j("form[name=galaxy-export-form]").validate({rules:{galaxyUrl:{required:true,url:true},galaxyApiKey:{required:true,minlength:32,maxlength:32}}});j("form[name=galaxy-export-form]").submit(function(I){I.preventDefault();if(j(this).valid()){j.ajax({type:j(this).attr("method"),url:j(this).attr("action"),data:JSON.stringify(j.extend({},j(this).serializeObject(),{dataRequest:o()})),contentType:"application/json"}).done(function(){D.createAlert([{message:"Exported data set to Galaxy"}],"success")}).always(function(){j("#galaxy-export-modal").modal("hide")})}});j("#genomebrowser-filter-button").click(function(){b()})})}($,window.top.molgenis=window.top.molgenis||{}));
© 2015 - 2025 Weber Informatics LLC | Privacy Policy