up demo by what
This commit is contained in:
parent
26bfe4ae36
commit
2238380e80
7 changed files with 43 additions and 13 deletions
|
@ -61,13 +61,13 @@ export class Home implements OnInit, OnDestroy {
|
||||||
|
|
||||||
// Propriétés pour les filtres
|
// Propriétés pour les filtres
|
||||||
searchText = '';
|
searchText = '';
|
||||||
selectedWhatFilter = 'culture';
|
selectedWhatFilter = '';
|
||||||
availableWhatTypes: string[] = [];
|
availableWhatTypes: string[] = [];
|
||||||
theme = signal<string | null>(null);
|
theme = signal<string | null>(null);
|
||||||
subthemes: Array<{ key: string, label: string, emoji: string }> = [];
|
subthemes: Array<{ key: string, label: string, emoji: string }> = [];
|
||||||
activeSubtheme = signal<string | null>(null);
|
activeSubtheme = signal<string | null>(null);
|
||||||
// Option bbox
|
// Option bbox
|
||||||
useBboxFilter = false;
|
useBboxFilter = true;
|
||||||
currentBbox: { minLng: number, minLat: number, maxLng: number, maxLat: number } | null = null;
|
currentBbox: { minLng: number, minLat: number, maxLng: number, maxLat: number } | null = null;
|
||||||
// Debounce pour la recherche
|
// Debounce pour la recherche
|
||||||
private searchDebounceTimer: any = null;
|
private searchDebounceTimer: any = null;
|
||||||
|
@ -130,7 +130,7 @@ export class Home implements OnInit, OnDestroy {
|
||||||
};
|
};
|
||||||
if (overrides.what) {
|
if (overrides.what) {
|
||||||
params.what = overrides.what;
|
params.what = overrides.what;
|
||||||
} else if (this.selectedWhatFilter) {
|
} else if (this.selectedWhatFilter && this.selectedWhatFilter !== '') {
|
||||||
params.what = this.selectedWhatFilter;
|
params.what = this.selectedWhatFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,6 +207,11 @@ export class Home implements OnInit, OnDestroy {
|
||||||
this.theme.set(t || null);
|
this.theme.set(t || null);
|
||||||
this.buildSubthemes();
|
this.buildSubthemes();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Ajouter les catégories principales
|
||||||
|
whatTypes.add('culture');
|
||||||
|
whatTypes.add('traffic');
|
||||||
|
|
||||||
this.availableWhatTypes = Array.from(whatTypes).sort();
|
this.availableWhatTypes = Array.from(whatTypes).sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,9 +249,15 @@ export class Home implements OnInit, OnDestroy {
|
||||||
|
|
||||||
// Filtre par type d'événement
|
// Filtre par type d'événement
|
||||||
if (this.selectedWhatFilter) {
|
if (this.selectedWhatFilter) {
|
||||||
filtered = filtered.filter(feature =>
|
filtered = filtered.filter(feature => {
|
||||||
feature?.properties?.what === this.selectedWhatFilter
|
const what = feature?.properties?.what || '';
|
||||||
);
|
// Si c'est une catégorie (culture, traffic), filtrer par préfixe
|
||||||
|
if (this.selectedWhatFilter === 'culture' || this.selectedWhatFilter === 'traffic') {
|
||||||
|
return what.startsWith(this.selectedWhatFilter + '.');
|
||||||
|
}
|
||||||
|
// Sinon, correspondance exacte
|
||||||
|
return what === this.selectedWhatFilter;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.filteredFeatures = filtered;
|
this.filteredFeatures = filtered;
|
||||||
|
|
|
@ -126,7 +126,7 @@ class DemoResource:
|
||||||
|
|
||||||
# Fetch events from the API
|
# Fetch events from the API
|
||||||
try:
|
try:
|
||||||
response = requests.get('/event?limit=1000')
|
response = requests.get('/event?limit=5000')
|
||||||
if response.status_code == 200 and response.text:
|
if response.status_code == 200 and response.text:
|
||||||
events_data = response.json()
|
events_data = response.json()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -10,6 +10,11 @@
|
||||||
color: #666;
|
color: #666;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
}
|
}
|
||||||
|
.event-details {
|
||||||
|
color: #888;
|
||||||
|
font-style: italic;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -39,7 +44,14 @@
|
||||||
<ul>
|
<ul>
|
||||||
{% for event in events_by_what[what_type]|sort(attribute='label') %}
|
{% for event in events_by_what[what_type]|sort(attribute='label') %}
|
||||||
<li>
|
<li>
|
||||||
<a href="/event/{{ event.id }}">{{ event.label or 'Unnamed Event' }}</a>
|
{% set event_name = event.name or event.title or event.short_description or event.label or 'Unnamed Event' %}
|
||||||
|
<a href="/event/{{ event.id }}">{{ event_name }}</a>
|
||||||
|
{% if event.label and event.label != event_name %}
|
||||||
|
<small class="event-details">({{ event.label }})</small>
|
||||||
|
{% endif %}
|
||||||
|
{% if event.short_description and event.short_description != event_name and event.short_description != event.label %}
|
||||||
|
<small class="event-details">- {{ event.short_description }}</small>
|
||||||
|
{% endif %}
|
||||||
<small>
|
<small>
|
||||||
[<a href="https://www.openstreetmap.org/?mlat={{ event.coordinates[1] }}&mlon={{ event.coordinates[0] }}&zoom=15">map</a>]
|
[<a href="https://www.openstreetmap.org/?mlat={{ event.coordinates[1] }}&mlon={{ event.coordinates[0] }}&zoom=15">map</a>]
|
||||||
</small>
|
</small>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
|
|
||||||
{% block title %}Événement {{ properties.label|default(id) }} - OpenEventDatabase{% endblock %}
|
{% block title %}Événement {{ properties.name or properties.title or properties.short_description or properties.label or id }} - OpenEventDatabase{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
<style>
|
<style>
|
||||||
|
@ -126,7 +126,14 @@
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
<div class="event-header">
|
<div class="event-header">
|
||||||
<h1 class="event-title">{{ properties.label|default('Événement sans titre') }}</h1>
|
{% set event_title = properties.name or properties.title or properties.short_description or properties.label or 'Événement sans titre' %}
|
||||||
|
<h1 class="event-title">{{ event_title }}</h1>
|
||||||
|
{% if properties.label and properties.label != event_title %}
|
||||||
|
<p class="event-subtitle">{{ properties.label }}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% if properties.short_description and properties.short_description != event_title and properties.short_description != properties.label %}
|
||||||
|
<p class="event-subtitle">{{ properties.short_description }}</p>
|
||||||
|
{% endif %}
|
||||||
<p class="event-subtitle">ID: {{ id }}</p>
|
<p class="event-subtitle">ID: {{ id }}</p>
|
||||||
<div class="nav-links">
|
<div class="nav-links">
|
||||||
<a href="/demo"><i class="fas fa-home"></i> Accueil</a>
|
<a href="/demo"><i class="fas fa-home"></i> Accueil</a>
|
||||||
|
|
|
@ -440,7 +440,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="event-title">
|
<div class="event-title">
|
||||||
<a href="/demo/by_id/${props.id}">${props.label || 'Événement sans titre'}</a>
|
<a href="/demo/by_id/${props.id}">${props.name || props.title || props.short_description || props.label || 'Événement sans titre'}</a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
// Get event properties
|
// Get event properties
|
||||||
const properties = event.properties;
|
const properties = event.properties;
|
||||||
const coordinates = event.geometry.coordinates;
|
const coordinates = event.geometry.coordinates;
|
||||||
const label = properties.label || 'Unnamed Event';
|
const label = properties.name || properties.title || properties.short_description || properties.label || 'Unnamed Event';
|
||||||
const what = properties.what || 'unknown';
|
const what = properties.what || 'unknown';
|
||||||
const timestamp = event.timestamp ? new Date(event.timestamp) : new Date();
|
const timestamp = event.timestamp ? new Date(event.timestamp) : new Date();
|
||||||
const formattedDate = timestamp.toLocaleString();
|
const formattedDate = timestamp.toLocaleString();
|
||||||
|
|
|
@ -352,7 +352,7 @@ class QualityAssuranceResource(BaseEvent):
|
||||||
# Add events
|
# Add events
|
||||||
for event in problematic_events:
|
for event in problematic_events:
|
||||||
properties = event.get('properties', {})
|
properties = event.get('properties', {})
|
||||||
event_title = properties.get('label', properties.get('name', f'Événement #{event["id"]}'))
|
event_title = properties.get('name') or properties.get('title') or properties.get('short_description') or properties.get('label') or f'Événement #{event["id"]}'
|
||||||
event_what = properties.get('what', 'Non spécifié')
|
event_what = properties.get('what', 'Non spécifié')
|
||||||
|
|
||||||
# Get severity classes for the card
|
# Get severity classes for the card
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue