mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-10-09 17:02:46 +02:00
tests liens ctc
This commit is contained in:
parent
6f3d19245e
commit
2fd0d8d933
3 changed files with 315 additions and 78 deletions
|
@ -218,14 +218,12 @@
|
|||
</ul>
|
||||
<div class="tab-content" id="themeTabsContent">
|
||||
<div class="tab-pane fade show active" id="tabTableContent" role="tabpanel" aria-labelledby="tab-table">
|
||||
<table class="table table-sm table-theme align-middle">
|
||||
<table class="table table-theme">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Catégorie</th>
|
||||
<th>Thème</th>
|
||||
<th>Nombre</th>
|
||||
<th>Complétion</th>
|
||||
<th>Progression 7j</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -294,79 +292,51 @@
|
|||
</table>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="tabCardsContent" role="tabpanel" aria-labelledby="tab-cards">
|
||||
{% for group_name, group_types in theme_groups %}
|
||||
<div class="mb-2">
|
||||
<div class="mb-1 text-muted">
|
||||
{% if group_name == 'emergency' %}🚨 Urgence
|
||||
{% elseif group_name == 'transport' %}🚌 Transport
|
||||
{% elseif group_name == 'healthcare' %}🏥 Santé
|
||||
{% elseif group_name == 'education' %}🎓 Éducation
|
||||
{% elseif group_name == 'security' %}🛡️ Sécurité
|
||||
{% elseif group_name == 'infrastructure' %}🏗️ Infrastructure
|
||||
{% else %}{{ group_name|capitalize }}
|
||||
{% set all_types = followup_labels|keys %}
|
||||
<div class="row">
|
||||
{% for type in all_types %}
|
||||
{% set data = latestFollowups[type]|default(null) %}
|
||||
{% set overpass_query = '[out:json][timeout:60];\narea["ref:INSEE"="' ~ stats.zone ~ '"]->.searchArea;\n(' ~ overpass_type_queries[type]|default('') ~ ');\n(._;>;);\nout meta;\n>;' %}
|
||||
{% set completion = data and data.completion is defined ? data.completion.getMeasure() : null %}
|
||||
{% set completion_class = '' %}
|
||||
{% if completion is not null %}
|
||||
{% if completion < 40 %}
|
||||
{% set completion_class = 'completion-low' %}
|
||||
{% elseif completion < 80 %}
|
||||
{% set completion_class = 'completion-medium' %}
|
||||
{% else %}
|
||||
{% set completion_class = 'completion-high' %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="theme-row-scroll">
|
||||
{% for type in group_types %}
|
||||
{% set data = latestFollowups[type]|default(null) %}
|
||||
{% set overpass_query = '[out:json][timeout:60];\narea["ref:INSEE"="' ~ stats.zone ~ '"]->.searchArea;\n(' ~ overpass_type_queries[type]|default('') ~ ');\n(._;>;);\nout meta;\n>;' %}
|
||||
{% set completion = data and data.completion is defined ? data.completion.getMeasure() : null %}
|
||||
{% set completion_class = '' %}
|
||||
{% if completion is not null %}
|
||||
{% if completion < 40 %}
|
||||
{% set completion_class = 'completion-low' %}
|
||||
{% elseif completion < 80 %}
|
||||
{% set completion_class = 'completion-medium' %}
|
||||
{% else %}
|
||||
{% set completion_class = 'completion-high' %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<div class="col-auto">
|
||||
<div class="card shadow-sm text-center compact-theme-card" style="min-width: 120px; max-width: 140px;">
|
||||
<div class="card-body p-2">
|
||||
<div class="d-flex align-items-center justify-content-between mb-1">
|
||||
<span class="completion-badge {{ completion_class }}"></span>
|
||||
<i class="bi {{ followup_icons[type]|default('bi-question-circle') }} fs-4"></i>
|
||||
</div>
|
||||
<div class="theme-title mb-1">
|
||||
<a href="http://127.0.0.1:8111/import?url=https://overpass-api.de/api/interpreter?data={{ overpass_query|url_encode }}" target="_blank" class="fw-bold text-decoration-none text-dark small" title="Charger dans JOSM">
|
||||
{{ followup_labels[type]|default(type|capitalize) }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="theme-stats small">
|
||||
<span title="Nombre">{{ data and data.count is defined ? data.count.getMeasure() : '?' }}</span> |
|
||||
<span title="Complétion">{{ completion is not null ? completion : '?' }}%</span>
|
||||
</div>
|
||||
<div class="theme-actions mt-1">
|
||||
<a href="{{ path('admin_followup_theme_graph', {'insee_code': stats.zone, 'theme': type}) }}" target="_blank" class="btn btn-sm btn-outline-primary btn-sm" title="Voir le graphique">
|
||||
<i class="bi bi-graph-up"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% if progression7Days[type] is defined %}
|
||||
{% set countDelta = progression7Days[type].count %}
|
||||
{% set completionDelta = progression7Days[type].completion %}
|
||||
{% if countDelta is not null or completionDelta is not null %}
|
||||
<small class="text-muted d-block mt-1">
|
||||
{% if countDelta is not null %}
|
||||
<span title="Progression sur 7 jours - Nombre d'objets">
|
||||
{{ countDelta > 0 ? '+' ~ countDelta : countDelta == 0 ? '0' : countDelta }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if completionDelta is not null %}
|
||||
<span title="Progression sur 7 jours - Complétion">
|
||||
{{ completionDelta > 0 ? '+' ~ completionDelta|round(1) : completionDelta == 0 ? '0' : completionDelta|round(1) }}%
|
||||
</span>
|
||||
{% endif %}
|
||||
</small>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col-auto">
|
||||
<div class="card shadow-sm text-center compact-theme-card" style="min-width: 120px; max-width: 140px;">
|
||||
<div class="card-body p-2">
|
||||
<div class="d-flex align-items-center justify-content-between mb-1">
|
||||
<span class="completion-badge {{ completion_class }}"></span>
|
||||
<i class="bi {{ followup_icons[type]|default('bi-question-circle') }} fs-4"></i>
|
||||
</div>
|
||||
<div class="theme-title mb-1">
|
||||
<a href="https://overpass-api.de/api/interpreter?data={{ overpass_query|url_encode }}" target="_blank" class="fw-bold text-decoration-none text-dark small" title="Voir le JSON Overpass">
|
||||
{{ followup_labels[type]|default(type|capitalize) }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="theme-stats small">
|
||||
<span title="Nombre">{{ data and data.count is defined ? data.count.getMeasure() : '?' }}</span> |
|
||||
<span title="Complétion">{{ completion is not null ? completion : '?' }}%</span>
|
||||
</div>
|
||||
<div class="theme-actions mt-1">
|
||||
<a href="{{ path('admin_followup_theme_graph', {'insee_code': stats.zone, 'theme': type}) }}" target="_blank" class="btn btn-sm btn-outline-primary btn-sm" title="Voir le graphique">
|
||||
<i class="bi bi-graph-up"></i>
|
||||
</a>
|
||||
<a href="http://127.0.0.1:8111/import?url=https://overpass-api.de/api/interpreter?data={{ overpass_query|url_encode }}" target="_blank" class="btn btn-sm btn-outline-dark btn-sm ms-1" title="Ouvrir dans JOSM">
|
||||
<i class="bi bi-box-arrow-up-right"></i> JOSM
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -603,6 +573,48 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Espace de dump JSON -->
|
||||
<div id="ctc-json-dump-container" class="mt-4" style="display:none;">
|
||||
<div class="card">
|
||||
<div class="card-header p-2">
|
||||
<i class="bi bi-file-earmark-code"></i> Dump du JSON récupéré
|
||||
</div>
|
||||
<div class="card-body p-2">
|
||||
<pre id="ctc-json-dump" style="max-height:400px;overflow:auto;"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 ctc-tests">
|
||||
<div class="card ctc-tests">
|
||||
<div class="card-header p-2">
|
||||
<i class="bi bi-link-45deg"></i> Tester les JSON Complète tes commerces
|
||||
</div>
|
||||
<div class="card-body p-2">
|
||||
<ul class="mb-0" style="font-size:0.95em;">
|
||||
{% set ctc_jsons = stats.getAllCTCUrlsMap() %}
|
||||
{% for key, url in ctc_jsons %}
|
||||
<li><a href="{{ url }}" target="_blank" rel="noopener">{{ key }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="mt-3">
|
||||
<div class="input-group">
|
||||
<select id="ctc-json-select" class="form-select">
|
||||
<option value="">Choisir un JSON à tester…</option>
|
||||
{% for key, url in ctc_jsons %}
|
||||
<option value="{{ url }}">{{ key }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button id="ctc-json-test-btn" class="btn btn-outline-primary" type="button">
|
||||
<i class="bi bi-bug"></i> Tester l'accès JSON CTC
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="ctc-json-error" class="alert alert-danger mt-4" style="display:none;"></div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
@ -1048,4 +1060,35 @@ if(dc ){
|
|||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const btn = document.getElementById('ctc-json-test-btn');
|
||||
const select = document.getElementById('ctc-json-select');
|
||||
const dumpContainer = document.getElementById('ctc-json-dump-container');
|
||||
const dump = document.getElementById('ctc-json-dump');
|
||||
const error = document.getElementById('ctc-json-error');
|
||||
if(btn && select) {
|
||||
btn.addEventListener('click', function() {
|
||||
const url = select.value;
|
||||
dumpContainer.style.display = 'none';
|
||||
error.style.display = 'none';
|
||||
dump.textContent = '';
|
||||
if(!url) return;
|
||||
fetch(url)
|
||||
.then(r => {
|
||||
if(!r.ok) throw new Error('Erreur HTTP ' + r.status);
|
||||
return r.json();
|
||||
})
|
||||
.then(data => {
|
||||
dump.textContent = JSON.stringify(data, null, 2);
|
||||
dumpContainer.style.display = '';
|
||||
})
|
||||
.catch(e => {
|
||||
error.textContent = 'Erreur lors de la récupération du JSON : ' + e.message;
|
||||
error.style.display = '';
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue