Changement dans la config pour éviter les url en dur + mise en place d'un mode démo
This commit is contained in:
@@ -45,8 +45,8 @@ export type NarrativeEntityType = 'arc' | 'chapter' | 'scene' | 'character';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AiChatService {
|
||||
private readonly loreEndpoint = 'http://localhost:8080/api/ai/chat/stream';
|
||||
private readonly campaignEndpoint = 'http://localhost:8080/api/ai/chat/stream-campaign';
|
||||
private readonly loreEndpoint = '/api/ai/chat/stream';
|
||||
private readonly campaignEndpoint = '/api/ai/chat/stream-campaign';
|
||||
|
||||
/**
|
||||
* Streame la réponse de l'IA pour un historique de messages donné (chat ancré Lore).
|
||||
|
||||
@@ -30,7 +30,7 @@ export interface ChapterDeletionImpact {
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CampaignService {
|
||||
private apiUrl = 'http://localhost:8080/api/campaigns';
|
||||
private apiUrl = '/api/campaigns';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
@@ -60,73 +60,73 @@ export class CampaignService {
|
||||
|
||||
// ========== ARC ==========
|
||||
getArcs(campaignId: string): Observable<Arc[]> {
|
||||
return this.http.get<Arc[]>(`http://localhost:8080/api/arcs/campaign/${campaignId}`);
|
||||
return this.http.get<Arc[]>(`/api/arcs/campaign/${campaignId}`);
|
||||
}
|
||||
|
||||
getArcById(id: string): Observable<Arc> {
|
||||
return this.http.get<Arc>(`http://localhost:8080/api/arcs/${id}`);
|
||||
return this.http.get<Arc>(`/api/arcs/${id}`);
|
||||
}
|
||||
|
||||
createArc(payload: ArcCreate): Observable<Arc> {
|
||||
return this.http.post<Arc>('http://localhost:8080/api/arcs', payload);
|
||||
return this.http.post<Arc>('/api/arcs', payload);
|
||||
}
|
||||
|
||||
updateArc(id: string, payload: ArcCreate): Observable<Arc> {
|
||||
return this.http.put<Arc>(`http://localhost:8080/api/arcs/${id}`, payload);
|
||||
return this.http.put<Arc>(`/api/arcs/${id}`, payload);
|
||||
}
|
||||
|
||||
deleteArc(id: string): Observable<void> {
|
||||
return this.http.delete<void>(`http://localhost:8080/api/arcs/${id}`);
|
||||
return this.http.delete<void>(`/api/arcs/${id}`);
|
||||
}
|
||||
|
||||
getArcDeletionImpact(id: string): Observable<ArcDeletionImpact> {
|
||||
return this.http.get<ArcDeletionImpact>(`http://localhost:8080/api/arcs/${id}/deletion-impact`);
|
||||
return this.http.get<ArcDeletionImpact>(`/api/arcs/${id}/deletion-impact`);
|
||||
}
|
||||
|
||||
// ========== CHAPTER ==========
|
||||
getChapters(arcId: string): Observable<Chapter[]> {
|
||||
return this.http.get<Chapter[]>(`http://localhost:8080/api/chapters/arc/${arcId}`);
|
||||
return this.http.get<Chapter[]>(`/api/chapters/arc/${arcId}`);
|
||||
}
|
||||
|
||||
getChapterById(id: string): Observable<Chapter> {
|
||||
return this.http.get<Chapter>(`http://localhost:8080/api/chapters/${id}`);
|
||||
return this.http.get<Chapter>(`/api/chapters/${id}`);
|
||||
}
|
||||
|
||||
createChapter(payload: ChapterCreate): Observable<Chapter> {
|
||||
return this.http.post<Chapter>('http://localhost:8080/api/chapters', payload);
|
||||
return this.http.post<Chapter>('/api/chapters', payload);
|
||||
}
|
||||
|
||||
updateChapter(id: string, payload: ChapterCreate): Observable<Chapter> {
|
||||
return this.http.put<Chapter>(`http://localhost:8080/api/chapters/${id}`, payload);
|
||||
return this.http.put<Chapter>(`/api/chapters/${id}`, payload);
|
||||
}
|
||||
|
||||
deleteChapter(id: string): Observable<void> {
|
||||
return this.http.delete<void>(`http://localhost:8080/api/chapters/${id}`);
|
||||
return this.http.delete<void>(`/api/chapters/${id}`);
|
||||
}
|
||||
|
||||
getChapterDeletionImpact(id: string): Observable<ChapterDeletionImpact> {
|
||||
return this.http.get<ChapterDeletionImpact>(`http://localhost:8080/api/chapters/${id}/deletion-impact`);
|
||||
return this.http.get<ChapterDeletionImpact>(`/api/chapters/${id}/deletion-impact`);
|
||||
}
|
||||
|
||||
// ========== SCENE ==========
|
||||
getScenes(chapterId: string): Observable<Scene[]> {
|
||||
return this.http.get<Scene[]>(`http://localhost:8080/api/scenes/chapter/${chapterId}`);
|
||||
return this.http.get<Scene[]>(`/api/scenes/chapter/${chapterId}`);
|
||||
}
|
||||
|
||||
getSceneById(id: string): Observable<Scene> {
|
||||
return this.http.get<Scene>(`http://localhost:8080/api/scenes/${id}`);
|
||||
return this.http.get<Scene>(`/api/scenes/${id}`);
|
||||
}
|
||||
|
||||
createScene(payload: SceneCreate): Observable<Scene> {
|
||||
return this.http.post<Scene>('http://localhost:8080/api/scenes', payload);
|
||||
return this.http.post<Scene>('/api/scenes', payload);
|
||||
}
|
||||
|
||||
updateScene(id: string, payload: SceneCreate): Observable<Scene> {
|
||||
return this.http.put<Scene>(`http://localhost:8080/api/scenes/${id}`, payload);
|
||||
return this.http.put<Scene>(`/api/scenes/${id}`, payload);
|
||||
}
|
||||
|
||||
deleteScene(id: string): Observable<void> {
|
||||
return this.http.delete<void>(`http://localhost:8080/api/scenes/${id}`);
|
||||
return this.http.delete<void>(`/api/scenes/${id}`);
|
||||
}
|
||||
|
||||
search(q: string): Observable<Campaign[]> {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Character, CharacterCreate } from './character.model';
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CharacterService {
|
||||
private apiUrl = 'http://localhost:8080/api/characters';
|
||||
private apiUrl = '/api/characters';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
|
||||
31
web/src/app/services/config.service.ts
Normal file
31
web/src/app/services/config.service.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
/**
|
||||
* Configuration publique chargee une seule fois au demarrage via APP_INITIALIZER.
|
||||
* Le flag demoMode bascule l'UI en mode vitrine (Settings/Export masques).
|
||||
*/
|
||||
export interface PublicConfig {
|
||||
demoMode: boolean;
|
||||
}
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ConfigService {
|
||||
private config: PublicConfig = { demoMode: false };
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
async load(): Promise<void> {
|
||||
try {
|
||||
this.config = await firstValueFrom(this.http.get<PublicConfig>('/api/config'));
|
||||
} catch {
|
||||
// Si l'endpoint n'est pas joignable au boot, on reste sur le default
|
||||
// (demoMode=false) pour ne pas bloquer l'app en dev.
|
||||
}
|
||||
}
|
||||
|
||||
get demoMode(): boolean {
|
||||
return this.config.demoMode;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ConversationService {
|
||||
private readonly apiUrl = 'http://localhost:8080/api/conversations';
|
||||
private readonly apiUrl = '/api/conversations';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { GameSystem, GameSystemCreate } from './game-system.model';
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class GameSystemService {
|
||||
private apiUrl = 'http://localhost:8080/api/game-systems';
|
||||
private apiUrl = '/api/game-systems';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import { Image } from './image.model';
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ImageService {
|
||||
/** Base absolue du backend — utile pour construire des URLs complètes (<img src>). */
|
||||
readonly apiBase = 'http://localhost:8080';
|
||||
/** Base du backend (vide = même origine que le front, résolue par le navigateur). */
|
||||
readonly apiBase = '';
|
||||
private apiUrl = `${this.apiBase}/api/images`;
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
@@ -28,8 +28,8 @@ export interface LoreDeletionImpact {
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class LoreService {
|
||||
private apiUrl = 'http://localhost:8080/api/lores';
|
||||
private nodesUrl = 'http://localhost:8080/api/lore-nodes';
|
||||
private apiUrl = '/api/lores';
|
||||
private nodesUrl = '/api/lore-nodes';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Page, PageCreate } from './page.model';
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class PageService {
|
||||
private apiUrl = 'http://localhost:8080/api/pages';
|
||||
private apiUrl = '/api/pages';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export interface OllamaModelInfo {
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class SettingsService {
|
||||
private readonly apiUrl = 'http://localhost:8080/api/settings';
|
||||
private readonly apiUrl = '/api/settings';
|
||||
|
||||
// HTTP Basic : le browser gere le prompt natif de credentials au premier 401.
|
||||
// withCredentials=true pour que les creds soient renvoyees sur les appels
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Template, TemplateCreate } from './template.model';
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class TemplateService {
|
||||
private apiUrl = 'http://localhost:8080/api/templates';
|
||||
private apiUrl = '/api/templates';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user