Commit 291af1b2 authored by Maxime Chaillet's avatar Maxime Chaillet

put doi inside the url and handle possible abscence of doi

parent c13c4fc0
......@@ -25,12 +25,11 @@
<script type="text/javascript">
$(document).ready(function() {
var params = new URLSearchParams(document.location.search.substring(1));
var doi = params.get("DOI");
var client = new ICATClient();
client.connect("myDoiNumberForTest");
client.connect(doi);
});
</script>
</head>
......
function ICATClient(){this.server="https://linfalcon.esrf.fr:8181",this.sessionId=null,this.connection={plugin:"simple",credentials:[{username:"root",password:"root"}]}}ICATClient.prototype.connect=function(s){var n=this;this.sessionId||$.ajax({url:this.server+"/icat/session",data:{json:JSON.stringify(this.connection)},type:"post",dataType:"json",success:function(e){n.sessionId=e.sessionId,n.getByDOI(s)},error:function(){alert("Sorry, there was a problem!")}})},ICATClient.prototype.getByDOI=function(s){var n="select inv from Investigation inv where inv.doi='"+s+"' INCLUDE inv.investigationInstruments invInstruments, inv.investigationUsers invUser, invUser.user, invInstruments.instrument";$.ajax({url:this.server+"/icat/entityManager",data:{sessionId:this.sessionId,server:this.server,query:n},type:"GET",dataType:"json",success:function(s){console.log(s),dust.render("esrf-landing-page",{investigation:s[0].Investigation,investigationUsers:s[0].Investigation.investigationUsers},function(s,n){$("#main").html(n)})},error:function(){alert("Sorry, error while processing the DOI request !")}})};
\ No newline at end of file
function ICATClient(){this.server="https://linfalcon.esrf.fr:8181",this.sessionId=null,this.connection={plugin:"simple",credentials:[{username:"root",password:"root"}]}}ICATClient.prototype.connect=function(n){var s=this;this.sessionId||$.ajax({url:this.server+"/icat/session",data:{json:JSON.stringify(this.connection)},type:"post",dataType:"json",success:function(e){s.sessionId=e.sessionId,s.getByDOI(n)},error:function(){alert("Sorry, there was a problem!")}})},ICATClient.prototype.getByDOI=function(n){var s="select inv from Investigation inv where inv.doi='"+n+"' INCLUDE inv.investigationInstruments invInstruments, inv.investigationUsers invUser, invUser.user, invInstruments.instrument";$.ajax({url:this.server+"/icat/entityManager",data:{sessionId:this.sessionId,server:this.server,query:s},type:"GET",dataType:"json",success:function(s){console.log(s),void 0!==s[0]?dust.render("esrf-landing-page",{investigation:s[0].Investigation,investigationUsers:s[0].Investigation.investigationUsers},function(n,s){$("#main").html(s)}):alert("The DOI number "+n+" was not found !")},error:function(){alert("Sorry, error while processing the DOI request !")}})};
\ No newline at end of file
......@@ -51,13 +51,20 @@ ICATClient.prototype.getByDOI = function(doi){
dataType : "json",
success: function( data ) {
console.log(data);
dust.render('esrf-landing-page',
if ( typeof data[0] !== "undefined" )
{
investigation : data[0].Investigation,
investigationUsers : data[0].Investigation.investigationUsers
}, function(err, out) {
$("#main").html(out);
});
dust.render('esrf-landing-page',
{
investigation : data[0].Investigation,
investigationUsers : data[0].Investigation.investigationUsers
},
function(err, out) {
$("#main").html(out);
});
}
else {
alert("The DOI number " + doi + " was not found !");
}
},
// Code to run if the request fails
error: function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment