From 03fe2769e067dd4b4dff3541f2ebaa876976c900 Mon Sep 17 00:00:00 2001 From: "francois.grand" <francois.grand@irstea.fr> Date: Wed, 2 May 2018 09:50:14 +0200 Subject: [PATCH 1/3] MAJ du fichier d'association des branches lors de la compilation --- jalhyd_branch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jalhyd_branch b/jalhyd_branch index 5f6e767f0..1f7391f92 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -47-ajouter-la-suppression-d-un-ouvrage-dans-les-ouvrages-paralleles +master -- GitLab From 47e3996a67877c879487f2bb4f030fef152a1e3d Mon Sep 17 00:00:00 2001 From: "francois.grand" <francois.grand@irstea.fr> Date: Wed, 2 May 2018 09:51:53 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=20#79=20utilisation=20de=20ServiceFactory?= =?UTF-8?q?=20=C3=A0=20la=20place=20de=20l'injection=20des=20services?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../horizontal-result-element.component.ts | 8 ++------ .../result-element/result-element-base.component.ts | 12 +++++++++--- .../vertical-result-element.component.ts | 8 ++------ 3 files changed, 13 insertions(+), 15 deletions(-) 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 d137a31c0..0925d4246 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 16e9a84cd..902471722 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 5028e6788..b5615bd38 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() { -- GitLab From 240de6b0bb26ebf652a85341b92b10f7242e375a Mon Sep 17 00:00:00 2001 From: "francois.grand" <francois.grand@irstea.fr> Date: Wed, 2 May 2018 10:37:26 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=20#79=20InternationalisationService=20:=20?= =?UTF-8?q?ajout=20de=20la=20m=C3=A9thode=20translate()=20pour=20traductio?= =?UTF-8?q?n=20les=20libell=C3=A9s=20de=20r=C3=A9sultats=20compl=C3=A9ment?= =?UTF-8?q?aires=20-=20suppression=20de=20CalculatedParamResults.=5FextraR?= =?UTF-8?q?esultHeaderMap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vertical-result-element.component.ts | 2 +- src/app/results/remous-results.ts | 1 - src/app/results/var-results.ts | 21 ++-------- .../internationalisation.service.ts | 40 +++++++++++++++++++ src/locale/error_messages.en.json | 8 +++- src/locale/error_messages.fr.json | 6 ++- 6 files changed, 56 insertions(+), 22 deletions(-) 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 b5615bd38..209f357b5 100644 --- a/src/app/components/result-element/vertical-result-element.component.ts +++ b/src/app/components/result-element/vertical-result-element.component.ts @@ -56,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 3f9a2be03..99cbddeb6 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 ebd48a211..c03b8c510 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 4b91abba1..a0878d77c 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 91b814d14..27500a7d6 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 cafedbd81..d0fa6e61f 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 -- GitLab