validation_report.html 3.99 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>

Pierre Dittgen's avatar
Pierre Dittgen committed
9
{# Schema info #}
Pierre Dittgen's avatar
Pierre Dittgen committed
10 11 12 13 14 15 16 17 18 19 20 21
<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 %}
22
                    à valider : {{ source.name }}
Pierre Dittgen's avatar
Pierre Dittgen committed
23 24 25
                </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>
Pierre Dittgen's avatar
Pierre Dittgen committed
39

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

45
{% if report.table.errors.structure %}
Pierre Dittgen's avatar
Pierre Dittgen committed
46
<div>
47
    <h3>Problèmes de structure</h3>
48 49 50 51 52
    {% for err in report.table.errors.structure %}
    <div class="alert alert-danger">
        {{ err.message | safe}}
    </div>
    {% endfor %}
Pierre Dittgen's avatar
Pierre Dittgen committed
53
</div>
54
{% endif %}
55

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

{% if report.table.errors.body %}
59 60 61 62

{% if not report.table.display_body_errors %}
Merci de corriger ce(s) erreur(s) pour visualiser les erreurs de contenu.
{% else %}
Pierre Dittgen's avatar
Pierre Dittgen committed
63
<div>
64
    <h3>Problèmes de contenu</h3>
Pierre Dittgen's avatar
Pierre Dittgen committed
65
    <div class="table-responsive-sm">
66
        <table class="table-sm table-bordered table-striped table-hover">
Pierre Dittgen's avatar
Pierre Dittgen committed
67
            <thead class="thead-light">
Pierre Dittgen's avatar
Pierre Dittgen committed
68
                <th scope="col">1</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
69 70
                {% for h in report.table.headers %}
                <th scope="col" data-toggle="tooltip" title="{{ report.table.headers_title[loop.index - 1]}}">{{ h }}</th>
71
                {% endfor %}
Pierre Dittgen's avatar
Pierre Dittgen committed
72 73
            </thead>
            <tbody>
74
                {% for row in report.table.errors.by_rows %}
Pierre Dittgen's avatar
Pierre Dittgen committed
75
                <tr>
76
                    {% if 'row' in row.errors %}
Pierre Dittgen's avatar
Pierre Dittgen committed
77 78
                    <th class="table-danger" data-toggle="tooltip" title="{{ row.errors.row.message }}">{{
                        row.row_id
79
                        }}</th>
Pierre Dittgen's avatar
Pierre Dittgen committed
80 81 82 83 84 85
                    {% if row.errors.row.code == 'blank-row' and not source_data.data_rows[row.row_id -2] %}
                    {% for _ in report.table.headers %}
                    <td class="table-danger" data-toggle="tooltip" title="{{ row.errors.row.message }}"></td>
                    {% endfor %}
                    {% endif %}
                    {% else %}
86
                    <th>{{ row.row_id }}</th>
87
                    {% endif %}
88 89
                    {% for d in source_data.data_rows[row.row_id - 2] %}
                    {% if loop.index in row.errors %}
90
                    <td class="table-danger" data-toggle="tooltip" title="{{ row.errors[loop.index].message }}">
Pierre Dittgen's avatar
Pierre Dittgen committed
91 92
                        {% elif 'row' in row.errors %}
                    <td class="table-danger" data-toggle="tooltip" title="{{ row.errors.row.message }}">
93 94 95
                        {% else %}
                    <td>
                        {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
96
                        {{ d }}
97
                    </td>
Pierre Dittgen's avatar
Pierre Dittgen committed
98 99
                    {% endfor %}
                </tr>
100
                {% endfor %}
Pierre Dittgen's avatar
Pierre Dittgen committed
101 102 103
            </tbody>
        </table>
    </div>
104
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
105 106 107
    {% endif %}

</div>
108

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

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

{#
{{ report.table.errors.structure|length }} erreur(s) détectée(s)
{{ report.table.errors.body|length }} erreur(s) détectée(s)

#}
130
{% endblock %}