Skip to content
Snippets Groups Projects
Commit b5092974 authored by mathias.chouet's avatar mathias.chouet
Browse files

Fix #442 - ParallelStructures: add device number in log messages

parent 71c89f33
No related branches found
No related tags found
1 merge request!102Resolve "Lois d'ouvrages: ajouter le n° d'ouvrage dans les logs"
Pipeline #138236 passed
259-bug-erreur-de-formulation-de-la-loi-de-cunge-en-orifice-denoye
260-messages-de-log-maintenir-un-pointeur-vers-le-resultat-afin-de-pouvoir-contextualiser-par-la
import { Component, Input, OnChanges } from "@angular/core";
import { Message, MessageSeverity } from "jalhyd";
import { Message, MessageSeverity, Result, Nub } from "jalhyd";
import { I18nService } from "../../services/internationalisation.service";
import { ApplicationSetupService } from "../../services/app-setup.service";
......
import { Injectable, isDevMode } from "@angular/core";
import { Message, MessageCode, Observable, Observer, Nub } from "jalhyd";
import { Message, MessageCode, Observable, Observer, Nub, CalculatorType } from "jalhyd";
import { StringMap } from "../stringmap";
import { ApplicationSetupService } from "./app-setup.service";
......@@ -141,6 +141,7 @@ export class I18nService extends Observable implements Observer {
* @param nDigits nombre de chiffres à utiliser pour l'arrondi dans le cas de données numériques
*/
public localizeMessage(r: Message, nDigits: number = 3): string {
let text: string;
let m: string = this.getMessageFromCode(r.code);
for (const k in r.extraVar) {
......@@ -191,7 +192,44 @@ export class I18nService extends Observable implements Observer {
return this.localizeText(p1);
});
return decodeHtml(m);
text = decodeHtml(m);
// prefix message if needed
if (r.parent && r.parent.parent && r.parent.parent.sourceNub) {
text = this.prefix(r.parent.parent.sourceNub, text);
}
return text;
}
/**
* Prefix given text message with context read from given Nub
* @param n Nub associated to original Message object, to read context from
* @param text text message to prefix
*/
private prefix(n: Nub, text: string): string {
let prefixed: string = text;
if (n.parent) {
// get child name and position from Nub's parent
const pos = String(n.findPositionInParent() + 1);
const name = this.childName(n.parent);
let m: Message;
// Detect downwalls
if (n.calcType === CalculatorType.CloisonAval) {
m = new Message(MessageCode.INFO_PARENT_PREFIX_DOWNWALL);
} else {
m = new Message(MessageCode.INFO_PARENT_PREFIX);
m.extraVar.name = name;
m.extraVar.position = pos;
}
const prefix = this.localizeMessage(m);
prefixed =
prefix.substring(0, 1).toUpperCase() + prefix.substring(1)
+ " "
+ prefixed.substring(0, 1).toLowerCase() + prefixed.substring(1);
// recursivity
prefixed = this.prefix(n.parent, prefixed);
}
return prefixed;
}
private replaceAll(str: string, find: string, replace: string) {
......
......@@ -167,6 +167,8 @@
"INFO_STUFF_MOVED": "%s #%s moved",
"INFO_STUFF_REMOVED": "%s #%s removed",
"INFO_STUFF_N": "%s #",
"INFO_CHILD_TYPE_CLOISON": "wall",
"INFO_CHILD_TYPE_CLOISON_PLUR": "walls",
"INFO_CHILD_TYPE_OUVRAGE": "device",
"INFO_CHILD_TYPE_OUVRAGE_PLUR": "devices",
"INFO_CHILD_TYPE_MACRORUGO": "apron",
......@@ -543,7 +545,7 @@
"WARNING_LECHAPT_CALMON_SPEED_OUTSIDE_04_2": "This formula is discouraged for a speed that is not between 0.4 and 2 m/s",
"WARNING_UPSTREAM_BOTTOM_HIGHER_THAN_WATER": "Upstream water elevation is lower or equal to bottom elevation",
"WARNING_DOWNSTREAM_BOTTOM_HIGHER_THAN_WATER": "Downstream water elevation is lower or equal to bottom elevation",
"WARNING_NEGATIVE_SILL": "Sill of device#%number# should be positive",
"WARNING_NEGATIVE_SILL": "Sill should be positive",
"WARNING_RAMP_WIDTH_LOWER_THAN_PATTERN_WIDTH": "Ramp width should contain at least one block (%pattern%m)",
"WARNING_RAMP_WIDTH_NOT_MULTIPLE_OF_HALF_PATTERN_WIDTH": "Ramp width should be a multiple of half the block width (%halfPattern%m). Nearest values are %lower% and %higher%",
"WARNING_YN_SECTION_PENTE_NEG_NULLE_HNORMALE_INF": "Normal depth: slope is negative or zero, normal depth is infinite",
......@@ -566,5 +568,7 @@
"WARNING_PAR_N_ROUNDED_TO_05": "Number of patterns was rounded to %val%",
"WARNING_PAR_M_ROUNDED_TO_1": "Number of longitudinal strips was rounded to %val%",
"WARNING_PAR_NOT_SUBMERGED": "Insufficient downstream submergence : fall at the last downstream baffle (%DH% m).",
"ERROR_PAR_M_GREATER_THAN_2_N": "Number of longitudinal strips exceeds 2N = %max%"
"ERROR_PAR_M_GREATER_THAN_2_N": "Number of longitudinal strips exceeds 2N = %max%",
"INFO_PARENT_PREFIX": "%name% #%position%: ",
"INFO_PARENT_PREFIX_DOWNWALL": "downwall: "
}
......@@ -167,6 +167,8 @@
"INFO_STUFF_MOVED": "%s n°%s déplacé(e)",
"INFO_STUFF_REMOVED": "%s n°%s supprimé(e)",
"INFO_STUFF_N": "%s n°",
"INFO_CHILD_TYPE_CLOISON": "cloison",
"INFO_CHILD_TYPE_CLOISON_PLUR": "cloisons",
"INFO_CHILD_TYPE_OUVRAGE": "ouvrage",
"INFO_CHILD_TYPE_OUVRAGE_PLUR": "ouvrages",
"INFO_CHILD_TYPE_MACRORUGO": "radier",
......@@ -544,7 +546,7 @@
"WARNING_LECHAPT_CALMON_SPEED_OUTSIDE_04_2": "Cette formule n'est pas conseillée pour une vitesse non comprise entre 0.4 et 2 m/s",
"WARNING_UPSTREAM_BOTTOM_HIGHER_THAN_WATER": "La cote de l'eau à l'amont est plus basse ou égale à la cote de fond",
"WARNING_DOWNSTREAM_BOTTOM_HIGHER_THAN_WATER": "La cote de l'eau à l'aval est plus basse ou égale à la cote de fond",
"WARNING_NEGATIVE_SILL": "La pelle du seuil de l'ouvrage n°%number% devrait être positive",
"WARNING_NEGATIVE_SILL": "La pelle du seuil devrait être positive",
"WARNING_RAMP_WIDTH_LOWER_THAN_PATTERN_WIDTH": "La largeur de la rampe devrait comprendre au moins un motif de plot (%pattern%m)",
"WARNING_RAMP_WIDTH_NOT_MULTIPLE_OF_HALF_PATTERN_WIDTH": "La largeur de la rampe devrait être un multiple d'un demi motif (%halfPattern%m). Les valeurs voisines sont %lower% et %higher%",
"WARNING_YN_SECTION_PENTE_NEG_NULLE_HNORMALE_INF": "Hauteur normale: pente négative ou nulle, hauteur normale infinie",
......@@ -567,5 +569,7 @@
"WARNING_PAR_N_ROUNDED_TO_05": "Le nombre de motifs a été arrondi à %val%",
"WARNING_PAR_M_ROUNDED_TO_1": "Le nombre de bandes a été arrondi à %val%",
"WARNING_PAR_NOT_SUBMERGED": "Ennoiement par l'aval insuffisant : chute au niveau du dernier ralentisseur aval (%DH% m).",
"ERROR_PAR_M_GREATER_THAN_2_N": "Le nombre de bandes dépasse 2N = %max%"
"ERROR_PAR_M_GREATER_THAN_2_N": "Le nombre de bandes dépasse 2N = %max%",
"INFO_PARENT_PREFIX": "%name% n°%position% : ",
"INFO_PARENT_PREFIX_DOWNWALL": "cloison aval : "
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment