diff --git a/example/index.html b/example/index.html index dcc483a..ba967ef 100644 --- a/example/index.html +++ b/example/index.html @@ -77,65 +77,34 @@

vals[entry.name] = entry.value return vals },{}); - BrAPI(form.server, form.username?{'username':username,'password':password}:undefined) + + var base_url = form.server; + if (base_url.slice(0,8)!="https://" && base_url.slice(0,7)!="http://"){ + base_url ="https://"+base_url; + } + if (base_url.slice(-1)!="/"){ + base_url+="/"; + } + + var server_url = base_url+"brapi/v1"; + var auth = form.username ? {'username':username,'password':password} : undefined; + var studyIds = form.study.split(",").map(function(s){return s.trim()}); + + $("#load-spin").show(); + + BrAPI(server_url, auth) .phenotypes_search({ - "studyDbIds" : form.study.split(",").map(function(s){return s.trim()}), - "observationLevel" : form.unit }) + "studyDbIds" : studyIds, + "observationLevel" : form.unit, + "pageSize" : 10000000}) .all(createSComp); - // params = ; - // loadBrAPIData(form.server,params,function(response){ - // createSComp(response.result.data); - // },form.username,form.password); + return false; }) }); - function loadBrAPIData(server,parameters,success,username,password){ - $("#load-spin").show(); - var base_url = server; - if (base_url.slice(0,8)!="https://" && base_url.slice(0,7)!="http://"){ - base_url ="https://"+base_url; - } - if (base_url.slice(-1)!="/"){ - base_url+="/"; - } - - var load_url = base_url+"brapi/v1/phenotypes-search"; - var data = { - "pageSize" : 10000000, - "page" : 0 - }; - d3.entries(parameters).forEach(function(entry){ - data[entry.key] = data[entry.key]||entry.value; - }); - - if(username){ - $.ajax({ - type: "POST", - url: base_url+"brapi/v1/token", - data: {'username':username,'password':password}, - success: function(response){ - data["access_token"] = response.access_token; - load(); - }, - }); - } - else { - load(); - } - - function load(){ - console.log(data); - $.ajax({ - type: "POST", - url: load_url, - data: data, - success: function(d){$("#load-spin").hide();success(d);}, - }); - } - }; - function createSComp(data){ + $("#load-spin").hide(); var scomp = StudyComparison(); var sharedVars = scomp.loadData(data); diff --git a/package.json b/package.json index e65eb0e..2009fa7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@solgenomics/brapi-study-comparison", - "version": "0.0.0", + "version": "1.0.0", "description": "", "main": "build/StudyComparison.js", "scripts": {