It fixes #1

parent 61f96544
node_modules/
bower_components/
.classpath
.metadata
bin/
......
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
files: ['Gruntfile.js', 'src/*.js', 'test/**/*.js'],
options: {
globals: {
jQuery: true
}
}
},
watch: {
files: ['<%= jshint.files %>', 'templates/**js'],
tasks: [ 'uglify','dustjs','wiredep']
},
uglify: {
options: {
mangle: true
},
my_target: {
files: {
'min/doi-landing-page.min.js': ['src/*js']
}
}
},
wiredep: {
target: {
src: 'index.html'
}
},
dustjs : {
compile : {
files : {
'min/precompiled.templates.min.js' : [ 'templates/**js' ]
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-wiredep');
grunt.loadNpmTasks('grunt-dustjs');
grunt.registerTask('default', ['jshint', 'dustjs', 'uglify', 'wiredep']);
};
{
"name": "ESRF DOI landing page",
"authors": [
"Alejandro De Maria Antolinos <demariaa@esrf.fr>",
"Maxime Chaillet <mchaille@esrf.fr>"
],
"description": "This is the landing page for the DOI at the ESRF",
"main": "index.html",
"moduleType": [],
"keywords": [
"DOI",
"ESRF",
"data",
"science",
"metadata"
],
"license": "MIT",
"homepage": "https://doi.esrf.fr",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"jquery": "^3.2.1",
"dustjs-linkedin": "^2.7.5",
"bootstrap": "^3.3.7"
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>details from DOI</title>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
var connection= {
json: "{\"plugin\":\"simple\",\"credentials\":[{\"username\":\"root\"}, {\"password\":\"root\"}]}"
}
var mySessionId="";
$(document).ready(function() {
console.log("Hello. The document is ready.");
$("#doiRequestDiv").hide();
$("#connectButton").click(function() {
console.log("You clicked on Connection button");
// From: http://learn.jquery.com/ajax/jquery-ajax-methods/
// Using the core $.ajax() method
$.ajax({
// The URL for the request
url: "https://linfalcon.esrf.fr:8181/icat/session",
// The data to send (will be converted to a query string)
data: connection,
// Whether this is a POST or GET request
type: "post",
// The type of data we expect back
//dataType : "text",
dataType : "json",
// Code to run if the request succeeds;
// the response is passed to the function
success: function( data ) {
console.log("You received some data!");
mySessionId = data.sessionId;
$("#connectionState").html("Your session ID is " + data.sessionId);
$("#doiRequestDiv").show();
},
// Code to run if the request fails
error: function() {
alert( "Sorry, there was a problem!" );
}
});
});
$("#getDoiButton").click(function() {
console.log("getDoiButton clicked");
var doiRequest = $("#doiId").val();
var myDoiQuery = "select distinct dataCollection from DataCollection dataCollection" +
" where dataCollection.doi='" + doiRequest + "'" +
" include dataCollection.parameters";
$.ajax({
// The URL for the request
url: "https://linfalcon.esrf.fr:8181/icat/entityManager",
// The data to send (will be converted to a query string)
data: {
sessionId: mySessionId,
server : "https://linfalcon.esrf.fr:8181",
query : myDoiQuery
},
type: "GET",
dataType : "json",
success: function( data ) {
console.log("The requested DOI was found !");
// data contains an array
receptionDOIInfo(data);
},
// Code to run if the request fails
error: function() {
alert( "Sorry, error while processing the DOI request !" );
}
});
});
});
function receptionDOIInfo(data){
if (data.length != 0)
{
var doiName = data[0].DataCollection.doi;
var doiId = data[0].DataCollection.id;
var title = data[0].DataCollection.parameters[0].stringValue;
var mintedDate = data[0].DataCollection.parameters[1].dateTimeValue;
var mintedBy = data[0].DataCollection.parameters[2].stringValue;
$("#doiResultDiv").html(
"Received Data : <BR/> " +
"doiName : " + doiName + " <BR/>" +
"doiID : " + doiId + " <BR/>" +
"title : " + title + " <BR/>" +
"mintedDate : " + mintedDate + " <BR/>" +
"mintedBy : " + mintedBy + " <BR/>"
);
} else {
$("#doiResultDiv").html("Sorry, the DOI was not found !" );
};
};
</script>
</head>
<body>
<h1>Salut</h1>
<p>Cliquer sur le bouton pour connexion sur ICAT server.</p>
<button id="connectButton">Connexion</button>
<div id="connectionState"></div>
<div id="doiRequestDiv"> Enter the requested DOI :
<input type="text" id="doiId">
<button id="getDoiButton"> Get it !</button>
</div>
<div id="doiResultDiv"> </div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<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">
<!-- bower:css -->
<!-- endbower -->
</head>
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/dustjs-linkedin/dist/dust-full.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<!-- endbower -->
<script src="min/doi-landing-page.min.js"></script>
<script src="min/precompiled.templates.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var client = new ICATClient();
client.connect("id010100");
});
</script>
</head>
<body>
<div id='main'></div>
</body>
</html>
\ No newline at end of file
function ICATClient(){this.server="https://icat.esrf.fr",this.sessionId=null,this.connection={plugin:"db",credentials:[{username:"reader",password:"reader"}]}}ICATClient.prototype.connect=function(e){var s=this;this.sessionId||$.ajax({url:this.server+"/icat/session",data:{json:JSON.stringify(this.connection)},type:"post",dataType:"json",success:function(n){s.sessionId=n.sessionId,s.getByDOI(e)},error:function(){alert("Sorry, there was a problem!")}})},ICATClient.prototype.getByDOI=function(e){var s="select inv from Investigation inv where inv.name='"+e+"' 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(e){console.log(e),dust.render("esrf-landing-page",{investigation:e[0].Investigation,investigationUsers:e[0].Investigation.investigationUsers},function(e,s){$("#main").html(s)})},error:function(){alert("Sorry, error while processing the DOI request !")}})};
\ 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-sm-4\" style=\"background-color:lavender;\">").f(ctx.getPath(true, ["investigation","name"]),ctx,"h").w("</div><div class=\"col-sm-4\" style=\"background-color:lavenderblush;\">.col-sm-4</div><div class=\"col-sm-4\" style=\"background-color:lavender;\">.col-sm-4</div></div>").s(ctx.getPath(true, ["investigationUsers"]),ctx,{"block":body_1},{}).w(" <div class=\"col-sm-12\" style=\"background-color:lavender;\">").f(ctx.getPath(true, ["investigation","summary"]),ctx,"h").w("</div> </div> ");}body_0.__dustBody=!0;function body_1(chk,ctx){return chk.w("<div class=\"row\"><div class=\"col-sm-12\" style=\"background-color:lavender;\">").f(ctx.getPath(true, ["user","name"]),ctx,"h").w("</div> </div>");}body_1.__dustBody=!0;return body_0}(dust));
\ No newline at end of file
{
"name": "doi-landing-page",
"version": "0.0.0",
"description": "",
"main": "Gruntfile.js",
"dependencies": {
"grunt": "^1.0.1",
"grunt-contrib-jshint": "^1.1.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-dust": "^0.9.4",
"grunt-dustjs": "^1.4.0"
},
"devDependencies": {
"grunt": "^1.0.1",
"grunt-contrib-jshint": "^1.1.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@gitlab.esrf.fr:icat/doi-landing-page.git"
},
"author": "",
"license": "ISC"
}
function ICATClient(){
this.server = "https://icat.esrf.fr";
this.sessionId = null;
this.connection = {
plugin : 'db',
credentials : [
{
username : 'reader',
password :'reader'
}
]
};
}
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!" );
}
});
}
};
ICATClient.prototype.getByDOI = function(doi){
var _this = this;
var query = "select inv from Investigation inv where inv.name='" + 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 ) {
console.log(data);
dust.render('esrf-landing-page',
{
investigation : data[0].Investigation,
investigationUsers : data[0].Investigation.investigationUsers
}, function(err, out) {
$("#main").html(out);
});
},
// Code to run if the request fails
error: function() {
alert( "Sorry, error while processing the DOI request !" );
}
});
};
<div class="container-fluid">
<div class="row">
<div class="col-sm-4" style="background-color:lavender;">{.investigation.name}</div>
<div class="col-sm-4" style="background-color:lavenderblush;">.col-sm-4</div>
<div class="col-sm-4" style="background-color:lavender;">.col-sm-4</div>
</div>
{#.investigationUsers}
<div class="row">
<div class="col-sm-12" style="background-color:lavender;">{.user.name}</div>
</div>
{/.investigationUsers}
<div class="col-sm-12" style="background-color:lavender;">{.investigation.summary}</div>
</div>
\ No newline at end of file
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