validation_report.html 5.24 KB
Newer Older
1
{% extends "base_template.html" %}
2
3
4

{% import 'schema_info_part.html' as schema_info_part %}

5
{% block title %}{{ title }}{% endblock %}
6

7
8
{% block head %}
{{ super() }}
Pierre Dittgen's avatar
Pierre Dittgen committed
9
<style>
Pierre Dittgen's avatar
Pierre Dittgen committed
10
11
12
13
14
15
16
17
18
19
20
21
  .popover .popover-body h2 {
    font-size: 1.2em;
    font-weight: bold;
  }
  #table-errors td h2 {
    font-size: 1em;
    font-weight: bold;
  }

  @media print {
    .hidden-print {
      display: none;
22
    }
Pierre Dittgen's avatar
Pierre Dittgen committed
23
  }
Pierre Dittgen's avatar
Pierre Dittgen committed
24
</style>
25
{% endblock %}
26

27
{% block content %}
28
{% if print_mode %}
Pierre Dittgen's avatar
Pierre Dittgen committed
29
<div class="row">
30
    <div class="col-md-5">
Pierre Dittgen's avatar
Pierre Dittgen committed
31
{% endif %}
Christophe Benz's avatar
Christophe Benz committed
32
        <h1 class="my-4">{{ title }}</h1>
Christophe Benz's avatar
Christophe Benz committed
33
        <p>Validation effectuée {{ validation_date }}</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
34
        <p><img src="{{ badge_url }}" alt="{{ badge_msg }}" title="{{ badge_msg }}"/></p>
Pierre Dittgen's avatar
Pierre Dittgen committed
35
{% if print_mode %}
36
37
38
39
40
41
42
    </div>
    <div class="col-md-7">
        <img src="{{ url_for('static', filename='img/logo-horizontal.png') }}" height="80" alt="Validata" />
    </div>
</div>
{% endif %}
{% if source.type == 'url' %}
Christophe Benz's avatar
Christophe Benz committed
43
<p class="hidden-print">
44
    <a href="{{ pdf_report_url }}&url={{source.name|urlencode}}" target="_blank">
Christophe Benz's avatar
Christophe Benz committed
45
46
47
        Télécharger en PDF
    </a>
</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
48
{% endif %}
49
50
51
52
    {# Schema info #}
    <div class="row">
        <div class="col-md-{% if print_mode %}12{% else %}5{% endif %} my-4">
            <div class="card bg-faded">
Christophe Benz's avatar
Christophe Benz committed
53
                <div class="card-body">
Pierre Dittgen's avatar
Pierre Dittgen committed
54
                    {{ schema_info_part.html(schema_info, schema_versions, schema_current_version) }}
55
                    <hr />
Christophe Benz's avatar
Christophe Benz committed
56
                    <div>
Pierre Dittgen's avatar
Pierre Dittgen committed
57
58
59
                        <h5 class="card-title">
                            Fichier traité
                        </h5>
Pierre Dittgen's avatar
Pierre Dittgen committed
60
61
                        {% if source.type == 'file' %}
                            {{ source.filename }}
62
                        {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
63
64
65
                        {% if source.type == 'url' %}
                            <a href="{{source.url}}" target="_blank">
                                {{source.url}}
Christophe Benz's avatar
Christophe Benz committed
66
                            </a>
67
68
                        {% endif %}
                        <br />
Christophe Benz's avatar
Christophe Benz committed
69
70
                        Dimensions : {{ report.table.col_count }} colonnes et {{ report.table.row_count }} lignes
                    </div>
71
                </div>
Pierre Dittgen's avatar
Pierre Dittgen committed
72
73
            </div>
        </div>
74
75
    </div>

Pierre Dittgen's avatar
Pierre Dittgen committed
76
    {% import 'validation_macros.html' as macros %}
Pierre Dittgen's avatar
Pierre Dittgen committed
77

78
79
80
    {% if report.error_count == 0 %}
    <h2>La table est valide</h2>
    <p>Aucune erreur détectée</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
81

Pierre Dittgen's avatar
Pierre Dittgen committed
82
    {{ macros.preview(source_data) }}
Pierre Dittgen's avatar
Pierre Dittgen committed
83

84
    {% else %}
Pierre Dittgen's avatar
Pierre Dittgen committed
85

86
    <h2>La table est invalide</h2>
Pierre Dittgen's avatar
Pierre Dittgen committed
87

Pierre Dittgen's avatar
Pierre Dittgen committed
88
89
90
91
92
93
94
95
    <p>
        {% set error_count = report.table['error-stats']['count'] %}
        {% if error_count == 1 %}
        1 erreur détectée.
        {% else %}
        {{ error_count }} erreurs détectées.
        {% endif %}
    </p>
Pierre Dittgen's avatar
Pierre Dittgen committed
96

Pierre Dittgen's avatar
Pierre Dittgen committed
97
    {{ macros.error_statistics(report) }}
Pierre Dittgen's avatar
Pierre Dittgen committed
98

Pierre Dittgen's avatar
Pierre Dittgen committed
99

Pierre Dittgen's avatar
Pierre Dittgen committed
100
    {% if report.table.errors.structure %}
Pierre Dittgen's avatar
Pierre Dittgen committed
101
        <h3>Erreurs de structure</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
        {# Non-column errors #}
        {% for err in report.table.errors.structure %}
            {% if not err.in_column_comp %}
                {{ err.content | safe }}
            {% endif %}
        {% endfor %}

        {# Column errors #}
        {% for err in report.table.errors.structure %}
            {% if err.in_column_comp %}
                {{ err.content | safe }}
            {% endif %}
        {% endfor %}


        {# Afficher un tableau de comparaison des colonnes #}
        {% if report.table.column_comparison_needed %}
Christophe Benz's avatar
Christophe Benz committed
119
        <table class="table table-bordered table-sm table-striped table-hover">
Pierre Dittgen's avatar
Pierre Dittgen committed
120
121
122
            <thead class="thead-light">
                <tr>
                    <th scope="col">Colonnes du fichier</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
123
                    <th scope="col">Colonnes attendues</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
124
125
126
                </tr>
            </thead>
            <tbody>
127
                {% for elt in report.table.column_comparison_info.table %}
Pierre Dittgen's avatar
Pierre Dittgen committed
128
                    <tr{% if elt[2] == 'ko' %} class="table-danger"{% endif %}>
Pierre Dittgen's avatar
Pierre Dittgen committed
129
130
                        <td>{{ elt[0] }}</td>
                        <td>{{ elt[1] }}</td>
Pierre Dittgen's avatar
Pierre Dittgen committed
131
132
133
134
                    </tr>
                {% endfor %}
            </tbody>
        </table>
135
        {% if report.table.column_comparison_info.has_missing %}
Pierre Dittgen's avatar
Pierre Dittgen committed
136
        <p>Attention : toutes les colonnes attendues doivent être présentes dans le fichier à valider.<p>
137
138
139
140
        {% endif %}
        {% if report.table.column_comparison_info.has_case_errors %}
        <p>Attention : la casse (minuscules/majuscules) doit être respectée dans les noms de colonne.<p>
        {% endif %}
Christophe Benz's avatar
Christophe Benz committed
141

142
        {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
143
    {% endif %}
144

Pierre Dittgen's avatar
Pierre Dittgen committed
145
146
    {# We do display body errors! #}
    {% if report.table.do_display_body_errors %}
Pierre Dittgen's avatar
Pierre Dittgen committed
147
    <h3>Erreurs de contenu</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
148
149

    {# No errors - display preview #}
150
    {% if not report.table.errors.body %}
Christophe Benz's avatar
Christophe Benz committed
151
    <p>
152
153
        Aucune erreur de contenu
    </p>
Pierre Dittgen's avatar
Pierre Dittgen committed
154
    {{ macros.preview(source_data) }}
Christophe Benz's avatar
Christophe Benz committed
155

Pierre Dittgen's avatar
Pierre Dittgen committed
156
    {% else %}
157

Pierre Dittgen's avatar
Pierre Dittgen committed
158
    {# display errors #}
Pierre Dittgen's avatar
Pierre Dittgen committed
159
    {{ macros.body_errors(report, source_data, print_mode) }}
Christophe Benz's avatar
Christophe Benz committed
160

161
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
162

Pierre Dittgen's avatar
Pierre Dittgen committed
163
164
    {# do not display errors #}
    {% else %}
Christophe Benz's avatar
Christophe Benz committed
165
    <p>
Pierre Dittgen's avatar
Pierre Dittgen committed
166
        Veuillez corriger ces erreurs pour visualiser les éventuelles erreurs de contenu.
167
168
    </p>
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
169
    {% endif %}
170
171
172


    {% endblock %}
Pierre Dittgen's avatar
Pierre Dittgen committed
173

Christophe Benz's avatar
Christophe Benz committed
174
{% block page_scripts %}
175
176
177
178
{% if schema_versions %}
{{ schema_info_part.script() }}
{% endif %}

Christophe Benz's avatar
Christophe Benz committed
179
180
<script>
$(function() {
Pierre Dittgen's avatar
Pierre Dittgen committed
181
182
183
184
185
186
    // Errors tooltip activate
    $('[data-toggle="popover"]').popover({
      html: true,
      placement: "auto",
      trigger: "hover"
    });
Christophe Benz's avatar
Christophe Benz committed
187
});
Pierre Dittgen's avatar
Pierre Dittgen committed
188
</script>
Christophe Benz's avatar
Christophe Benz committed
189
{% endblock %}