validation_report.html 3.66 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 -->
Pierre Dittgen's avatar
Pierre Dittgen committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<div class="row">
    <div class="col-md-5">
        <div class="card bg-faded">
            <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>
26 27 28
    </div>
</div>

Pierre Dittgen's avatar
Pierre Dittgen committed
29

30
{% if report.error_count == 0 %}
31 32
<h2>La table est valide</h2>
<p>Aucune erreur détectée</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
33 34 35

{% include 'table_preview.html' %}

36
{% else %}
Pierre Dittgen's avatar
Pierre Dittgen committed
37

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

41 42 43
{% if source_type == 'url' %}
<button class="btn btn-primary" id="btn-reload">Relancer la validation</button>
{% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
44 45
<!-- table checks -->

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

Pierre Dittgen's avatar
Pierre Dittgen committed
57
<!-- row checks -->
58 59

{% if report.table.errors.body %}
Pierre Dittgen's avatar
Pierre Dittgen committed
60
<div>
61
    <h3>Erreurs de valeurs</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
62

Pierre Dittgen's avatar
Pierre Dittgen committed
63
    <div class="table-responsive-sm">
Pierre Dittgen's avatar
Pierre Dittgen committed
64 65
        <table class="table-sm table-bordered">
            <thead class="thead-light">
Pierre Dittgen's avatar
Pierre Dittgen committed
66
                <th scope="col">1</th>
67
                {% for h in report['table']['headers'] %}
Pierre Dittgen's avatar
Pierre Dittgen committed
68
                <th scope="col">{{ h }}</th>
69
                {% endfor %}
Pierre Dittgen's avatar
Pierre Dittgen committed
70 71
            </thead>
            <tbody>
72
                {% for row in report.table.errors.by_rows %}
Pierre Dittgen's avatar
Pierre Dittgen committed
73
                <tr>
74
                    {% if 'row' in row.errors %}
Pierre Dittgen's avatar
Pierre Dittgen committed
75 76
                    <th class="table-danger" data-toggle="tooltip" title="{{ row.errors.row.message }}">{{
                        row.row_id
77
                        }}</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
78 79 80 81
                    {% if row.errors.row.code == 'blank-row' %}
                    <td colspan="{{ report.table.col_count }}" class="table-danger" data-toggle="tooltip" title="{{ row.errors.row.message }}">
                        {% endif %}
                        {% else %}
82
                    <th>{{ row.row_id }}</th>
83
                    {% endif %}
84 85
                    {% for d in source_data.data_rows[row.row_id - 2] %}
                    {% if loop.index in row.errors %}
86
                    <td class="table-danger" data-toggle="tooltip" title="[{{row.errors[loop.index].code}}] {{ row.errors[loop.index].message }}">
Pierre Dittgen's avatar
Pierre Dittgen committed
87 88
                        {% elif 'row' in row.errors %}
                    <td class="table-danger" data-toggle="tooltip" title="{{ row.errors.row.message }}">
89 90 91
                        {% else %}
                    <td>
                        {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
92
                        {{ d }}
93
                    </td>
Pierre Dittgen's avatar
Pierre Dittgen committed
94 95
                    {% endfor %}
                </tr>
96
                {% endfor %}
Pierre Dittgen's avatar
Pierre Dittgen committed
97 98 99
            </tbody>
        </table>
    </div>
Pierre Dittgen's avatar
Pierre Dittgen committed
100 101 102 103

    {% endif %}

</div>
104 105


106
<!--
107
<pre>
108
    {{ report_str }}
109
</pre>
110
-->
111

Pierre Dittgen's avatar
Pierre Dittgen committed
112
{% endif %}
113 114
{% endblock %}
{% block footer %}
115 116
<script>
    $(function () {
117
        // Errors tooltip activate
118
        $('[data-toggle="tooltip"]').tooltip()
119 120 121 122 123 124

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