From c2415576c946325a9ba5b33195c6211d3f2c38f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Sun, 28 May 2023 23:14:14 +0200 Subject: [PATCH] Add excel to report --- benchmark/scripts/be_flask.py | 1 + .../scripts/templates/partials/js_report.js | 20 ++++++++++++++++++- .../partials/table_report_bootstrap.html | 3 +++ .../partials/table_report_bulma.html | 3 +++ benchmark/scripts/templates/report.html | 4 +++- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/benchmark/scripts/be_flask.py b/benchmark/scripts/be_flask.py index 9af9c83..e42342e 100755 --- a/benchmark/scripts/be_flask.py +++ b/benchmark/scripts/be_flask.py @@ -67,6 +67,7 @@ def show(): return render_template( "report.html", data=data, + file=selected_file, summary=summary, framework=app.config[FRAMEWORK], ) diff --git a/benchmark/scripts/templates/partials/js_report.js b/benchmark/scripts/templates/partials/js_report.js index 4cbe71e..de7d2cb 100644 --- a/benchmark/scripts/templates/partials/js_report.js +++ b/benchmark/scripts/templates/partials/js_report.js @@ -8,4 +8,22 @@ $(document).ready(function () { $(this).addClass('{{ selected }}'); } }); - }); \ No newline at end of file + }); + function excelFile() { + var selectedFiles = ["{{ file }}"]; + // send data to server with ajax post + $.ajax({ + type:'POST', + url:'/excel', + data: JSON.stringify(selectedFiles), + contentType: "application/json", + dataType: 'json', + success: function(data){ + alert("Se ha generado el archivo "+data.file); + }, + error: function (xhr, ajaxOptions, thrownError) { + var mensaje = JSON.parse(xhr.responseText || '{\"mensaje\": \"Error indeterminado\"}'); + alert(mensaje.mensaje); + } + }); +} \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_report_bootstrap.html b/benchmark/scripts/templates/partials/table_report_bootstrap.html index c434c5d..f88210d 100644 --- a/benchmark/scripts/templates/partials/table_report_bootstrap.html +++ b/benchmark/scripts/templates/partials/table_report_bootstrap.html @@ -79,6 +79,9 @@ Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} Number of files: {{ data.results | length }} +
+ +
\ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_report_bulma.html b/benchmark/scripts/templates/partials/table_report_bulma.html index f126a8d..3b2c556 100644 --- a/benchmark/scripts/templates/partials/table_report_bulma.html +++ b/benchmark/scripts/templates/partials/table_report_bulma.html @@ -85,6 +85,9 @@ Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }}

Number of files: {{ data.results | length }}

+
+ +
\ No newline at end of file diff --git a/benchmark/scripts/templates/report.html b/benchmark/scripts/templates/report.html index 50d768c..6ab0303 100644 --- a/benchmark/scripts/templates/report.html +++ b/benchmark/scripts/templates/report.html @@ -4,10 +4,12 @@ {% if framework == "bootstrap" %} {% set center = "text-center" %} {% set right = "text-end" %} - {% include "partials/table_report_bootstrap.html" %} + {% set button = "btn btn-primary" %} + {% include "partials/table_report_bootstrap.html" %} {% else %} {% set center = "has-text-centered" %} {% set right = "has-text-right" %} + {% set button = "button is-primary" %} {% include "partials/table_report_bulma.html" %} {% endif %} {% endblock %}