Skip to content
Snippets Groups Projects
Commit d7b4e180 authored by francois.grand's avatar francois.grand
Browse files

- début de création de la calculette "conduite distributrice"

- réorganisation des répertoires source
parent d4dc0064
No related branches found
No related tags found
No related merge requests found
Showing
with 722 additions and 14 deletions
import { Component } from '@angular/core';
import { ParamService } from './param-service/param.service';
import { HttpService } from './http.service';
import { InternationalisationService } from './internationalisation.service';
import { ParamService } from './services/param/param.service';
import { HttpService } from './services/http/http.service';
import { InternationalisationService } from './services/internationalisation/internationalisation.service';
@Component({
selector: 'nghyd-app',
template: `
<cond-distri></cond-distri>
<!--
<h1>{{title}}</h1>
<param-input symbol="Q"></param-input>
<param-input symbol="Q"></param-input>
<param-input symbol="Ks"></param-input>
<!--
-->
`,
providers: [ParamService, InternationalisationService, HttpService]
})
export class AppComponent {
title = "Calculette hydro";
constructor(private intlService: InternationalisationService) { }
private initLocale() {
let docLocale: string = document['locale'] as string;
this.intlService.setLocale(docLocale);
//console.log("doc locale " + docLocale);
}
ngOnInit() {
......
......@@ -6,7 +6,10 @@ import { FormsModule } from '@angular/forms'; // <-- NgModel lives here
import { MdInputModule } from '@angular/material';
import { AppComponent } from './app.component';
import { ParamInputComponent } from './param-input/param-input.component';
import { ParamInputComponent } from './components/param-input/param-input.component';
import { FieldSetComponent } from './components/field-set/field-set.component';
import { ParamFieldLineComponent } from './components/param-field-line/param-field-line.component';
import { CondDistriComponent } from './calculators/cond_distri/conddistri.component';
@NgModule({
imports: [
......@@ -17,7 +20,10 @@ import { ParamInputComponent } from './param-input/param-input.component';
],
declarations: [
AppComponent,
ParamInputComponent
ParamInputComponent,
FieldSetComponent,
ParamFieldLineComponent,
CondDistriComponent
],
bootstrap: [AppComponent]
})
......
[
{
"id": "fs_hydraulique",
"option": "cal",
"fields": [
{
"type": "input",
"id": "Q",
"unit": "m³/s",
"value": 3
},
{
"type": "input",
"id": "D",
"unit": "m",
"value": 1.2
},
{
"type": "input",
"id": "J",
"unit": "m",
"value": 0.6
},
{
"type": "input",
"id": "Lg",
"unit": "m",
"value": 100
},
{
"type": "input",
"id": "Nu",
"unit": "Pa·s",
"value": 1E-6
}
]
},
{
"id": "fs_param_calc",
"option": "fix",
"fields": [
{
"type": "input",
"id": "Pr",
"unit": "m",
"value": 0.001
}
]
},
{
"id": "options",
"idCal": "J"
}
]
\ No newline at end of file
{
"fs_hydraulique": "Hydraulic features",
"Q": "Flow",
"D": "Pipe diameter",
"J": "Head drop",
"Lg": "Pipe length",
"Nu": "Dynamic (shear) viscosity",
"fs_param_calc": "Calculation parameters",
"Pr": "Display accuracy"
}
\ No newline at end of file
{
"fs_hydraulique": "Caractéristiques hydrauliques",
"Q": "Débit",
"D": "Diamètre du tuyau",
"J": "Perte de charge",
"Lg": "Longueur du tuyau",
"Nu": "Viscosité dynamique",
"fs_param_calc": "Paramètres de calcul",
"Pr": "Précision de calcul"
}
\ No newline at end of file
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var param_service_1 = require("../../services/param/param.service");
var http_service_1 = require("../../services/http/http.service");
var internationalisation_service_1 = require("../../services/internationalisation/internationalisation.service");
var field_set_component_1 = require("../../components/field-set/field-set.component");
var CondDistriComponent = (function () {
function CondDistriComponent(paramService, httpService, intlService) {
this.paramService = paramService;
this.httpService = httpService;
this.intlService = intlService;
this._title = "Conduite distributrice";
this._localisation = {};
this._config = {};
this._fieldSets = [];
}
CondDistriComponent.prototype.loadLocalisation = function () {
var ths = this;
var processData = function (s) {
// fermeture nécessaire pour capturer la valeur de this (undefined sinon)
ths._localisation = JSON.parse(s);
ths.paramService.updateLocalisation(ths._localisation);
};
var f = "app/calculators/cond_distri/cond_distri." + this.intlService.languageCode + ".json";
this.httpService.httpGetRequest(undefined, undefined, undefined, f, processData);
};
CondDistriComponent.prototype.logObject = function (obj) {
console.log(JSON.stringify(obj));
};
CondDistriComponent.prototype.parseConfig = function () {
this._fieldSets = [];
for (var conf_index in this._config) {
//this.logObject(this._fieldSets);
var conf = this._config[conf_index];
//console.log(conf);
var conf_id = conf["id"];
if (conf_id.startsWith("fs_")) {
var fieldSet = new field_set_component_1.FieldSet();
fieldSet.title = this._localisation[conf_id];
var fields = conf["fields"];
for (var field_index in fields) {
var field = fields[field_index];
// console.log(field);
if (field["type"] === "input") {
var input_id = field["id"];
// console.log(input_id);
var param = this.paramService.getParameter(input_id);
if (param != undefined) {
//this.logObject(param);
fieldSet.params.push(param);
}
}
}
if (fieldSet.params.length > 0) {
// this.logObject(fieldSet);
this._fieldSets.push(fieldSet);
}
}
}
};
CondDistriComponent.prototype.loadConfig = function () {
var ths = this;
var processData = function (s) {
// fermeture nécessaire pour capturer la valeur de this (undefined sinon)
ths._config = JSON.parse(s);
ths.parseConfig();
};
var f = "app/calculators/cond_distri/cond_distri.config.json";
this.httpService.httpGetRequest(undefined, undefined, undefined, f, processData);
};
CondDistriComponent.prototype.ngOnInit = function () {
this.loadLocalisation();
this.loadConfig();
};
return CondDistriComponent;
}());
CondDistriComponent = __decorate([
core_1.Component({
selector: 'cond-distri',
template: "\n <h1>{{_title}}</h1>\n <field-set *ngFor=\"let fs of _fieldSets\" [fieldSet]=fs></field-set>\n <!--\n <field-set *ngFor=\"let fs of _fieldSets\" title=\"fs.title\" fields=\"fs.paramList\"></field-set>\n <field-set title=\"titre de field set\" fields=\"Q,D\"></field-set>\n <param-input symbol=\"Q\"></param-input>\n <param-input symbol=\"Q\"></param-input>\n <param-input symbol=\"Ks\"></param-input>\n <field-set title=\"aaaa\"></field-set>\n -->\n "
}),
__metadata("design:paramtypes", [param_service_1.ParamService, http_service_1.HttpService, internationalisation_service_1.InternationalisationService])
], CondDistriComponent);
exports.CondDistriComponent = CondDistriComponent;
//# sourceMappingURL=conddistri.component.js.map
\ No newline at end of file
{"version":3,"file":"conddistri.component.js","sourceRoot":"","sources":["conddistri.component.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAkD;AAElD,oEAAkE;AAClE,iEAA+D;AAC/D,iHAA+G;AAC/G,sFAA0E;AAiB1E,IAAa,mBAAmB;IAO5B,6BAAoB,YAA0B,EAAU,WAAwB,EAAU,WAAwC;QAA9G,iBAAY,GAAZ,YAAY,CAAc;QAAU,gBAAW,GAAX,WAAW,CAAa;QAAU,gBAAW,GAAX,WAAW,CAA6B;QAN1H,WAAM,GAAG,wBAAwB,CAAC;QAElC,kBAAa,GAAG,EAAE,CAAC;QACnB,YAAO,GAAG,EAAE,CAAC;QACb,eAAU,GAAe,EAAE,CAAC;IAGpC,CAAC;IAEO,8CAAgB,GAAxB;QACI,IAAI,GAAG,GAAG,IAAI,CAAC;QACf,IAAI,WAAW,GAAG,UAAU,CAAS;YACjC,yEAAyE;YACzE,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAClC,GAAG,CAAC,YAAY,CAAC,kBAAkB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC3D,CAAC,CAAA;QAGD,IAAI,CAAC,GAAW,0CAA0C,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,GAAG,OAAO,CAAA;QACpG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;IACrF,CAAC;IAEO,uCAAS,GAAjB,UAAkB,GAAO;QACrB,OAAO,CAAC,GAAG,CAAC,IAAI,CA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AAC,CAAC;oBAC7B,4BAA4B;oBAC5B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACnC,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAEO,wCAAU,GAAlB;QACI,IAAI,GAAG,GAAG,IAAI,CAAC;QACf,IAAI,WAAW,GAAG,UAAU,CAAS;YACjC,yEAAyE;YACzE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC5B,GAAG,CAAC,WAAW,EAAE,CAAC;QACtB,CAAC,CAAA;QAED,IAAI,CAAC,GAAW,qDAAqD,CAAA;QACrE,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;IACrF,CAAC;IAED,sCAAQ,GAAR;QACI,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IACL,0BAAC;AAAD,CAAC,AA9ED,IA8EC;AA9EY,mBAAmB;IAf/B,gBAAS,CAAC;QACP,QAAQ,EAAE,aAAa;QACvB,QAAQ,EAAE,idAWX;KACF,CAAC;qCAQoC,4BAAY,EAAuB,0BAAW,EAAuB,0DAA2B;GAPzH,mBAAmB,CA8E/B;AA9EY,kDAAmB"}
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { ParamService } from '../../services/param/param.service';
import { HttpService } from '../../services/http/http.service';
import { InternationalisationService } from '../../services/internationalisation/internationalisation.service';
import { FieldSet } from '../../components/field-set/field-set.component';
@Component({
selector: 'cond-distri',
template: `
<h1>{{_title}}</h1>
<field-set *ngFor="let fs of _fieldSets" [fieldSet]=fs></field-set>
<!--
<field-set *ngFor="let fs of _fieldSets" title="fs.title" fields="fs.paramList"></field-set>
<field-set title="titre de field set" fields="Q,D"></field-set>
<param-input symbol="Q"></param-input>
<param-input symbol="Q"></param-input>
<param-input symbol="Ks"></param-input>
<field-set title="aaaa"></field-set>
-->
`
})
export class CondDistriComponent implements OnInit {
private _title = "Conduite distributrice";
private _localisation = {};
private _config = {};
private _fieldSets: FieldSet[] = [];
constructor(private paramService: ParamService, private httpService: HttpService, private intlService: InternationalisationService) {
}
private loadLocalisation() {
let ths = this;
let processData = function (s: string) {
// fermeture nécessaire pour capturer la valeur de this (undefined sinon)
ths._localisation = JSON.parse(s);
ths.paramService.updateLocalisation(ths._localisation);
}
let f: string = "app/calculators/cond_distri/cond_distri." + this.intlService.languageCode + ".json"
this.httpService.httpGetRequest(undefined, undefined, undefined, f, processData);
}
private logObject(obj: {}) {
console.log(JSON.stringify(obj));
}
private parseConfig() {
this._fieldSets = [];
for (let conf_index in this._config) {
//this.logObject(this._fieldSets);
let conf = this._config[conf_index];
//console.log(conf);
let conf_id: string = conf["id"];
if (conf_id.startsWith("fs_")) {
let fieldSet: FieldSet = new FieldSet();
fieldSet.title = this._localisation[conf_id];
let fields = conf["fields"];
for (let field_index in fields) {
let field = fields[field_index];
// console.log(field);
if (field["type"] === "input") {
let input_id = field["id"];
// console.log(input_id);
let param = this.paramService.getParameter(input_id);
if (param != undefined) {
//this.logObject(param);
fieldSet.params.push(param);
}
}
}
if (fieldSet.params.length > 0) {
// this.logObject(fieldSet);
this._fieldSets.push(fieldSet);
}
}
}
}
private loadConfig() {
let ths = this;
let processData = function (s: string) {
// fermeture nécessaire pour capturer la valeur de this (undefined sinon)
ths._config = JSON.parse(s);
ths.parseConfig();
}
let f: string = "app/calculators/cond_distri/cond_distri.config.json"
this.httpService.httpGetRequest(undefined, undefined, undefined, f, processData);
}
ngOnInit() {
this.loadLocalisation();
this.loadConfig();
}
}
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var ngparam_1 = require("../../services/ngparam");
var FieldSet = (function () {
function FieldSet() {
this.params = [];
}
FieldSet.prototype.addParameter = function (prm) {
this.params.push(new ngparam_1.NgParameter(prm));
};
return FieldSet;
}());
exports.FieldSet = FieldSet;
var FieldSetComponent = (function () {
function FieldSetComponent() {
}
Object.defineProperty(FieldSetComponent.prototype, "fieldSet", {
set: function (fs) {
this._fieldSet = fs;
},
enumerable: true,
configurable: true
});
return FieldSetComponent;
}());
__decorate([
core_1.Input(),
__metadata("design:type", FieldSet),
__metadata("design:paramtypes", [FieldSet])
], FieldSetComponent.prototype, "fieldSet", null);
FieldSetComponent = __decorate([
core_1.Component({
selector: "field-set",
templateUrl: "./field-set.html",
styles: [".field_set_title {\
font-weight: bold;\
margin: 0.3em 0 0.2em;\
padding: 0.3em;\
background-color: #eeeeee;\
}"]
}),
__metadata("design:paramtypes", [])
], FieldSetComponent);
exports.FieldSetComponent = FieldSetComponent;
//# sourceMappingURL=field-set.component.js.map
\ No newline at end of file
{"version":3,"file":"field-set.component.js","sourceRoot":"","sources":["field-set.component.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAiD;AAIjD,kDAAqD;AAErD;IAII;QACI,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACrB,CAAC;IAEM,+BAAY,GAAnB,UAAoB,GAAoB;QACpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,qBAAW,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC;IACL,eAAC;AAAD,CAAC,AAXD,IAWC;AAXY,4BAAQ;AAuBrB,IAAa,iBAAiB;IAW1B;IACA,CAAC;IALD,sBAAY,uCAAQ;aAApB,UAAqB,EAAY;YAC7B,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACxB,CAAC;;;OAAA;IAIL,wBAAC;AAAD,CAAC,AAbD,IAaC;AANG;IADC,YAAK,EAAE;8BACiB,QAAQ;qCAAR,QAAQ;iDAEhC;AATQ,iBAAiB;IAV7B,gBAAS,CAAC;QACP,QAAQ,EAAE,WAAW;QACrB,WAAW,EAAE,kBAAkB;QAC/B,MAAM,EAAE,CAAC;;;;;UAKH,CAAC;KACV,CAAC;;GACW,iBAAiB,CAa7B;AAbY,8CAAiB"}
\ No newline at end of file
import { Component, Input } from '@angular/core';
import { ParamDefinition } from 'jalhyd';
import { NgParameter } from '../../services/ngparam';
export class FieldSet {
title: string;
params: NgParameter[];
constructor() {
this.params = [];
}
public addParameter(prm: ParamDefinition) {
this.params.push(new NgParameter(prm));
}
}
@Component({
selector: "field-set",
templateUrl: "./field-set.html",
styles: [".field_set_title {\
font-weight: bold;\
margin: 0.3em 0 0.2em;\
padding: 0.3em;\
background-color: #eeeeee;\
}"]
})
export class FieldSetComponent {
/**
* field set attribute
*/
private _fieldSet: FieldSet;
@Input()
private set fieldSet(fs: FieldSet) {
this._fieldSet = fs;
}
constructor() {
}
}
<table>
<tr id="tr_type_section_fs">
<td colspan="5">
<div class="field_set_title">{{_fieldSet.title}}</div>
<div *ngFor="let p of _fieldSet.params">
<param-field-line [symbol]=p.symbol></param-field-line>
</div>
</td>
</tr>
</table>
<!--
<div *ngFor="let s of _fieldList">
<param-field-line *ngFor="let s of _fieldList" [symbol]=s></param-field-line>
-->
\ No newline at end of file
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var param_service_1 = require("../../services/param/param.service");
var ParamFieldLineComponent = (function () {
function ParamFieldLineComponent(paramService) {
this.paramService = paramService;
}
Object.defineProperty(ParamFieldLineComponent.prototype, "symbol", {
/**
* Parameter symbol string
*/
get: function () {
return this._param.symbol;
},
/**
* Parameter symbol (Q, Ks, B, ...) input attribute
*/
set: function (s) {
this._param = this.paramService.getParameter(s);
this._label = this._param.label;
},
enumerable: true,
configurable: true
});
return ParamFieldLineComponent;
}());
__decorate([
core_1.Input(),
__metadata("design:type", String),
__metadata("design:paramtypes", [String])
], ParamFieldLineComponent.prototype, "symbol", null);
ParamFieldLineComponent = __decorate([
core_1.Component({
selector: "param-field-line",
templateUrl: "./param-field-line.html"
}),
__metadata("design:paramtypes", [param_service_1.ParamService])
], ParamFieldLineComponent);
exports.ParamFieldLineComponent = ParamFieldLineComponent;
//# sourceMappingURL=param-field-line.component.js.map
\ No newline at end of file
{"version":3,"file":"param-field-line.component.js","sourceRoot":"","sources":["param-field-line.component.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAyD;AAEzD,oEAAkE;AAOlE,IAAa,uBAAuB;IAwBhC,iCAAoB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAC9C,CAAC;IAbD,sBAAY,2CAAM;QAKlB;;WAEG;aACH;YACI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9B,CAAC;QAdD;;WAEG;aAEH,UAAmB,CAAS;YACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAChD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QACpC,CAAC;;;OAAA;IAWL,8BAAC;AAAD,CAAC,AA1BD,IA0BC;AAdG;IADC,YAAK,EAAE;;;qDAIP;AAfQ,uBAAuB;IAJnC,gBAAS,CAAC;QACP,QAAQ,EAAE,kBAAkB;QAC5B,WAAW,EAAE,yBAAyB;KACzC,CAAC;qCAyBoC,4BAAY;GAxBrC,uBAAuB,CA0BnC;AA1BY,0DAAuB"}
\ No newline at end of file
import { Component, Input, OnInit } from '@angular/core';
import { ParamService } from '../../services/param/param.service';
import { NgParameter } from '../../services/ngparam';
@Component({
selector: "param-field-line",
templateUrl: "./param-field-line.html"
})
export class ParamFieldLineComponent {
private _param: NgParameter;
/**
* associated (localised) label
*/
private _label: string;
/**
* Parameter symbol (Q, Ks, B, ...) input attribute
*/
@Input()
private set symbol(s: string) {
this._param = this.paramService.getParameter(s);
this._label = this._param.label;
}
/**
* Parameter symbol string
*/
private get symbol(): string {
return this._param.symbol;
}
constructor(private paramService: ParamService) {
}
}
<tr id="tr_FT_rLargeurFond">
<td align="right">{{_label}}</td>
<td>
<!--
<input id="champ_FT_rLargeurFond" type="text" value="2.5" maxlength="30" name="FT_rLargeurFond" />
-->
<param-input [symbol]="symbol"></param-input>
</td>
<!--
<td align="center">
<input type="radio" id="fix_FT_rLargeurFond" name="choix_champs_FT_rLargeurFond" value="fix" onclick="gestion_radios('FT_rLargeurFond', 'fix')"
checked="checked" />
</td>
<td align="center">
<input type="radio" id="var_FT_rLargeurFond" name="choix_champs_FT_rLargeurFond" value="var" onclick="gestion_radios('FT_rLargeurFond', 'var')"
/>
</td>
<td align="center">
<input type="radio" id="cal_FT_rLargeurFond" name="choix_champs_FT_rLargeurFond" value="cal" onclick="gestion_radios('FT_rLargeurFond', 'cal')"
/>
</td>
-->
</tr>
\ No newline at end of file
......@@ -3,7 +3,7 @@ format de l'attribut i18n :
i18n="<meaning>|<description>@@<custom id>"
<p i18n="titre saisie|Titre du contrôle de saisie de paramètre@@titre_saisie_param">Saisie de paramètre</p>
-->
<p i18n="@@titre_saisie_param">Saisie de paramètre</p>
<p *ngIf="displayTitle" i18n="@@titre_saisie_param">Saisie de paramètre</p>
<md-input-container>
<input mdInput placeholder="{{_paramDef.symbol}}" [ngModel]="_uiValue.uncheckedValueString" (ngModelChange)="setValue($event)"
/>
......
// cf. https://blog.thoughtram.io/angular/2016/07/27/custom-form-controls-in-angular-2.html
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var forms_1 = require("@angular/forms");
var jalhyd_1 = require("jalhyd");
var param_service_1 = require("../../services/param/param.service");
var internationalisation_service_1 = require("../../services/internationalisation/internationalisation.service");
var ParamInputComponent = ParamInputComponent_1 = (function () {
function ParamInputComponent(paramService, changeDetector, intlService) {
this.paramService = paramService;
this.changeDetector = changeDetector;
this.intlService = intlService;
/**
* flag d'affichage du titre
*/
this.displayTitle = false;
// ControlValueAccessor interface
this.propagateChange = function (_) { };
this._id = ParamInputComponent_1._idGen++;
if (ParamInputComponent_1._startTime == undefined)
ParamInputComponent_1._startTime = new Date().getTime();
this._uiValue = new jalhyd_1.NumericalString();
}
ParamInputComponent.prototype.hasError = function () {
var res = (this._message != undefined);
if (res)
this.log("hasError : true " + this._message);
else
this.log("hasError : false");
return res;
};
ParamInputComponent.prototype.getSfromUI = function () {
return this._fromUI ? " fromUI " : " fromMODEL";
};
ParamInputComponent.prototype.getSParam = function () {
return " " + this._paramDef.symbol + "=" + this._paramDef.toString();
};
ParamInputComponent.prototype.getSUIvalue = function (v) {
if (v === void 0) { v = undefined; }
if (v == undefined)
return " uiValue=" + this._uiValue.toString() + "";
return " uiValue=" + v.toString() + "";
};
ParamInputComponent.prototype.ngOnInit = function () {
// retrieve parameter from symbol
this._paramDef = this.paramService.getParameter(this._paramSymbol);
};
// private getValue() {
// if (this._paramDef.isDefined)
// return this._paramDef.v;
// return "";
// // return this._uiValue.value;
// }
/**
* fonction appelée lorsque l'utilisateur fait une saisie
* @param event valeur du contrôle
*/
ParamInputComponent.prototype.setValue = function (event) {
this._fromUI = true;
this._uiValue.value = event;
this.log(this._uiValue.toString());
return this.validateUIValue();
};
/**
* fonction appelée lors d'un rafraîchissement de l'UI
*/
ParamInputComponent.prototype.ngDoCheck = function () {
this.log("ngDoCheck start : " + this.getSParam() + this.getSUIvalue() + this.getSfromUI());
if (this._fromUI)
this.updateMessage(this._uiValue);
else {
if (this._paramDef.isDefined) {
this.updateMessage(new jalhyd_1.NumericalString(this._paramDef.v));
this._uiValue.value = String(this._paramDef.v);
}
else
this.updateMessage(this._uiValue);
}
this.log("ngDoCheck end : " + this.getSParam() + this.getSUIvalue());
this._fromUI = false;
};
ParamInputComponent.prototype.updateMessage = function (v) {
this.log("updateMessage start :" + this.getSParam() + this.getSfromUI() + this.getSUIvalue(v) + " message=" + this._message);
if (v.isNumerical) {
this._message = undefined;
try {
this._paramDef.checkValue(v.numericalValue);
}
catch (e) {
if (e instanceof jalhyd_1.ErrorMessage)
this._message = this.intlService.localizeErrorMessage(e);
else
this._message = "invalid value";
}
}
else {
switch (this.intlService.lang) {
case internationalisation_service_1.Language.FRENCH:
this._message = "Veuillez entrer une valeur numérique";
break;
default:
this._message = "Please enter a numerical value";
}
}
this.log("updateMessage end :" + this.getSParam() + this.getSfromUI() + this.getSUIvalue(v) + " message=" + this._message);
};
ParamInputComponent.prototype.validateUIValue = function () {
this.log("");
this.log("validateValue start : val '" + this._uiValue.toString() + "'" + this.getSParam() + this.getSfromUI());
var ok = this._uiValue.isNumerical;
if (ok) {
try {
if (!this._paramDef.isDefined || this._paramDef.v != this._uiValue.numericalValue) {
this._paramDef.v = this._uiValue.numericalValue;
this.changeDetector.detectChanges(); // provoque une détection des changements dans les contrôles
}
}
catch (e) {
ok = false;
}
}
if (!ok) {
this.log("validateValue end : " + this.getSParam());
var err = {
rangeError: {
// given: val,
given: this._uiValue.toString(),
max: 4,
min: 0
}
};
return err;
}
this.log("validateValue end : " + this.getSParam());
return null;
};
ParamInputComponent.prototype.log = function (m) {
// let t: number = new Date().getTime() - ParamInputComponent._startTime;
// console.log("ParamInputComponent(" + this._id + ") " + t + " : " + m);
};
/*
//From ControlValueAccessor interface
writeValue(value: any) {
if (value !== this.innerValue) {
this.innerValue = value;
}
}
*/
ParamInputComponent.prototype.writeValue = function (value) {
this.log("writeValue " + value);
};
ParamInputComponent.prototype.registerOnChange = function (fn) {
this.propagateChange = fn;
};
ParamInputComponent.prototype.registerOnTouched = function () { };
return ParamInputComponent;
}());
ParamInputComponent._idGen = 0; // A VIRER
__decorate([
core_1.Input('symbol'),
__metadata("design:type", String)
], ParamInputComponent.prototype, "_paramSymbol", void 0);
ParamInputComponent = ParamInputComponent_1 = __decorate([
core_1.Component({
selector: 'param-input[symbol]',
/* OK
<input placeholder="{{_paramDef.symbol}}" [ngModel]="_paramDef.v" (ngModelChange)="setValue($event)"/>
<p *ngIf="_message">{{_message}}</p>
*/
templateUrl: "./param-input.component.html",
providers: [
{
provide: forms_1.NG_VALUE_ACCESSOR,
useExisting: core_1.forwardRef(function () { return ParamInputComponent_1; }),
multi: true
},
{
provide: forms_1.NG_VALIDATORS,
useExisting: core_1.forwardRef(function () { return ParamInputComponent_1; }),
multi: true
}
]
}),
__metadata("design:paramtypes", [param_service_1.ParamService, core_1.ChangeDetectorRef, internationalisation_service_1.InternationalisationService])
], ParamInputComponent);
exports.ParamInputComponent = ParamInputComponent;
var ParamInputComponent_1;
//# sourceMappingURL=param-input.component.js.map
\ No newline at end of file
{"version":3,"file":"param-input.component.js","sourceRoot":"","sources":["param-input.component.ts"],"names":[],"mappings":"AAAA,2FAA2F;;;;;;;;;;;;AAE3F,sCAAiG;AACjG,wCAAqG;AAErG,iCAAwE;AAExE,oEAAkE;AAClE,iHAAyH;AAuBzH,IAAa,mBAAmB;IAmC5B,6BAAoB,YAA0B,EAAU,cAAiC,EAAU,WAAwC;QAAvH,iBAAY,GAAZ,YAAY,CAAc;QAAU,mBAAc,GAAd,cAAc,CAAmB;QAAU,gBAAW,GAAX,WAAW,CAA6B;QAjB3I;;WAEG;QACI,iBAAY,GAAY,KAAK,CAAC;QAkKrC,iCAAiC;QAEjC,oBAAe,GAAG,UAAC,CAAM,IAAO,CAAC,CAAC;QArJ9B,IAAI,CAAC,GAAG,GAAG,qBAAmB,CAAC,MAAM,EAAE,CAAC;QACxC,EAAE,CAAC,CAAC,qBAAmB,CAAC,UAAU,IAAI,SAAS,CAAC;YAC5C,qBAAmB,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAE1D,IAAI,CAAC,QAAQ,GAAG,IAAI,wBAAe,EAAE,CAAC;IAC1C,CAAC;IAED,sCAAQ,GAAR;QACI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,SAAS,CAAC,CAAC;QACvC,EAAE,CAAC,CAAC,GAAG,CAAC;YACJ,IAAI,CAAC,GAAG,CAAC,kBAAkB,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI;YACA,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC;IACf,CAAC;IAEO,wCAAU,GAAlB;QACI,MAAM,CAAC,IAAI,CAAC,OAAO,GAAG,UAAU,GAAG,YAAY,CAAC;IACpD,CA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ACI,OAAO,EAAE,qBAAa;gBACtB,WAAW,EAAE,iBAAU,CAAC,cAAM,OAAA,qBAAmB,EAAnB,CAAmB,CAAC;gBAClD,KAAK,EAAE,IAAI;aACd;SACJ;KACJ,CAAC;qCAoCoC,4BAAY,EAA0B,wBAAiB,EAAuB,0DAA2B;GAnClI,mBAAmB,CA4M/B;AA5MY,kDAAmB"}
\ No newline at end of file
......@@ -5,8 +5,9 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR, NG_VALIDATORS, FormControl } f
import { ParamDefinition, NumericalString, ErrorMessage } from 'jalhyd';
import { ParamService } from '../param-service/param.service';
import { InternationalisationService, Language } from '../internationalisation.service';
import { ParamService } from '../../services/param/param.service';
import { InternationalisationService, Language } from '../../services/internationalisation/internationalisation.service';
import { NgParameter } from '../../services/ngparam';
@Component({
selector: 'param-input[symbol]',
......@@ -38,7 +39,7 @@ export class ParamInputComponent implements ControlValueAccessor, OnInit, DoChec
/**
* managed parameter
*/
private _paramDef: ParamDefinition;
private _paramDef: NgParameter;
private _message: string;
......@@ -46,6 +47,11 @@ export class ParamInputComponent implements ControlValueAccessor, OnInit, DoChec
private _id: number; // A VIRER
private static _startTime: number; // A VIRER
/**
* flag d'affichage du titre
*/
public displayTitle: boolean = false;
/**
* true si la modification du paramètre géré vient de l'interface utilisateur
*
......@@ -93,7 +99,7 @@ export class ParamInputComponent implements ControlValueAccessor, OnInit, DoChec
ngOnInit() {
// retrieve parameter from symbol
this._paramDef = this.paramService.getParameter(this._paramSymbol);
}
}
// private getValue() {
// if (this._paramDef.isDefined)
......
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