Fix : problème d'ascenseur en bas de la page au niveau des templates
Some checks failed
Build & Push Images / build (brain) (push) Successful in 1m1s
Build & Push Images / build (core) (push) Successful in 1m32s
E2E Tests / e2e (push) Failing after 4m13s
Build & Push Images / build (web) (push) Successful in 1m53s

Sélection du template par défaut lors de la création d'une page en fonction du dossier
Passage v0.6.2
This commit is contained in:
2026-04-25 01:39:05 +02:00
parent d24d6459a0
commit 88278bd1dd
9 changed files with 132 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { shareReplay, tap } from 'rxjs/operators';
import { Lore, LoreCreate, LoreNode, LoreNodeCreate } from './lore.model';
/** Compte des entités qui seront supprimées en cascade avec un dossier. */
@@ -23,6 +24,11 @@ export interface LoreDeletionImpact {
/**
* Service HTTP pour la gestion des Lores.
* Port de sortie vers le Backend Java (Architecture Hexagonale).
*
* Les lectures agrégées par la sidebar (getAllLores, getLoreById, getLoreNodes)
* sont mises en cache via `shareReplay(1)` pour éviter 5 fetchs redondants à
* chaque navigation interne. Toute mutation (create/update/delete) invalide
* l'ensemble du cache du service.
*/
@Injectable({
providedIn: 'root'
@@ -31,26 +37,51 @@ export class LoreService {
private apiUrl = '/api/lores';
private nodesUrl = '/api/lore-nodes';
private allLoresCache: Observable<Lore[]> | null = null;
private loreByIdCache = new Map<string, Observable<Lore>>();
private nodesByLoreIdCache = new Map<string, Observable<LoreNode[]>>();
constructor(private http: HttpClient) {}
/** Vide tous les caches de lecture — appelé après toute mutation. */
private invalidate(): void {
this.allLoresCache = null;
this.loreByIdCache.clear();
this.nodesByLoreIdCache.clear();
}
getAllLores(): Observable<Lore[]> {
return this.http.get<Lore[]>(this.apiUrl);
if (!this.allLoresCache) {
this.allLoresCache = this.http.get<Lore[]>(this.apiUrl).pipe(
tap({ error: () => (this.allLoresCache = null) }),
shareReplay(1)
);
}
return this.allLoresCache;
}
getLoreById(id: string): Observable<Lore> {
return this.http.get<Lore>(`${this.apiUrl}/${id}`);
let obs = this.loreByIdCache.get(id);
if (!obs) {
obs = this.http.get<Lore>(`${this.apiUrl}/${id}`).pipe(
tap({ error: () => this.loreByIdCache.delete(id) }),
shareReplay(1)
);
this.loreByIdCache.set(id, obs);
}
return obs;
}
createLore(lore: LoreCreate): Observable<Lore> {
return this.http.post<Lore>(this.apiUrl, lore);
return this.http.post<Lore>(this.apiUrl, lore).pipe(tap(() => this.invalidate()));
}
updateLore(id: string, lore: LoreCreate): Observable<Lore> {
return this.http.put<Lore>(`${this.apiUrl}/${id}`, lore);
return this.http.put<Lore>(`${this.apiUrl}/${id}`, lore).pipe(tap(() => this.invalidate()));
}
deleteLore(id: string): Observable<void> {
return this.http.delete<void>(`${this.apiUrl}/${id}`);
return this.http.delete<void>(`${this.apiUrl}/${id}`).pipe(tap(() => this.invalidate()));
}
getLoreDeletionImpact(id: string): Observable<LoreDeletionImpact> {
@@ -58,7 +89,15 @@ export class LoreService {
}
getLoreNodes(loreId: string): Observable<LoreNode[]> {
return this.http.get<LoreNode[]>(`${this.nodesUrl}?loreId=${loreId}`);
let obs = this.nodesByLoreIdCache.get(loreId);
if (!obs) {
obs = this.http.get<LoreNode[]>(`${this.nodesUrl}?loreId=${loreId}`).pipe(
tap({ error: () => this.nodesByLoreIdCache.delete(loreId) }),
shareReplay(1)
);
this.nodesByLoreIdCache.set(loreId, obs);
}
return obs;
}
getLoreNodeById(id: string): Observable<LoreNode> {
@@ -66,16 +105,16 @@ export class LoreService {
}
createLoreNode(node: LoreNodeCreate): Observable<LoreNode> {
return this.http.post<LoreNode>(this.nodesUrl, node);
return this.http.post<LoreNode>(this.nodesUrl, node).pipe(tap(() => this.invalidate()));
}
/** PUT complet — envoie l'objet entier au backend (qui attend un LoreNodeDTO). */
updateLoreNode(id: string, node: LoreNode): Observable<LoreNode> {
return this.http.put<LoreNode>(`${this.nodesUrl}/${id}`, node);
return this.http.put<LoreNode>(`${this.nodesUrl}/${id}`, node).pipe(tap(() => this.invalidate()));
}
deleteLoreNode(id: string): Observable<void> {
return this.http.delete<void>(`${this.nodesUrl}/${id}`);
return this.http.delete<void>(`${this.nodesUrl}/${id}`).pipe(tap(() => this.invalidate()));
}
getLoreNodeDeletionImpact(id: string): Observable<LoreNodeDeletionImpact> {