diff --git a/src/app/calculators/generic/ngparam.ts b/src/app/calculators/generic/ngparam.ts index f477e9ec55601b48d6c3fc8c767654727ed37ea1..8d7f12bdbef62d30e46ee7867c7b044de0a529d7 100644 --- a/src/app/calculators/generic/ngparam.ts +++ b/src/app/calculators/generic/ngparam.ts @@ -1,4 +1,4 @@ -import { ComputeNodeType, ParamDefinition, ParamDomainValue, ErrorMessage } from 'jalhyd'; +import { ComputeNodeType, ParamDefinition, ParamDomainValue } from 'jalhyd'; import { InputField, Dependency, DependencyConditionType, ValueDependencyCondition } from './formulaire'; import { StringMap } from '../../stringmap'; diff --git a/src/app/components/param-input/param-input.component.ts b/src/app/components/param-input/param-input.component.ts index acf2d03f06a481c635c970a90edcc0ae41aa3f64..47c7e7695f29873a87eb89367f7c1dc8fa6582d1 100644 --- a/src/app/components/param-input/param-input.component.ts +++ b/src/app/components/param-input/param-input.component.ts @@ -3,7 +3,7 @@ import { Component, Input, forwardRef, OnInit, DoCheck, ChangeDetectorRef } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR, NG_VALIDATORS, FormControl } from '@angular/forms'; -import { ComputeNodeType, ParamDefinition, NumericalString, ErrorMessage } from 'jalhyd'; +import { ComputeNodeType, ParamDefinition, NumericalString, Message } from 'jalhyd'; import { ParamService } from '../../services/param/param.service'; import { InternationalisationService, LanguageCode } from '../../services/internationalisation/internationalisation.service'; @@ -152,8 +152,8 @@ export class ParamInputComponent implements ControlValueAccessor, OnInit, DoChec this._paramDef.checkValue(v.numericalValue); } catch (e) { - if (e instanceof ErrorMessage) - this._message = this.intlService.localizeErrorMessage(e); + if (e instanceof Message) + this._message = this.intlService.localizeMessage(e); else this._message = "invalid value"; } diff --git a/src/app/components/remous-results/remous-results.component.ts b/src/app/components/remous-results/remous-results.component.ts index f26d1c4b858df47b4b0831304df5bbc210ba9b20..89358f567f6e8cfc77aec2cfddc30d5f3894bb88 100644 --- a/src/app/components/remous-results/remous-results.component.ts +++ b/src/app/components/remous-results/remous-results.component.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core'; -import { ErrorMessage } from 'jalhyd'; +import { Message } from 'jalhyd'; import { InternationalisationService } from '../../services/internationalisation/internationalisation.service'; @@ -174,8 +174,8 @@ export class RemousResultsComponent { this._results.push({ "abs": x, "flu": f, "tor": t }); } - public addLogEntry(m: ErrorMessage, nDigits: number) { - this._logEntries.push(this.intlService.localizeErrorMessage(m, nDigits)); + public addLogEntry(m: Message, nDigits: number) { + this._logEntries.push(this.intlService.localizeMessage(m, nDigits)); } public setPenteFond(v: number) { diff --git a/src/app/services/internationalisation/internationalisation.service.ts b/src/app/services/internationalisation/internationalisation.service.ts index d76b6c925c1d3233922d2ee380b044d0a01f0244..c1a2ffc6bb3f66d0dcbdfeb762ee513c6a47195e 100644 --- a/src/app/services/internationalisation/internationalisation.service.ts +++ b/src/app/services/internationalisation/internationalisation.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { Response } from '@angular/http'; -import { ErrorMessage, ErrorCode } from "jalhyd"; +import { Message, MessageCode } from "jalhyd"; import { HttpService } from "../http/http.service"; import { Observable } from "../observer"; @@ -47,7 +47,7 @@ export class Language { export class InternationalisationService extends Observable { private _currLang: Language; private _sLang: string; - private _errorMessages: StringMap; + private _Messages: StringMap; private _languages: Language[]; @@ -71,7 +71,7 @@ export class InternationalisationService extends Observable { if (l.code == lc) return l; } - throw new ErrorMessage(ErrorCode.ERROR_LANG_UNSUPPORTED); + throw new Message(MessageCode.ERROR_LANG_UNSUPPORTED); } private getLanguageFromTag(tag: string) { @@ -79,7 +79,7 @@ export class InternationalisationService extends Observable { if (l.tag === tag) return l; } - let e = new ErrorMessage(ErrorCode.ERROR_LANG_UNSUPPORTED); + let e = new Message(MessageCode.ERROR_LANG_UNSUPPORTED); e.extraVar["locale"] = tag; throw e; } @@ -96,17 +96,17 @@ export class InternationalisationService extends Observable { this._currLang = this.getLanguageFromCode(lng); } - let prom = this.httpGetErrorMessages(); + let prom = this.httpGetMessages(); prom.then((res) => { this.notifyObservers(undefined); }) } - private httpGetErrorMessages(): Promise<Response> { + private httpGetMessages(): Promise<Response> { let is: InternationalisationService = this; let processData = function (s: string) { // fermeture nécessaire pour capturer la valeur de this (undefined sinon) - is._errorMessages = JSON.parse(s); + is._Messages = JSON.parse(s); } let l; @@ -123,9 +123,9 @@ export class InternationalisationService extends Observable { return this.httpService.httpGetRequest(undefined, undefined, undefined, "locale/" + f, processData); } - private getErrorMessageFromCode(c: ErrorCode): string { - let sCode: string = ErrorCode[c]; - return this._errorMessages[ErrorCode[c]]; + private getMessageFromCode(c: MessageCode): string { + let sCode: string = MessageCode[c]; + return this._Messages[MessageCode[c]]; } private replaceAll(str: string, find: string, replace: string) { @@ -137,9 +137,9 @@ export class InternationalisationService extends Observable { * @param r message * @param nDigits nombre de chiffres à utiliser pour l'arrondi dans le cas de données numériques */ - public localizeErrorMessage(r: ErrorMessage, nDigits: number = 3): string { - let sCode: string = ErrorCode[r.code]; - let m: string = this.getErrorMessageFromCode(r.code); + public localizeMessage(r: Message, nDigits: number = 3): string { + let sCode: string = MessageCode[r.code]; + let m: string = this.getMessageFromCode(r.code); for (let k in r.extraVar) { let v: any = r.extraVar[k];