Commit 3781f3d2 authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos

Merge branch 'master' of gitlab.esrf.fr:icat/doi-landing-page

parents 96b44ad4 734ed5b5
......@@ -12,7 +12,7 @@ module.exports = function(grunt) {
},
watch: {
files: ['<%= jshint.files %>', 'templates/**js'],
tasks: [ 'uglify','dustjs','wiredep']
tasks: [ 'uglify','dustjs','cssmin','wiredep']
},
uglify: {
options: {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -5,8 +5,7 @@
<title>details from DOI</title>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<link rel="stylesheet" href="/min/output.min.css" >
......@@ -20,13 +19,19 @@
<script type="text/javascript">
$(document).ready(function() {
var params = new URLSearchParams(document.location.search.substring(1));
console.log(params);
new ICATClient().connect(params.get("DOI"));
});
$(document).on({
ajaxStart: function(){ $("body").addClass("loading");},
ajaxStop: function() { $("body").removeClass("loading"); }
});
</script>
</head>
<body>
<div id='main'></div>
<div id='main' ></div>
<div class="modal"> <!-- nothing to write here --></div>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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 () {
alert("Sorry, there was a connexion problem with the server. Please contact the webmaster.");
}
});
}
};
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) {
$("#main").html(out);
});
}
else {
alert("The DOI number " + doi + " was not found !");
}
},
// Code to run if the request fails
error: function() {
alert( "Sorry, error while processing the DOI request !" );
}
});
};
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 {
alert("Sorry, the requested DOI was not found.");
}
},
// Code to run if the request fails
error : function () {
alert("Sorry, error while processing the request. Please contact the webmaster");
}
});
};
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