validation_report.html 3.1 KB
Newer Older
1 2 3 4 5 6 7 8
{% extends "base.html" %}
{% block title %}{{ title }}{% endblock %}
{% block head %}
{{ super() }}
{% endblock %}
{% block content %}
<h1>{{ title }}</h1>

9
<!-- Schema info -->
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<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>

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

{% include 'table_preview.html' %}

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

33
<h2>La table est invalide</h2>
34
<p>{{ report.error_count }} erreur(s) détectée(s)</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
35

36 37 38
{% if source_type == 'url' %}
<button class="btn btn-primary" id="btn-reload">Relancer la validation</button>
{% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
39 40
<!-- table checks -->

41
{% if report.table.errors.structure %}
Pierre Dittgen's avatar
Pierre Dittgen committed
42
<div>
43
    <h3>Problèmes de structure</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
44
    <ul>
45
        {% for err in report.table.errors.structure %}
46
        <li>[{{ err.code }}] {{ err.message }}</li>
Pierre Dittgen's avatar
Pierre Dittgen committed
47 48 49
        {% endfor %}
    </ul>
</div>
50
{% endif %}
51

Pierre Dittgen's avatar
Pierre Dittgen committed
52
<!-- row checks -->
53 54

{% if report.table.errors.body %}
Pierre Dittgen's avatar
Pierre Dittgen committed
55
<div>
56
    <h3>Erreurs de valeurs</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
57

Pierre Dittgen's avatar
Pierre Dittgen committed
58
    <div class="table-responsive-sm">
Pierre Dittgen's avatar
Pierre Dittgen committed
59 60
        <table class="table-sm table-bordered">
            <thead class="thead-light">
61 62
                <th scope="col">Ligne</th>
                {% for h in report['table']['headers'] %}
Pierre Dittgen's avatar
Pierre Dittgen committed
63
                <th scope="col">{{ h }}</th>
64
                {% endfor %}
Pierre Dittgen's avatar
Pierre Dittgen committed
65 66
            </thead>
            <tbody>
67
                {% for row in report.table.errors.by_rows %}
Pierre Dittgen's avatar
Pierre Dittgen committed
68
                <tr>
69 70 71 72
                    {% if 'row' in row.errors %}
                    <th class="table-danger data-toggle=" tooltip" title="{{ row.errors.row.message }}">{{ row.row_id
                        }}</th>
                    {% else %}
73
                    <th>{{ row.row_id }}</th>
74
                    {% endif %}
75 76
                    {% for d in source_data.data_rows[row.row_id - 2] %}
                    {% if loop.index in row.errors %}
77
                    <td class="table-danger" data-toggle="tooltip" title="[{{row.errors[loop.index].code}}] {{ row.errors[loop.index].message }}">
78 79 80 81 82
                        {% else %}
                    <td>
                        {% endif %}
                        {{ d | truncate(30) }}
                    </td>
Pierre Dittgen's avatar
Pierre Dittgen committed
83 84
                    {% endfor %}
                </tr>
85
                {% endfor %}
Pierre Dittgen's avatar
Pierre Dittgen committed
86 87 88
            </tbody>
        </table>
    </div>
Pierre Dittgen's avatar
Pierre Dittgen committed
89 90 91 92

    {% endif %}

</div>
93 94


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

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

        // Reload to re-validate
        $('#btn-reload').on('click', function () {
            $(this).prop('disabled', true)
            window.location.reload(true);
        })
114 115
    })
</script>
116
{% endblock %}