From 5256bdae162e5e1844b1f2c632139e1ef79b767e Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@nibio.no> Date: Wed, 28 Feb 2024 09:52:09 +0100 Subject: [PATCH] Fix weather data render bug --- ipmd/static/ipmd/js/ipmdlib.js | 5 ++++- ipmd/templates/ipmd/saddlegallmidgeform.html | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ipmd/static/ipmd/js/ipmdlib.js b/ipmd/static/ipmd/js/ipmdlib.js index e17d4325..ecdf682f 100644 --- a/ipmd/static/ipmd/js/ipmdlib.js +++ b/ipmd/static/ipmd/js/ipmdlib.js @@ -255,6 +255,7 @@ async function runModel(endpoint, inputData) */ function getDateArray(timestart, interval, length) { + let dateArray = []; currentTime = moment(timestart); for(let i=0;i< length; i++) @@ -406,7 +407,9 @@ async function isPointCoveredByDatasource(coordinate, datasource) * @param {String} tableClass for styling the table, e.g. using Bootstrap */ function renderWeatherData(weatherData, container, tableClass){ - let dates = getDateArray(weatherData.timeStart, weatherData.interval, weatherData.locationWeatherData[0].length); + console.info(weatherData); + + let dates = getDateArray(weatherData.timeStart, weatherData.interval, weatherData.locationWeatherData[0].data.length); let html = "<table" + (tableClass != undefined ? " class=\"" + tableClass + "\"" : "") + "><thead><tr><th>Time</th>"; weatherData.weatherParameters.forEach(function(weatherParameterId){ html +="<th>" + getWeatherParameter(weatherParameterId).name + "</th>"; diff --git a/ipmd/templates/ipmd/saddlegallmidgeform.html b/ipmd/templates/ipmd/saddlegallmidgeform.html index 9e23a430..b87e2920 100644 --- a/ipmd/templates/ipmd/saddlegallmidgeform.html +++ b/ipmd/templates/ipmd/saddlegallmidgeform.html @@ -478,7 +478,7 @@ } // 2. Forecast weather data - if(currentForecastWeatherDatasource != undefined) + if(currentForecastWeatherDatasource != undefined && moment(inputData.optionalData.endDate).add(1,"days").isAfter(moment())) { coordinate = getLatLon(); if(coordinate == null) @@ -518,7 +518,6 @@ } else { - // Is useless until method is implemented weatherData = mergeWeatherData(weatherData, forecastData); } } -- GitLab