added incidence rate from API to UI

This commit is contained in:
Luis Aleixo 2022-10-12 16:49:42 +02:00
parent 917567c5df
commit 1a93439984
3 changed files with 27 additions and 2 deletions

View file

@ -418,6 +418,19 @@ function show_sensors_data(url) {
}
};
function geographic_cases(location_country_name) {
$.ajax({
url: `${$('#url_prefix').data().calculator_prefix}/cases/${location_country_name}`,
type: 'GET',
success: function (result) {
$('#geographic_cases').val(result);
},
error: function(_, _, errorThrown) {
console.log(errorThrown);
}
});
}
$("#sensors").change(function (el) {
sensor_id = DATA_FROM_SENSORS.findIndex(function(sensor) {
return sensor.RoomId == el.target.value
@ -930,6 +943,9 @@ $(document).ready(function () {
}
}
// Update geographic_cases
geographic_cases('CHE');
// When the document is ready, deal with the fact that we may be here
// as a result of a forward/back browser action. If that is the case, update
// the visibility of some of our inputs.
@ -1120,9 +1136,12 @@ $(document).ready(function () {
success: function (locations) {
// If there isn't precisely one result something is very wrong.
geocoded_loc = locations.candidates[0];
$('input[name="location_name"]').val(selectedSuggestion.text);
$('input[name="location_latitude"]').val(geocoded_loc.location.y.toPrecision(7));
$('input[name="location_longitude"]').val(geocoded_loc.location.x.toPrecision(7));
// Update geographic_cases
geographic_cases(geocoded_loc.attributes['country']);
}
});

View file

@ -386,8 +386,13 @@
<div class="col-sm-6 pl-0 align-self-center"><input type="number" step="any" id="geographic_population" class="non_zero form-control" name="geographic_population" placeholder="Inhabitants (#)" min="0"></div>
</div>
<div class="form-group row">
<div class="col-sm-4"><label class="col-form-label">New confirmed cases (weekly):</label></div>
<div class="col-sm-6 pl-0 align-self-center"><input type="number" step="any" id="geographic_cases" class="non_zero form-control" name="geographic_cases" placeholder="Cases (#7-day rolling avg)" min="0"></div>
<div class="col-sm-4"><label class="col-form-label pt-0">New confirmed cases (weekly):</label></div>
<div class="col-sm-6 pl-0 pt-1 align-self-center">
<input type="number" step="any" id="geographic_cases" class="non_zero form-control" name="geographic_cases" placeholder="Cases (#7-day rolling avg)" min="0">
<small class="form-text text-muted">
Source: World Health Organization.
</small>
</div>
</div>
<div class="form-group row">
<div class="col-sm-4"><label class="col-form-label">Confidence level:</label></div>

View file

@ -28,6 +28,7 @@ REQUIREMENTS: dict = {
'memoization',
'mistune',
'numpy',
'pandas',
'psutil',
'python-dateutil',
'retry',