Commit 0bb8d84a authored by Maxime Chaillet's avatar Maxime Chaillet

#3 Handle error message when the ICAT server is not reachable or not responding

parent 974659eb
This source diff could not be displayed because it is too large. You can view the blob instead.
(function(dust){dust.register("doi-not-found-page",body_0);function body_0(chk,ctx){return chk.w("<div class=\"container-fluid\"><div class=\"row\"><div class=\"col-3\" > </div><div class=\"col-6 blueBackground text-center\" > <img src=\"./src/esrfLogo.png\"> </img> </div><div class=\"col-3\"> </div></div><div class=\"row\"><div class=\"col-12 text-center\" > <h2> Not found </h2> </div></div><div class=\"row\"><div class=\"col-3\" > </div><div class=\"col-6 lightRedBackground text-center\" > <p> ").f(ctx.get(["message"], false),ctx,"h").w(" </p> </div><div class=\"col-3\" > </div></div></div> ");}body_0.__dustBody=!0;return body_0}(dust));
(function(dust){dust.register("esrf-landing-page",body_0);function body_0(chk,ctx){return chk.w("<div class=\"container-fluid\"><div class=\"row\"><div class=\"col-12 col-sm-4 blueBackground\" > <img id=\"logo\" src=\"./src/esrfLogo.png\"> </img> </div><div class=\"col-12 col-sm-8 blueBackground flex\"> <div class=\"col-12 whiteVCenteredFont text-right\" > ").f(ctx.getPath(false, ["investigation","doi"]),ctx,"h").w(" </div></div></div><div class=\"row\"><div class=\"col-8\" > <label>Title</label><p class=\"grayBackground\"> ").f(ctx.getPath(false, ["investigation","summary"]),ctx,"h").w(" </p><label> Abstract </label><p class=\"grayBackground\"> </p><p><label> Experimental report </label> <button type=\"button\" class=\"btn btn-primary btn-lg btn-block blueBackground disabled\" style='background-color:#D7D7D7; border:1px solid #D7D7D7;'>Download experimental report </button> </p><p><label> Download data </label><button type=\"button\" class=\"btn btn-primary btn-lg btn-block blueBackground disabled\" style='background-color:#D7D7D7; border:1px solid #D7D7D7;'>Download data </button></p></div><div class=\"col-4\"><div class=\"row\"> <div class=\"col-12\" ><label> Identifier </label><p> ").f(ctx.getPath(false, ["investigation","id"]),ctx,"h").w("</p><label> Authors </label>").s(ctx.getPath(false, ["investigation","investigationUsers"]),ctx,{"block":body_1},{}).w("<label> Publisher </label><p> ESRF </p><label> Publication year </label><p> year </p><label> Proposal number </label><p> ").f(ctx.getPath(false, ["investigation","name"]),ctx,"h").w(" </p> \t</div></div></div></div></div>");}body_0.__dustBody=!0;function body_1(chk,ctx){return chk.h("eq",ctx,{"block":body_2},{"key":ctx.get(["role"], false),"value":"Principal investigator"},"h").h("eq",ctx,{"block":body_3},{"key":ctx.get(["role"], false),"value":"Proposal scientist"},"h");}body_1.__dustBody=!0;function body_2(chk,ctx){return chk.w(" <p>").f(ctx.getPath(true, ["user","fullName"]),ctx,"h").w("</p> ");}body_2.__dustBody=!0;function body_3(chk,ctx){return chk.w("<p>").f(ctx.getPath(true, ["user","fullName"]),ctx,"h").w("</p>");}body_3.__dustBody=!0;return body_0}(dust));
\ No newline at end of file
(function(dust){dust.register("esrf-landing-page",body_0);function body_0(chk,ctx){return chk.w("<div class=\"container-fluid\"><div class=\"row\"><div class=\"col-12 col-sm-4 blueBackground\" > <img id=\"logo\" src=\"./src/esrfLogo.png\"> </img> </div><div class=\"col-12 col-sm-8 blueBackground flex\"> <div class=\"col-12 whiteVCenteredFont text-right\" > ").f(ctx.getPath(false, ["investigation","doi"]),ctx,"h").w(" </div></div></div><div class=\"row\"><div class=\"col-8\" > <label>Title</label><p class=\"grayBackground\"> ").f(ctx.getPath(false, ["investigation","summary"]),ctx,"h").w(" </p><label> Abstract </label><p class=\"grayBackground\"> </p><p><label> Experimental report </label> <button type=\"button\" class=\"btn btn-primary btn-lg btn-block blueBackground disabled\" style='background-color:#D7D7D7; border:1px solid #D7D7D7;'>Download experimental report </button> </p><p><label> Download data </label><button type=\"button\" class=\"btn btn-primary btn-lg btn-block blueBackground disabled\" style='background-color:#D7D7D7; border:1px solid #D7D7D7;'>Download data </button></p></div><div class=\"col-4\"><div class=\"row\"> <div class=\"col-12\" ><label> Identifier </label><p> ").f(ctx.getPath(false, ["investigation","id"]),ctx,"h").w("</p><label> Authors </label>").s(ctx.getPath(false, ["investigation","investigationUsers"]),ctx,{"block":body_1},{}).w("<label> Publisher </label><p> ESRF </p><label> Publication year </label><p> year </p><label> Proposal number </label><p> ").f(ctx.getPath(false, ["investigation","name"]),ctx,"h").w(" </p> \t</div></div></div></div></div>");}body_0.__dustBody=!0;function body_1(chk,ctx){return chk.h("eq",ctx,{"block":body_2},{"key":ctx.get(["role"], false),"value":"Principal investigator"},"h").h("eq",ctx,{"block":body_3},{"key":ctx.get(["role"], false),"value":"Proposal scientist"},"h");}body_1.__dustBody=!0;function body_2(chk,ctx){return chk.w(" <p>").f(ctx.getPath(true, ["user","fullName"]),ctx,"h").w("</p> ");}body_2.__dustBody=!0;function body_3(chk,ctx){return chk.w("<p>").f(ctx.getPath(true, ["user","fullName"]),ctx,"h").w("</p>");}body_3.__dustBody=!0;return body_0}(dust));
(function(dust){dust.register("handling-error-page",body_0);function body_0(chk,ctx){return chk.w("<div class=\"container-fluid\"><div class=\"row\"><div class=\"col-3\" > </div><div class=\"col-6 blueBackground text-center\" > <img src=\"./src/esrfLogo.png\"> </img> </div><div class=\"col-3\"> </div></div><div class=\"row\"><div class=\"col-12 text-center\" > <h2> Not found </h2> </div></div><div class=\"row\"><div class=\"col-3\" > </div><div class=\"col-6 lightRedBackground text-center\" > <p> ").f(ctx.get(["message"], false),ctx,"h").w(" </p> </div><div class=\"col-3\" > </div></div></div>");}body_0.__dustBody=!0;return body_0}(dust));
\ No newline at end of file
function ICATClient(){
function ICATClient() {
this.server = "https://linfalcon.esrf.fr:8181";
this.sessionId = null;
this.connection = {
plugin : 'simple',
credentials : [
{
username : 'root',
password :'root'
}
]
};
plugin : 'simple',
credentials : [ {
username : 'root',
password : 'root'
} ]
};
}
ICATClient.prototype.connect = function(doi){
var _this = this;
if (!this.sessionId){
$.ajax({
url: this.server + "/icat/session",
data: { json : JSON.stringify(this.connection) },
type: "post",
dataType : "json",
success: function( data ) {
_this.sessionId = data.sessionId;
_this.getByDOI(doi);
ICATClient.prototype.connect = function (doi) {
var _this = this;
if (!this.sessionId) {
$.ajax({
url : this.server + "/icat/session",
data : {
json : JSON.stringify(this.connection)
},
type : "post",
dataType : "json",
success : function (data) {
_this.sessionId = data.sessionId;
_this.getByDOI(doi);
},
error: function() {
alert( "Sorry, there was a problem!" );
}
});
}
},
error : function () {
dust.render(
'handling-error-page',
{
message : "Sorry, there was a connexion problem with the server. Please contact the webmaster."
}, function (err, out) {
$("#main").html(out);
});
}
});
}
};
ICATClient.prototype.getByDOI = function(doi){
var _this = this;
var query = "select inv from Investigation inv where inv.doi='" + doi + "' INCLUDE inv.investigationInstruments invInstruments, inv.investigationUsers invUser, invUser.user, invInstruments.instrument" ;
$.ajax({
url: this.server + "/icat/entityManager",
data: {
sessionId: _this.sessionId,
ICATClient.prototype.getByDOI = function (doi) {
var _this = this;
var query = "select inv from Investigation inv where inv.doi='" +
doi +
"' 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 : query
},
type: "GET",
dataType : "json",
success: function( data ) {
if ( typeof data[0] !== "undefined" )
{
dust.render('esrf-landing-page',
{
investigation : data[0].Investigation,
investigationUsers : data[0].Investigation.investigationUsers
},
function(err, out) {
query : query
},
type : "GET",
dataType : "json",
success : function (data) {
if (typeof data[0] !== "undefined") {
dust.render(
'esrf-landing-page',
{
investigation : data[0].Investigation,
investigationUsers : data[0].Investigation.investigationUsers
}, function (err, out) {
$("#main").html(out);
});
} else {
dust.render('handling-error-page', {
message : "Sorry, the requested DOI was not found."
}, function (err, out) {
$("#main").html(out);
});
}
else {
dust.render('doi-not-found-page',
{
message : "Sorry, the requested DOI was not found."
},
function(err, out) {
$("#main").html(out);
});
}
},
// Code to run if the request fails
error: function() {
alert( "Sorry, error while processing the DOI request !" );
}
});
};
}
},
// Code to run if the request fails
error : function () {
dust.render(
'handling-error-page',
{
message : "Sorry, error while processing the request. Please contact the webmaster."
}, function (err, out) {
$("#main").html(out);
});
}
});
};
......@@ -15,4 +15,4 @@
<div class="col-6 lightRedBackground text-center" > <p> {message} </p> </div>
<div class="col-3" > </div>
</div>
</div>
</div>
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