validation_report.html 2.63 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
{% extends "base.html" %}
{% block title %}{{ title }}{% endblock %}
{% block head %}
{{ super() }}
{% endblock %}
{% block content %}
<h1>{{ title }}</h1>

<div class="card bg-faded" style="width: 30rem;">
    <div class="card-body">
        <h5 class="card-title">
            Schéma {{ val_info.code }}
            <span class="badge badge-primary">{{ val_info.version }}</span>
        </h5>
        <h6 class="card-subtitle mb-2 text-muted">{{ val_info.description }}</h6>
        <p class="text">
            {% if source_type == 'file' %}Fichier{% endif %}
            {% if source_type == 'url' %}URL{% endif %}
            à valider : {{ source }}
        </p>
    </div>
</div>

{% if report.valid %}
<h2>La table est valide</h2>
<p>Aucune erreur détectée</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
27 28 29

{% include 'table_preview.html' %}

30
{% else %}
Pierre Dittgen's avatar
Pierre Dittgen committed
31

32
<h2>La table est invalide</h2>
Pierre Dittgen's avatar
Pierre Dittgen committed
33
<p>{{ report['tables'][0]['errors']|length }} erreur(s) détectée(s)</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
34

Pierre Dittgen's avatar
Pierre Dittgen committed
35 36 37
<!-- table checks -->

<div>
38
    <h3>Erreurs de table</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
39 40 41 42 43 44 45 46 47 48
    <ul>
        {% for err in report['tables'][0]['errors'] %}
        {% if err.context == 'table' or err.context == 'head' %}
        <li>
            <pre>{{ err }}</pre>
        </li>
        {% endif %}
        {% endfor %}
    </ul>
</div>
49

Pierre Dittgen's avatar
Pierre Dittgen committed
50 51
<!-- row checks -->
<div>
52
    <h3>Erreurs de valeurs</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
53

Pierre Dittgen's avatar
Pierre Dittgen committed
54 55
    {% set line = {'no': 0} %}

Pierre Dittgen's avatar
Pierre Dittgen committed
56
    {% for err in report['tables'][0]['errors'] %}
57

Pierre Dittgen's avatar
Pierre Dittgen committed
58 59
    {% if err.context == 'body' %}

Pierre Dittgen's avatar
Pierre Dittgen committed
60 61 62 63 64
    {% if line.no != err['row-number'] %}
    {% if line.update({'no': err['row-number']}) %}{% endif %}
    <h4>Ligne {{ line.no - 1}}</h4>
    {% endif %}

Pierre Dittgen's avatar
Pierre Dittgen committed
65
    <div class="table-responsive-sm">
Pierre Dittgen's avatar
Pierre Dittgen committed
66 67
        <table class="table-sm table-bordered">
            <thead class="thead-light">
Pierre Dittgen's avatar
Pierre Dittgen committed
68 69
                {% for h in report['tables'][0]['headers'] %}
                <th scope="col">{{ h }}</th>
70
                {% endfor %}
Pierre Dittgen's avatar
Pierre Dittgen committed
71 72 73 74 75 76
            </thead>
            <!-- TODO: regrouper les erreurs par ligne ? -->
            <tbody>
                <tr>
                    {% for d in source_data.data_rows[err['row-number'] - 2] %}
                    {% if loop.index == err['column-number'] %}
77
                    <td class="table-danger" data-toggle="tooltip" title="{{ err.message }}">{{ d }}</td>
Pierre Dittgen's avatar
Pierre Dittgen committed
78 79 80 81 82 83 84 85
                    {% else %}
                    <td>{{ d }}</td>
                    {% endif %}
                    {% endfor %}
                </tr>
            </tbody>
        </table>
    </div>
86
    <p class="text">{{ err.message }}</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
87 88 89 90 91

    {% endif %}
    {% endfor %}

</div>
92 93


94
<!--
95
<pre>
96
    {{ report_str }}
97
</pre>
98
-->
99

Pierre Dittgen's avatar
Pierre Dittgen committed
100
{% endif %}
101 102
{% endblock %}
{% block footer %}
103 104 105 106 107
<script>
    $(function () {
        $('[data-toggle="tooltip"]').tooltip()
    })
</script>
108
{% endblock %}