diff --git a/ipmd/static/ipmd/js/ipmdlib.js b/ipmd/static/ipmd/js/ipmdlib.js index 3445c6d70a5cf0626e96b4782afdd3164f1498f3..30859cd26e81f087ec1346d9a988b476b5e63c4c 100644 --- a/ipmd/static/ipmd/js/ipmdlib.js +++ b/ipmd/static/ipmd/js/ipmdlib.js @@ -104,6 +104,29 @@ async function getWeatherDatasources() return await response.json(); } +/** + * TODO Add more filtering than just authenticationType + * @param {String} filterCriteria {"authenticationType": ["NONE", "CREDENTIALS", "BEARER_TOKEN"]} + */ +async function getFilteredWeatherDatasources(filterCriteria) +{ + let allWeatherDatasources = await getWeatherDatasources(); + let filteredWeatherDatasources = allWeatherDatasources; + let authenticationType = filterCriteria["authenticationType"]; + if(authenticationType != undefined) + { + filteredWeatherDatasources = []; + for(let i=0;i< allWeatherDatasources.length; i++) + { + if(allWeatherDatasources[i].authentication_type == authenticationType || (allWeatherDatasources[i].authentication_type == undefined && authenticationType == "NONE")) + { + filteredWeatherDatasources.push(allWeatherDatasources[i]) + } + } + } + return filteredWeatherDatasources; +} + /** * * @param {String} weatherDatasource diff --git a/ipmd/templates/ipmd/saddlegallmidgeform.html b/ipmd/templates/ipmd/saddlegallmidgeform.html index 023edf430f461d9f90e45fc8fee62ae6af6c8e57..077d49f25658637338c611ba17fe4c61c0fbe01d 100644 --- a/ipmd/templates/ipmd/saddlegallmidgeform.html +++ b/ipmd/templates/ipmd/saddlegallmidgeform.html @@ -138,7 +138,7 @@ parameterInfo.style.display = "block"; // Pull weather data sources from web service, render lists (historic and forecast sources, some are both) - weatherDatasources = await getWeatherDatasources(); + weatherDatasources = await getFilteredWeatherDatasources({"authenticationType":"NONE"}); //console.info(weatherDatasources); weatherDatasources.sort((a, b) => { return (a.name < b.name) ? -1 : (a.name > b.name) ? 1 : 0; @@ -586,364 +586,5 @@ renderWeatherData(weatherData, document.getElementById("weatherData"), "table table-striped") } - - - // Mock result!!! Waiting for ADAS to fix CORS issue - const mockResult={ - "timeStart": "2023-06-30T22:00:00+00:00", - "timeEnd": "2023-08-10T22:00:00+00:00", - "interval": 86400, - "resultParameters": [ - "Cumulative_DayDegrees", - "StartOfEmergenceThreshold", - "FirstThreshold", - "SecondThreshold", - "ThirdThreshold" - ], - "locationResult": [ - { - "longitude": 10.62687, - "latitude": 62.10944, - "altitude": 478.0, - "data": [ - [ - 12.957083333333332, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 26.471249999999998, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 38.164583333333333, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 50.12833333333333, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 63.424166666666665, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 76.315416666666664, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 90.9525, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 106.4175, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 124.07208333333334, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 143.23041666666666, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 158.54916666666665, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 173.02458333333331, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 186.06041666666664, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 198.31124999999997, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 210.43499999999997, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 224.8820833333333, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 239.05541666666665, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 251.71874999999997, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 263.06991666666664, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 274.32391666666666, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 284.68975, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 296.90266666666668, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 309.94766666666669, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 322.764, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 334.34983333333332, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 346.98191666666668, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 359.79066666666665, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 372.52816666666666, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 386.75358333333332, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 402.21066666666667, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 416.82858333333331, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 428.63025, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 442.98983333333331, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 456.554, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 470.31691666666666, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 483.14233333333334, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 497.56275, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 508.33566666666667, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 521.79775, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 533.56191666666666, - 500.0, - 750.47, - 1023.93, - 1500.0 - ], - [ - 545.3566992753623, - 500.0, - 750.47, - 1023.93, - 1500.0 - ] - ], - "warningStatus": [ - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 4, - 4, - 4, - 4 - ], - "width": 5, - "length": 41 - } - ], - "message": "Start of cumulative emergence: 07/08/2023 .", - "messageType": 0 - }; - </script> {% endblock %} \ No newline at end of file