diff --git a/src/main/java/org/gcube/nlphub/legacy/Constants.java b/src/main/java/org/gcube/nlphub/legacy/Constants.java index 6a44325..092c6dd 100644 --- a/src/main/java/org/gcube/nlphub/legacy/Constants.java +++ b/src/main/java/org/gcube/nlphub/legacy/Constants.java @@ -12,6 +12,7 @@ public class Constants { public static String CONTENT_TYPE = "Content-Type"; public static String UNAVAILABLE = "unavailable"; public static String ERROR_ID = "ERROR"; + public static String INPUT_FILE_PARAMETER = "input-file"; public static String getToken(HttpServletRequest request, boolean devMode) { String token = request.getParameter(TOKEN_PARAMETER); diff --git a/src/main/java/org/gcube/nlphub/mapper/DefaultMapper.java b/src/main/java/org/gcube/nlphub/mapper/DefaultMapper.java index 8a5672a..027ee6d 100644 --- a/src/main/java/org/gcube/nlphub/mapper/DefaultMapper.java +++ b/src/main/java/org/gcube/nlphub/mapper/DefaultMapper.java @@ -71,7 +71,7 @@ public class DefaultMapper implements JsonMapper { String remoteJson = "http://data.d4science.org/a2JtV0lOUUxsenZCM2RmcFRqVGtWWm42NU9LQnFGTk9HbWJQNStIS0N6Yz0-VLT"; String alg = "ENGLISH_NAMED_ENTITY_RECOGNIZER"; //remoteJson = "http://data.d4science.org/T21IcHlMSzFJRCttZ1lHVzMxd2dyWjVOUEpyY2dwUVNHbWJQNStIS0N6Yz0-VLT"; - + //remoteJson = "http://data.d4science.org/bDZLVkdlaVBjZCtLSWsrWUNQdHk3MUs4cEtDUGF5NktHbWJQNStIS0N6Yz0"; DefaultMapper dm = new DefaultMapper(); try { String s = dm.getJson(alg, remoteJson); diff --git a/src/main/java/org/gcube/nlphub/nlp/RunnerCommander.java b/src/main/java/org/gcube/nlphub/nlp/RunnerCommander.java index 9d802d1..f7de531 100644 --- a/src/main/java/org/gcube/nlphub/nlp/RunnerCommander.java +++ b/src/main/java/org/gcube/nlphub/nlp/RunnerCommander.java @@ -64,9 +64,15 @@ public class RunnerCommander extends Thread { public void startProcess() { start(); + // the following loop is needed in order to wait the end of all computations + // before return... + long counter = 0; while(!complete) { try { sleep(sleepTime); + counter += sleepTime; + if(counter > 2*maxWaitingTime) + complete = true; } catch (InterruptedException x) { logger.info("Interrupted."); } diff --git a/src/main/webapp/css/custom.css b/src/main/webapp/css/custom.css index acec328..257f123 100644 --- a/src/main/webapp/css/custom.css +++ b/src/main/webapp/css/custom.css @@ -213,6 +213,12 @@ select { border: solid 1px gray; padding: 10px; background: white; + /*width:300px; + height:300px;*/ + margin:0 auto; + left:50%; + top:50%; + transform: translate(-50%, -50%); } #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) { .left-side { 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 { font-size: 12px !important; } diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index aa75164..d2ccbeb 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -1,3 +1,4 @@ +<%@ page import="org.gcube.nlphub.legacy.Constants" %> @@ -19,7 +20,10 @@ - + diff --git a/src/main/webapp/js/main.js b/src/main/webapp/js/main.js index 6493189..593a058 100644 --- a/src/main/webapp/js/main.js +++ b/src/main/webapp/js/main.js @@ -12,7 +12,8 @@ var resultText = ""; var hexLetters = '0123456789ABCDEF'; var txtFlag = true; var checkedAnnotation = ""; -var checkedAlgs = []; +//var checkedAlgs = []; +var algIndexedArray = []; // ------------------------------------------------------------------------------------------------------ // 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 language = lineTokens[i][4].replace(/"/g, " ").trim(); - algorithms[algorithms.length] = { + algorithms.push ( { "name" : algName, "description" : algDescription, "id" : algId, "lang" : language, "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 // is set. if ($("#input-textarea").val().length > 0) { + freeText = $("#input-textarea").val(); + console.log("/nlphub/nlphub-uploader-servlet?freetext=" + + encodeURIComponent(freeText)); $ .ajax({ url : "/nlphub/nlphub-uploader-servlet?freetext=" - + encodeURI(freeText), + + encodeURIComponent(freeText), type : "POST", async : true, contentType : "text/plain; charset=utf-8", @@ -433,12 +439,12 @@ setEventListeners = function() { * show the in-progress popup */ showProgress = function() { - var width = $(".progress-circular-div").width(); - var height = $(".progress-circular-div").height(); - var left = parseInt((window.innerWidth - width) / 2); - var top = parseInt((window.innerHeight - height) / 2); - $(".progress-circular-div").css("left", left); - $(".progress-circular-div").css("top", top); +// var width = $(".progress-circular-div").width(); +// var height = $(".progress-circular-div").height(); +// var left = parseInt((window.innerWidth - width) / 2); +// var top = parseInt((window.innerHeight - height) / 2); +// $(".progress-circular-div").css("left", left); +// $(".progress-circular-div").css("top", top); $(".hidden-div").css("display", "block"); $(".hidden-div").show(); } @@ -645,6 +651,7 @@ buildAnnotationList = function(list) { $("#colored-annotations :radio").change(function() { if (this.checked) { checkedAnnotation = this.getAttribute("named"); + filterAlgorithmsByAnnotation(checkedAnnotation); rewriteText("#" + this.value); } }); @@ -676,10 +683,10 @@ buildAlgortihmList = function() { } - buildCheckedAlgs(); + //buildCheckedAlgs(); $("#algorithm-params-div :checkbox").change(function () { - buildCheckedAlgs(); + //buildCheckedAlgs(); rewriteText($("#colored-annotations :checked")[0].value); }); } @@ -687,14 +694,14 @@ buildAlgortihmList = function() { /* * build the internal global variable checkedAlgs used to filter results */ -buildCheckedAlgs = function() { - checkedAlgs = []; - for (var i = 0; i < jsonContent.output.result.length; i++) { - if($("#algorithm" + i).is(":checked")) { - checkedAlgs.push($("#algorithm" + i).attr("named")); - } - } -} +//buildCheckedAlgs = function() { +// checkedAlgs = []; +// for (var i = 0; i < jsonContent.output.result.length; i++) { +// if($("#algorithm" + i).is(":checked")) { +// checkedAlgs.push($("#algorithm" + i).attr("named")); +// } +// } +//} /* * Utility function @@ -800,8 +807,26 @@ rewriteText = function(color) { }, 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) { for (var i = 0; i < jsonContent.output.result.length; i++) { @@ -821,13 +846,14 @@ checkAnnotation = function(annotation) { * Retrieve the annotation indices from the json */ getIndices = function() { + var checkedAlgs = $("#algorithm-params-div input[type=checkbox]:checked"); var indices = []; // get indices for (var i = 0; i < jsonContent.output.result.length; i++) { // filter on algorithm var found = false; for(var j=0; j