Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Validata
validata-ui
Commits
64f76d5b
Commit
64f76d5b
authored
Sep 28, 2018
by
Pierre Dittgen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Affichage des données avec les erreurs
parent
c100e2ac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
19 deletions
+23
-19
validata_ui_next/templates/table_preview.html
validata_ui_next/templates/table_preview.html
+3
-3
validata_ui_next/templates/validation_report.html
validata_ui_next/templates/validation_report.html
+12
-10
validata_ui_next/views.py
validata_ui_next/views.py
+8
-6
No files found.
validata_ui_next/templates/table_preview.html
View file @
64f76d5b
<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>
...
...
validata_ui_next/templates/validation_report.html
View file @
64f76d5b
...
...
@@ -35,7 +35,7 @@
<!-- table checks -->
<div>
<h
4
>
Erreurs de table
</h
4
>
<h
3
>
Erreurs de table
</h
3
>
<ul>
{% for err in report['tables'][0]['errors'] %}
{% if err.context == 'table' or err.context == 'head' %}
...
...
@@ -49,12 +49,13 @@
<!-- row checks -->
<div>
<h
4
>
Erreurs de valeurs
</h
4
>
<h
3
>
Erreurs de valeurs
</h
3
>
{% 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]['head
er
s
']
|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-numb
er']
- 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 %}
...
...
validata_ui_next/views.py
View file @
64f76d5b
...
...
@@ -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'
]}])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment