diff --git a/caimira/apps/calculator/__init__.py b/caimira/apps/calculator/__init__.py index 8399bd9d..54b641fe 100644 --- a/caimira/apps/calculator/__init__.py +++ b/caimira/apps/calculator/__init__.py @@ -122,6 +122,9 @@ class ConcentrationModel(BaseRequestHandler): max_workers=self.settings['handler_worker_pool_size'], timeout=300, ) + # Re-generate the report with the conditional probability of infection plot + if self.get_cookie('conditional_plot'): + form.conditional_probability_plot = True if self.get_cookie('conditional_plot') == '1' else False report_task = executor.submit( report_generator.build_report, base_url, form, executor_factory=functools.partial( diff --git a/caimira/apps/calculator/static/js/report.js b/caimira/apps/calculator/static/js/report.js index 511958ae..df7cfbb9 100644 --- a/caimira/apps/calculator/static/js/report.js +++ b/caimira/apps/calculator/static/js/report.js @@ -1,3 +1,8 @@ +function on_report_load(conditional_probability_plot) { + // Check/uncheck uncertainties image generation + document.getElementById('conditional_probability_plot').checked = conditional_probability_plot +} + /* Generate the concentration plot using d3 library. */ function draw_plot(svg_id) { @@ -1069,6 +1074,20 @@ function display_rename_column(bool, id) { else document.getElementById(id).style.display = 'none'; } +function conditional_probability_plot(value, is_generated) { + // If the image was previously generated, there is no need to reload the page. + if (value && is_generated == 1) { + document.getElementById('conditional_probability_div').style.display = 'block' + } + else if (value && is_generated == 0) { + document.getElementById('label_conditional_probability_plot').innerHTML = `Loading...`; + document.getElementById('conditional_probability_plot').setAttribute('disabled', true); + window.location.reload(); + } + else document.getElementById('conditional_probability_div').style.display = "none"; + document.cookie = `conditional_plot= ${+value}; path=/`; +} + function export_csv() { // This function generates a CSV file according to the user's input. // It is composed of a list of lists. diff --git a/caimira/apps/templates/base/calculator.form.html.j2 b/caimira/apps/templates/base/calculator.form.html.j2 index 00dd2a37..576cf535 100644 --- a/caimira/apps/templates/base/calculator.form.html.j2 +++ b/caimira/apps/templates/base/calculator.form.html.j2 @@ -400,15 +400,14 @@ -
- - +
+
diff --git a/caimira/apps/templates/base/calculator.report.html.j2 b/caimira/apps/templates/base/calculator.report.html.j2 index ed5c5cc5..5e640393 100644 --- a/caimira/apps/templates/base/calculator.report.html.j2 +++ b/caimira/apps/templates/base/calculator.report.html.j2 @@ -15,7 +15,7 @@ - +