diff --git a/VIPSWeb/static/js/util.js b/VIPSWeb/static/js/util.js index 9aa3d20a870d2fb16fc7b682442da0d4de2222df..8f2a2ce7c723363bf32d853bf9b59226cb8cbdb5 100755 --- a/VIPSWeb/static/js/util.js +++ b/VIPSWeb/static/js/util.js @@ -334,6 +334,11 @@ function getJSON(ambiguousVar) } } + +function isDictEmpty(v){ + return Object.keys(v).length == 0; +} + function isDict(v){ return typeof v==='object' && v!==null && !(v instanceof Array) && !(v instanceof Date); } diff --git a/cerealblotchmodels/locale/de/LC_MESSAGES/django.mo b/cerealblotchmodels/locale/de/LC_MESSAGES/django.mo index 01a204af9666829002cccf454223039e23666e9f..8d0348cd4f57fc0808a17665a2327698bb2fb9dc 100755 Binary files a/cerealblotchmodels/locale/de/LC_MESSAGES/django.mo and b/cerealblotchmodels/locale/de/LC_MESSAGES/django.mo differ diff --git a/cerealblotchmodels/locale/de/LC_MESSAGES/django.po b/cerealblotchmodels/locale/de/LC_MESSAGES/django.po index 61811b7b0599d3f8e2eb9e25a8ab62db8698b9a8..8c1b819ac2ce41feec91a432d21a6b516c636ff3 100755 --- a/cerealblotchmodels/locale/de/LC_MESSAGES/django.po +++ b/cerealblotchmodels/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-04-23 14:14+0200\n" +"POT-Creation-Date: 2018-05-02 11:21+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -28,6 +28,7 @@ msgid "Background data for the barley net blotch model" msgstr "" #: templates/cerealblotchmodels/barleynetblotchform.html:49 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:45 #: templates/cerealblotchmodels/wheatleafblotchform.html:49 msgid "Weather station" msgstr "" @@ -138,13 +139,13 @@ msgid "Disease" msgstr "" #: templates/cerealblotchmodels/barleynetblotchform.html:206 -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:333 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:382 #: templates/cerealblotchmodels/wheatleafblotchform.html:208 msgid "Time" msgstr "" #: templates/cerealblotchmodels/barleynetblotchform.html:214 -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:341 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:389 #: templates/cerealblotchmodels/wheatleafblotchform.html:216 msgid "Warning status" msgstr "" @@ -160,12 +161,13 @@ msgid "Disease value" msgstr "" #: templates/cerealblotchmodels/barleynetblotchform.html:267 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:438 #: templates/cerealblotchmodels/wheatleafblotchform.html:269 msgid "Barley net blotch development" msgstr "" #: templates/cerealblotchmodels/barleynetblotchform.html:279 -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:263 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:308 #: templates/cerealblotchmodels/wheatleafblotchform.html:281 msgid "Select weather station" msgstr "" @@ -203,10 +205,6 @@ msgstr "" msgid "Please select" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:45 -msgid "WeatherStation" -msgstr "" - #: templates/cerealblotchmodels/septoriahumiditymodelform.html:53 msgid "Sprayings" msgstr "" @@ -273,45 +271,58 @@ msgid "Number of consecutive 'humid hours'" msgstr "" #: templates/cerealblotchmodels/septoriahumiditymodelform.html:138 -msgid "Spraying protection period" +msgid "Spraying protection days" msgstr "" #: templates/cerealblotchmodels/septoriahumiditymodelform.html:143 msgid "Leaf life time (days)" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:303 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:350 msgid "The model is running, please wait" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:320 -msgid "Temperature, hourly mean" +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:369 +msgid "Leaf wetness, hourly" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:321 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:370 msgid "Rain, hourly" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:322 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:371 msgid "Relative humidity, hourly mean" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:323 -msgid "Leaf wetness, hourly" +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:372 +msgid "Humid hour (yes/no)" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:324 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:373 msgid "Humid period hour" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:325 -msgid "Humid hour (yes/no)" +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:374 +msgid "Humid hour sum" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:326 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:375 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:433 msgid "Humid period hour outside protection period" msgstr "" +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:429 +msgid "Hours" +msgstr "" + +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:434 +msgid "Threshold humid period" +msgstr "" + +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:435 +msgid "Spraying protection period" +msgstr "" + #: templates/cerealblotchmodels/wheatleafblotchform.html:25 #: templates/cerealblotchmodels/wheatleafblotchform.html:34 msgid "Wheat leaf blotch" diff --git a/cerealblotchmodels/locale/nb/LC_MESSAGES/django.mo b/cerealblotchmodels/locale/nb/LC_MESSAGES/django.mo index 3f0be08a16babeb7ab2fb54c2ef07cb5b7e468d5..67fcaa9b70056f1e1b90b5f6284d8373f7a71f5a 100755 Binary files a/cerealblotchmodels/locale/nb/LC_MESSAGES/django.mo and b/cerealblotchmodels/locale/nb/LC_MESSAGES/django.mo differ diff --git a/cerealblotchmodels/locale/nb/LC_MESSAGES/django.po b/cerealblotchmodels/locale/nb/LC_MESSAGES/django.po index 130c40e9e6c7e1d5fe00c1f6a13b4de6f16bc081..8ba9b8a32d934cfb3bca59b2ac4f41379f2aa875 100755 --- a/cerealblotchmodels/locale/nb/LC_MESSAGES/django.po +++ b/cerealblotchmodels/locale/nb/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-04-23 14:14+0200\n" +"POT-Creation-Date: 2018-05-02 11:21+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -28,6 +28,7 @@ msgid "Background data for the barley net blotch model" msgstr "Bakgrunnsdata for byggbrunflekkmodellen" #: templates/cerealblotchmodels/barleynetblotchform.html:49 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:45 #: templates/cerealblotchmodels/wheatleafblotchform.html:49 msgid "Weather station" msgstr "Målestasjon" @@ -138,13 +139,13 @@ msgid "Disease" msgstr "Sykdom" #: templates/cerealblotchmodels/barleynetblotchform.html:206 -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:333 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:382 #: templates/cerealblotchmodels/wheatleafblotchform.html:208 msgid "Time" msgstr "Tid" #: templates/cerealblotchmodels/barleynetblotchform.html:214 -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:341 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:389 #: templates/cerealblotchmodels/wheatleafblotchform.html:216 msgid "Warning status" msgstr "Varselstatus" @@ -160,12 +161,13 @@ msgid "Disease value" msgstr "Sykdomsverdi" #: templates/cerealblotchmodels/barleynetblotchform.html:267 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:438 #: templates/cerealblotchmodels/wheatleafblotchform.html:269 msgid "Barley net blotch development" msgstr "Utvikling av byggbrunflekk" #: templates/cerealblotchmodels/barleynetblotchform.html:279 -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:263 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:308 #: templates/cerealblotchmodels/wheatleafblotchform.html:281 msgid "Select weather station" msgstr "Velg målestasjon" @@ -203,21 +205,14 @@ msgstr "Land" msgid "Please select" msgstr "Vennligst velg" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:45 -#, fuzzy -msgid "WeatherStation" -msgstr "Målestasjon" - #: templates/cerealblotchmodels/septoriahumiditymodelform.html:53 -#, fuzzy msgid "Sprayings" -msgstr "Sprøytedato" +msgstr "Sprøytinger" #: templates/cerealblotchmodels/septoriahumiditymodelform.html:55 #: templates/cerealblotchmodels/septoriahumiditymodelform.html:60 -#, fuzzy msgid "Spraying 1" -msgstr "Sprøytedato" +msgstr "Sprøytedato 1" #: templates/cerealblotchmodels/septoriahumiditymodelform.html:70 msgid "Phenology" @@ -245,7 +240,7 @@ msgstr "Alle kjerner fullt strukket ut (vs 75)" #: templates/cerealblotchmodels/septoriahumiditymodelform.html:100 msgid "Threshold values for 'humid hour'" -msgstr "Terskelverdier for \"fuktig time\"" +msgstr "Terskelverdier for fuktig time" #: templates/cerealblotchmodels/septoriahumiditymodelform.html:102 msgid "Relative humidity" @@ -256,9 +251,8 @@ msgid "Leaf wetness (min/hour)" msgstr "Bladfukt (min/t)" #: templates/cerealblotchmodels/septoriahumiditymodelform.html:112 -#, fuzzy msgid "Precipitation" -msgstr "Plantevernmiddel" +msgstr "Nedbør" #: templates/cerealblotchmodels/septoriahumiditymodelform.html:117 msgid "Sliding hours past (hours)" @@ -277,55 +271,64 @@ msgid "Number of consecutive 'humid hours'" msgstr "Antall sammenhengende \"fuktige timer\"" #: templates/cerealblotchmodels/septoriahumiditymodelform.html:138 -msgid "Spraying protection period" +msgid "Spraying protection days" msgstr "Antall dager beskyttelse etter sprøyting" #: templates/cerealblotchmodels/septoriahumiditymodelform.html:143 msgid "Leaf life time (days)" msgstr "Levetid for blad (dager)" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:303 -#, fuzzy +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:350 msgid "The model is running, please wait" msgstr "Modellen kjører, vennligst vent" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:320 -#, fuzzy -msgid "Temperature, hourly mean" -msgstr "Temperatur, døgngjennomsnitt" +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:369 +msgid "Leaf wetness, hourly" +msgstr "Bladfukt, timesverdi" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:321 -#, fuzzy +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:370 msgid "Rain, hourly" -msgstr "Regn, daglig" +msgstr "Regn, timeverdi" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:322 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:371 msgid "Relative humidity, hourly mean" msgstr "Relativ luftfuktighet, timesgjennomsnitt" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:323 -msgid "Leaf wetness, hourly" -msgstr "Bladfukt, timesverdi" +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:372 +msgid "Humid hour (yes/no)" +msgstr "Fuktig time (ja/nei)" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:324 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:373 msgid "Humid period hour" msgstr "Time nr i fuktig periode" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:325 -msgid "Humid hour (yes/no)" -msgstr "Fuktig time (ja/nei)" +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:374 +msgid "Humid hour sum" +msgstr "Sum fuktige timer" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:326 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:375 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:433 msgid "Humid period hour outside protection period" msgstr "Time nr x i fuktig periode utenfor sprøyteperiode" +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:429 +msgid "Hours" +msgstr "Timer" + +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:434 +msgid "Threshold humid period" +msgstr "Terskelverdier for fuktig time" + +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:435 +msgid "Spraying protection period" +msgstr "Beskyttelse etter sprøyting" + #: templates/cerealblotchmodels/wheatleafblotchform.html:25 #: templates/cerealblotchmodels/wheatleafblotchform.html:34 msgid "Wheat leaf blotch" msgstr "Bladflekksjukdommer i hvete" #: templates/cerealblotchmodels/wheatleafblotchform.html:42 -#, fuzzy msgid "Background data for the wheat leaf blotch model" -msgstr "Bakgrunnsdata for byggbrunflekkmodellen" +msgstr "Bakgrunnsdata for bladflekksjukdomsmodellen" diff --git a/cerealblotchmodels/locale/zh_CN/LC_MESSAGES/django.mo b/cerealblotchmodels/locale/zh_CN/LC_MESSAGES/django.mo index 1d22b3b4c2987addf1f13ebb79af5b91d2e7356e..298a32a2cda4024a7a483c6ad7510817220325a8 100755 Binary files a/cerealblotchmodels/locale/zh_CN/LC_MESSAGES/django.mo and b/cerealblotchmodels/locale/zh_CN/LC_MESSAGES/django.mo differ diff --git a/cerealblotchmodels/locale/zh_CN/LC_MESSAGES/django.po b/cerealblotchmodels/locale/zh_CN/LC_MESSAGES/django.po index 8a241ec4d271fcd041479120c2a0d392bc5b2869..eff7c52ba4ecf3582c06e155873fcd1bd57d91e1 100755 --- a/cerealblotchmodels/locale/zh_CN/LC_MESSAGES/django.po +++ b/cerealblotchmodels/locale/zh_CN/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-04-23 14:14+0200\n" +"POT-Creation-Date: 2018-05-02 11:21+0200\n" "PO-Revision-Date: 2016-10-07 11:05+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -28,6 +28,7 @@ msgid "Background data for the barley net blotch model" msgstr "大麦网斑病模型的背景数据" #: templates/cerealblotchmodels/barleynetblotchform.html:49 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:45 #: templates/cerealblotchmodels/wheatleafblotchform.html:49 msgid "Weather station" msgstr "气象站" @@ -138,13 +139,13 @@ msgid "Disease" msgstr "疾病" #: templates/cerealblotchmodels/barleynetblotchform.html:206 -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:333 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:382 #: templates/cerealblotchmodels/wheatleafblotchform.html:208 msgid "Time" msgstr "时间" #: templates/cerealblotchmodels/barleynetblotchform.html:214 -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:341 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:389 #: templates/cerealblotchmodels/wheatleafblotchform.html:216 msgid "Warning status" msgstr "预警信息" @@ -160,12 +161,13 @@ msgid "Disease value" msgstr "疾病值" #: templates/cerealblotchmodels/barleynetblotchform.html:267 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:438 #: templates/cerealblotchmodels/wheatleafblotchform.html:269 msgid "Barley net blotch development" msgstr "大麦网斑病发展" #: templates/cerealblotchmodels/barleynetblotchform.html:279 -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:263 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:308 #: templates/cerealblotchmodels/wheatleafblotchform.html:281 msgid "Select weather station" msgstr "选择气象站" @@ -203,12 +205,6 @@ msgstr "" msgid "Please select" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:45 -#, fuzzy -#| msgid "Weather station" -msgid "WeatherStation" -msgstr "气象站" - #: templates/cerealblotchmodels/septoriahumiditymodelform.html:53 #, fuzzy #| msgid "Spraying date" @@ -281,51 +277,62 @@ msgid "Number of consecutive 'humid hours'" msgstr "" #: templates/cerealblotchmodels/septoriahumiditymodelform.html:138 -msgid "Spraying protection period" +msgid "Spraying protection days" msgstr "" #: templates/cerealblotchmodels/septoriahumiditymodelform.html:143 msgid "Leaf life time (days)" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:303 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:350 #, fuzzy #| msgid "Model is running, please wait" msgid "The model is running, please wait" msgstr "模型在运行,请等候" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:320 -#, fuzzy -#| msgid "Temperature, daily mean" -msgid "Temperature, hourly mean" -msgstr "日均温" +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:369 +msgid "Leaf wetness, hourly" +msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:321 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:370 #, fuzzy #| msgid "Rain, daily" msgid "Rain, hourly" msgstr "日降雨" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:322 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:371 msgid "Relative humidity, hourly mean" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:323 -msgid "Leaf wetness, hourly" +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:372 +msgid "Humid hour (yes/no)" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:324 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:373 msgid "Humid period hour" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:325 -msgid "Humid hour (yes/no)" +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:374 +msgid "Humid hour sum" msgstr "" -#: templates/cerealblotchmodels/septoriahumiditymodelform.html:326 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:375 +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:433 msgid "Humid period hour outside protection period" msgstr "" +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:429 +msgid "Hours" +msgstr "" + +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:434 +msgid "Threshold humid period" +msgstr "" + +#: templates/cerealblotchmodels/septoriahumiditymodelform.html:435 +msgid "Spraying protection period" +msgstr "" + #: templates/cerealblotchmodels/wheatleafblotchform.html:25 #: templates/cerealblotchmodels/wheatleafblotchform.html:34 msgid "Wheat leaf blotch" @@ -337,6 +344,16 @@ msgstr "" msgid "Background data for the wheat leaf blotch model" msgstr "大麦网斑病模型的背景数据" +#, fuzzy +#~| msgid "Weather station" +#~ msgid "WeatherStation" +#~ msgstr "气象站" + +#, fuzzy +#~| msgid "Temperature, daily mean" +#~ msgid "Temperature, hourly mean" +#~ msgstr "日均温" + #, fuzzy #~| msgid "Background data for the barley net blotch model" #~ msgid "Background data for the Septoria humidity model" diff --git a/cerealblotchmodels/templates/cerealblotchmodels/septoriahumiditymodelform.html b/cerealblotchmodels/templates/cerealblotchmodels/septoriahumiditymodelform.html index 40618e9dd12bec3f3af72e51240db903284012d7..8521ab64367e4fe3ffbea3bfea736000a2531f70 100644 --- a/cerealblotchmodels/templates/cerealblotchmodels/septoriahumiditymodelform.html +++ b/cerealblotchmodels/templates/cerealblotchmodels/septoriahumiditymodelform.html @@ -42,7 +42,7 @@ <span class="help-block" id="{{ form_id }}_organizationId_countryCode_validation"></span> </div> <div class="form-group"> - <label for="weatherStationId">{% trans "WeatherStation" %}</label> + <label for="weatherStationId">{% trans "Weather station" %}</label> <select name="weatherStationId" id="weatherStationId" class="form-control"> <option value="">{% trans "Please select" %}</option> <option value="test">TEST</option> @@ -135,7 +135,7 @@ <span class="help-block" id="{{ form_id }}_thresholdHumidPeriodHours_validation"></span> </div> <div class="form-group"> - <label for="sprayingProtectionDays">{% trans "Spraying protection period" %}</label> + <label for="sprayingProtectionDays">{% trans "Spraying protection days" %}</label> <input type="number" name="sprayingProtectionDays" class="form-control" value="10"/> <span class="help-block" id="{{ form_id }}_sprayingProtectionDays_validation"></span> </div> @@ -149,10 +149,15 @@ </div> <div class="row"> <div class="col-md-12 form-group"> - <button type="button" class="btn btn-primary" onclick="if(validateForm(document.getElementById('{{ form_id }}'))){runModel();}">{% trans "Run model" %}</button> + <button type="button" class="btn btn-primary" onclick="if(validateForm(document.getElementById('{{ form_id }}'))){storeUserSettings();runModel();}">{% trans "Run model" %}</button> </div> </div> </form> + + <div class="row"> + <div class="col-md-12" id="chartContainer" style="height:400px; display: none;"> + </div> + </div> <div class="row"> <div class="col-md-12"> <div class="table-responsive"> @@ -169,19 +174,54 @@ <script type="text/javascript" src="{% static "js/3rdparty/highcharts.js" %}"></script> <script type="text/javascript" src="{% static "js/util.js" %}"></script> <script type="text/javascript" src="{% static "js/validateForm.js" %}"></script> +<script type="text/javascript" src="{% static "forecasts/js/forecasts.js" %}"></script> <script type="text/javascript"> var danishPostCodesUTM; var organizations; var allowedCountryCodes = ["NO","DK","SE","FI","LT"]; + var formFields = [ + "organizationId_countryCode", + "weatherStationId", + "dateSpraying1", + "dateSpraying2", + "dateGs31", + "date3rdUpperLeafEmerging", + "date2ndUpperLeafEmerging", + "dateUpperLeafEmerging", + "dateGs75", + "thresholdRelativeHumidity", + "thresholdLeafWetness", + "thresholdPrecipitation", + "slidingHoursPast", + "slidingHoursAhead", + "thresholdHumidPeriodHours", + "sprayingProtectionDays", + "leafLifeTime" + ]; + + var specialFormFields = ["organizationId_countryCode","weatherStationId"]; // Must be initialized after a few events $(document).ready(function() { - initOrganizations(); + //initWeatherStations(); // Init form validation loadFormDefinition("{{ form_id }}","/static/cerealblotchmodels/formdefinitions/"); - initDanishPostCodesUTM(); - updateGSDates(); + initDanishPostCodesUTM(function(){ + initOrganizations(function(){ + var userSettings = getLocalSettings(getNameSpaced("{{ form_id }}",formFields), false); + if(!isDictEmpty(userSettings)) { + renderUserSettings(userSettings); + } + else + { + updateGSDates(); + } + }); + + }); + + }); - var initDanishPostCodesUTM = function(){ + var initDanishPostCodesUTM = function(callback){ $.ajax({ type:"GET", url: "{% static "cerealblotchmodels/weatherDataInfo/PostalCodesUTM.xml" %}", @@ -190,6 +230,7 @@ danishPostCodesUTM = Array.prototype.slice.call(data.getElementsByTagName("PostalCode"),0).sort(function(a,b){ return a.getElementsByTagName("CityName")[0].firstChild.nodeValue < b.getElementsByTagName("CityName")[0].firstChild.nodeValue ? -1 : 1; }); + callback(); }, 400: handleAjaxError, 401: handleAjaxError, @@ -199,7 +240,7 @@ }); }; - var initOrganizations = function(){ + var initOrganizations = function(callback){ $.ajax({ type:"GET", url: settings.vipslogicProtocol + "://" + settings.vipslogicServerName + "/rest/organization", @@ -219,6 +260,9 @@ } } } + renderUserSetting(orgSelect); + orgSelect.onchange(); + callback(); }, 400: handleAjaxError, 401: handleAjaxError, @@ -251,6 +295,7 @@ //console.info(opt); selectList.options[selectList.options.length] = opt; } + renderUserSetting(selectList); } else { @@ -267,7 +312,9 @@ var ws = data[i]; wsHTML.push("<option value=\"" + ws["pointOfInterestId"] + "\">" + ws["name"] + "</option>"); } - document.getElementById("weatherStationId").innerHTML = wsHTML.join(""); + var wsSelect = document.getElementById("weatherStationId"); + wsSelect.innerHTML = wsHTML.join(""); + renderUserSetting(wsSelect); }, 400: handleAjaxError, 401: handleAjaxError, @@ -299,6 +346,7 @@ } var runModel = function(){ + document.getElementById("chartContainer").style.display="none"; // Hide chart // Insert please wait message document.getElementById("resultsTable").innerHTML='<div class="alert alert-info" role="alert">{% trans "The model is running, please wait" %}</div>'; var formStr = $("#{{ form_id }}").serialize(); @@ -316,13 +364,15 @@ //console.log(formStr); } + var resultParameterOrdering = ["WEATHER.UM","WEATHER.RR","WEATHER.BT","SEPTORIAHU.HH","SEPTORIAHU.HPH","SEPTORIAHU.HHS","SEPTORIAHU.HPHPP"]; + var paramDict = { - "WEATHER.TM": "{% trans "Temperature, hourly mean" %}", + "WEATHER.BT" : "{% trans "Leaf wetness, hourly" %}", "WEATHER.RR" : "{% trans "Rain, hourly" %}", "WEATHER.UM": "{% trans "Relative humidity, hourly mean" %}", - "WEATHER.BT" : "{% trans "Leaf wetness, hourly" %}", - "SEPTORIAHU.HPH" : "{% trans "Humid period hour" %}", "SEPTORIAHU.HH" : "{% trans "Humid hour (yes/no)" %}", + "SEPTORIAHU.HPH" : "{% trans "Humid period hour" %}", + "SEPTORIAHU.HHS" : "{% trans "Humid hour sum" %}", "SEPTORIAHU.HPHPP" : "{% trans "Humid period hour outside protection period" %}" }; @@ -333,10 +383,9 @@ var headingLine = "<tr><td style=\"font-weight: bold;\">{% trans "Time" %}</td>"; if(data.length > 0) { - var allKeys = JSON.parse(data[0].keys); - for(var i=0;i<allKeys.length;i++) + for(var i in paramDict) { - headingLine +="<td style=\"font-weight: bold;\">" + paramDict[allKeys[i]] + "</td>"; + headingLine +="<td style=\"font-weight: bold;\">" + paramDict[i] + "</td>"; } headingLine +="<td style=\"font-weight: bold;\">{% trans "Warning status" %}</td>"; headingLine += "</tr>"; @@ -350,9 +399,9 @@ } var resultLine = "<tr><td>" + moment(data[row]["validTimeStart"]).format("YYYY-MM-DD HH:mm") + "</td>"; var allValues = JSON.parse(data[row].allValues); - for(var i in allKeys) + for(var i in paramDict) { - var value = allValues[allKeys[i]]; + var value = allValues[i]; if(value != null && $.isNumeric(value)) { value = parseFloat(value).toFixed(2); @@ -369,10 +418,72 @@ table.push("</table>"); document.getElementById("resultsTable").innerHTML=table.join(""); } + + // Then: The chart + // We must sort data ascending again + document.getElementById("chartContainer").style.display="block"; + data.reverse(); + var warningStatusPlotBandData = getWarningStatusPlotBandData(data); + //console.log(warningStatusPlotBandData); + var data = getHighChartsSeries( + data, + [ + {"color": "#6600FF", "opposite": false, "abbr": " ", "title": "{% trans "Hours" %}"}, + {min: 0, max: 1.5, visible: false} + ], + [ + {key: "SEPTORIAHU.HPHPP", type: "spline", color: "black", name: "{% trans "Humid period hour outside protection period" %}", yAxis: 0}, + {key: "SEPTORIAHU.THPHPP", type: "spline", color: "red", name: "{% trans "Threshold humid period" %}", yAxis: 0}, + {key: "SEPTORIAHU.SPP", type: "spline", lineWidth: 5, color: "blue", name: "{% trans "Spraying protection period" %}", yAxis: 1}, + ] + ); + renderForecastChart("chartContainer", "{% trans "Barley net blotch development" %}", warningStatusPlotBandData, data); } var handleAjaxError = function(jqXHR,textStatus,errorThrown){ alert(textStatus); }; + + var renderUserSettings = function(userSettings){ + // Strip namespace from form field + var theForm = document.getElementById('{{ form_id }}'); + for(var i in userSettings){ + var fieldName = i.substring("{{form_id}}.".length); + if(specialFormFields.indexOf(fieldName) < 0){ + theForm[fieldName].value = userSettings[i]; + } + } + }; + + var renderUserSetting = function(formField) + { + var localStorageKey = "{{form_id}}." + formField.name; + + var locallyStoredValue = getLocalSettings([localStorageKey]) != null ? getLocalSettings([localStorageKey])[localStorageKey] : null; + if(locallyStoredValue != null) + { + formField.value = locallyStoredValue; + } + } + + var getNameSpaced = function(nameSpace, anArray){ + var retVal = []; + for(var i = 0; i<anArray.length;i++) + { + retVal.push(nameSpace + "." + anArray[i]); + } + return retVal; + }; + + var storeUserSettings = function(){ + var theForm = document.getElementById('{{ form_id }}'); + var settingsDict = {} + for(var i in formFields) + { + // Need to add the formId as namespace to avoid confusion in Local Storage + settingsDict["{{ form_id }}" + "." + formFields[i]] = theForm[formFields[i]].value; + } + storeLocalSettings(settingsDict); + }; </script> {% endblock %} \ No newline at end of file diff --git a/forecasts/static/forecasts/js/forecasts.js b/forecasts/static/forecasts/js/forecasts.js index 0753c1aed6834b104208f727c51a0bf8e5345d78..4358c0d04a2c1190ed929318f1234bfa6bcd3876 100755 --- a/forecasts/static/forecasts/js/forecasts.js +++ b/forecasts/static/forecasts/js/forecasts.js @@ -275,7 +275,7 @@ function getWarningStatusPlotBandData(forecastResults) if(plotBand != null && plotBand["to"] == null) { // Moment.js!!! - plotBand.to = getUnixTimestampFromJSONforecastResults([forecastResults.length -1]["validTimeStart"]) + bandOffset; + plotBand.to = getUnixTimestampFromJSON([forecastResults.length -1]["validTimeStart"]) + bandOffset; plotBands.push(plotBand); } @@ -298,7 +298,8 @@ function getHighChartsSeries(forecastResults, yAxisList, parameterList) name: parameter.name, showInLegend: (parameter.showInLegend === undefined || parameter.showInLegend === null || parameter.showInLegend === true), color: parameter.color, - yAxis: parameter.yAxis + yAxis: parameter.yAxis, + lineWidth: parameter.lineWidth !== undefined ? parameter.lineWidth: 2 }; }