liste des évènements non localisés
This commit is contained in:
parent
22314d7b9e
commit
8aa4e107ac
7 changed files with 72 additions and 5 deletions
|
@ -9,6 +9,7 @@
|
|||
<input class="input" type="text" placeholder="Rechercher...">
|
||||
</div>
|
||||
<hr>
|
||||
<app-unlocated-events [events]="features"></app-unlocated-events>
|
||||
<app-menu></app-menu>
|
||||
<hr>
|
||||
<app-edit-form [selected]="selected" (saved)="onSaved($event)" (created)="onCreated($event)" (deleted)="onDeleted($event)"></app-edit-form>
|
||||
|
|
|
@ -3,12 +3,13 @@ import {Menu} from './menu/menu';
|
|||
import { AllEvents } from '../../maps/all-events/all-events';
|
||||
import { EditForm } from '../../forms/edit-form/edit-form';
|
||||
import { OedbApi } from '../../services/oedb-api';
|
||||
|
||||
import { UnlocatedEvents } from '../../shared/unlocated-events/unlocated-events';
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
imports: [
|
||||
Menu,
|
||||
AllEvents,
|
||||
UnlocatedEvents,
|
||||
EditForm
|
||||
],
|
||||
templateUrl: './home.html',
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div id="search_input">
|
||||
<input type="text" value="" placeholder="Rechercher une catégorie d'évènement">
|
||||
</div>
|
||||
<div id="what_categories">
|
||||
<!-- <div id="what_categories">
|
||||
@for (oedbc of oedb_what_categories; track $index) {
|
||||
<div class="category">
|
||||
<div class="emoji">
|
||||
|
@ -21,14 +21,14 @@
|
|||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<hr>
|
||||
(bouton de template pour ne pas remplir le formulaire)
|
||||
<hr>
|
||||
|
||||
(reste optionnel du formulaire)
|
||||
<label for="where">Nom</label>
|
||||
<!-- <label for="where">Nom</label>
|
||||
<input type="text" name="name">
|
||||
|
||||
<label for="where">Description</label>
|
||||
|
@ -51,7 +51,7 @@
|
|||
<option value="point"></option>
|
||||
<option value="polyline"></option>
|
||||
<option value="bbox"></option>
|
||||
</select>
|
||||
</select> -->
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<h2>{{unlocated.length}} Évènements non localisés</h2>
|
||||
<button (click)="display_list = !display_list">Afficher/Masquer la liste</button>
|
||||
@if (display_list) {
|
||||
<ul>
|
||||
<li *ngFor="let event of unlocated">
|
||||
{{ event?.properties?.what || event?.properties?.label || event?.properties?.name || 'Évènement sans nom' }}
|
||||
<pre>{{event | json}}</pre>
|
||||
</li>
|
||||
</ul>
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UnlocatedEvents } from './unlocated-events';
|
||||
|
||||
describe('UnlocatedEvents', () => {
|
||||
let component: UnlocatedEvents;
|
||||
let fixture: ComponentFixture<UnlocatedEvents>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [UnlocatedEvents]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(UnlocatedEvents);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
32
frontend/src/app/shared/unlocated-events/unlocated-events.ts
Normal file
32
frontend/src/app/shared/unlocated-events/unlocated-events.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-unlocated-events',
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
templateUrl: './unlocated-events.html',
|
||||
styleUrl: './unlocated-events.scss'
|
||||
})
|
||||
export class UnlocatedEvents implements OnInit{
|
||||
|
||||
@Input() events: Array<any> = [];
|
||||
unlocated: Array<any> = [];
|
||||
display_list = false
|
||||
|
||||
ngOnInit() {
|
||||
this.unlocated = (this.events || []).filter(ev => {
|
||||
// Vérifie si la géométrie est un point
|
||||
if (!ev.geometry || ev.geometry.type !== 'Point') return false;
|
||||
const coords = ev.geometry.coordinates;
|
||||
// Vérifie si les coordonnées sont valides
|
||||
if (!Array.isArray(coords) || coords.length !== 2) return true;
|
||||
// Si les coordonnées sont [0,0], on considère comme non localisé
|
||||
if (coords[0] === 0 && coords[1] === 0) return true;
|
||||
// Si l'une des coordonnées est manquante ou nulle
|
||||
if (coords[0] == null || coords[1] == null) return true;
|
||||
return false;
|
||||
});
|
||||
console.log('unlocated events', this.unlocated);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue