diff --git a/jalhyd_branch b/jalhyd_branch index 5f6e767f0cb49d2f5a889a9ddd564a6000de42cf..1f7391f92b6a3792204e07e99f71f643cc35e7e1 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -47-ajouter-la-suppression-d-un-ouvrage-dans-les-ouvrages-paralleles +master diff --git a/src/app/components/result-element/horizontal-result-element.component.ts b/src/app/components/result-element/horizontal-result-element.component.ts index d137a31c0864eaf5fad094ac83a5d88ed607ca42..0925d424692886a28c8d6984a30babb217e88d3c 100644 --- a/src/app/components/result-element/horizontal-result-element.component.ts +++ b/src/app/components/result-element/horizontal-result-element.component.ts @@ -25,12 +25,8 @@ export class HorizontalResultElementComponent extends ResultElementBaseComponent this._headerKeys = h; } - constructor( - appSetupService: ApplicationSetupService, - intlService: InternationalisationService, - private vcRef: ViewContainerRef - ) { - super(appSetupService, intlService); + constructor(private vcRef: ViewContainerRef) { + super(); } ngOnChanges() { diff --git a/src/app/components/result-element/result-element-base.component.ts b/src/app/components/result-element/result-element-base.component.ts index 16e9a84cd192ef67cd3d4fb905967a0c71e209d5..90247172240ecaae5672a9734a265ce51467cb14 100644 --- a/src/app/components/result-element/result-element-base.component.ts +++ b/src/app/components/result-element/result-element-base.component.ts @@ -5,6 +5,7 @@ import { ResultElement } from 'jalhyd'; import { ApplicationSetupService } from "../../services/app-setup/app-setup.service"; import { InternationalisationService } from "../../services/internationalisation/internationalisation.service"; import { OnChanges } from "@angular/core/src/metadata/lifecycle_hooks"; +import { ServiceFactory } from "../../services/service-factory"; /** * classe de base pour l'affichage d'un ResultElement @@ -50,10 +51,15 @@ export class ResultElementBaseComponent implements OnChanges { */ protected _emptyTooltip: boolean = false; + protected appSetupService: ApplicationSetupService; + + protected intlService: InternationalisationService; + constructor( - protected appSetupService: ApplicationSetupService, - private intlService: InternationalisationService - ) { } + ) { + this.appSetupService = ServiceFactory.instance.applicationSetupService; + this.intlService = ServiceFactory.instance.internationalisationService; + } /** * appelé quand les @Input changent diff --git a/src/app/components/result-element/vertical-result-element.component.ts b/src/app/components/result-element/vertical-result-element.component.ts index 5028e67886fbabf67e38e78842558fad75951640..209f357b5f0f1f96c650f9cd9e5f8a98d2fc28e7 100644 --- a/src/app/components/result-element/vertical-result-element.component.ts +++ b/src/app/components/result-element/vertical-result-element.component.ts @@ -35,12 +35,8 @@ export class VerticalResultElementComponent extends ResultElementBaseComponent { // template des tr pour les extraResult @ViewChild("extraResultTr") trTemplate: TemplateRef<any>; - constructor( - appSetupService: ApplicationSetupService, - intlService: InternationalisationService, - private vcRef: ViewContainerRef - ) { - super(appSetupService, intlService); + constructor(private vcRef: ViewContainerRef) { + super(); } private get resultLabel() { @@ -60,7 +56,7 @@ export class VerticalResultElementComponent extends ResultElementBaseComponent { const lblClass = (i % 2) == 0 ? "label1" : "label2"; const valueClass = (i % 2) == 0 ? "value1" : "value2"; this.vcRef.createEmbeddedView(this.trTemplate, { - extraRes: { "label": k, "value": er.toFixed(nDigits) }, + extraRes: { "label": this.intlService.translate(k), "value": er.toFixed(nDigits) }, classes: { "label_class": lblClass, "value_class": valueClass } }); i++; diff --git a/src/app/results/remous-results.ts b/src/app/results/remous-results.ts index 3f9a2be03c2311ca95955df0cbde580512b619d7..99cbddeb6fb468cab402617cd2bf0ad979b2bfa8 100644 --- a/src/app/results/remous-results.ts +++ b/src/app/results/remous-results.ts @@ -145,7 +145,6 @@ export class RemousResults extends CalculatorResults { if (this._hasExtra) keys.push("tRes"); this._varResults.extraResultKeys = keys; - this._varResults.extraResultHeaderMap = { "flu": "Ligne d'eau fluviale", "tor": "Ligne d'eau torrentielle", "tRes": this._extraParamLabel }; this._varResults.update(true); } diff --git a/src/app/results/var-results.ts b/src/app/results/var-results.ts index ebd48a211ecf0cac640f460bceccd075dc89bb63..c03b8c5104c450533f6f5b8d3528d9d640da719f 100644 --- a/src/app/results/var-results.ts +++ b/src/app/results/var-results.ts @@ -2,6 +2,7 @@ import { CalculatorResults } from "./calculator-results"; import { CalculatedParamResults } from "./param-calc-results"; import { NgParameter } from "../formulaire/ngparam"; import { ResultElement } from "jalhyd"; +import { ServiceFactory } from "../services/service-factory"; /** * type de graphe @@ -40,11 +41,6 @@ export class VarResults extends CalculatedParamResults { */ private _extraResultKeys: string[]; - /** - * mapping clé de résultat complémentaire <-> titre de colonne - */ - private _extraResultHeaderMap: { [key: string]: string }; - /** * entête des colonnes des résultats supplémentaires */ @@ -75,7 +71,6 @@ export class VarResults extends CalculatedParamResults { this._variableParamHeader = undefined; this._extraResultHeaders = []; this._extraResultKeys = []; - this._extraResultHeaderMap = {}; this._yValues = []; this._graphTitle = undefined; } @@ -121,10 +116,6 @@ export class VarResults extends CalculatedParamResults { this._extraResultKeys = k; } - public set extraResultHeaderMap(m: { [key: string]: string }) { - this._extraResultHeaderMap = m; - } - public update(displaySymbol: boolean) { if (this._variableParamHeader === undefined) this._variableParamHeader = CalculatorResults.paramLabel(this.variatedParameter, displaySymbol); @@ -143,12 +134,8 @@ export class VarResults extends CalculatedParamResults { // entêtes des résultats supplémentaires - for (const k of this._extraResultKeys) { - const h = this._extraResultHeaderMap[k]; - if (h) - this._extraResultHeaders.push(h); - else - this._extraResultHeaders.push(k); - } + const intlService = ServiceFactory.instance.internationalisationService; + for (const k of this._extraResultKeys) + this._extraResultHeaders.push(intlService.translate(k)); } } diff --git a/src/app/services/internationalisation/internationalisation.service.ts b/src/app/services/internationalisation/internationalisation.service.ts index 4b91abba1cf1dd332fac8427d9139a539d1ae61f..a0878d77cd7c087ba09c5e2ffebb10a2c0e3a576 100644 --- a/src/app/services/internationalisation/internationalisation.service.ts +++ b/src/app/services/internationalisation/internationalisation.service.ts @@ -166,4 +166,44 @@ export class InternationalisationService extends Observable { return "<messages not loaded>"; return this._Messages[code]; } + + public translate(o: any) { + let res; + if (typeof o === "string") { + switch (o) { + case "flu": + res = this.localizeText("INFO_REMOUSRESULTS_LIGNEFLUVIALE"); + break; + + case "tor": + res = this.localizeText("INFO_REMOUSRESULTS_LIGNETORRENTIELLE"); + break; + + default: + // const re = new RegExp("([A-Z,a-z]+)\[(\\d+\)]\\.(.+)"); + const re = /([A-Z,a-z]+)\[(\d+)\]\.(.+)/; + const match = re.exec(o); + if (match) + if (match[1] === "ouvrage") + res = this.localizeText("INFO_OUVRAGE") + " n°" + (+match[2] + 1); + + const p = match[3]; + switch (p) { + case "Q": + res += " : " + this.localizeText("INFO_GRANDEUR_" + p); + break; + + case "Q_Mode": + res += " : " + this.localizeText("INFO_TYPE_ECOULEMENT"); + break; + + case "Q_Regime": + res += " : " + this.localizeText("INFO_REGIME"); + break; + } + break; + } + } + return res; + } } diff --git a/src/locale/error_messages.en.json b/src/locale/error_messages.en.json index 91b814d14049e7914d84b5361f9764702e256c4a..27500a7d68dd672a5752ef35eb824c0a19b1340e 100644 --- a/src/locale/error_messages.en.json +++ b/src/locale/error_messages.en.json @@ -43,11 +43,12 @@ "INFO_LECHAPT_TITRE": "Lechapt-Calmon", "INFO_REGUNI_TITRE": "Uniform flow calculation", "INFO_SECTPARAM_TITRE": "Parametric section", + "INFO_GRANDEUR_Q": "Flow (m³/s)", "INFO_GRANDEUR_HS": "Specific head (m)", "INFO_GRANDEUR_HSC": "Critical head (m)", "INFO_GRANDEUR_B": "Surface width (m)", "INFO_GRANDEUR_P": "Wetted perimeter (m)", - "INFO_GRANDEUR_S": "Wetted area (m2)", + "INFO_GRANDEUR_S": "Wetted area (m²)", "INFO_GRANDEUR_R": "Hydraulic radius (m)", "INFO_GRANDEUR_V": "Average speed (m/s)", "INFO_GRANDEUR_FR": "Froude number", @@ -81,5 +82,8 @@ "INFO_OPTION_NO": "No", "INFO_PABDIM_TITRE": "Pool pass: dimensions", "INFO_PABPUISS_TITRE": "Pool pass: dissipated power", - "INFO_OUVRAGEPARAL_TITRE": "Parallel structures" + "INFO_OUVRAGEPARAL_TITRE": "Parallel structures", + "INFO_OUVRAGE": "Structure", + "INFO_TYPE_ECOULEMENT": "Mode", + "INFO_REGIME": "Regime" } \ No newline at end of file diff --git a/src/locale/error_messages.fr.json b/src/locale/error_messages.fr.json index cafedbd81bcd5b54ee550b77b6160a43780ec3f7..d0fa6e61fb32081e1e15b56619e2a936c6bf40ba 100644 --- a/src/locale/error_messages.fr.json +++ b/src/locale/error_messages.fr.json @@ -49,11 +49,12 @@ "INFO_LECHAPT_TITRE": "Lechapt-Calmon", "INFO_REGUNI_TITRE": "Régime uniforme", "INFO_SECTPARAM_TITRE": "Section paramétrée", + "INFO_GRANDEUR_Q": "Débit (m³/s)", "INFO_GRANDEUR_HS": "La charge spécifique (m)", "INFO_GRANDEUR_HSC": "La charge critique (m)", "INFO_GRANDEUR_B": "La largeur au miroir (m)", "INFO_GRANDEUR_P": "Le périmètre mouillé (m)", - "INFO_GRANDEUR_S": "La surface mouillée (m2)", + "INFO_GRANDEUR_S": "La surface mouillée (m²)", "INFO_GRANDEUR_R": "Le rayon hydraulique (m)", "INFO_GRANDEUR_V": "La vitesse moyenne (m/s)", "INFO_GRANDEUR_FR": "Le Froude", @@ -88,6 +89,9 @@ "INFO_PABDIM_TITRE": "Passe à bassin : dimensions", "INFO_PABPUISS_TITRE": "Passe à bassin : puissance dissipée", "INFO_OUVRAGEPARAL_TITRE": "Ouvrages en parallèle", + "INFO_OUVRAGE": "Ouvrage", + "INFO_TYPE_ECOULEMENT": "Type d'écoulement", + "INFO_REGIME": "Régime", "WARNING_STRUCTUREKIVI_PELLE_TROP_FAIBLE": "La pelle du seuil doit mesurer au moins 0,1 m. Le coefficient béta est forcé à 0", "WARNING_STRUCTUREKIVI_HP_TROP_ELEVE": "h/p ne doit pas être supérieur à 2,5. h/p est forcé à 2,5" } \ No newline at end of file