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

Revert "feat: Fix URL configs"

This reverts commit 9654df5a
parent 9654df5a
No related branches found
No related tags found
1 merge request!25Revert "feat: Fix URL configs"
...@@ -128,7 +128,7 @@ INCLUDE_ORGANIZATION_IDS =[1,2,3,4,5] ...@@ -128,7 +128,7 @@ INCLUDE_ORGANIZATION_IDS =[1,2,3,4,5]
# Use this if you want to override and show icons for stations belonging to several organizations # Use this if you want to override and show icons for stations belonging to several organizations
#FORECAST_MAP_ORGANIZATION_IDS =[1,6] #FORECAST_MAP_ORGANIZATION_IDS =[1,6]
# The server hostname used for VIPSCoreManager # The server hostname used for VIPSCoreManager
VIPSCOREMANAGER_SERVER_NAME = "http://vipscoremanager" VIPSCOREMANAGER_SERVER_NAME = "vipscoremanager"
# Local path to self signed certificate of VIPSCoreManager. # Local path to self signed certificate of VIPSCoreManager.
# Set to none if using certificate signed by a CA # Set to none if using certificate signed by a CA
#VIPSCOREMANAGER_SSLCERT_PATH ="/path/to/myselfsignedcertificate.crt" #VIPSCOREMANAGER_SSLCERT_PATH ="/path/to/myselfsignedcertificate.crt"
......
...@@ -437,27 +437,27 @@ class Model: ...@@ -437,27 +437,27 @@ class Model:
def get_model(model_id): def get_model(model_id):
cur_language = translation.get_language() cur_language = translation.get_language()
local_name = Model.get_local_name_for_model(model_id) local_name = Model.get_local_name_for_model(model_id)
description = requests.get("%s/models/%s/description/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id, cur_language), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH).text description = requests.get("http://%s/models/%s/description/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id, cur_language), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH).text
warning_status_interpretation = requests.get("%s/models/%s/warningstatusinterpretation/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id, cur_language), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH).text warning_status_interpretation = requests.get("http://%s/models/%s/warningstatusinterpretation/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id, cur_language), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH).text
usage = requests.get("%s/models/%s/usage/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id, cur_language), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH).text usage = requests.get("http://%s/models/%s/usage/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id, cur_language), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH).text
sample_config = requests.get("%s/models/%s/sampleconfig" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH).text sample_config = requests.get("http://%s/models/%s/sampleconfig" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH).text
return Model(model_id, local_name, description, warning_status_interpretation, usage, sample_config) return Model(model_id, local_name, description, warning_status_interpretation, usage, sample_config)
@staticmethod @staticmethod
def get_local_name_for_model(model_id): def get_local_name_for_model(model_id):
cur_language = translation.get_language() cur_language = translation.get_language()
return requests.get("%s/models/%s/name/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id, cur_language), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH).text return requests.get("http://%s/models/%s/name/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id, cur_language), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH).text
@staticmethod @staticmethod
def get_local_warning_status_interpretation_for_model(model_id): def get_local_warning_status_interpretation_for_model(model_id):
cur_language = translation.get_language() cur_language = translation.get_language()
return requests.get("%s/models/%s/warningstatusinterpretation/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id, cur_language), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH).text return requests.get("http://%s/models/%s/warningstatusinterpretation/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id, cur_language), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH).text
@staticmethod @staticmethod
def get_models_local_names(): def get_models_local_names():
cur_language = translation.get_language() cur_language = translation.get_language()
model_ids = requests.get("%s/models/json/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME,cur_language), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH) model_ids = requests.get("http://%s/models/json/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME,cur_language), verify=settings.VIPSCOREMANAGER_SSLCERT_PATH)
#print("http://%s/models/json/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME,cur_language)) #print("http://%s/models/json/%s" % (settings.VIPSCOREMANAGER_SERVER_NAME,cur_language))
#print(model_ids.text) #print(model_ids.text)
return model_ids return model_ids
......
...@@ -39,16 +39,18 @@ var detailURL = null; ...@@ -39,16 +39,18 @@ var detailURL = null;
var DEBUG = true; var DEBUG = true;
// Settings for VIPS forecasting system // Settings for VIPS forecasting system
var serverUri = settings.vipsCoremanagerServerName; //var serverUri = settings.vipsCoremanagerServerName;
var serverUri = "https://coremanager.vips.nibio.no";
//var serverUri = "http://vipscoremanager";
var runUri= serverUri + "/models/OATFLOWERM/run"; var runUri= serverUri + "/models/OATFLOWERM/run";
var coreUserName = ""; var coreUserName = "";
var corePass = ""; var corePass = "";
// Location of weather data source NOT USED // Location of weather data source NOT USED
//const LMTServicesBaseUri = settings.LMT_SERVICES_URL; //var weatherDataBaseUri = "https://lmt.nibio.no/agrometbase/export/getSeasonDailyTemperaturesJSON.php";
//const OpenMeteoBaseUri = "https://weather.vips.nibio.no/rest/grid/openmeteo/" //var weatherDataBaseUri = "http://agrometbase-local/agrometbase/export/getSeasonDailyTemperaturesJSON.php";
const LMTServicesBaseUri = "https://lmt.nibio.no/services/";
const OpenMeteoBaseUri = "https://weather.vips.nibio.no/rest/grid/openmeteo/"
// Setting current time // Setting current time
var now = moment(); var now = moment();
//var now = moment("2014-07-04"); //var now = moment("2014-07-04");
...@@ -61,11 +63,10 @@ var now = moment(); ...@@ -61,11 +63,10 @@ var now = moment();
*/ */
var oatForm = function(options) var oatForm = function(options)
{ {
// Get options, validate // Get options, validate
this.target = options.target; this.target = options.target;
this.weatherStations = options.weatherStations; this.weatherStations = options.weatherStations;
coreUserName = options.coreUserName; coreUsername = options.coreUserName;
corePass = options.corePass; corePass = options.corePass;
//console.log(options.now); //console.log(options.now);
now = options.now != undefined ? moment(options.now) : now; now = options.now != undefined ? moment(options.now) : now;
...@@ -82,7 +83,7 @@ var oatForm = function(options) ...@@ -82,7 +83,7 @@ var oatForm = function(options)
// Then, add weather stations // Then, add weather stations
for(i in this.weatherStations) for(i in this.weatherStations)
{ {
var option = new Option(this.weatherStations[i].name,this.weatherStations[i].weatherstationId); var option = new Option(this.weatherStations[i].name,this.weatherStations[i].weatherstation_id);
theForm.weatherStationId.options[theForm.weatherStationId.options.length]=option; theForm.weatherStationId.options[theForm.weatherStationId.options.length]=option;
} }
}; };
...@@ -90,9 +91,8 @@ var oatForm = function(options) ...@@ -90,9 +91,8 @@ var oatForm = function(options)
/** /**
* Start the chain of functions that run the model * Start the chain of functions that run the model
*/ */
var submitForm = function(LMTServicesBaseUri, OpenMeteoBaseUri) var submitForm = function()
{ {
// TODO: Validate input // TODO: Validate input
// Date of sowing format // Date of sowing format
if(!getDateOfSowing().isValid()) if(!getDateOfSowing().isValid())
...@@ -126,21 +126,21 @@ var submitForm = function(LMTServicesBaseUri, OpenMeteoBaseUri) ...@@ -126,21 +126,21 @@ var submitForm = function(LMTServicesBaseUri, OpenMeteoBaseUri)
document.getElementById("errorMsg").style.display="none"; document.getElementById("errorMsg").style.display="none";
// Start chain of async functions // Start chain of async functions
createConfig(LMTServicesBaseUri, OpenMeteoBaseUri); createConfig();
} }
/** /**
* Creates the configuration for weather data. Moves on to running model after data returns * Creates the configuration for weather data. Moves on to running model after data returns
*/ */
const createConfig = async function(LMTServicesBaseUri, OpenMeteoBaseUri){ const createConfig = async function(){
const theForm = document.getElementById(theFormId); const theForm = document.getElementById(theFormId);
const weatherStationId = theForm.weatherStationId.options[theForm.weatherStationId.selectedIndex].value; const weatherStationId = theForm.weatherStationId.options[theForm.weatherStationId.selectedIndex].value;
const dateOfSowing = getDateOfSowing(); const dateOfSowing = getDateOfSowing();
const normalDataRequestUri = LMTServicesBaseUri + "/rest/vips/getdata/grovfornormal?" + const normalDataRequestUri = LMTServicesBaseUri + "rest/vips/getdata/grovfornormal?" +
"elementMeasurementTypes[]=TM&timeZone=Europe/Oslo" + "elementMeasurementTypes[]=TM&timeZone=Europe/Oslo" +
"&weatherStationId=" + weatherStationId + "&weatherStationId=" + weatherStationId +
"&startDate=" + now.format("YYYY-MM-DD") + "&startDate=" + now.format("YYYY-MM-DD") +
...@@ -164,12 +164,13 @@ const createConfig = async function(LMTServicesBaseUri, OpenMeteoBaseUri){ ...@@ -164,12 +164,13 @@ const createConfig = async function(LMTServicesBaseUri, OpenMeteoBaseUri){
normalData.sort(sortWeatherData) normalData.sort(sortWeatherData)
const measuredDataRequestUri = document.getElementById("coordinates").checked? const measuredDataRequestUri = document.getElementById("coordinates").checked?
OpenMeteoBaseUri.replace("%s", document.getElementById("longitude").value + "_" + document.getElementById("latitude").value) + OpenMeteoBaseUri + "?longitude=" + document.getElementById("longitude").value +
"?elementMeasurementTypes[]=TM&logIntervalId=2" + "&elementMeasurementTypes[]=TM&logIntervalId=2" +
"&latitude=" + document.getElementById("latitude").value +
"&timeZone=Europe/Oslo" + "&timeZone=Europe/Oslo" +
"&startDate=" + dateOfSowing.format("YYYY-MM-DD") + "&startDate=" + dateOfSowing.format("YYYY-MM-DD") +
"&endDate=" + moment(now).add(10, "days").format("YYYY-MM-DD") "&endDate=" + moment(now).add(10, "days").format("YYYY-MM-DD")
: LMTServicesBaseUri + "/rest/vips/getdata/forecastfallback?"+ : LMTServicesBaseUri + "rest/vips/getdata/forecastfallback?"+
"elementMeasurementTypes[]=TM&logInterval=1d" + "elementMeasurementTypes[]=TM&logInterval=1d" +
"&weatherStationId=" + weatherStationId + "&weatherStationId=" + weatherStationId +
"&timeZone=Europe/Oslo" + "&timeZone=Europe/Oslo" +
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
</fieldset> </fieldset>
<div class="form-group"> <div class="form-group">
<button type="button" class="btn btn-primary" onclick="prepareSubmit();storeUserSettings();">Beregn</button> <button type="button" class="btn btn-primary" onclick="submitForm();storeUserSettings();">Beregn</button>
</div> </div>
...@@ -119,7 +119,6 @@ ...@@ -119,7 +119,6 @@
const userSettingsRadios = ["weatherdataType"]; const userSettingsRadios = ["weatherdataType"];
window.weatherStations = []; window.weatherStations = [];
window.weatherStationIds = []; window.weatherStationIds = [];
let gridDataURL = undefined;
const inputLatitudeElement = document.getElementById("latitude"); const inputLatitudeElement = document.getElementById("latitude");
const inputLongitudeElement = document.getElementById("longitude"); const inputLongitudeElement = document.getElementById("longitude");
...@@ -128,14 +127,9 @@ ...@@ -128,14 +127,9 @@
let userSettings = getLocalSettings(getNameSpaced("{{ form_id }}",userSettingsFields.concat(userSettingsRadios)), false); let userSettings = getLocalSettings(getNameSpaced("{{ form_id }}",userSettingsFields.concat(userSettingsRadios)), false);
fetch("{{ settings.VIPSLOGIC_PROTOCOL }}://{{ settings.VIPSLOGIC_SERVER_NAME }}/rest/organization/{{ settings.VIPS_ORGANIZATION_ID }}")
.then(response => response.json())
.then(organizationJson => {
gridDataURL = organizationJson.defaultGridWeatherStationDataSource.datafetchUriExpression;
});
fetch("{{ settings.LMT_SERVICES_URL }}/rest/weatherstation/weatherstations/normaldata") fetch("https://lmt.nibio.no/agrometbase/export/getNormalDataStationsJSON.php")
.then(response => { .then(response => {
if(response.ok) if(response.ok)
{ {
...@@ -196,11 +190,6 @@ ...@@ -196,11 +190,6 @@
}); });
}; };
window.prepareSubmit = function(){
console.info("GET URLS");
submitForm("{{ settings.LMT_SERVICES_URL }}", gridDataURL);
}
window.displayCoordinatesInput = function () { window.displayCoordinatesInput = function () {
document.getElementById("coordinates").checked = true; document.getElementById("coordinates").checked = true;
document.getElementById('input-coordinates').style.display="block"; document.getElementById('input-coordinates').style.display="block";
...@@ -276,7 +265,7 @@ ...@@ -276,7 +265,7 @@
} }
window.openPoiMap = () => { window.openPoiMap = () => {
fetch("{{ settings.LMT_SERVICES_URL }}/rest/weatherstation/ipmdecisions", { fetch("https://lmt.nibio.no/services/rest/weatherstation/ipmdecisions", {
method: 'GET' method: 'GET'
}) })
.then(response => response.json()) .then(response => response.json())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment