- Possibilité de discuter avec un PDF ; RAG ou analyse approfondie. Enlèvement de l'autre outil PDF de discussion qui analysait d'abord un PDF en proposant directement une intégration sans attendre qu'on pose de question - Mise en place de l'import directement dans les outils dans la sidebar - Mise en place d'un outil pour créer des tables aléatoires avec possibilité d'utiliser pendant la partie - Mise en place d'un outil pour mettre en place des PNJ, scènes, chapitre.... directement à partir de la discussion avec le PDF - Mise en place RAG avec mistal-embeding ou nomic si on utilise ollama - Mise en place mistral, google en fournisseurs alternatifs pour l'IA dans le cloud - version 0.11.0-bêta
98 lines
3.8 KiB
TypeScript
98 lines
3.8 KiB
TypeScript
import { Component, OnInit, OnDestroy } from '@angular/core';
|
|
import { CommonModule } from '@angular/common';
|
|
import { ReactiveFormsModule, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
import { forkJoin } from 'rxjs';
|
|
import { LucideAngularModule, BookOpen } from 'lucide-angular';
|
|
import { CampaignService } from '../../../services/campaign.service';
|
|
import { CharacterService } from '../../../services/character.service';
|
|
import { NpcService } from '../../../services/npc.service';
|
|
import { RandomTableService } from '../../../services/random-table.service';
|
|
import { LayoutService } from '../../../services/layout.service';
|
|
import { loadCampaignTreeData, buildCampaignSidebarConfig } from '../../campaign-tree.helper';
|
|
import { IconPickerComponent } from '../../../shared/icon-picker/icon-picker.component';
|
|
import { CAMPAIGN_ICON_OPTIONS } from '../../campaign-icons';
|
|
|
|
/**
|
|
* Écran de création d'un nouvel Arc narratif (contexte Campagne).
|
|
* Formulaire simple : nom + description. L'ordre est auto-calculé depuis
|
|
* le nombre d'arcs existants dans la campagne courante.
|
|
*/
|
|
@Component({
|
|
selector: 'app-arc-create',
|
|
standalone: true,
|
|
imports: [CommonModule, ReactiveFormsModule, LucideAngularModule, IconPickerComponent],
|
|
templateUrl: './arc-create.component.html',
|
|
styleUrls: ['./arc-create.component.scss']
|
|
})
|
|
export class ArcCreateComponent implements OnInit, OnDestroy {
|
|
readonly BookOpen = BookOpen;
|
|
readonly campaignIconOptions = CAMPAIGN_ICON_OPTIONS;
|
|
|
|
form: FormGroup;
|
|
campaignId = '';
|
|
selectedIcon: string | null = null;
|
|
private existingArcCount = 0;
|
|
|
|
constructor(
|
|
private fb: FormBuilder,
|
|
private route: ActivatedRoute,
|
|
private router: Router,
|
|
private campaignService: CampaignService,
|
|
private characterService: CharacterService,
|
|
private npcService: NpcService,
|
|
private randomTableService: RandomTableService,
|
|
private layoutService: LayoutService
|
|
) {
|
|
this.form = this.fb.group({
|
|
name: ['', Validators.required],
|
|
description: [''],
|
|
// Type structurel : LINEAR (séquentiel) par défaut, HUB (sandbox/quêtes parallèles).
|
|
type: ['LINEAR', Validators.required]
|
|
});
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
this.campaignId = this.route.snapshot.paramMap.get('campaignId')!;
|
|
this.loadLayout();
|
|
}
|
|
|
|
private loadLayout(): void {
|
|
forkJoin({
|
|
campaign: this.campaignService.getCampaignById(this.campaignId),
|
|
allCampaigns: this.campaignService.getAllCampaigns(),
|
|
treeData: loadCampaignTreeData(this.campaignService, this.campaignId, this.characterService, this.npcService, this.randomTableService)
|
|
}).subscribe(({ campaign, allCampaigns, treeData }) => {
|
|
this.existingArcCount = treeData.arcs.length;
|
|
|
|
this.layoutService.show(buildCampaignSidebarConfig(campaign, allCampaigns, treeData, this.campaignId));
|
|
});
|
|
}
|
|
|
|
submit(): void {
|
|
if (this.form.invalid) return;
|
|
this.campaignService.createArc({
|
|
name: this.form.value.name,
|
|
description: this.form.value.description,
|
|
campaignId: this.campaignId,
|
|
order: this.existingArcCount + 1,
|
|
type: this.form.value.type,
|
|
icon: this.selectedIcon
|
|
}).subscribe({
|
|
next: (created) => this.router.navigate(['/campaigns', this.campaignId, 'arcs', created.id]),
|
|
error: () => console.error('Erreur lors de la création de l\'arc')
|
|
});
|
|
}
|
|
|
|
cancel(): void {
|
|
this.router.navigate(['/campaigns', this.campaignId]);
|
|
}
|
|
|
|
ngOnDestroy(): void {
|
|
// Volontairement vide : la sidebar reste prise en charge par le composant
|
|
// suivant (autre sous-route ou le composant detail parent) qui appellera
|
|
// show(). Eviter d'appeler hide() ici previent le clignotement / la
|
|
// disparition de la sidebar lors des navigations internes a la section.
|
|
}
|
|
}
|