Skip to content
Snippets Groups Projects
Commit 2e519f77 authored by mathias.chouet's avatar mathias.chouet
Browse files

Removed debug messages; worked on notifications for chained computation

parent c2970c6f
No related branches found
No related tags found
1 merge request!40Resolve "Amélioration du système de paramètres liés"
......@@ -18,6 +18,7 @@ import { nghydDateRev } from "../date_revision";
import { DialogConfirmEmptySessionComponent } from "./components/dialog-confirm-empty-session/dialog-confirm-empty-session.component";
import { DialogLoadSessionComponent } from "./components/dialog-load-session/dialog-load-session.component";
import { DialogSaveSessionComponent } from "./components/dialog-save-session/dialog-save-session.component";
import { NotificationsService } from "./services/notifications/notifications.service";
@Component({
......@@ -66,6 +67,7 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
private router: Router,
private formulaireService: FormulaireService,
private httpService: HttpService,
private notificationsService: NotificationsService,
private confirmEmptySessionDialog: MatDialog,
private saveSessionDialog: MatDialog,
private loadSessionDialog: MatDialog,
......@@ -76,6 +78,7 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
ServiceFactory.instance.applicationSetupService = appSetupService;
ServiceFactory.instance.i18nService = intlService;
ServiceFactory.instance.formulaireService = formulaireService;
ServiceFactory.instance.notificationsService = notificationsService;
this.router.events.subscribe((event: Event) => {
// close side navigation when clicking a calculator tab
......@@ -217,16 +220,7 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
// interface Observer
update(sender: any, data: any): void {
if (sender instanceof ErrorService) {
// on ouvre un dialogue avec le message d'erreur reçu
// if (this._displayErrorDialog) {
// let dialogRef = this.dialog.open(AlertDialog);
// let ad: AlertDialog = dialogRef.componentInstance;
// ad.text = String(data);
// }
// else
console.log(data);
} else if (sender instanceof FormulaireService) {
if (sender instanceof FormulaireService) {
switch (data["action"]) {
case "createForm":
// add newly created form to calculators list
......
......@@ -164,7 +164,6 @@ export class GenericCalculatorComponent extends BaseComponent implements OnInit,
}
ngDoCheck() {
console.log(">>> UI validity", this._isUIValid);
this.isCalculateDisabled = ! this._isUIValid;
}
......@@ -203,6 +202,7 @@ export class GenericCalculatorComponent extends BaseComponent implements OnInit,
this._formulaire.onRadioClick(this._pendingRadioClickInfo);
this._pendingRadioClickInfo = undefined;
}
// @TODO call this._isUIValid here ?
}
public onCloseForm() {
......
......@@ -3,12 +3,22 @@ import { Nub, Result, ParamDomainValue, Observer } from "jalhyd";
import { FormResult } from "./form-result";
import { FormulaireDefinition } from "./form-definition";
import { NgParameter } from "../ngparam";
import { NotificationsService } from "../../services/notifications/notifications.service";
import { ServiceFactory } from "../../services/service-factory";
import { I18nService } from "../../services/internationalisation/internationalisation.service";
export abstract class FormCompute implements Observer {
private notificationsService: NotificationsService;
private intlService: I18nService;
constructor(protected _formBase: FormulaireDefinition, protected _formResult: FormResult) {
// indirectly subscribe to Nub result updates
this._formBase.addObserver(this);
this.notificationsService = ServiceFactory.instance.notificationsService;
this.intlService = ServiceFactory.instance.i18nService;
}
protected abstract compute();
......@@ -107,10 +117,11 @@ export abstract class FormCompute implements Observer {
case "nubResultUpdated":
// forward Nub results update notification to FormCompute objects
this.reaffectResultComponents();
/* console.log("_____forwarding 2");
this._formBase.notifyObservers({
"action": "resultsUpdated",
}, this._formBase); */
// @TODO reenable later wen chain computation is executed only once or it is a snackbar hell !
/* this.notificationsService.notify(
this.intlService.localizeText("INFO_SNACKBAR_RESULTS_CALCULATED") + " " + this._formBase.calculatorName,
1500
); */
break;
}
}
......
......@@ -115,7 +115,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
// replace Nub
this._currentNub = n;
// subscribe to new Nub (for result updates)
console.log("SET CURRENT NUB -- (re)subscribe to Nub", this._currentNub.uid);
this._currentNub.addObserver(this);
}
......@@ -487,7 +486,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
// interface Observer
public update(sender: any, data: any) {
console.log("--- FormDefinition received update", sender.constructor.name, data);
if (sender instanceof Nub) {
switch (data.action) {
case "resultUpdated":
......
......@@ -616,7 +616,7 @@ export class FormulaireService extends Observable {
if (notify) {
this.notificationsService.notify(
this.intlService.localizeText("INFO_SNACKBAR_RESULTS_INVALIDATED") + " " + form.calculatorName,
2000
1500
);
}
}
......
......@@ -2,6 +2,7 @@ import { ApplicationSetupService } from "./app-setup/app-setup.service";
import { FormulaireService } from "./formulaire/formulaire.service";
import { I18nService } from "./internationalisation/internationalisation.service";
import { HttpService } from "./http/http.service";
import { NotificationsService } from "./notifications/notifications.service";
export class ServiceFactory {
private static _instance: ServiceFactory; // instance pour le pattern singleton
......@@ -16,6 +17,8 @@ export class ServiceFactory {
public httpService: HttpService;
public notificationsService: NotificationsService;
public static get instance() {
if (ServiceFactory._instance === undefined) {
ServiceFactory._instance = new ServiceFactory();
......
......@@ -204,6 +204,7 @@
"INFO_SETUP_PRECISION_AFFICHAGE": "Display accuracy",
"INFO_SETUP_PRECISION_CALCUL": "Computation accuracy",
"INFO_SETUP_TITLE": "Application setup",
"INFO_SNACKBAR_RESULTS_CALCULATED": "Results calculated for",
"INFO_SNACKBAR_RESULTS_INVALIDATED": "Results invalidated for",
"INFO_SNACKBAR_SETTINGS_SAVED": "Settings saved on this device",
"INFO_SNACKBAR_DEFAULT_SETTINGS_RESTORED": "Default settings restored",
......
......@@ -204,6 +204,7 @@
"INFO_SETUP_PRECISION_AFFICHAGE": "Précision d'affichage",
"INFO_SETUP_PRECISION_CALCUL": "Précision de calcul",
"INFO_SETUP_TITLE": "Paramètres de l'application",
"INFO_SNACKBAR_RESULTS_CALCULATED": "Résultats calculés pour",
"INFO_SNACKBAR_RESULTS_INVALIDATED": "Résultats invalidés pour",
"INFO_SNACKBAR_SETTINGS_SAVED": "Paramètres enregistrés sur cet appareil",
"INFO_SNACKBAR_DEFAULT_SETTINGS_RESTORED": "Paramètres par défaut restaurés",
......
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