This commit is contained in:
Erik Perrone 2018-03-21 14:44:38 +00:00
parent e325ac0e01
commit d5cf7f42d8
6 changed files with 153 additions and 24 deletions

View File

@ -12,6 +12,7 @@ public class Constants {
public static String CONTENT_TYPE = "Content-Type"; public static String CONTENT_TYPE = "Content-Type";
public static String UNAVAILABLE = "unavailable"; public static String UNAVAILABLE = "unavailable";
public static String ERROR_ID = "ERROR"; public static String ERROR_ID = "ERROR";
public static String INPUT_FILE_PARAMETER = "input-file";
public static String getToken(HttpServletRequest request, boolean devMode) { public static String getToken(HttpServletRequest request, boolean devMode) {
String token = request.getParameter(TOKEN_PARAMETER); String token = request.getParameter(TOKEN_PARAMETER);

View File

@ -71,7 +71,7 @@ public class DefaultMapper implements JsonMapper {
String remoteJson = "http://data.d4science.org/a2JtV0lOUUxsenZCM2RmcFRqVGtWWm42NU9LQnFGTk9HbWJQNStIS0N6Yz0-VLT"; String remoteJson = "http://data.d4science.org/a2JtV0lOUUxsenZCM2RmcFRqVGtWWm42NU9LQnFGTk9HbWJQNStIS0N6Yz0-VLT";
String alg = "ENGLISH_NAMED_ENTITY_RECOGNIZER"; String alg = "ENGLISH_NAMED_ENTITY_RECOGNIZER";
//remoteJson = "http://data.d4science.org/T21IcHlMSzFJRCttZ1lHVzMxd2dyWjVOUEpyY2dwUVNHbWJQNStIS0N6Yz0-VLT"; //remoteJson = "http://data.d4science.org/T21IcHlMSzFJRCttZ1lHVzMxd2dyWjVOUEpyY2dwUVNHbWJQNStIS0N6Yz0-VLT";
//remoteJson = "http://data.d4science.org/bDZLVkdlaVBjZCtLSWsrWUNQdHk3MUs4cEtDUGF5NktHbWJQNStIS0N6Yz0";
DefaultMapper dm = new DefaultMapper(); DefaultMapper dm = new DefaultMapper();
try { try {
String s = dm.getJson(alg, remoteJson); String s = dm.getJson(alg, remoteJson);

View File

@ -64,9 +64,15 @@ public class RunnerCommander extends Thread {
public void startProcess() { public void startProcess() {
start(); start();
// the following loop is needed in order to wait the end of all computations
// before return...
long counter = 0;
while(!complete) { while(!complete) {
try { try {
sleep(sleepTime); sleep(sleepTime);
counter += sleepTime;
if(counter > 2*maxWaitingTime)
complete = true;
} catch (InterruptedException x) { } catch (InterruptedException x) {
logger.info("Interrupted."); logger.info("Interrupted.");
} }

View File

@ -213,6 +213,12 @@ select {
border: solid 1px gray; border: solid 1px gray;
padding: 10px; padding: 10px;
background: white; background: white;
/*width:300px;
height:300px;*/
margin:0 auto;
left:50%;
top:50%;
transform: translate(-50%, -50%);
} }
#progress-caption { #progress-caption {
@ -290,6 +296,20 @@ select {
} }
} }
@media (width: 600px) {
.left-side {
width: 100%;
height: 100%;
}
.right-side {
width: 100%;
height: 100%;
}
.left-side-half {
height: 4vh;
}
}
@media (max-width: 430px) { @media (max-width: 430px) {
.left-side { .left-side {
width: 100%; width: 100%;
@ -304,6 +324,78 @@ select {
} }
} }
@media (width: 430px) {
.left-side {
width: 100%;
height: 100%;
}
.right-side {
width: 100%;
height: 100%;
}
.left-side-half {
height: 6vh;
}
}
@media (max-width: 300px) {
.left-side {
width: 100%;
height: 100%;
}
.right-side {
width: 100%;
height: 100%;
}
.left-side-half {
height: 8vh;
}
}
@media (width: 300px) {
.left-side {
width: 100%;
height: 100%;
}
.right-side {
width: 100%;
height: 100%;
}
.left-side-half {
height: 8vh;
}
}
@media (max-width: 250px) {
.left-side {
width: 100%;
height: 100%;
}
.right-side {
width: 100%;
height: 100%;
}
.left-side-half {
height: 10vh;
}
}
@media (width: 250px) {
.left-side {
width: 100%;
height: 100%;
}
.right-side {
width: 100%;
height: 100%;
}
.left-side-half {
height: 10vh;
}
}
#algorithm-param_div { #algorithm-param_div {
font-size: 12px !important; font-size: 12px !important;
} }

View File

@ -1,3 +1,4 @@
<%@ page import="org.gcube.nlphub.legacy.Constants" %>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -19,7 +20,10 @@
<script type="text/javascript" src="js/jquery.uploadfile.min.js"></script> <script type="text/javascript" src="js/jquery.uploadfile.min.js"></script>
<script type="text/javascript" src="js/main.js"></script> <script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="js/merge.js"></script> <script type="text/javascript" src="js/merge.js"></script>
<script type="text/javascript">
var inputFile = '<%= ((request.getParameter(Constants.INPUT_FILE_PARAMETER) == null) ? "" : "" + request.getParameter(Constants.INPUT_FILE_PARAMETER)) %>';
var cGubeToken = '<%= ((request.getParameter(Constants.TOKEN_PARAMETER) == null) ? "" : "" + request.getParameter(Constants.TOKEN_PARAMETER)) %>';
</script>
</head> </head>
<body style="padding: 0 15px;"> <body style="padding: 0 15px;">

View File

@ -12,7 +12,8 @@ var resultText = "";
var hexLetters = '0123456789ABCDEF'; var hexLetters = '0123456789ABCDEF';
var txtFlag = true; var txtFlag = true;
var checkedAnnotation = ""; var checkedAnnotation = "";
var checkedAlgs = []; //var checkedAlgs = [];
var algIndexedArray = [];
// ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------
// Starting point: get the csv file with algorithm parameters and set the page // Starting point: get the csv file with algorithm parameters and set the page
@ -267,13 +268,15 @@ getAlgorithms = function(lineTokens) {
var annotationList = lineTokens[i][3].replace(/"/g, " ").trim(); var annotationList = lineTokens[i][3].replace(/"/g, " ").trim();
var language = lineTokens[i][4].replace(/"/g, " ").trim(); var language = lineTokens[i][4].replace(/"/g, " ").trim();
algorithms[algorithms.length] = { algorithms.push ( {
"name" : algName, "name" : algName,
"description" : algDescription, "description" : algDescription,
"id" : algId, "id" : algId,
"lang" : language, "lang" : language,
"annotations" : annotationList "annotations" : annotationList
}; });
algIndexedArray[algorithms[algorithms.length-1].id.substr(algorithms[0].id.lastIndexOf(".")+1)] = algorithms[algorithms.length-1];
} }
} }
} }
@ -397,11 +400,14 @@ setEventListeners = function() {
// must be written in the workspace and the public link // must be written in the workspace and the public link
// is set. // is set.
if ($("#input-textarea").val().length > 0) { if ($("#input-textarea").val().length > 0) {
freeText = $("#input-textarea").val(); freeText = $("#input-textarea").val();
console.log("/nlphub/nlphub-uploader-servlet?freetext="
+ encodeURIComponent(freeText));
$ $
.ajax({ .ajax({
url : "/nlphub/nlphub-uploader-servlet?freetext=" url : "/nlphub/nlphub-uploader-servlet?freetext="
+ encodeURI(freeText), + encodeURIComponent(freeText),
type : "POST", type : "POST",
async : true, async : true,
contentType : "text/plain; charset=utf-8", contentType : "text/plain; charset=utf-8",
@ -433,12 +439,12 @@ setEventListeners = function() {
* show the in-progress popup * show the in-progress popup
*/ */
showProgress = function() { showProgress = function() {
var width = $(".progress-circular-div").width(); // var width = $(".progress-circular-div").width();
var height = $(".progress-circular-div").height(); // var height = $(".progress-circular-div").height();
var left = parseInt((window.innerWidth - width) / 2); // var left = parseInt((window.innerWidth - width) / 2);
var top = parseInt((window.innerHeight - height) / 2); // var top = parseInt((window.innerHeight - height) / 2);
$(".progress-circular-div").css("left", left); // $(".progress-circular-div").css("left", left);
$(".progress-circular-div").css("top", top); // $(".progress-circular-div").css("top", top);
$(".hidden-div").css("display", "block"); $(".hidden-div").css("display", "block");
$(".hidden-div").show(); $(".hidden-div").show();
} }
@ -645,6 +651,7 @@ buildAnnotationList = function(list) {
$("#colored-annotations :radio").change(function() { $("#colored-annotations :radio").change(function() {
if (this.checked) { if (this.checked) {
checkedAnnotation = this.getAttribute("named"); checkedAnnotation = this.getAttribute("named");
filterAlgorithmsByAnnotation(checkedAnnotation);
rewriteText("#" + this.value); rewriteText("#" + this.value);
} }
}); });
@ -676,10 +683,10 @@ buildAlgortihmList = function() {
} }
buildCheckedAlgs(); //buildCheckedAlgs();
$("#algorithm-params-div :checkbox").change(function () { $("#algorithm-params-div :checkbox").change(function () {
buildCheckedAlgs(); //buildCheckedAlgs();
rewriteText($("#colored-annotations :checked")[0].value); rewriteText($("#colored-annotations :checked")[0].value);
}); });
} }
@ -687,14 +694,14 @@ buildAlgortihmList = function() {
/* /*
* build the internal global variable checkedAlgs used to filter results * build the internal global variable checkedAlgs used to filter results
*/ */
buildCheckedAlgs = function() { //buildCheckedAlgs = function() {
checkedAlgs = []; // checkedAlgs = [];
for (var i = 0; i < jsonContent.output.result.length; i++) { // for (var i = 0; i < jsonContent.output.result.length; i++) {
if($("#algorithm" + i).is(":checked")) { // if($("#algorithm" + i).is(":checked")) {
checkedAlgs.push($("#algorithm" + i).attr("named")); // checkedAlgs.push($("#algorithm" + i).attr("named"));
} // }
} // }
} //}
/* /*
* Utility function * Utility function
@ -800,8 +807,26 @@ rewriteText = function(color) {
}, 50); }, 50);
} }
filterAlgorithmsByAnnotation = function() {
if($("#result-params-div input[type=radio]:checked").length < 1)
return;
var annotation = $("#result-params-div input[type=radio]:checked")[0].getAttribute("named");
var algs = $("#algorithm-params-div input[type=checkbox]");
for(var i=0; i< algs.length; i++) {
var named = $("#algorithm-params-div input[type=checkbox]")[i].getAttribute("named");
var annList = algIndexedArray[named].annotations;
if(annList.indexOf(annotation) >= 0) {
$($("#algorithm-params-div input[type=checkbox]")[i]).attr("checked", "")
}
else {
$($("#algorithm-params-div input[type=checkbox]")[i]).removeAttr("checked")
}
}
}
/* /*
* Find if the annotation is presente in the json * Find if the annotation is present in the json
*/ */
checkAnnotation = function(annotation) { checkAnnotation = function(annotation) {
for (var i = 0; i < jsonContent.output.result.length; i++) { for (var i = 0; i < jsonContent.output.result.length; i++) {
@ -821,13 +846,14 @@ checkAnnotation = function(annotation) {
* Retrieve the annotation indices from the json * Retrieve the annotation indices from the json
*/ */
getIndices = function() { getIndices = function() {
var checkedAlgs = $("#algorithm-params-div input[type=checkbox]:checked");
var indices = []; var indices = [];
// get indices // get indices
for (var i = 0; i < jsonContent.output.result.length; i++) { for (var i = 0; i < jsonContent.output.result.length; i++) {
// filter on algorithm // filter on algorithm
var found = false; var found = false;
for(var j=0; j<checkedAlgs.length; j++) { for(var j=0; j<checkedAlgs.length; j++) {
if(checkedAlgs[j] == jsonContent.output.result[i].algorithm) { if(checkedAlgs[j].getAttribute("named") == jsonContent.output.result[i].algorithm) {
found = true; found = true;
break; break;
} }