validation_report.html 5.93 KB
Newer Older
1
{% extends "base_template.html" %}
2 3 4
{% block title %}{{ title }}{% endblock %}
{% block head %}
{{ super() }}
Pierre Dittgen's avatar
Pierre Dittgen committed
5
<style>
Pierre Dittgen's avatar
Pierre Dittgen committed
6 7 8 9 10 11 12 13 14 15 16 17
  .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;
18
    }
Pierre Dittgen's avatar
Pierre Dittgen committed
19
  }
Pierre Dittgen's avatar
Pierre Dittgen committed
20
</style>
21 22
{% endblock %}
{% block content %}
23
{% if print_mode %}
Pierre Dittgen's avatar
Pierre Dittgen committed
24
<div class="row">
25
    <div class="col-md-5">
Pierre Dittgen's avatar
Pierre Dittgen committed
26
{% endif %}
Christophe Benz's avatar
Christophe Benz committed
27
        <h1 class="my-4">{{ title }}</h1>
Christophe Benz's avatar
Christophe Benz committed
28
        <p>Validation effectuée {{ validation_date }}</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
29
        <p><img src="{{ badge_url }}" alt="{{ badge_msg }}" title="{{ badge_msg }}"/></p>
Pierre Dittgen's avatar
Pierre Dittgen committed
30
{% if print_mode %}
31 32 33 34 35 36 37
    </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
38
<p class="hidden-print">
Pierre Dittgen's avatar
Pierre Dittgen committed
39
    <a href="{{ url_for('pdf_report') }}?schema={{schema_url|urlencode}}&url={{source.name|urlencode}}" target="_blank">
Christophe Benz's avatar
Christophe Benz committed
40 41 42
        Télécharger en PDF
    </a>
</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
43
{% endif %}
44 45 46 47 48 49
    {# Schema info #}
    <div class="row">
        <div class="col-md-{% if print_mode %}12{% else %}5{% endif %} my-4">
            <div class="card bg-faded">
                <div class="card-body">
                    <h5 class="card-title">
Pierre Dittgen's avatar
Pierre Dittgen committed
50
                        Schéma
51 52 53 54
                        <span class="badge badge-primary">{{ val_info.version }}</span>
                    </h5>
                    <h6 class="card-subtitle mb-2 text-muted">{{ val_info.description }}</h6>
                    {% if val_info.author or val_info.contributor %}
Christophe Benz's avatar
Christophe Benz committed
55
                    <p>
56 57 58 59 60 61 62
                        {% if val_info.author %}
                        Auteur : {{ val_info.author }}
                        {% endif %}
                        {% if val_info.contributor %}
                        <br />Contributeur(s) : {{ val_info.contributor }}
                        {% endif %}
                    </p>
Pierre Dittgen's avatar
Pierre Dittgen committed
63
                    {% endif %}
64
                    <p>
Pierre Dittgen's avatar
Pierre Dittgen committed
65
                        <a href="{{ schema_url }}" target="_blank" class="card-link">{{ schema_url }}</a>
66 67
                    </p>
                    <hr />
Christophe Benz's avatar
Christophe Benz committed
68
                    <div>
Pierre Dittgen's avatar
Pierre Dittgen committed
69 70 71
                        <h5 class="card-title">
                            Fichier traité
                        </h5>
72
                        {% if source_type == 'file' %}
Christophe Benz's avatar
Christophe Benz committed
73
                            {{ source.name }}
74 75
                        {% endif %}
                        {% if source_type == 'url' %}
Christophe Benz's avatar
Christophe Benz committed
76
                            <a href="{{source.name}}" target="_blank">
77
                                {{source.name}}
Christophe Benz's avatar
Christophe Benz committed
78
                            </a>
79 80
                        {% endif %}
                        <br />
Christophe Benz's avatar
Christophe Benz committed
81 82
                        Dimensions : {{ report.table.col_count }} colonnes et {{ report.table.row_count }} lignes
                    </div>
83
                </div>
Pierre Dittgen's avatar
Pierre Dittgen committed
84 85
            </div>
        </div>
86 87
    </div>

Pierre Dittgen's avatar
Pierre Dittgen committed
88
    {% import 'validation_macros.html' as macros %}
Pierre Dittgen's avatar
Pierre Dittgen committed
89

90 91 92
    {% 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
93

Pierre Dittgen's avatar
Pierre Dittgen committed
94
    {{ macros.preview(source_data) }}
Pierre Dittgen's avatar
Pierre Dittgen committed
95

96
    {% else %}
Pierre Dittgen's avatar
Pierre Dittgen committed
97

98
    <h2>La table est invalide</h2>
Pierre Dittgen's avatar
Pierre Dittgen committed
99

Pierre Dittgen's avatar
Pierre Dittgen committed
100 101 102 103 104 105 106 107
    <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
108

Pierre Dittgen's avatar
Pierre Dittgen committed
109
    {{ macros.error_statistics(report) }}
Pierre Dittgen's avatar
Pierre Dittgen committed
110

Pierre Dittgen's avatar
Pierre Dittgen committed
111

Pierre Dittgen's avatar
Pierre Dittgen committed
112
    {% if report.table.errors.structure %}
Pierre Dittgen's avatar
Pierre Dittgen committed
113
        <h3>Erreurs de structure</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
        {# 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
131
        <table class="table table-bordered table-sm table-striped table-hover">
Pierre Dittgen's avatar
Pierre Dittgen committed
132 133 134
            <thead class="thead-light">
                <tr>
                    <th scope="col">Colonnes du fichier</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
135
                    <th scope="col">Colonnes attendues</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
136 137 138
                </tr>
            </thead>
            <tbody>
139
                {% for elt in report.table.column_comparison_info.table %}
Pierre Dittgen's avatar
Pierre Dittgen committed
140
                    <tr{% if elt[2] == 'ko' %} class="table-danger"{% endif %}>
Pierre Dittgen's avatar
Pierre Dittgen committed
141 142
                        <td>{{ elt[0] }}</td>
                        <td>{{ elt[1] }}</td>
Pierre Dittgen's avatar
Pierre Dittgen committed
143 144 145 146
                    </tr>
                {% endfor %}
            </tbody>
        </table>
147
        {% if report.table.column_comparison_info.has_missing %}
Pierre Dittgen's avatar
Pierre Dittgen committed
148
        <p>Attention : toutes les colonnes attendues doivent être présentes dans le fichier à valider.<p>
149 150 151 152
        {% 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
153

154
        {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
155
    {% endif %}
156

Pierre Dittgen's avatar
Pierre Dittgen committed
157 158
    {# We do display body errors! #}
    {% if report.table.do_display_body_errors %}
Pierre Dittgen's avatar
Pierre Dittgen committed
159
    <h3>Erreurs de contenu</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
160 161

    {# No errors - display preview #}
162
    {% if not report.table.errors.body %}
Christophe Benz's avatar
Christophe Benz committed
163
    <p>
164 165
        Aucune erreur de contenu
    </p>
Pierre Dittgen's avatar
Pierre Dittgen committed
166
    {{ macros.preview(source_data) }}
Christophe Benz's avatar
Christophe Benz committed
167

Pierre Dittgen's avatar
Pierre Dittgen committed
168
    {% else %}
169

Pierre Dittgen's avatar
Pierre Dittgen committed
170
    {# display errors #}
Pierre Dittgen's avatar
Pierre Dittgen committed
171
    {{ macros.body_errors(report, source_data, print_mode) }}
Christophe Benz's avatar
Christophe Benz committed
172

173
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
174

Pierre Dittgen's avatar
Pierre Dittgen committed
175 176
    {# do not display errors #}
    {% else %}
Christophe Benz's avatar
Christophe Benz committed
177
    <p>
Pierre Dittgen's avatar
Pierre Dittgen committed
178
        Veuillez corriger ces erreurs pour visualiser les éventuelles erreurs de contenu.
179 180
    </p>
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
181
    {% endif %}
182 183 184


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

186 187
    {% block footer %}
    <script>
Pierre Dittgen's avatar
Pierre Dittgen committed
188 189 190 191 192 193 194 195 196
  $(function() {
    // Errors tooltip activate
    $('[data-toggle="popover"]').popover({
      html: true,
      placement: "auto",
      trigger: "hover"
    });
  });
</script>
197

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