From 4e1d0f42391fd5edf63910fea2a16787b66024e6 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 17 Jan 2019 14:09:04 +0100 Subject: [PATCH] tslint --- src/app/components/base/base.component.ts | 6 +- .../calculator-results.component.ts | 2 +- .../field-set/field-set.component.ts | 1 + .../fieldset-container.component.ts | 7 +- .../fixed-results.component.ts | 3 +- .../fixedvar-results.component.ts | 17 +- .../generic-calculator/calc-name.component.ts | 6 +- .../generic-input/generic-input.component.ts | 4 +- .../load-calculator-anchor.directive.ts | 3 +- .../load-calculator.component.ts | 4 +- src/app/components/log/log.component.ts | 2 +- .../param-values/param-values.component.ts | 22 +- .../remous-results.component.ts | 376 +++++++++--------- .../horizontal-result-element.component.ts | 7 +- .../result-element-base.component.ts | 8 +- .../vertical-result-element.component.ts | 7 +- .../save-calculator-anchor.directive.ts | 3 +- .../save-calculator.component.ts | 2 +- .../section-results.component.ts | 6 +- src/app/formulaire/check-field.ts | 2 +- .../concrete/form-lechapt-calmon.ts | 2 +- .../definition/form-compute-courbe-remous.ts | 2 +- .../form-compute-parallel-structures.ts | 4 +- .../definition/form-def-fixedvar.ts | 16 +- .../definition/form-def-paramcalc.ts | 4 +- .../formulaire/definition/form-def-section.ts | 2 +- .../definition/form-result-section.ts | 6 +- src/app/formulaire/dependency/dependency.ts | 4 +- src/app/formulaire/field.ts | 2 +- .../form-iterator/deep-element-iterator.ts | 7 +- .../form-iterator/top-element-iterator.ts | 5 +- src/app/formulaire/formulaire-node.ts | 4 +- src/app/results/param-calc-results.ts | 6 +- src/app/results/remous-results.ts | 8 +- src/app/results/section-results.ts | 2 +- src/app/services/service-factory.ts | 2 +- 36 files changed, 291 insertions(+), 273 deletions(-) diff --git a/src/app/components/base/base.component.ts b/src/app/components/base/base.component.ts index 0fefbaf2c..5bdc6df61 100644 --- a/src/app/components/base/base.component.ts +++ b/src/app/components/base/base.component.ts @@ -15,10 +15,10 @@ export abstract class BaseComponent implements AfterViewChecked, OnChanges { * événement émis en même temps que l'appel à afterFirstViewChecked() */ @Output() - private onFirstViewCheck: EventEmitter<void>; + private firstViewCheck: EventEmitter<void>; constructor() { - this.onFirstViewCheck = new EventEmitter(); + this.firstViewCheck = new EventEmitter(); } public ngAfterViewChecked() { @@ -28,7 +28,7 @@ export abstract class BaseComponent implements AfterViewChecked, OnChanges { this.afterFirstViewChecked(); if (this.emitFirstViewCheck) { - this.onFirstViewCheck.emit(); + this.firstViewCheck.emit(); } } } diff --git a/src/app/components/calculator-results/calculator-results.component.ts b/src/app/components/calculator-results/calculator-results.component.ts index 9457d7385..c6489fa69 100644 --- a/src/app/components/calculator-results/calculator-results.component.ts +++ b/src/app/components/calculator-results/calculator-results.component.ts @@ -38,7 +38,7 @@ export class CalculatorResultsComponent implements AfterViewChecked { public set formulaire(f: FormulaireDefinition) { this._formulaire = f; - if (this._formulaire == undefined) { + if (this._formulaire === undefined) { this.fixedVarResultsComponent.results = undefined; this.sectionResultsComponent.results = undefined; this.remousResultsComponent.results = undefined; diff --git a/src/app/components/field-set/field-set.component.ts b/src/app/components/field-set/field-set.component.ts index bacdb00a9..25bc9982c 100644 --- a/src/app/components/field-set/field-set.component.ts +++ b/src/app/components/field-set/field-set.component.ts @@ -154,6 +154,7 @@ export class FieldSetComponent implements DoCheck { /** * événement de changement d'état d'un radio */ + // tslint:disable-next-line:no-output-on-prefix @Output() private onRadio = new EventEmitter<any>(); diff --git a/src/app/components/fieldset-container/fieldset-container.component.ts b/src/app/components/fieldset-container/fieldset-container.component.ts index c4c1e5800..dc176ffa5 100644 --- a/src/app/components/fieldset-container/fieldset-container.component.ts +++ b/src/app/components/fieldset-container/fieldset-container.component.ts @@ -12,7 +12,7 @@ import { FormulaireDefinition } from "../../formulaire/definition/form-definitio export class FieldsetContainerComponent implements DoCheck, AfterViewInit { public get title(): string { - if (this._container == undefined) { + if (this._container === undefined) { return undefined; } return this._container.label; @@ -42,6 +42,7 @@ export class FieldsetContainerComponent implements DoCheck, AfterViewInit { /** * événément de changement d'état d'un radio */ + // tslint:disable-next-line:no-output-on-prefix @Output() private onRadio = new EventEmitter<any>(); @@ -70,7 +71,7 @@ export class FieldsetContainerComponent implements DoCheck, AfterViewInit { this._fieldsetComponents.forEach(fs => fs.showButtons = true); // désactivation du bouton supprimer s'il n'en reste qu'un - if (this._fieldsetComponents.length == 1) { + if (this._fieldsetComponents.length === 1) { const fs = this._fieldsetComponents.last as FieldSetComponent; fs.enableRemoveButton = false; } else { @@ -121,7 +122,7 @@ export class FieldsetContainerComponent implements DoCheck, AfterViewInit { private updateValidity() { this._isValid = false; - if (this._fieldsetComponents != undefined) { + if (this._fieldsetComponents !== undefined) { this._isValid = this._fieldsetComponents.reduce( // callback ( diff --git a/src/app/components/fixedvar-results/fixed-results.component.ts b/src/app/components/fixedvar-results/fixed-results.component.ts index b599d014a..0b7056b8f 100644 --- a/src/app/components/fixedvar-results/fixed-results.component.ts +++ b/src/app/components/fixedvar-results/fixed-results.component.ts @@ -65,8 +65,9 @@ export class FixedResultsComponent { } private getFixedParamClass(i: number) { - // if (this._results.isFixed && i == this._results.fixedResults.length - 1) + // if (this._results.isFixed && i === this._results.fixedResults.length - 1) // return "font-weight-bold"; + // tslint:disable-next-line:no-bitwise return "result_id_" + String(i & 1); } diff --git a/src/app/components/fixedvar-results/fixedvar-results.component.ts b/src/app/components/fixedvar-results/fixedvar-results.component.ts index 218f0c0bf..8ef80d00c 100644 --- a/src/app/components/fixedvar-results/fixedvar-results.component.ts +++ b/src/app/components/fixedvar-results/fixedvar-results.component.ts @@ -73,7 +73,7 @@ export class FixedVarResultsComponent implements DoCheck { public set results(rs: CalculatorResults[]) { this._fixedResults = undefined; this._varResults = undefined; - if (rs != undefined) { + if (rs !== undefined) { for (const r of rs) { if (r instanceof FixedResults) { this._fixedResults = r; @@ -99,10 +99,10 @@ export class FixedVarResultsComponent implements DoCheck { } this._doUpdate = false; - if (this._fixedResults != undefined) { + if (this._fixedResults !== undefined) { this._doUpdate = this._fixedResults.hasResults || this._fixedResults.hasLog; } - if (this._varResults != undefined) { + if (this._varResults !== undefined) { this._doUpdate = this._doUpdate || this._varResults.hasResults || this._varResults.hasLog; } } @@ -140,7 +140,7 @@ export class FixedVarResultsComponent implements DoCheck { * @returns true si les résultats ont pu être mis à jour */ private updateResults() { - const fixedUpdated = this._fixedResults != undefined && this.fixedResultsComponent != undefined; + const fixedUpdated = this._fixedResults !== undefined && this.fixedResultsComponent !== undefined; if (fixedUpdated) { this.fixedResultsComponent.results = this._fixedResults; } @@ -148,12 +148,12 @@ export class FixedVarResultsComponent implements DoCheck { let graphUpdated: boolean; let varUpdated: boolean; if (this._varResults && this._varResults.hasResults) { - varUpdated = this.varResultsComponent != undefined; + varUpdated = this.varResultsComponent !== undefined; if (varUpdated) { this.varResultsComponent.results = this._varResults; } - graphUpdated = this.resultsGraphComponent != undefined; + graphUpdated = this.resultsGraphComponent !== undefined; if (graphUpdated) { this.resultsGraphComponent.results = this._varResults; this.resultsGraphComponent.updateView(); @@ -163,7 +163,7 @@ export class FixedVarResultsComponent implements DoCheck { graphUpdated = true; } - const logUpdated = this.logComponent != undefined; + const logUpdated = this.logComponent !== undefined; if (logUpdated) { this.logComponent.log = this.mergedGlobalLogs; } @@ -186,6 +186,7 @@ export class FixedVarResultsComponent implements DoCheck { } private getFixedResultClass(i: number) { + // tslint:disable-next-line:no-bitwise return "result_id_" + String(i & 1); } @@ -211,6 +212,6 @@ export class FixedVarResultsComponent implements DoCheck { } private get hasResults(): boolean { - return this._fixedResults != undefined && this._fixedResults.hasResults; + return this._fixedResults !== undefined && this._fixedResults.hasResults; } } diff --git a/src/app/components/generic-calculator/calc-name.component.ts b/src/app/components/generic-calculator/calc-name.component.ts index 45334b4ab..21e9d67ac 100644 --- a/src/app/components/generic-calculator/calc-name.component.ts +++ b/src/app/components/generic-calculator/calc-name.component.ts @@ -23,7 +23,7 @@ export class CalculatorNameComponent extends GenericInputComponent { * retourne la valeur du modèle */ protected getModelValue(): any { - if (this._form == undefined) { + if (this._form === undefined) { return undefined; } return this._form.calculatorName; @@ -47,7 +47,7 @@ export class CalculatorNameComponent extends GenericInputComponent { let msg; let valid = false; - if (!(typeof (v) == "string") || v.length < 1) { + if (!(typeof (v) === "string") || v.length < 1) { msg = "Veuillez entrer un nom"; } else { valid = true; @@ -73,7 +73,7 @@ export class CalculatorNameComponent extends GenericInputComponent { let valid = false; let msg: string; - if (ui == undefined || ui.length < 1) { + if (ui === undefined || ui.length < 1) { msg = "Veuillez entrer un nom"; } else { valid = true; diff --git a/src/app/components/generic-input/generic-input.component.ts b/src/app/components/generic-input/generic-input.component.ts index 3780d95a1..a2edd6947 100644 --- a/src/app/components/generic-input/generic-input.component.ts +++ b/src/app/components/generic-input/generic-input.component.ts @@ -334,7 +334,7 @@ export class TestInputComponent extends GenericInputComponent { } protected modelToUI(v: any): string { - if (typeof (v) == "number") + if (typeof (v) === "number") return String(v); return undefined; } @@ -400,7 +400,7 @@ export class Test2InputComponent extends GenericInputComponent { } protected modelToUI(v: any): string { - if (typeof (v) == "number") + if (typeof (v) === "number") return String(v); return undefined; } diff --git a/src/app/components/load-calculator/load-calculator-anchor.directive.ts b/src/app/components/load-calculator/load-calculator-anchor.directive.ts index dda914998..af1770fb2 100644 --- a/src/app/components/load-calculator/load-calculator-anchor.directive.ts +++ b/src/app/components/load-calculator/load-calculator-anchor.directive.ts @@ -15,7 +15,8 @@ export class LoadCalcDialogAnchorDirective { public createDialog(): ComponentRef<LoadCalculatorComponent> { this.viewContainer.clear(); - const compFactory: ComponentFactory<LoadCalculatorComponent> = this.componentFactoryResolver.resolveComponentFactory(LoadCalculatorComponent); + const compFactory: ComponentFactory<LoadCalculatorComponent> + = this.componentFactoryResolver.resolveComponentFactory(LoadCalculatorComponent); const compRef: ComponentRef<LoadCalculatorComponent> = this.viewContainer.createComponent(compFactory); // compRef.instance.confirmResult.subscribe(() => { diff --git a/src/app/components/load-calculator/load-calculator.component.ts b/src/app/components/load-calculator/load-calculator.component.ts index d008d92f9..5fa455f31 100644 --- a/src/app/components/load-calculator/load-calculator.component.ts +++ b/src/app/components/load-calculator/load-calculator.component.ts @@ -90,13 +90,13 @@ export class LoadCalculatorComponent { } public get showSelectButtons(): boolean { - return this._calculators && this._calculators.length != 0; + return this._calculators && this._calculators.length !== 0; } private getSelectedFile(): File { const files: { [key: string]: File } = this.fileSelector.nativeElement.files; for (const key in files) { - if (!isNaN(parseInt(key))) { + if (!isNaN(Number(key))) { return files[key]; } } diff --git a/src/app/components/log/log.component.ts b/src/app/components/log/log.component.ts index b2dd3cde8..67234e62f 100644 --- a/src/app/components/log/log.component.ts +++ b/src/app/components/log/log.component.ts @@ -43,7 +43,7 @@ export class LogComponent { } public get hasEntries(): boolean { - return this._log != undefined && this._log.messages.length != 0; + return this._log !== undefined && this._log.messages.length !== 0; } private get messages(): Message[] { diff --git a/src/app/components/param-values/param-values.component.ts b/src/app/components/param-values/param-values.component.ts index 7a7431235..333927017 100644 --- a/src/app/components/param-values/param-values.component.ts +++ b/src/app/components/param-values/param-values.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, Output, EventEmitter, ViewChild, AfterViewChecked } from "@angular/core"; +import { Component, Input, Output, EventEmitter, ViewChild, AfterViewChecked, OnChanges } from "@angular/core"; import { ParamValueMode } from "jalhyd"; @@ -30,7 +30,7 @@ import { ValueListComponent } from "./value-list.component"; }` ] }) -export class ParamValuesComponent extends BaseComponent implements AfterViewChecked { +export class ParamValuesComponent extends BaseComponent implements AfterViewChecked, OnChanges { @Input() private param: NgParameter; @@ -114,13 +114,13 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec // valeur pour min : celle déjà définie ou celle déduite de la valeur saisie let min: number = this.param.minValue; - if (min == undefined) { + if (min === undefined) { min = this.param.getValue() / 2; } // valeur pour max : celle déjà définie ou celle déduite de la valeur saisie let max: number = this.param.maxValue; - if (max == undefined) { + if (max === undefined) { max = this.param.getValue() * 2; } @@ -132,7 +132,7 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec // valeur du pas let step = this.param.stepValue; - if (step == undefined) { + if (step === undefined) { step = (max - min) / 20; } this.param.stepValue = step; @@ -153,10 +153,10 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec * initialisation de la liste de valeurs avec celle du paramètre géré */ private initList() { - if (this._doInitList && this._listComponent != undefined) { + if (this._doInitList && this._listComponent !== undefined) { this._doInitList = false; let l = this.param.valueList; - if (l == undefined) { + if (l === undefined) { if (this.param.isDefined) { l = [this.param.getValue()]; } else { @@ -173,16 +173,16 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec * revalidation de tous les composants enfants */ private validateAll() { - if (this._minComponent != undefined) { + if (this._minComponent !== undefined) { this._minComponent.validate(); } - if (this._maxComponent != undefined) { + if (this._maxComponent !== undefined) { this._maxComponent.validate(); } - if (this._stepComponent != undefined) { + if (this._stepComponent !== undefined) { this._stepComponent.validate(); } - if (this._listComponent != undefined) { + if (this._listComponent !== undefined) { this._listComponent.validate(); } } diff --git a/src/app/components/remous-results/remous-results.component.ts b/src/app/components/remous-results/remous-results.component.ts index 290ae0548..3d47a7708 100644 --- a/src/app/components/remous-results/remous-results.component.ts +++ b/src/app/components/remous-results/remous-results.component.ts @@ -1,4 +1,4 @@ -import { Component, ViewChild } from "@angular/core"; +import { Component, ViewChild, DoCheck } from "@angular/core"; import { ArrayReverseIterator, ResultElement, INumberIterator } from "jalhyd"; @@ -8,6 +8,183 @@ import { RemousResults } from "../../results/remous-results"; import { CalculatorResults } from "../../results/calculator-results"; import { VarResultsComponent } from "../fixedvar-results/var-results.component"; +/** + * données pour une ligne dans le graphe + */ +class LineData { + /** + * abscisses + */ + private _tx: number[]; + + /** + * orodonnées + */ + private _ty: number[] = []; + + /** + * graphe auquel aapartient la ligne + */ + private _parentGraph: GraphData; + + /** + * données fournies à ChartJS + */ + private _data = {}; + + /** + * profondeur à laquelle est dessinée la ligne + * les profondeurs les plus petites sont dessinées derrière les profondeurs les plus grandes + */ + public z: number; + + constructor(gr: GraphData) { + this._parentGraph = gr; + this._tx = gr.tx; + for (let i = this._tx.length - 1; i >= 0; i--) { + this._ty.push(null); + } + } + + public getYat(x: number) { + const i = this._tx.indexOf(x); + return this._ty[i]; + } + + public setPoint(x: number, y: number) { + const i = this._tx.indexOf(x); + this._ty[i] = y; + } + + public mapPoint(x: number, y: number) { + this.setPoint(x, this._parentGraph.mapY(x, y)); + } + + public get ty() { + return this._ty; + } + + public get tx() { + return this._tx; + } + + public hasYs(): boolean { + for (const y of this._ty) { + if (y !== null) { + return true; + } + } + return false; + } + + public get data() { + return this._data; + } + + public set data(d: {}) { + this._data = d; + this._data["data"] = this._ty; + } +} + +class GraphData { + /** + * tableau des (labels) des abscisses + */ + private _tx: number[]; + + private _lines: LineData[] = []; + + /** + * pente du fond + */ + private _penteFond: number; + + /** + * longueur du bief + */ + private _longBief: number; + + constructor(tX: number[], pente: number, bief: number) { + this._tx = tX; + this._penteFond = pente; + this._longBief = bief; + } + + /** + * crée une ligne dans le graphe + * @param z profondeur de la lign + */ + public newLine(z: number): LineData { + const res = new LineData(this); + res.z = z; + this._lines.push(res); + return res; + } + + public get tx(): number[] { + return this._tx; + } + + /** + * transforme une cote en tenant compte du fond + * @param x abscisse où se trouve la cote à transformer + * @param y cote à transformer + */ + public mapY(x: number, y: number) { + let d: number; + if (this._penteFond >= 0) { + d = this._penteFond * (this._longBief - x); + } else { + d = -this._penteFond * x; + } + return y + d; + } + + /** + * dessine une ligne droite + * @param y0 y en x=0 + * @param ymax y en x=xmax + * @param color couleur de la ligne + * @param lbl légende de la ligne + * @param fillColor couleur de remplissage sous la ligne + */ + public drawLine(y0: number, ymax: number, prof: number, color: string, lbl: string, fillColor?: string) { + const l = this.newLine(prof); + l.mapPoint(0, y0); + l.mapPoint(this._longBief, ymax); + + // l.data = { label: lbl, data: l, fill: fillColor !== undefined, tension: 0, + // borderColor: color, backgroundColor: fillColor, pointRadius: 0 }; + l.data = { + label: lbl, fill: fillColor !== undefined, tension: 0, spanGaps: true, + borderColor: color, backgroundColor: fillColor, pointRadius: 0 + }; + } + + public get data() { + const ds = []; + this._lines.sort((a, b) => { + if (a.z > b.z) { + return -1; + } + if (a.z < b.z) { + return 1; + } + return 0; + }); + + for (const l of this._lines) { + ds.push(l.data); + } + + return { + labels: this._tx, + datasets: ds + }; + } +} + @Component({ selector: "remous-results", templateUrl: "./remous-results.component.html", @@ -32,7 +209,7 @@ import { VarResultsComponent } from "../fixedvar-results/var-results.component"; ` ] }) -export class RemousResultsComponent { +export class RemousResultsComponent implements DoCheck { private _remousResults: RemousResults; /* @@ -350,10 +527,24 @@ export class RemousResultsComponent { // ajout des données au graphique if (lineTor !== undefined) { - lineTor.data = { label: this.uitextLigneTorrentielle, tension: 0, borderColor: "#77A3CD", pointBackgroundColor: "#77A3CD", pointRadius: 4, backgroundColor: "#D1D0D4" }; + lineTor.data = { + label: this.uitextLigneTorrentielle, + tension: 0, + borderColor: "#77A3CD", + pointBackgroundColor: "#77A3CD", + pointRadius: 4, + backgroundColor: "#D1D0D4" + }; } if (lineFlu !== undefined) { - lineFlu.data = { label: this.uitextLigneFluviale, tension: 0, borderColor: "#0093BD", pointBackgroundColor: "#0093BD", pointRadius: 4, backgroundColor: "#D1D0D4" }; + lineFlu.data = { + label: this.uitextLigneFluviale, + tension: 0, + borderColor: "#0093BD", + pointBackgroundColor: "#0093BD", + pointRadius: 4, + backgroundColor: "#D1D0D4" + }; } this.graph1_data = gr1.data; @@ -402,6 +593,7 @@ export class RemousResultsComponent { } private getResultClass(i: number) { + // tslint:disable-next-line:no-bitwise return "result_id_" + String(i & 1); } @@ -413,179 +605,3 @@ export class RemousResultsComponent { return this._remousResults && this._remousResults.result && this._remousResults.result.ok; } } - -/** - * données pour une ligne dans le graphe - */ -class LineData { - /** - * abscisses - */ - private _tx: number[]; - - /** - * orodonnées - */ - private _ty: number[] = []; - - /** - * graphe auquel aapartient la ligne - */ - private _parentGraph: GraphData; - - /** - * données fournies à ChartJS - */ - private _data = {}; - - /** - * profondeur à laquelle est dessinée la ligne - * les profondeurs les plus petites sont dessinées derrière les profondeurs les plus grandes - */ - public z: number; - - constructor(gr: GraphData) { - this._parentGraph = gr; - this._tx = gr.tx; - for (let i = this._tx.length - 1; i >= 0; i--) { - this._ty.push(null); - } - } - - public getYat(x: number) { - const i = this._tx.indexOf(x); - return this._ty[i]; - } - - public setPoint(x: number, y: number) { - const i = this._tx.indexOf(x); - this._ty[i] = y; - } - - public mapPoint(x: number, y: number) { - this.setPoint(x, this._parentGraph.mapY(x, y)); - } - - public get ty() { - return this._ty; - } - - public get tx() { - return this._tx; - } - - public hasYs(): boolean { - for (const y of this._ty) { - if (y != null) { - return true; - } - } - return false; - } - - public get data() { - return this._data; - } - - public set data(d: {}) { - this._data = d; - this._data["data"] = this._ty; - } -} - -class GraphData { - /** - * tableau des (labels) des abscisses - */ - private _tx: number[]; - - private _lines: LineData[] = []; - - /** - * pente du fond - */ - private _penteFond: number; - - /** - * longueur du bief - */ - private _longBief: number; - - constructor(tX: number[], pente: number, bief: number) { - this._tx = tX; - this._penteFond = pente; - this._longBief = bief; - } - - /** - * crée une ligne dans le graphe - * @param z profondeur de la lign - */ - public newLine(z: number): LineData { - const res = new LineData(this); - res.z = z; - this._lines.push(res); - return res; - } - - public get tx(): number[] { - return this._tx; - } - - /** - * transforme une cote en tenant compte du fond - * @param x abscisse où se trouve la cote à transformer - * @param y cote à transformer - */ - public mapY(x: number, y: number) { - let d: number; - if (this._penteFond >= 0) { - d = this._penteFond * (this._longBief - x); - } else { - d = -this._penteFond * x; - } - return y + d; - } - - /** - * dessine une ligne droite - * @param y0 y en x=0 - * @param ymax y en x=xmax - * @param color couleur de la ligne - * @param lbl légende de la ligne - * @param fillColor couleur de remplissage sous la ligne - */ - public drawLine(y0: number, ymax: number, prof: number, color: string, lbl: string, fillColor: string = undefined) { - const l = this.newLine(prof); - l.mapPoint(0, y0); - l.mapPoint(this._longBief, ymax); - - // l.data = { label: lbl, data: l, fill: fillColor != undefined, tension: 0, borderColor: color, backgroundColor: fillColor, pointRadius: 0 }; - l.data = { - label: lbl, fill: fillColor !== undefined, tension: 0, spanGaps: true, - borderColor: color, backgroundColor: fillColor, pointRadius: 0 - }; - } - - public get data() { - const ds = []; - this._lines.sort((a, b) => { - if (a.z > b.z) { - return -1; - } - if (a.z < b.z) { - return 1; - } - return 0; - }); - - for (const l of this._lines) { - ds.push(l.data); - } - - return { - labels: this._tx, - datasets: ds - }; - } -} 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 6404ab4ff..faa0174d6 100644 --- a/src/app/components/result-element/horizontal-result-element.component.ts +++ b/src/app/components/result-element/horizontal-result-element.component.ts @@ -1,9 +1,4 @@ import { Component, Input, ViewChild, TemplateRef, ViewContainerRef } from "@angular/core"; - -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 { ResultElementBaseComponent } from "./result-element-base.component"; @@ -11,7 +6,7 @@ import { ResultElementBaseComponent } from "./result-element-base.component"; selector: "[horizontal-result-element]", templateUrl: "./horizontal-result-element.component.html" }) -export class HorizontalResultElementComponent extends ResultElementBaseComponent { +export class HorizontalResultElementComponent extends ResultElementBaseComponent implements OnChanges { // template des td pour les extraResult @ViewChild("extraResultTd") tdTemplate: TemplateRef<any>; 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 519fd4665..ac70e0257 100644 --- a/src/app/components/result-element/result-element-base.component.ts +++ b/src/app/components/result-element/result-element-base.component.ts @@ -73,15 +73,15 @@ export class ResultElementBaseComponent implements OnChanges { const nDigits = this.appSetupService.displayDigits; const r: ResultElement = this._resultElement; - this._hasValue = r != undefined && r.vCalc != undefined; - this._hasError = r == undefined || (r.vCalc == undefined && r.extraResults.length > 0); + this._hasValue = r !== undefined && r.vCalc !== undefined; + this._hasError = r === undefined || (r.vCalc === undefined && r.extraResults.length > 0); this._value = this._hasValue ? this._value = r.vCalc.toFixed(nDigits) : " "; // texte du tooltip let res = ""; - if (this._resultElement != undefined) { + if (this._resultElement !== undefined) { for (const m of this._resultElement.log.messages) { if (res.length > 0) { res += "<br/>"; @@ -91,7 +91,7 @@ export class ResultElementBaseComponent implements OnChanges { } this._htmlTooltip = res; - this._emptyTooltip = this._htmlTooltip.length == 0; + this._emptyTooltip = this._htmlTooltip.length === 0; } public get hasValue() { 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 91da58811..646b83cc4 100644 --- a/src/app/components/result-element/vertical-result-element.component.ts +++ b/src/app/components/result-element/vertical-result-element.component.ts @@ -1,9 +1,4 @@ import { Component, Input, ViewChild, TemplateRef, ViewContainerRef } from "@angular/core"; - -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 { ResultElementBaseComponent } from "./result-element-base.component"; @@ -25,7 +20,7 @@ import { ResultElementBaseComponent } from "./result-element-base.component"; }` ] }) -export class VerticalResultElementComponent extends ResultElementBaseComponent { +export class VerticalResultElementComponent extends ResultElementBaseComponent implements OnChanges { /** * nom de la variable */ diff --git a/src/app/components/save-calculator/save-calculator-anchor.directive.ts b/src/app/components/save-calculator/save-calculator-anchor.directive.ts index 012ffef46..c59a1913d 100644 --- a/src/app/components/save-calculator/save-calculator-anchor.directive.ts +++ b/src/app/components/save-calculator/save-calculator-anchor.directive.ts @@ -15,7 +15,8 @@ export class SaveCalcDialogAnchorDirective { public createDialog(): ComponentRef<SaveCalculatorComponent> { this.viewContainer.clear(); - const compFactory: ComponentFactory<SaveCalculatorComponent> = this.componentFactoryResolver.resolveComponentFactory(SaveCalculatorComponent); + const compFactory: ComponentFactory<SaveCalculatorComponent> + = this.componentFactoryResolver.resolveComponentFactory(SaveCalculatorComponent); const compRef: ComponentRef<SaveCalculatorComponent> = this.viewContainer.createComponent(compFactory); // dialogComponentRef.instance.close.subscribe(() => { diff --git a/src/app/components/save-calculator/save-calculator.component.ts b/src/app/components/save-calculator/save-calculator.component.ts index a8e3b3e1d..2dfd207bb 100644 --- a/src/app/components/save-calculator/save-calculator.component.ts +++ b/src/app/components/save-calculator/save-calculator.component.ts @@ -91,7 +91,7 @@ export class SaveCalculatorComponent { private onCheckCalc(event: any) { for (const c of this._calculators) { - if (c.uid == +event.target.value) { + if (c.uid === +event.target.value) { c.selected = event.target.checked; } } diff --git a/src/app/components/section-results/section-results.component.ts b/src/app/components/section-results/section-results.component.ts index 965475284..ae3598d0f 100644 --- a/src/app/components/section-results/section-results.component.ts +++ b/src/app/components/section-results/section-results.component.ts @@ -1,6 +1,6 @@ import { Component, ViewChild, DoCheck } from "@angular/core"; -import { acSection, Result, ResultElement } from "jalhyd"; +import { ResultElement } from "jalhyd"; import { SectionCanvasComponent } from "../section-canvas/section-canvas.component"; import { SectionResults } from "../../results/section-results"; @@ -29,8 +29,7 @@ import { InternationalisationService } from "../../services/internationalisation .result_id_2 { font-weight: bold; } - ` - ] + `] }) export class SectionResultsComponent implements DoCheck { @@ -135,6 +134,7 @@ export class SectionResultsComponent implements DoCheck { } private getResultClass(i: number) { + // tslint:disable-next-line:no-bitwise return "result_id_" + String(i & 1); } } diff --git a/src/app/formulaire/check-field.ts b/src/app/formulaire/check-field.ts index f508e699a..073816613 100644 --- a/src/app/formulaire/check-field.ts +++ b/src/app/formulaire/check-field.ts @@ -23,6 +23,6 @@ export class CheckField extends Field { public parseConfig(json: {}, data?: {}) { this._confId = json["id"]; - this.setValue(json["value"] == "true"); + this.setValue(json["value"] === "true"); } } diff --git a/src/app/formulaire/definition/concrete/form-lechapt-calmon.ts b/src/app/formulaire/definition/concrete/form-lechapt-calmon.ts index 635c40292..b8f6b3543 100644 --- a/src/app/formulaire/definition/concrete/form-lechapt-calmon.ts +++ b/src/app/formulaire/definition/concrete/form-lechapt-calmon.ts @@ -64,7 +64,7 @@ export class FormulaireLechaptCalmon extends FormulaireDefinition implements Obs public update(sender: any, data: any) { // en cas de changement de valeur du select de matériau, effacement des résultats et MAJ des champs L,M,N if (sender instanceof SelectField) { - if (data.action == "select") { + if (data.action === "select") { this.reset(); } } diff --git a/src/app/formulaire/definition/form-compute-courbe-remous.ts b/src/app/formulaire/definition/form-compute-courbe-remous.ts index 6d996a2ab..e65553d0e 100644 --- a/src/app/formulaire/definition/form-compute-courbe-remous.ts +++ b/src/app/formulaire/definition/form-compute-courbe-remous.ts @@ -1,4 +1,4 @@ -import { SectionParametree, acSection, ParamsEquation, ComputeNode, Result, MethodeResolution, CourbeRemousParams, CourbeRemous, ResultElement, ParamValues, CalculatorType } from "jalhyd"; +import { acSection, Result, MethodeResolution, CourbeRemousParams, CourbeRemous } from "jalhyd"; import { SelectField } from "../select-field"; import { RemousResults } from "../../results/remous-results"; diff --git a/src/app/formulaire/definition/form-compute-parallel-structures.ts b/src/app/formulaire/definition/form-compute-parallel-structures.ts index 1dd15b5c1..f53ef23d8 100644 --- a/src/app/formulaire/definition/form-compute-parallel-structures.ts +++ b/src/app/formulaire/definition/form-compute-parallel-structures.ts @@ -47,7 +47,7 @@ export class FormComputeParallelStructures extends FormComputeFixedVar { */ protected getParameterRefid(p: NgParameter) { const [fsc, fs, i] = this.structureParents(p); - if (i == -1) { + if (i === -1) { return super.getParameterRefid(p); } @@ -56,7 +56,7 @@ export class FormComputeParallelStructures extends FormComputeFixedVar { protected setParameterValue(node: ComputeNode, p: NgParameter, val: number) { const [fsc, fs, i] = this.structureParents(p); - if (i == -1) { + if (i === -1) { super.setParameterValue(node, p, val); } else { const n: ParallelStructure = node as ParallelStructure; diff --git a/src/app/formulaire/definition/form-def-fixedvar.ts b/src/app/formulaire/definition/form-def-fixedvar.ts index a83d7839d..9e72537aa 100644 --- a/src/app/formulaire/definition/form-def-fixedvar.ts +++ b/src/app/formulaire/definition/form-def-fixedvar.ts @@ -2,9 +2,6 @@ import { ParamValueMode } from "jalhyd"; import { ParamRadioConfig, NgParameter } from "../ngparam"; import { FormulaireDefinition } from "./form-definition"; -import { FormulaireElement } from "../formulaire-element"; -import { InputField } from "../input-field"; -import { CheckField } from "../check-field"; /** * gestion des formulaires avec "paramètre fixé" et "paramètre à varier" @@ -19,10 +16,13 @@ export class FormDefFixedVar { /** * remet les radios de tous les paramètres à FIX sauf "me" et ceux (celui) à l'état "except" */ - protected resetOtherRadio(me: NgParameter, except: ParamRadioConfig = undefined) { + protected resetOtherRadio(me: NgParameter, except?: ParamRadioConfig) { for (const p of this._formBase.allFormElements) { if (p instanceof NgParameter) { - if (p != me && p.radioState != except && p.radioState != ParamRadioConfig.LINK && p.radioConfig != ParamRadioConfig.FIX) { + if (p !== me && p.radioState !== except + && p.radioState !== ParamRadioConfig.LINK + && p.radioConfig !== ParamRadioConfig.FIX) { + p.valueMode = ParamValueMode.SINGLE; } } @@ -87,7 +87,7 @@ export class FormDefFixedVar { } else { const refParamValues = sourceParam.paramDefinition.referencedParamValues; if (refParamValues !== undefined) { // cad si on référence un paramètre et non un Result par ex - if (refParamValues.valueMode == ParamValueMode.LINK) { + if (refParamValues.valueMode === ParamValueMode.LINK) { throw new Error(`références de paramètre en chaîne non pris en charge`); } } // cas à traiter @@ -138,12 +138,12 @@ export class FormDefFixedVar { this.processRadioStateChange(sourceParam, oldState); // on vérifie qu'il y a au moins un paramètre "à calculer" et sinon, on prend le 1er qui est à "fixé" - if (this._formBase.getDisplayedParamFromState(ParamRadioConfig.CAL) == undefined) { + if (this._formBase.getDisplayedParamFromState(ParamRadioConfig.CAL) === undefined) { let newCal: NgParameter; for (const p of this._formBase.allFormElements) { if (p instanceof NgParameter) { - if (p.radioConfig == ParamRadioConfig.CAL && p.radioState == ParamRadioConfig.FIX && p != sourceParam) { + if (p.radioConfig === ParamRadioConfig.CAL && p.radioState === ParamRadioConfig.FIX && p !== sourceParam) { newCal = p; break; } diff --git a/src/app/formulaire/definition/form-def-paramcalc.ts b/src/app/formulaire/definition/form-def-paramcalc.ts index e48206721..b31c93a14 100644 --- a/src/app/formulaire/definition/form-def-paramcalc.ts +++ b/src/app/formulaire/definition/form-def-paramcalc.ts @@ -29,7 +29,7 @@ export class FormDefParamToCalculate extends FormDefFixedVar { // id du paramètre à calculer par défaut this._defaultCalculatedParam = o["idCal"]; - if (this._defaultCalculatedParam != undefined) { + if (this._defaultCalculatedParam !== undefined) { const p = this.setDefault(); p.isDefault = true; } @@ -41,7 +41,7 @@ export class FormDefParamToCalculate extends FormDefFixedVar { * met le paramètre par défaut à CAL sauf si c'est "except" * @param except paramètre à ne pas remettre à CAL */ - private setDefault(except: NgParameter = undefined): NgParameter { + private setDefault(except?: NgParameter): NgParameter { const defaultParamCal: NgParameter = this._formBase.getParamFromSymbol(this._defaultCalculatedParam); if (except === undefined || defaultParamCal.uid !== except.uid) { defaultParamCal.valueMode = ParamValueMode.CALCUL; diff --git a/src/app/formulaire/definition/form-def-section.ts b/src/app/formulaire/definition/form-def-section.ts index 69fa4c92d..734243db2 100644 --- a/src/app/formulaire/definition/form-def-section.ts +++ b/src/app/formulaire/definition/form-def-section.ts @@ -27,7 +27,7 @@ export class FormDefSection { } private get hasSectionNodeTypeSource(): boolean { - return this._sectionSourceId != undefined; + return this._sectionSourceId !== undefined; } public getSectionVariatedParameter(): NgParameter { diff --git a/src/app/formulaire/definition/form-result-section.ts b/src/app/formulaire/definition/form-result-section.ts index 0b828129e..868b1de8e 100644 --- a/src/app/formulaire/definition/form-result-section.ts +++ b/src/app/formulaire/definition/form-result-section.ts @@ -60,9 +60,9 @@ export class FormResultSection extends FormResult { } public get hasResults(): boolean { - return (this._fixedResults != undefined && this._fixedResults.hasResults) - || (this._varResults != undefined && this._varResults.hasResults) - || (this._sectionResults != undefined && this._sectionResults.hasResults); + return (this._fixedResults !== undefined && this._fixedResults.hasResults) + || (this._varResults !== undefined && this._varResults.hasResults) + || (this._sectionResults !== undefined && this._sectionResults.hasResults); } public get results(): CalculatorResults[] { diff --git a/src/app/formulaire/dependency/dependency.ts b/src/app/formulaire/dependency/dependency.ts index a7b8a4634..368ac35a0 100644 --- a/src/app/formulaire/dependency/dependency.ts +++ b/src/app/formulaire/dependency/dependency.ts @@ -21,9 +21,9 @@ export abstract class Dependency { private getMasterElement(id: string): FormulaireElement { let parentNode = this._slave.parent; - while (parentNode != undefined) { + while (parentNode !== undefined) { const res: FormulaireElement = parentNode.getFormulaireNodeById(id) as FormulaireElement; - if (res != undefined) { + if (res !== undefined) { return res; } parentNode = parentNode.parent; diff --git a/src/app/formulaire/field.ts b/src/app/formulaire/field.ts index d5f7c2df7..c8d2f84b6 100644 --- a/src/app/formulaire/field.ts +++ b/src/app/formulaire/field.ts @@ -23,7 +23,7 @@ export abstract class Field extends FormulaireElement { super.parseDependencies(json); const dep = json["dep_value"]; - if (dep != undefined) { + if (dep !== undefined) { this.parse_value_dependencies(dep); } } diff --git a/src/app/formulaire/form-iterator/deep-element-iterator.ts b/src/app/formulaire/form-iterator/deep-element-iterator.ts index a4a1aae30..8834c2847 100644 --- a/src/app/formulaire/form-iterator/deep-element-iterator.ts +++ b/src/app/formulaire/form-iterator/deep-element-iterator.ts @@ -5,8 +5,11 @@ import { FormulaireElement } from "../formulaire-element"; * itérateur qui extrait récursivement les FormulaireElement dans un tableau de FormulaireElement * (qui peut contenir des FieldsetContainer) */ -export class DeepFormulaireElementIterator extends AbstractFormulaireNodeIterator<FormulaireElement> implements IterableIterator<FormulaireElement> { - // interface IterableIterator +export class DeepFormulaireElementIterator + extends AbstractFormulaireNodeIterator<FormulaireElement> + implements IterableIterator<FormulaireElement> { + + // interface IterableIterator [Symbol.iterator](): IterableIterator<FormulaireElement> { return this; diff --git a/src/app/formulaire/form-iterator/top-element-iterator.ts b/src/app/formulaire/form-iterator/top-element-iterator.ts index 1b1f35dc6..32f9e63e9 100644 --- a/src/app/formulaire/form-iterator/top-element-iterator.ts +++ b/src/app/formulaire/form-iterator/top-element-iterator.ts @@ -5,7 +5,10 @@ import { FormulaireElement } from "../formulaire-element"; * itérateur qui extrait les FormulaireElement de 1er niveau dans un tableau de FormulaireElement * (qui peut contenir des FieldsetContainer) */ -export class TopFormulaireElementIterator extends AbstractFormulaireNodeIterator<FormulaireElement> implements IterableIterator<FormulaireElement> { +export class TopFormulaireElementIterator + extends AbstractFormulaireNodeIterator<FormulaireElement> + implements IterableIterator<FormulaireElement> { + protected isDeepIterator(): boolean { return false; } diff --git a/src/app/formulaire/formulaire-node.ts b/src/app/formulaire/formulaire-node.ts index 8d84e222d..128e3b100 100644 --- a/src/app/formulaire/formulaire-node.ts +++ b/src/app/formulaire/formulaire-node.ts @@ -78,7 +78,7 @@ export abstract class FormulaireNode implements IObservable { * cherche un FormulaireNode par son id numérique unique */ public getFormulaireNodeByUid(uid: number): FormulaireNode { - if (this.uid == uid) { + if (this.uid === uid) { return this; } @@ -100,7 +100,7 @@ export abstract class FormulaireNode implements IObservable { private kidIndex(kid: FormulaireNode): number { let n = 0; for (const k of this._kids) { - if (k._uid == kid._uid) { + if (k._uid === kid._uid) { return n; } n++; diff --git a/src/app/results/param-calc-results.ts b/src/app/results/param-calc-results.ts index 3c768a3da..5a3d6adec 100644 --- a/src/app/results/param-calc-results.ts +++ b/src/app/results/param-calc-results.ts @@ -54,20 +54,20 @@ export abstract class CalculatedParamResults extends CalculatorResults { } public get hasResults(): boolean { - if (this._result == undefined) { + if (this._result === undefined) { return false; } return this._result.ok; } public get hasLog(): boolean { - if (this._result == undefined) { + if (this._result === undefined) { return false; } return this._result.hasLog; } public get log(): cLog { - return this._result && this._result.log; // return x == undefined ? undefined : x.y + return this._result && this._result.log; // return x === undefined ? undefined : x.y } } diff --git a/src/app/results/remous-results.ts b/src/app/results/remous-results.ts index fdcdadd69..d8c61df5c 100644 --- a/src/app/results/remous-results.ts +++ b/src/app/results/remous-results.ts @@ -199,10 +199,10 @@ export class RemousResults extends CalculatorResults { } public get hasResults(): boolean { - return this._hautBerge != undefined || - this._penteFond != undefined || - this._hautNormale != undefined || - this._hautCritique != undefined || + return this._hautBerge !== undefined || + this._penteFond !== undefined || + this._hautNormale !== undefined || + this._hautCritique !== undefined || (this._result && this._result.ok); } diff --git a/src/app/results/section-results.ts b/src/app/results/section-results.ts index 8e3d3b88d..ee05b2943 100644 --- a/src/app/results/section-results.ts +++ b/src/app/results/section-results.ts @@ -35,6 +35,6 @@ export class SectionResults extends CalculatorResults { } public get hasResults(): boolean { - return this._section != undefined && this._result != undefined; + return this._section !== undefined && this._result !== undefined; } } diff --git a/src/app/services/service-factory.ts b/src/app/services/service-factory.ts index f40bf9a5c..682cc5c08 100644 --- a/src/app/services/service-factory.ts +++ b/src/app/services/service-factory.ts @@ -20,7 +20,7 @@ export class ServiceFactory { public httpService: HttpService; public static get instance() { - if (ServiceFactory._instance == undefined) { + if (ServiceFactory._instance === undefined) { ServiceFactory._instance = new ServiceFactory(); } return ServiceFactory._instance; -- GitLab