Import de règles : compteur d'attente et message de nouvel essai
Qualité & Sécurité / Web (ESLint · angular-eslint + sonarjs) (push) Successful in 35s
Qualité & Sécurité / Trivy (CVE dépendances Maven / pip / npm) (push) Failing after 1m2s
Qualité & Sécurité / MegaLinter (PMD · Ruff · Bandit · gitleaks · hadolint) (push) Failing after 1m48s
Qualité & Sécurité / Web (ESLint · angular-eslint + sonarjs) (push) Successful in 35s
Qualité & Sécurité / Trivy (CVE dépendances Maven / pip / npm) (push) Failing after 1m2s
Qualité & Sécurité / MegaLinter (PMD · Ruff · Bandit · gitleaks · hadolint) (push) Failing after 1m48s
Après une erreur passagère du fournisseur IA, « nouvel essai dans 3s » restait affiché pendant tout l'essai suivant, qui peut durer plusieurs minutes : l'import paraissait bloqué alors qu'il avançait. - Brain : un message annonce le lancement de l'essai suivant (« Nouvel essai en cours (tentative 2/3)… »). - Écran du système de jeu : au-delà de 15 s sans nouvelle, un compteur indique depuis combien de temps l'IA travaille sur le morceau. Vérifié : brain (234 tests), vitest, build, lint sans erreur. À redéployer : web + brain.
This commit is contained in:
@@ -60,6 +60,9 @@
|
||||
@if (importStatus) {
|
||||
<p class="import-status" role="status">{{ importStatus }}</p>
|
||||
}
|
||||
@if (importWaitLabel) {
|
||||
<p class="import-waiting">{{ 'gameSystemEdit.importWaiting' | translate:{ time: importWaitLabel } }}</p>
|
||||
}
|
||||
@if (importFound.length) {
|
||||
<p class="import-found">
|
||||
{{ 'gameSystemEdit.sectionsFound' | translate:{ titles: importFound.join(' · ') } }}
|
||||
|
||||
@@ -173,6 +173,13 @@
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.import-waiting {
|
||||
margin: 0.45rem 0 0;
|
||||
color: var(--text-muted, #9ca3af);
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.import-note {
|
||||
margin: -0.4rem 0 1rem;
|
||||
padding: 0.55rem 0.8rem;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
@@ -52,7 +52,7 @@ type RulesLang = 'fr' | 'en';
|
||||
templateUrl: './game-system-edit.component.html',
|
||||
styleUrls: ['./game-system-edit.component.scss']
|
||||
})
|
||||
export class GameSystemEditComponent implements OnInit {
|
||||
export class GameSystemEditComponent implements OnInit, OnDestroy {
|
||||
readonly Save = Save;
|
||||
readonly ArrowLeft = ArrowLeft;
|
||||
readonly Dices = Dices;
|
||||
@@ -82,6 +82,14 @@ export class GameSystemEditComponent implements OnInit {
|
||||
* en cours, pas l'historique.
|
||||
*/
|
||||
importStatus: string | null = null;
|
||||
/**
|
||||
* Secondes écoulées depuis le dernier évènement du flux. Un morceau peut occuper
|
||||
* l'IA plusieurs minutes (et un nouvel essai après une erreur autant) : sans ce
|
||||
* compteur, l'écran paraît figé alors que l'import avance.
|
||||
*/
|
||||
importWaitSeconds = 0;
|
||||
private lastImportEventAt = 0;
|
||||
private importWaitTimer?: ReturnType<typeof setInterval>;
|
||||
|
||||
name = '';
|
||||
description = '';
|
||||
@@ -177,9 +185,12 @@ export class GameSystemEditComponent implements OnInit {
|
||||
this.importProgress = null;
|
||||
this.importFound = [];
|
||||
this.importStatus = null;
|
||||
this.startImportWait();
|
||||
|
||||
this.service.importRulesStream(file).subscribe({
|
||||
next: (ev) => {
|
||||
this.lastImportEventAt = Date.now();
|
||||
this.importWaitSeconds = 0;
|
||||
if (ev.type === 'progress') {
|
||||
// Un morceau vient d'aboutir : le message d'attente est obsolète.
|
||||
this.importStatus = null;
|
||||
@@ -254,6 +265,34 @@ export class GameSystemEditComponent implements OnInit {
|
||||
this.importing = false;
|
||||
this.importPhase = '';
|
||||
this.importProgress = null;
|
||||
this.stopImportWait();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.stopImportWait();
|
||||
}
|
||||
|
||||
/** Le compteur ne s'affiche qu'au-delà de quelques secondes sans nouvelle. */
|
||||
get importWaitLabel(): string | null {
|
||||
const s = this.importWaitSeconds;
|
||||
if (s < 15) return null;
|
||||
const m = Math.floor(s / 60);
|
||||
return m > 0 ? `${m} min ${String(s % 60).padStart(2, '0')} s` : `${s} s`;
|
||||
}
|
||||
|
||||
private startImportWait(): void {
|
||||
this.stopImportWait();
|
||||
this.lastImportEventAt = Date.now();
|
||||
this.importWaitSeconds = 0;
|
||||
this.importWaitTimer = setInterval(() => {
|
||||
this.importWaitSeconds = Math.floor((Date.now() - this.lastImportEventAt) / 1000);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
private stopImportWait(): void {
|
||||
if (this.importWaitTimer) clearInterval(this.importWaitTimer);
|
||||
this.importWaitTimer = undefined;
|
||||
this.importWaitSeconds = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user