Skip to content
Snippets Groups Projects
Commit 484cde5c authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Updating the map with model info and a bit of layout fix

Running the GRIDZYMOSE model twice a day, to see if it works better
parent 142ab42d
Branches
Tags
1 merge request!17Develop
This commit is part of merge request !17. Comments created here will be created in the context of that merge request.
...@@ -479,6 +479,18 @@ public class ForecastBean { ...@@ -479,6 +479,18 @@ public class ForecastBean {
return retVal; return retVal;
} }
public ModelInformation getModelInformation(String modelId)
{
try
{
return em.createNamedQuery("ModelInformation.findByModelId", ModelInformation.class).setParameter("modelId", modelId).getSingleResult();
}
catch(NoResultException ex)
{
return null;
}
}
/** /**
* Stores a forecast configuration, including model specific form fields * Stores a forecast configuration, including model specific form fields
* @param forecastConfiguration * @param forecastConfiguration
......
...@@ -215,7 +215,7 @@ public class SchedulingBean { ...@@ -215,7 +215,7 @@ public class SchedulingBean {
// Run grid models // Run grid models
VIPSLogicTaskCollector runGridModelsCollector = new VIPSLogicTaskCollector(-1); VIPSLogicTaskCollector runGridModelsCollector = new VIPSLogicTaskCollector(-1);
runGridModelsCollector.getTasks().add(everyNightPattern, VipsLogicTaskFactory.createVipsLogicTask(VipsLogicTaskFactory.RUN_GRID_MODELS_TASK)); runGridModelsCollector.getTasks().add(morningAndAfternoonPattern, VipsLogicTaskFactory.createVipsLogicTask(VipsLogicTaskFactory.RUN_GRID_MODELS_TASK));
List<TaskCollector> definedTasks = new ArrayList<>(); List<TaskCollector> definedTasks = new ArrayList<>();
definedTasks.add(modelRunCollector); definedTasks.add(modelRunCollector);
......
...@@ -56,6 +56,7 @@ import no.nibio.vips.logic.entity.ForecastConfiguration; ...@@ -56,6 +56,7 @@ import no.nibio.vips.logic.entity.ForecastConfiguration;
import no.nibio.vips.logic.entity.ForecastModelConfiguration; import no.nibio.vips.logic.entity.ForecastModelConfiguration;
import no.nibio.vips.logic.entity.Message; import no.nibio.vips.logic.entity.Message;
import no.nibio.vips.logic.entity.MessageTag; import no.nibio.vips.logic.entity.MessageTag;
import no.nibio.vips.logic.entity.ModelInformation;
import no.nibio.vips.logic.entity.Organism; import no.nibio.vips.logic.entity.Organism;
import no.nibio.vips.logic.entity.Organization; import no.nibio.vips.logic.entity.Organization;
import no.nibio.vips.logic.entity.PointOfInterest; import no.nibio.vips.logic.entity.PointOfInterest;
...@@ -1026,6 +1027,16 @@ public class LogicService { ...@@ -1026,6 +1027,16 @@ public class LogicService {
return Response.ok().entity(SessionControllerGetter.getUserBean().getOrganizations()).build(); return Response.ok().entity(SessionControllerGetter.getUserBean().getOrganizations()).build();
} }
@GET
@Path("model/{modelId}")
@Produces("application/json;charset=UTF-8")
public Response getModelInformation(@PathParam("modelId") String modelId)
{
ModelInformation retVal = SessionControllerGetter.getForecastBean().getModelInformation(modelId);
return retVal != null ? Response.ok().entity(retVal).build()
: Response.status(Response.Status.NOT_FOUND).entity("ERROR: Could not find model with id=" + modelId).build();
}
/** /**
* Get the client to use for calling VIPSCoreManager REST services programmatically * Get the client to use for calling VIPSCoreManager REST services programmatically
* @return * @return
......
...@@ -95,4 +95,20 @@ along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>. ...@@ -95,4 +95,20 @@ along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>.
position: relative; position: relative;
bottom: -5px; bottom: -5px;
width: 50px; width: 50px;
}
#popup {
position: absolute !important;
right: 0;
left: 0;
margin-left: auto;
margin-right: auto;
width: 80%;
padding: 20px !important;
z-index: 1000;
display: none;
background-color: white;
border: 2px solid black;
font-family: Arial, Helvetica, sans-serif;
font-size: small;
} }
\ No newline at end of file
...@@ -42,9 +42,10 @@ var initMap = function () ...@@ -42,9 +42,10 @@ var initMap = function ()
+ " <div id='legend'>" + " <div id='legend'>"
+ " <table>" + " <table>"
+ " <tr><td>0</td><td style='color: #777777; font-weight: bold;'>" + geti18nText("risk_no") + "</td></tr>" + " <tr><td>0</td><td style='color: #777777; font-weight: bold;'>" + geti18nText("risk_no") + "</td></tr>"
+ " <tr><td>0-20</td><td style='color: yellow; font-weight: bold;'>" + geti18nText("risk_low") + "</td></tr>" + " <tr><td>0-20</td><td style='color: yellow; background-color: #777777; font-weight: bold;'>" + geti18nText("risk_low") + "</td></tr>"
+ " <tr><td>20-40</td><td style='color: orange; font-weight: bold;'>" + geti18nText("risk_medium") + "</td></tr>" + " <tr><td>20-40</td><td style='color: orange; font-weight: bold; '>" + geti18nText("risk_medium") + "</td></tr>"
+ " <tr><td>" + geti18nText("over") + " 40</td><td style='color: red; font-weight: bold;'>" + geti18nText("risk_high") + "</td></tr>" + " <tr><td>" + geti18nText("over") + " 40</td><td style='color: red; font-weight: bold;'>" + geti18nText("risk_high") + "</td></tr>"
+ " <tr><td><span style='cursor:pointer; color: green;' onclick='showModelInfo();'><i class='fas fa-info-circle'></i></span></td><td></td></tr>"
+ " </table>" + " </table>"
+ " </div>" + " </div>"
+ " </div>" + " </div>"
...@@ -53,7 +54,10 @@ var initMap = function () ...@@ -53,7 +54,10 @@ var initMap = function ()
+ "<div id='subMap1'><div id='subMap1DateField' class='dateField'></div></div>" + "<div id='subMap1'><div id='subMap1DateField' class='dateField'></div></div>"
+ "<div id='subMap2'><div id='subMap2DateField' class='dateField'></div></div>" + "<div id='subMap2'><div id='subMap2DateField' class='dateField'></div></div>"
+ "<div id='subMap3'><div id='subMap3DateField' class='dateField'></div></div>" + "<div id='subMap3'><div id='subMap3DateField' class='dateField'></div></div>"
+ "<div id='subMap4'><div id='subMap4DateField' class='dateField'></div></div>"; + "<div id='subMap4'><div id='subMap4DateField' class='dateField'></div></div>"
+ "<div id='popup'></div>";
+ "</div>"
for(var mapName in featureOverlays) for(var mapName in featureOverlays)
{ {
...@@ -161,6 +165,21 @@ var ajax = function(url, callback) ...@@ -161,6 +165,21 @@ var ajax = function(url, callback)
xhr.send(); xhr.send();
}; };
var showModelInfo = function()
{
ajax(hostName + "/rest/model/GRIDZYMOSE", function(e){
var modelInfo = JSON.parse(e.target.responseText);
document.getElementById('popup').innerHTML= "<p><button type='button' onclick='hideModelInfo();'>" + geti18nText("close") + "</button></p>"
+ modelInfo.defaultDescription.replace("\n","<br/><br/>");
document.getElementById('popup').style.display="block";
});
}
var hideModelInfo = function()
{
document.getElementById('popup').style.display="none";
}
function getTodayAtMidnight() function getTodayAtMidnight()
{ {
...@@ -223,7 +242,14 @@ document.addEventListener("DOMContentLoaded", function() { ...@@ -223,7 +242,14 @@ document.addEventListener("DOMContentLoaded", function() {
{ {
src: hostName + "/public/nordic_septoria_whs/moment-timezone-with-data.js" src: hostName + "/public/nordic_septoria_whs/moment-timezone-with-data.js"
}, },
initMap function() {
loadHeadElement("script",
{
src: "https://kit.fontawesome.com/567c8b1eb5.js"
},
initMap
);
}
); );
} }
); );
...@@ -289,7 +315,8 @@ var dict = { ...@@ -289,7 +315,8 @@ var dict = {
"risk_high" : { "no": "Høy risiko", "dk": "Høj risiko", "en": "High risk"}, "risk_high" : { "no": "Høy risiko", "dk": "Høj risiko", "en": "High risk"},
"over" : { "no": "Over", "dk": "Over", "en": "Over"}, "over" : { "no": "Over", "dk": "Over", "en": "Over"},
"poweredBy" : { "no": "Drevet av", "dk": "Drevet af", "en": "Powered by"} "poweredBy" : { "no": "Drevet av", "dk": "Drevet af", "en": "Powered by"},
"close" : { "no": "Lukk", "dk": "Lukk", "en": "Close"}
}; };
var geti18nText = function(keyword) var geti18nText = function(keyword)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment