validation_report.html 5.97 KB
Newer Older
1
{% extends "base_template.html" %}
2

Christophe Benz's avatar
Christophe Benz committed
3 4
{% import 'schema_info_macros.html' as schema_info_macros %}
{% import 'validation_macros.html' as macros %}
5

Christophe Benz's avatar
Christophe Benz committed
6
{% block title %}{{ section_title }} – {{ schema_info.title }}{% endblock %}
7

8 9
{% block head %}
{{ super() }}
Pierre Dittgen's avatar
Pierre Dittgen committed
10
<style>
Pierre Dittgen's avatar
Pierre Dittgen committed
11 12 13 14 15 16 17 18 19 20 21 22
  .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;
23
    }
Pierre Dittgen's avatar
Pierre Dittgen committed
24
  }
Pierre Dittgen's avatar
Pierre Dittgen committed
25
</style>
26
{% endblock %}
27

28
{% block content %}
29
<div class="container">
Christophe Benz's avatar
Christophe Benz committed
30

31
    <p class="text-muted">Validation effectuée {{ validation_date }}</p>
Christophe Benz's avatar
Christophe Benz committed
32

33 34 35 36 37 38 39
    {% if source.type == 'url' %}
    <p class="hidden-print">
        <a class="btn btn-outline-secondary" href="{{ pdf_report_url }}&url={{source.url|urlencode}}" target="_blank">
            Télécharger en PDF
        </a>
    </p>
    {% endif %}
Christophe Benz's avatar
Christophe Benz committed
40

41
    {# Schema info #}
Christophe Benz's avatar
Christophe Benz committed
42 43 44 45
    <div class="row my-4">
        <div class="col-lg-6 mb-4">
            <div class="card">
                <div class="card-body">
46
                    {{ schema_info_macros.html(schema_info, None, None, schema_current_version, doc_url) }}
Christophe Benz's avatar
Christophe Benz committed
47 48 49 50 51
                </div>
            </div>
        </div>
        <div class="col-lg-6">
            <div class="card">
Christophe Benz's avatar
Christophe Benz committed
52
                <div class="card-body">
Christophe Benz's avatar
Christophe Benz committed
53 54 55 56 57 58 59 60 61 62
                    <h2 class="card-title">
                        Fichier {% if report.error_count == 0 %}valide{% else %}invalide{% endif %}
                    </h2>

                    {% if display_badge %}
                    <p><img src="{{ badge_url }}" alt="{{ badge_msg }}" /></p>
                    {% endif %}

                    <p>
                        <code>
Pierre Dittgen's avatar
Pierre Dittgen committed
63 64
                        {% if source.type == 'file' %}
                            {{ source.filename }}
Christophe Benz's avatar
Christophe Benz committed
65 66
                        {% elif source.type == 'url' %}
                            <a href="{{source.url}}" target="_blank">{{source.filename}}</a>
67
                        {% endif %}
Christophe Benz's avatar
Christophe Benz committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
                        </code>
                        ({{ report.table.col_count }} colonnes × {{ report.table.row_count }} lignes)
                    </p>

                    {% if report.error_count == 0 %}
                    <p>Aucune erreur détectée</p>
                    {% else %}
                    {{ macros.error_statistics(report) }}
                    <p>
                        {% set error_count = report.table['error-stats']['count'] %}
                        Total :
                        {% if error_count == 1 %}
                        1 erreur détectée
                        {% else %}
                        {{ error_count }} erreurs détectées
83
                        {% endif %}
Christophe Benz's avatar
Christophe Benz committed
84 85
                    </p>
                    {% endif %}
86
                </div>
Pierre Dittgen's avatar
Pierre Dittgen committed
87 88
            </div>
        </div>
89 90
    </div>

91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
    {% if report.error_count > 0 %}
        {% if report.table.errors.structure %}
            <h3 class="my-4">Erreurs de structure</h3>
            {# 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 %}
                <table class="table table-bordered table-sm table-striped table-hover">
                    <thead class="thead-light">
                        <tr>
                            <th scope="col">Colonnes du fichier</th>
                            <th scope="col">Colonnes attendues</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for elt in report.table.column_comparison_info.table %}
                            <tr{% if elt[2] == 'ko' %} class="table-danger"{% endif %}>
                                <td>{{ elt[0] }}</td>
                                <td>{{ elt[1] }}</td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>

                {% if report.table.column_comparison_info.has_missing %}
                <p>Attention : toutes les colonnes attendues doivent être présentes dans le fichier à valider.<p>
                {% 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 %}
Pierre Dittgen's avatar
Pierre Dittgen committed
135 136

            {% endif %}
137
        {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
138
    {% endif %}
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
</div>

{% if report.table.do_display_body_errors %} {# We do display body errors! #}
    <div class="mx-4">
        {% if report.table.errors.body %}
            <h3 class="my-4">Erreurs de contenu</h3>
            {{ macros.body_errors(report, source_data, print_mode) }}
        {% else %}
            {{ macros.preview(source_data) }}
        {% endif %}
    </div>
{% else %} {# do not display errors #}
    <p>Veuillez corriger ces erreurs pour visualiser les éventuelles erreurs de contenu.</p>
{% endif %}
{% endblock %}
Pierre Dittgen's avatar
Pierre Dittgen committed
154

Christophe Benz's avatar
Christophe Benz committed
155
{% block page_scripts %}
Christophe Benz's avatar
Christophe Benz committed
156
<script>
Pierre Dittgen's avatar
Pierre Dittgen committed
157 158 159 160 161 162 163 164 165 166 167 168 169
// Popovers that stays while on popover bubble
// https://stackoverflow.com/questions/15989591/how-can-i-keep-bootstrap-popover-alive-while-the-popover-is-being-hovered
$('[data-toggle="popover"]').popover({
    trigger: 'manual',
    html: true,
    animation: false,
    placement: 'auto'
})
.on('mouseenter', function () {
    var _this = this;
    $(this).popover('show');
    $('.popover').on('mouseleave', function () {
        $(_this).popover('hide');
Pierre Dittgen's avatar
Pierre Dittgen committed
170
    });
Pierre Dittgen's avatar
Pierre Dittgen committed
171 172 173 174 175 176 177
}).on('mouseleave', function () {
    var _this = this;
    setTimeout(function () {
        if (!$('.popover:hover').length) {
            $(_this).popover('hide');
        }
    }, 100);
Christophe Benz's avatar
Christophe Benz committed
178
});
Pierre Dittgen's avatar
Pierre Dittgen committed
179
</script>
Christophe Benz's avatar
Christophe Benz committed
180
{% endblock %}