diff --git a/src/app/components/pab-results/pab-results.component.ts b/src/app/components/pab-results/pab-results.component.ts index cd5fe967ea30c14ce2a54c02a848ca0003aad086..ff73e62cbe9c14ca7c584acf7be3e4a19566cb11 100644 --- a/src/app/components/pab-results/pab-results.component.ts +++ b/src/app/components/pab-results/pab-results.component.ts @@ -1,6 +1,6 @@ import { Component, ViewChild, DoCheck } from "@angular/core"; -import { Result, cLog, Message, MessageCode } from "jalhyd"; +import { Result, cLog, Message, MessageCode, MessageSeverity } from "jalhyd"; import { LogComponent } from "../../components/log/log.component"; import { CalculatorResults } from "../../results/calculator-results"; @@ -118,19 +118,77 @@ export class PabResultsComponent implements DoCheck { } /** - * Retourne true si au moins une des cloisons a un message de log dans - * un de ses ResultElement + * Returns the number of errors, warnings, infos among children logs */ - private childrenHaveLogs(): boolean { + private logStats(): any { + const ret = { + info: 0, + warning: 0, + error: 0 + }; + if (this._pabResults.result && this._pabResults.result.hasLog) { + for (const re of this._pabResults.result.resultElements) { + if (re.hasLog) { + for (const m of re.log.messages) { + const s = m.getSeverity(); + switch (s) { + case MessageSeverity.INFO: + ret.info ++; + break; + case MessageSeverity.WARNING: + ret.warning ++; + break; + case MessageSeverity.ERROR: + ret.error ++; + break; + } + } + } + } + } for (const cr of this._pabResults.cloisonsResults) { if (cr && cr.hasLog) { - return true; + for (const re of cr.resultElements) { + if (re.hasLog) { + for (const m of re.log.messages) { + const s = m.getSeverity(); + switch (s) { + case MessageSeverity.INFO: + ret.info ++; + break; + case MessageSeverity.WARNING: + ret.warning ++; + break; + case MessageSeverity.ERROR: + ret.error ++; + break; + } + } + } + } } } if (this._pabResults.cloisonAvalResults && this._pabResults.cloisonAvalResults.hasLog) { - return true; + for (const re of this._pabResults.cloisonAvalResults.resultElements) { + if (re.hasLog) { + for (const m of re.log.messages) { + const s = m.getSeverity(); + switch (s) { + case MessageSeverity.INFO: + ret.info ++; + break; + case MessageSeverity.WARNING: + ret.warning ++; + break; + case MessageSeverity.ERROR: + ret.error ++; + break; + } + } + } + } } - return false; + return ret; } /* @@ -144,10 +202,16 @@ export class PabResultsComponent implements DoCheck { this.mergeGlobalLog(this._pabResults.result, l); // un problème avec la PAB en général / les cloisons, à une étape quelconque ? if ( - (this.pabResults.hasLog || this.childrenHaveLogs()) + (this.pabResults.hasLog) && l.messages.length === 0 // existing global messages make generic message below useless ) { - l.add(new Message(MessageCode.WARNING_PROBLEMS_ENCOUNTERED)); + const logStats = this.logStats(); + const m = new Message(MessageCode.WARNING_PROBLEMS_ENCOUNTERED); + m.extraVar.info = "" + logStats.info; // to avoid displaying fixed number of digits + m.extraVar.warning = "" + logStats.warning; + m.extraVar.error = "" + logStats.error; + l.add(m); + // l.add(new Message(MessageCode.WARNING_PROBLEMS_ENCOUNTERED)); } } // sinon pas de log global (aucun paramètre ne varie) return l; diff --git a/src/app/results/pab-results.ts b/src/app/results/pab-results.ts index b30a28cfa576624811b33b414cb0810a223c50d9..317914470e2565bcb1e82d22ce853dc42ae0560b 100644 --- a/src/app/results/pab-results.ts +++ b/src/app/results/pab-results.ts @@ -69,8 +69,10 @@ export class PabResults extends CalculatedParamResults { this.Z2 = []; } - // returns true if at least one log message is present in the PAB result or any - // of the children result + /** + * Returns true if at least one log message is present in the PAB result or any + * of the children results + */ public get hasLog(): boolean { if (this.cloisonsResults) { for (const cr of this.cloisonsResults) { diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index cbd1869b35c80d863f7bc5bba1d1b983f062e291..78e3384d637e0a52cca6d3e71361631bd9639783 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -302,7 +302,7 @@ "INFO_PARAMFIELD_VARIATED": "Variated", "INFO_PARAMMODE_LIST": "Values list", "INFO_PARAMMODE_MINMAX": "Min/max", - "WARNING_PROBLEMS_ENCOUNTERED": "Problems occurred during calculation", + "WARNING_PROBLEMS_ENCOUNTERED": "Problems occurred during calculation (info: %info%, warning: %warning%, error: %error%)", "INFO_REGIMEUNIFORME_TITRE_COURT": "Uniform flow", "INFO_REGIMEUNIFORME_TITRE": "Uniform flow calculation", "INFO_REMOUS_CALCUL_FLUVIAL": "Downstream boundary condition >= Critical elevation: calculation of subcritical part from downstream", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index a789665c678ed1bc9fb742a69275b3d904bb9617..e9135bada0233eb094b618f0933407f3d1f5a239 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -302,7 +302,7 @@ "INFO_PARAMFIELD_VARIATED": "Varié", "INFO_PARAMMODE_LIST": "Liste de valeurs", "INFO_PARAMMODE_MINMAX": "Min/max", - "WARNING_PROBLEMS_ENCOUNTERED": "Des problèmes sont survenus durant le calcul", + "WARNING_PROBLEMS_ENCOUNTERED": "Des problèmes sont survenus durant le calcul (info: %info%, avertissement: %warning%, erreur: %error%)", "INFO_REGIMEUNIFORME_TITRE_COURT": "R. uniforme", "INFO_REGIMEUNIFORME_TITRE": "Régime uniforme", "INFO_REMOUS_CALCUL_FLUVIAL": "Condition limite aval >= Hauteur critique : calcul de la partie fluviale à partir de l'aval",