Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSWeb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
VIPSWeb
Commits
35dd76aa
Commit
35dd76aa
authored
1 year ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Add input checks
parent
eeb24cb5
No related branches found
No related tags found
2 merge requests
!17
Saddlegallmidge form idec 372
,
!12
feat: Add test page (spatial) with mapserver layer in openlayers map
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ipmd/templates/ipmd/saddlegallmidgeform.html
+57
-6
57 additions, 6 deletions
ipmd/templates/ipmd/saddlegallmidgeform.html
with
57 additions
and
6 deletions
ipmd/templates/ipmd/saddlegallmidgeform.html
+
57
−
6
View file @
35dd76aa
...
...
@@ -68,7 +68,7 @@
</div>
<div
class=
"col-md-6"
><div
id=
"forecastDatasourceMap"
></div></div>
</div>
<button
class=
"btn btn-primary"
type=
"button"
onclick=
"submitData();"
>
Submit
</button>
<button
class=
"btn btn-primary"
type=
"button"
onclick=
"submitData();"
>
Run
</button>
<div
style=
"aspect-ratio: 2;"
>
<canvas
id=
"resultChart"
></canvas>
</div>
...
...
@@ -168,8 +168,8 @@
// TODO: Remove this auto-mock!!
/*editor.getValue().optionalData.startDate="2023-08-01";
editor.getValue().optionalData.endDate="2023-0
8
-1
9
";
document.getElementById("longitude").value="11.781989";
editor.getValue().optionalData.endDate="2023-0
9
-1
6
";
/*
document.getElementById("longitude").value="11.781989";
document.getElementById("latitude").value="59.680468";*/
//submitData();
}
...
...
@@ -356,7 +356,13 @@
*/
function
getLatLon
()
{
return
[
document
.
getElementById
(
"
longitude
"
).
value
,
document
.
getElementById
(
"
latitude
"
).
value
];
let
lon
=
document
.
getElementById
(
"
longitude
"
).
value
;
let
lat
=
document
.
getElementById
(
"
latitude
"
).
value
;
if
(
!
isEmpty
(
lon
)
&&
!
isEmpty
(
lat
))
{
return
[
lon
,
lat
];
}
else
return
null
;
}
/**
...
...
@@ -364,7 +370,27 @@
* Also collects weather data (which goes into the input data Json)
*/
async
function
submitData
(){
// Input validation
const
errors
=
editor
.
validate
();
if
(
errors
.
length
)
{
console
.
log
(
errors
);
alert
(
"
Input data errors. Please check your browser's error log. (TODO: improve this message!!)
"
)
return
;
}
let
inputData
=
editor
.
getValue
();
/*
The saddle gall midge model input_data schema does not require the dates to be set,
so we must check manually
*/
if
(
isEmpty
(
inputData
.
optionalData
.
startDate
)
||
isEmpty
(
inputData
.
optionalData
.
endDate
))
{
alert
(
"
ERROR: Your start and/or end date is not set.
"
);
return
;
}
// Add hidden parameters
let
fullSchema
=
JSON
.
parse
(
currentModelMetaData
[
"
execution
"
][
"
input_schema
"
]);
const
hiddenParameters
=
currentModelMetaData
[
"
execution
"
][
"
input_schema_categories
"
][
"
hidden
"
];
...
...
@@ -376,6 +402,12 @@
// Check for weatherData element. Assuming it's at the root node
if
(
fullSchema
[
"
properties
"
][
"
weatherData
"
]
!==
undefined
)
{
// Input check
if
(
currentWeatherDatasource
==
undefined
&&
currentForecastWeatherDatasource
==
undefined
)
{
alert
(
"
ERROR: No weather datasource(s) selected
"
);
return
;
}
let
forecastData
=
undefined
;
// 1. Historic weather data
if
(
currentWeatherDatasource
!=
undefined
)
...
...
@@ -384,6 +416,13 @@
{
let
weatherStationId
=
selectList
.
options
[
selectList
.
selectedIndex
].
value
;
// Input check: Is a weather station selected?
if
(
weatherStationId
==
"
-1
"
)
{
alert
(
"
ERROR: No weather station has been selected
"
);
return
;
}
weatherData
=
await
getStationWeatherData
(
getWeatherDatasourceEndpoint
(
currentWeatherDatasource
),
weatherStationId
,
...
...
@@ -406,6 +445,11 @@
else
{
coordinate
=
getLatLon
();
if
(
coordinate
==
null
)
{
alert
(
"
ERROR: Your location is not set
"
);
return
;
}
// Need to check that the selected datasource covers the requested location
if
(
!
await
isPointCoveredByDatasource
(
coordinate
,
currentWeatherDatasource
))
{
...
...
@@ -436,6 +480,13 @@
// 2. Forecast weather data
if
(
currentForecastWeatherDatasource
!=
undefined
)
{
coordinate
=
getLatLon
();
if
(
coordinate
==
null
)
{
alert
(
"
ERROR: Your location is not set
"
);
return
;
}
// Need to check that the selected datasource covers the requested location
if
(
!
await
isPointCoveredByDatasource
(
getLatLon
(),
currentForecastWeatherDatasource
))
{
...
...
@@ -444,8 +495,8 @@
}
forecastData
=
await
getLocationWeatherData
(
getWeatherDatasourceEndpoint
(
currentForecastWeatherDatasource
),
document
.
getElementById
(
"
longitude
"
).
value
,
document
.
getElementById
(
"
latitude
"
).
value
,
coordinate
[
0
]
,
coordinate
[
1
]
,
getPragmaticWeatherParameterList
(
function
(){
let
parameterList
=
[]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment