Commit 64f76d5b authored by Pierre Dittgen's avatar Pierre Dittgen

Affichage des données avec les erreurs

parent c100e2ac
<p class="text">
Affichage de {{ preview.rows_nb }} lignes sur {{ preview.total_rows_nb }} au total
Affichage de {{ source_data.preview_rows_nb }} lignes sur {{ source_data.rows_nb }} au total
</p>
<div class="table-responsive">
<table class="table table-striped table-bordered table-sm table-hover">
<thead class="thead-light">
<tr>
{% for col in preview.header %}
{% for col in source_data.header %}
<th scope="col">{{ col }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in preview.data_rows %}
{% for row in source_data.data_rows %}
<tr>
{% for val in row %}
<td>{{ val }}</td>
......
......@@ -35,7 +35,7 @@
<!-- table checks -->
<div>
<h4>Erreurs de table</h4>
<h3>Erreurs de table</h3>
<ul>
{% for err in report['tables'][0]['errors'] %}
{% if err.context == 'table' or err.context == 'head' %}
......@@ -49,12 +49,13 @@
<!-- row checks -->
<div>
<h4>Erreurs de valeurs</h4>
<h3>Erreurs de valeurs</h3>
{% for err in report['tables'][0]['errors'] %}
{% if err.context == 'body' %}
<table>
<table class="table-sm table-bordered table-striped table-hover">
<thead>
<th>#</th>
{% for h in report['tables'][0]['headers'] %}
......@@ -62,16 +63,16 @@
{% endfor %}
</thead>
<!-- TODO: regrouper les erreurs par ligne ? -->
<!-- Récupérer les valeurs de la ligne à partir de tabulator -->
<tbody>
<tr>
<td>{{ err['row-number'] }}</td>
<td colspan="{{report['tables'][0]['headers']|length}}">
valeurs à afficher ici avec des couleurs pour souligner les cases en faute !!!
</td>
<td>{{ err['row-number'] - 1 }}</td>
{% for d in source_data.data_rows[err['row-number'] - 2] %}
<td>{{ d }}</td>
{% endfor %}
</tr>
</tbody>
</table>
<p class="text">{{ err.message }}</p>
{% endif %}
{% endfor %}
......@@ -79,10 +80,11 @@
</div>
<!--
<pre>
<!-- {{ report_str }} -->
{{ report_str }}
</pre>
-->
{% endif %}
{% endblock %}
......
......@@ -15,7 +15,7 @@ from flask import Flask, jsonify, redirect, render_template, request, url_for
import tabulator
def compute_source_preview(source, max_rows=5):
def extract_source_data(source, preview_rows_nb=5):
""" Computes table preview """
header = None
rows = []
......@@ -25,10 +25,12 @@ def compute_source_preview(source, max_rows=5):
if header is None:
header = row
else:
rows.append(row)
nb_rows += 1
if len(rows) <= max_rows:
rows.append(row)
return {'header': header, 'data_rows': rows, 'total_rows_nb': nb_rows, 'rows_nb': len(rows)}
return {'header': header,
'data_rows': rows,
'rows_nb': nb_rows,
'preview_rows_nb': min(preview_rows_nb, nb_rows)}
ERR_CODE_TO_CONTEXT = dict([
......@@ -84,13 +86,13 @@ def validate(schema_code, source, source_type):
report = ValidatorHelper.validate(schema_code, source, source_type)
report = contextualize(report)
preview = compute_source_preview(source)
source_data = extract_source_data(source)
# Complete report
val_info = ValidatorHelper.schema_info(schema_code)
return render_template('validation_report.html', title='Rapport de validation',
val_info=ValidatorHelper.schema_info(schema_code), report=report,
source=source, source_type=source_type, preview=preview,
source=source, source_type=source_type, source_data=source_data,
report_str=json.dumps(report, sort_keys=True, indent=2),
breadcrumbs=[{'url': url_for('home'), 'title': 'Accueil'},
{'url': url_for('scdl_validator', val_code=schema_code), 'title': val_info['title']}])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment