diff --git a/VIPSWeb/local_settings_sample.py b/VIPSWeb/local_settings_sample.py index 032636e1a6d00d4f5b955dbafc17f2ae96542b3c..d358377fded8a7f2141ec119e489912d64cafc93 100755 --- a/VIPSWeb/local_settings_sample.py +++ b/VIPSWeb/local_settings_sample.py @@ -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 #FORECAST_MAP_ORGANIZATION_IDS =[1,6] # The server hostname used for VIPSCoreManager -VIPSCOREMANAGER_SERVER_NAME = "http://vipscoremanager" +VIPSCOREMANAGER_SERVER_NAME = "vipscoremanager" # Local path to self signed certificate of VIPSCoreManager. # Set to none if using certificate signed by a CA #VIPSCOREMANAGER_SSLCERT_PATH ="/path/to/myselfsignedcertificate.crt" diff --git a/forecasts/models.py b/forecasts/models.py index a8cb3b82679496ff996367c913977d8f7c439716..4c6d2b9c7af18e6bb1d09b2034dd6bba9a2a1665 100755 --- a/forecasts/models.py +++ b/forecasts/models.py @@ -437,27 +437,27 @@ class Model: def get_model(model_id): cur_language = translation.get_language() 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 - warning_status_interpretation = requests.get("%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 - sample_config = requests.get("%s/models/%s/sampleconfig" % (settings.VIPSCOREMANAGER_SERVER_NAME, model_id), 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("http://%s/models/%s/warningstatusinterpretation/%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("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) @staticmethod def get_local_name_for_model(model_id): 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 def get_local_warning_status_interpretation_for_model(model_id): 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 def get_models_local_names(): 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(model_ids.text) return model_ids diff --git a/fusarium/static/fusarium/js/oatFloweringModelForm.js b/fusarium/static/fusarium/js/oatFloweringModelForm.js index 9c3a777ec75b18a350b935ec38d5c16f825ca4ba..5dcbb7b3a8659100d9838a64dfbc449f7cdf81cd 100755 --- a/fusarium/static/fusarium/js/oatFloweringModelForm.js +++ b/fusarium/static/fusarium/js/oatFloweringModelForm.js @@ -39,16 +39,18 @@ var detailURL = null; var DEBUG = true; // 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 coreUserName = ""; var corePass = ""; // Location of weather data source NOT USED -//const LMTServicesBaseUri = settings.LMT_SERVICES_URL; -//const OpenMeteoBaseUri = "https://weather.vips.nibio.no/rest/grid/openmeteo/" - - +//var weatherDataBaseUri = "https://lmt.nibio.no/agrometbase/export/getSeasonDailyTemperaturesJSON.php"; +//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 var now = moment(); //var now = moment("2014-07-04"); @@ -61,11 +63,10 @@ var now = moment(); */ var oatForm = function(options) { - // Get options, validate this.target = options.target; this.weatherStations = options.weatherStations; - coreUserName = options.coreUserName; + coreUsername = options.coreUserName; corePass = options.corePass; //console.log(options.now); now = options.now != undefined ? moment(options.now) : now; @@ -82,7 +83,7 @@ var oatForm = function(options) // Then, add weather stations 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; } }; @@ -90,9 +91,8 @@ var oatForm = function(options) /** * Start the chain of functions that run the model */ -var submitForm = function(LMTServicesBaseUri, OpenMeteoBaseUri) +var submitForm = function() { - // TODO: Validate input // Date of sowing format if(!getDateOfSowing().isValid()) @@ -126,21 +126,21 @@ var submitForm = function(LMTServicesBaseUri, OpenMeteoBaseUri) document.getElementById("errorMsg").style.display="none"; // Start chain of async functions - createConfig(LMTServicesBaseUri, OpenMeteoBaseUri); + createConfig(); } /** * 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 weatherStationId = theForm.weatherStationId.options[theForm.weatherStationId.selectedIndex].value; const dateOfSowing = getDateOfSowing(); - const normalDataRequestUri = LMTServicesBaseUri + "/rest/vips/getdata/grovfornormal?" + + const normalDataRequestUri = LMTServicesBaseUri + "rest/vips/getdata/grovfornormal?" + "elementMeasurementTypes[]=TM&timeZone=Europe/Oslo" + "&weatherStationId=" + weatherStationId + "&startDate=" + now.format("YYYY-MM-DD") + @@ -164,12 +164,13 @@ const createConfig = async function(LMTServicesBaseUri, OpenMeteoBaseUri){ normalData.sort(sortWeatherData) const measuredDataRequestUri = document.getElementById("coordinates").checked? - OpenMeteoBaseUri.replace("%s", document.getElementById("longitude").value + "_" + document.getElementById("latitude").value) + - "?elementMeasurementTypes[]=TM&logIntervalId=2" + + OpenMeteoBaseUri + "?longitude=" + document.getElementById("longitude").value + + "&elementMeasurementTypes[]=TM&logIntervalId=2" + + "&latitude=" + document.getElementById("latitude").value + "&timeZone=Europe/Oslo" + "&startDate=" + dateOfSowing.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" + "&weatherStationId=" + weatherStationId + "&timeZone=Europe/Oslo" + diff --git a/fusarium/templates/fusarium/oat_flowering.html b/fusarium/templates/fusarium/oat_flowering.html index 2f1c0019c4baf4439e26e6339156729ffa027bdf..cca6ef376cfee33f347859925c7165581d517610 100755 --- a/fusarium/templates/fusarium/oat_flowering.html +++ b/fusarium/templates/fusarium/oat_flowering.html @@ -83,7 +83,7 @@ </fieldset> <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> @@ -119,7 +119,6 @@ const userSettingsRadios = ["weatherdataType"]; window.weatherStations = []; window.weatherStationIds = []; - let gridDataURL = undefined; const inputLatitudeElement = document.getElementById("latitude"); const inputLongitudeElement = document.getElementById("longitude"); @@ -128,14 +127,9 @@ 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 => { if(response.ok) { @@ -196,11 +190,6 @@ }); }; - window.prepareSubmit = function(){ - console.info("GET URLS"); - submitForm("{{ settings.LMT_SERVICES_URL }}", gridDataURL); - } - window.displayCoordinatesInput = function () { document.getElementById("coordinates").checked = true; document.getElementById('input-coordinates').style.display="block"; @@ -276,7 +265,7 @@ } window.openPoiMap = () => { - fetch("{{ settings.LMT_SERVICES_URL }}/rest/weatherstation/ipmdecisions", { + fetch("https://lmt.nibio.no/services/rest/weatherstation/ipmdecisions", { method: 'GET' }) .then(response => response.json())