import { ANALYZE_FOR_ENTRY_COMPONENTS, Component,AfterViewChecked, OnInit, ChangeDetectorRef, Input, Output, EventEmitter, AfterViewInit, NgZone, ChangeDetectionStrategy, ViewChild, OnChanges, SimpleChange, SimpleChanges, DoCheck, AfterContentChecked, AfterContentInit } from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser'; import {MatIconRegistry, MatSelectChange} from '@angular/material'; import {ReponseService} from '../question/ReponseService'; import {WizardDefinition, UserAccess} from '../models/PrjdeVie'; import {FormControl, ReactiveFormsModule} from '@angular/forms'; import {Observable} from 'rxjs'; import {map,startWith} from 'rxjs/operators'; import { ActivatedRoute, ParamMap } from '@angular/router'; import { AppComponent } from '../app.component'; export class Client{ constructor(public idClient: number){} } export class Data{ idwizard: string; constructor(public idClient: number){} } @Component({ selector: 'app-header', templateUrl: './header.component.html', styleUrls: ['./header.component.css'], providers: [ ReponseService] }) export class HeaderComponent implements OnInit,OnChanges //,OnChanges, DoCheck, AfterViewChecked, AfterContentInit, AfterContentChecked { searchCtrl : FormControl; hideSearchCtrl: boolean; user: string; wizardKey: number; idWizard: string; personId: string; @Output() valueChanged = new EventEmitter(); idWizardNumber : number; //Gestione dei clienti listClients: UserAccess [] = []; clients: Client[] = []; filteredClients: Observable<any[]>; clientId: number; public client: number; emitflag : boolean; ngOnChanges(changes: SimpleChanges){ for (let propName in changes) { let change = changes[propName]; let curVal = JSON.stringify(change.currentValue); let prevVal = JSON.stringify(change.previousValue); console.log(curVal+ "+++++"); console.log(prevVal + "++++"); } } constructor( private ref: ChangeDetectorRef,private zone:NgZone ,private route: ActivatedRoute,iconRegistry: MatIconRegistry, sanitazer: DomSanitizer , private was:ReponseService, public cd: ChangeDetectorRef) { this.emitflag = false; this.hideSearchCtrl = true; this.searchCtrl = new FormControl(); //console.log(this.clientId + " Initial value of clientId"); this.filteredClients = new Observable<any[]>(); //list of client // this.filteredClients = this.searchCtrl.valueChanges.pipe( //startWith(''), //map(client => client ? this.filterClients(client.toString()): this.clients.slice()) //); iconRegistry.addSvgIcon('logo-PG', sanitazer. bypassSecurityTrustResourceUrl('assets/brand-logo-brown.svg')); //this.user = "test"; console.log("HEADER COMPONENT User Login: " + was.getUser().subscribe( data => { console.log(data); this.user = data; //console.log("user" + data); console.log("HEADER COMPONENT User Login after subscribe: " + this. user); } ) ); this.route.paramMap.subscribe(params => { //console.log(params.get('personId')); this.personId = params.get('personId'); console.log("ngOnInit: " + this.personId); }); if (this.personId !== null){ console.log("ngOnInit 1" + this.personId); var wi = new WizardDefinition(); wi.WiClient = Number (this.personId); wi.WiUser = ''; wi.WiOpenDate = new Date(); wi.WiCloseDate = new Date(); wi.WiKey= 0; console.log("Creation Wizard: OpenDate: " + wi.WiOpenDate + "CloseDate" + wi.WiCloseDate); if(wi !== null){ console.log("HEADER ngOnInit Creation Wizard: OpenDate: " + wi.WiOpenDate + "CloseDate" + wi.WiCloseDate + "for id person" + this. personId); var response = this.was.postWizardStart(wi); response.subscribe(res => { this.idWizard = res.headers.get('idWizard'); console.log("HEADER ngOnInit 2 OK 200 Server - Idwizard is: " + this.idWizard); // this.ref.markForCheck() console.log(this.idWizard + " +++" + res.headers.get('idWizard' ) ) ; this.valueChanged.emit(this.idWizard); this.ngAfterContentChecked(); }, err => { console.log(err); }); } } } ngOnInit() { // this.route.paramMap.subscribe(params => { // //console.log(params.get('personId')); // this.personId = params.get('personId'); // console.log("ngOnInit: " + this.personId); // }); // if (this.personId !== null){ // console.log("ngOnInit 1" + this.personId); // var wi = new WizardDefinition(); // wi.WiClient = Number (this.personId); // wi.WiUser = ''; // wi.WiOpenDate = new Date(); // wi.WiCloseDate = new Date(); // wi.WiKey= 0; // console.log("Creation Wizard: OpenDate: " + wi.WiOpenDate + "CloseDate" + wi.WiCloseDate); // if(wi !== null){ // console.log("HEADER ngOnInit Creation Wizard: OpenDate: " + wi.WiOpenDate + "CloseDate" + wi.WiCloseDate + "for id person" + this.personId); // var response = this.was.postWizardStart(wi); // response.subscribe(res => { // this.idWizard = res.headers.get('idWizard'); // console.log("HEADER ngOnInit 2 OK 200 Server - Idwizard is: " + this.idWizard); // // this.ref.markForCheck() // console.log(this.idWizard + " +++" + res.headers.get('idWizard') ) ; // this.valueChanged.emit(this.idWizard); // this.ngAfterContentChecked(); // }, // err => { // console.log(err); // }); // } // // this.emitValue("0000000000000"); // } // //PersonId // //console.log('HEADER ngOnInit Person Id from route', this.route.snapshot.params.personId); // this.route.paramMap.subscribe(params => { // //console.log(params.get('personId')); // this.personId = params.get('personId'); // //console.log("HEADER ngOnInit HEADER COMPONENT personId: " + this.personId); // if (this.personId !== null){ // var wi = new WizardDefinition(); // wi.WiClient = Number (this.personId); // wi.WiUser = ''; // wi.WiOpenDate = new Date(); // wi.WiCloseDate = new Date(); // wi.WiKey= 0; // } // if(wi !== null){ // console.log("HEADER ngOnInit Creation Wizard: OpenDate: " + wi.WiOpenDate + "CloseDate" + wi.WiCloseDate + "for id person" + this.personId); // var response = this.was.postWizardStart(wi); // response.subscribe(res => { this.zone.run(() => { // this.idWizard = res.headers.get('idWizard'); // console.log("HEADER ngOnInit OK 200 Server - Idwizard is: " + this.idWizard); // this.emitValue(this.idWizard); // console.log("AFTER emit value to parent" + this.idWizard); // this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard); // }); // }, // err => { // console.log(err); // }); // } // console.log("AFTER emit value to parent 22" + this.idWizard); // this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard); // }); // if (this.personId != null){ // //this.emitValue(this.idWizard); // // // } // else // { // // //console.log("Value of client" + this.clientId); // this.searchCtrl.valueChanges.subscribe(val => { // //console.log("New research, value of client code" + val); // if (val != 0){ // this.clientId = val; // } // console.log("New research, value of clientId attribute" + val); // console.log("getListCodeClients"); // this.filteredClients = new Observable<any[]>(); // console.log("User Login into getListCodeClients: " + this.was.getUser().subscribe( // data => // { // console.log(data); // this.user = data; // } ) // ); // try{ // this.was.getClientsByUser(this.user.substring(2, this.user.length), this.clientId.toString()).subscribe(clientList => { // this.clients = []; // clientList.forEach(element => // { // console.log("PersonId " + element.personId); // this.clients.push(new Client(Number (element.personId))); // }); // this.filteredClients = this.searchCtrl.valueChanges.pipe( // startWith(''), // map(client => client ? this.filterClients(client.toString()): this.clients.slice()) // ); // }); // } // catch(e){ // console.log(e); // } // } // ); // } // setInterval( ()=>{ // if((Number(this.idWizard))> 0){ // this.emitValue(this.idWizard); // //this.valueChanged.emit(this.idWizard); // this.ref.detectChanges(); // this.ref.markForCheck(); // console.log(this.idWizard + "setInterval"); // } // },3000 // ); } openSearch(){ /* if (this.hideSearchCtrl == true) this.hideSearchCtrl = false; else*/ this.hideSearchCtrl = false; } filterClients(idClient: string){ //call get client return this.clients.filter(client => client.idClient.toString(). indexOf(idClient.toLocaleLowerCase()) === 0); } updateIdClient(clientID: any, event: MatSelectChange){ this.clientId = Number(clientID); console.log("Client ...: " + this.clientId); console.log("Client ...: " + this.clientId); console.log("Client ...: " + this.clientId); // //this.getListCodeClients(); // //get user console.log("User Login into getListCodeClients: " + this.was.getUser ().subscribe( data => { console.log(data); this.user = data; //console.log("user" + data); //console.log("User Login ng oninit: " + this.user); } ) ); console.log("idclient into header" + this.clientId); console.log("event" + event.source.selected); if (event.source.selected && this.personId == null){ var wi = new WizardDefinition(); wi.WiClient = Number (this.clientId); wi.WiUser = this.user; wi.WiOpenDate = new Date(); wi.WiCloseDate = new Date(); wi.WiKey= 0; console.log("Creation Wizard: OpenDate: " + wi.WiOpenDate + "CloseDate" + wi.WiCloseDate); var response = this.was.postWizardStart(wi); response.subscribe(res => { this.idWizard = res.headers.get('idWizard'); console.log("OK 200 Server - Idwizard is: " + this.idWizard); this.valueChanged.emit(this.idWizard); this.clientId = clientID.toString(); }, err => { console.log(err); }); } this.hideSearchCtrl = true; } emitValue(value:string){ // setInterval( ()=>{ // if((Number(value))> 0){ // this.valueChanged.emit(value); // console.log("emitvalueToParent WIZARD ID" + value); // } // },15000 // ); } emitValue2(){ this.ref.detectChanges(); this.ref.markForCheck(); this.valueChanged.emit(this.idWizard); console.log("------------------------------->" + " " + this.idWizard); } ngDoCheck(){ //setInterval( ()=>{ // if((Number(this.idWizard))> 0){ // this.valueChanged.emit(this.idWizard); // console.log("ngdoCheck" + this.idWizard); // //this.ngDoCheck(); // } // },15000 // ); } // ngAfterContentInit(){ // this.ref.markForCheck(); // if(this.emitflag) // { // console.log(" ngAfterContentInit: START " + " " + this.idWizard); // this.valueChanged.emit(this.idWizard); // } // console.log(" ngAfterContentInit: END "); // } ngAfterContentChecked(){ if(Number(this.idWizard)> 0){ console.log("ngAfterContentChecked this id " + this.idWizard); this.valueChanged.emit(this.idWizard); } } // ngAfterViewInit(){ // this.ref.markForCheck() // if(this.emitflag) // { // console.log(" ngAfterViewInit: START " + " " + this.idWizard); // this.valueChanged.emit(this.idWizard); // } // console.log(" ngAfterViewInit: END "); // } // ngAfterViewChecked(){ // if(this.emitflag) // { // console.log(" ngAfterViewChecked: START " + " " + this.idWizard); // this.valueChanged.emit(this.idWizard); // } // console.log(" ngAfterViewChecked: END "); // } } -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/angular/12601a1a-01d9-40fd-b5bc-c32f14b22019%40googlegroups.com.
import { ANALYZE_FOR_ENTRY_COMPONENTS, Component,AfterViewChecked, OnInit, ChangeDetectorRef, Input, Output, EventEmitter, AfterViewInit, NgZone, ChangeDetectionStrategy, ViewChild, OnChanges, SimpleChange, SimpleChanges, DoCheck, AfterContentChecked, AfterContentInit } from '@angular/core'; import {DomSanitizer} from '@angular/platform-browser'; import {MatIconRegistry, MatSelectChange} from '@angular/material'; import {ReponseService} from '../question/ReponseService'; import {WizardDefinition, UserAccess} from '../models/PrjdeVie'; import {FormControl, ReactiveFormsModule} from '@angular/forms'; import {Observable} from 'rxjs'; import {map,startWith} from 'rxjs/operators'; import { ActivatedRoute, ParamMap } from '@angular/router'; import { AppComponent } from '../app.component'; export class Client{ constructor(public idClient: number){} } export class Data{ idwizard: string; constructor(public idClient: number){} } @Component({ selector: 'app-header', templateUrl: './header.component.html', styleUrls: ['./header.component.css'], providers: [ ReponseService] }) export class HeaderComponent implements OnInit,OnChanges //,OnChanges, DoCheck, AfterViewChecked, AfterContentInit, AfterContentChecked { searchCtrl : FormControl; hideSearchCtrl: boolean; user: string; wizardKey: number; idWizard: string; personId: string; @Output() valueChanged = new EventEmitter(); idWizardNumber : number; //Gestione dei clienti listClients: UserAccess [] = []; clients: Client[] = []; filteredClients: Observable<any[]>; clientId: number; public client: number; emitflag : boolean; ngOnChanges(changes: SimpleChanges){ for (let propName in changes) { let change = changes[propName]; let curVal = JSON.stringify(change.currentValue); let prevVal = JSON.stringify(change.previousValue); console.log(curVal+ "+++++"); console.log(prevVal + "++++"); } } constructor( private ref: ChangeDetectorRef,private zone:NgZone ,private route: ActivatedRoute,iconRegistry: MatIconRegistry, sanitazer: DomSanitizer, private was:ReponseService, public cd: ChangeDetectorRef) { this.emitflag = false; this.hideSearchCtrl = true; this.searchCtrl = new FormControl(); //console.log(this.clientId + " Initial value of clientId"); this.filteredClients = new Observable<any[]>(); //list of client // this.filteredClients = this.searchCtrl.valueChanges.pipe( //startWith(''), //map(client => client ? this.filterClients(client.toString()): this.clients.slice()) //); iconRegistry.addSvgIcon('logo-PG', sanitazer.bypassSecurityTrustResourceUrl('assets/brand-logo-brown.svg')); //this.user = "test"; console.log("HEADER COMPONENT User Login: " + was.getUser().subscribe( data => { console.log(data); this.user = data; //console.log("user" + data); console.log("HEADER COMPONENT User Login after subscribe: " + this.user); } ) ); this.route.paramMap.subscribe(params => { //console.log(params.get('personId')); this.personId = params.get('personId'); console.log("ngOnInit: " + this.personId); }); if (this.personId !== null){ console.log("ngOnInit 1" + this.personId); var wi = new WizardDefinition(); wi.WiClient = Number (this.personId); wi.WiUser = ''; wi.WiOpenDate = new Date(); wi.WiCloseDate = new Date(); wi.WiKey= 0; console.log("Creation Wizard: OpenDate: " + wi.WiOpenDate + "CloseDate" + wi.WiCloseDate); if(wi !== null){ console.log("HEADER ngOnInit Creation Wizard: OpenDate: " + wi.WiOpenDate + "CloseDate" + wi.WiCloseDate + "for id person" + this.personId); var response = this.was.postWizardStart(wi); response.subscribe(res => { this.idWizard = res.headers.get('idWizard'); console.log("HEADER ngOnInit 2 OK 200 Server - Idwizard is: " + this.idWizard); // this.ref.markForCheck() console.log(this.idWizard + " +++" + res.headers.get('idWizard') ) ; this.valueChanged.emit(this.idWizard); this.ngAfterContentChecked(); }, err => { console.log(err); }); } } } ngOnInit() { // this.route.paramMap.subscribe(params => { // //console.log(params.get('personId')); // this.personId = params.get('personId'); // console.log("ngOnInit: " + this.personId); // }); // if (this.personId !== null){ // console.log("ngOnInit 1" + this.personId); // var wi = new WizardDefinition(); // wi.WiClient = Number (this.personId); // wi.WiUser = ''; // wi.WiOpenDate = new Date(); // wi.WiCloseDate = new Date(); // wi.WiKey= 0; // console.log("Creation Wizard: OpenDate: " + wi.WiOpenDate + "CloseDate" + wi.WiCloseDate); // if(wi !== null){ // console.log("HEADER ngOnInit Creation Wizard: OpenDate: " + wi.WiOpenDate + "CloseDate" + wi.WiCloseDate + "for id person" + this.personId); // var response = this.was.postWizardStart(wi); // response.subscribe(res => { // this.idWizard = res.headers.get('idWizard'); // console.log("HEADER ngOnInit 2 OK 200 Server - Idwizard is: " + this.idWizard); // // this.ref.markForCheck() // console.log(this.idWizard + " +++" + res.headers.get('idWizard') ) ; // this.valueChanged.emit(this.idWizard); // this.ngAfterContentChecked(); // }, // err => { // console.log(err); // }); // } // // this.emitValue("0000000000000"); // } // //PersonId // //console.log('HEADER ngOnInit Person Id from route', this.route.snapshot.params.personId); // this.route.paramMap.subscribe(params => { // //console.log(params.get('personId')); // this.personId = params.get('personId'); // //console.log("HEADER ngOnInit HEADER COMPONENT personId: " + this.personId); // if (this.personId !== null){ // var wi = new WizardDefinition(); // wi.WiClient = Number (this.personId); // wi.WiUser = ''; // wi.WiOpenDate = new Date(); // wi.WiCloseDate = new Date(); // wi.WiKey= 0; // } // if(wi !== null){ // console.log("HEADER ngOnInit Creation Wizard: OpenDate: " + wi.WiOpenDate + "CloseDate" + wi.WiCloseDate + "for id person" + this.personId); // var response = this.was.postWizardStart(wi); // response.subscribe(res => { this.zone.run(() => { // this.idWizard = res.headers.get('idWizard'); // console.log("HEADER ngOnInit OK 200 Server - Idwizard is: " + this.idWizard); // this.emitValue(this.idWizard); // console.log("AFTER emit value to parent" + this.idWizard); // this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard); // }); // }, // err => { // console.log(err); // }); // } // console.log("AFTER emit value to parent 22" + this.idWizard); // this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard);this.emitValue(this.idWizard); // }); // if (this.personId != null){ // //this.emitValue(this.idWizard); // // // } // else // { // // //console.log("Value of client" + this.clientId); // this.searchCtrl.valueChanges.subscribe(val => { // //console.log("New research, value of client code" + val); // if (val != 0){ // this.clientId = val; // } // console.log("New research, value of clientId attribute" + val); // console.log("getListCodeClients"); // this.filteredClients = new Observable<any[]>(); // console.log("User Login into getListCodeClients: " + this.was.getUser().subscribe( // data => // { // console.log(data); // this.user = data; // } ) // ); // try{ // this.was.getClientsByUser(this.user.substring(2, this.user.length), this.clientId.toString()).subscribe(clientList => { // this.clients = []; // clientList.forEach(element => // { // console.log("PersonId " + element.personId); // this.clients.push(new Client(Number (element.personId))); // }); // this.filteredClients = this.searchCtrl.valueChanges.pipe( // startWith(''), // map(client => client ? this.filterClients(client.toString()): this.clients.slice()) // ); // }); // } // catch(e){ // console.log(e); // } // } // ); // } // setInterval( ()=>{ // if((Number(this.idWizard))> 0){ // this.emitValue(this.idWizard); // //this.valueChanged.emit(this.idWizard); // this.ref.detectChanges(); // this.ref.markForCheck(); // console.log(this.idWizard + "setInterval"); // } // },3000 // ); } openSearch(){ /* if (this.hideSearchCtrl == true) this.hideSearchCtrl = false; else*/ this.hideSearchCtrl = false; } filterClients(idClient: string){ //call get client return this.clients.filter(client => client.idClient.toString().indexOf(idClient.toLocaleLowerCase()) === 0); } updateIdClient(clientID: any, event: MatSelectChange){ this.clientId = Number(clientID); console.log("Client ...: " + this.clientId); console.log("Client ...: " + this.clientId); console.log("Client ...: " + this.clientId); // //this.getListCodeClients(); // //get user console.log("User Login into getListCodeClients: " + this.was.getUser().subscribe( data => { console.log(data); this.user = data; //console.log("user" + data); //console.log("User Login ng oninit: " + this.user); } ) ); console.log("idclient into header" + this.clientId); console.log("event" + event.source.selected); if (event.source.selected && this.personId == null){ var wi = new WizardDefinition(); wi.WiClient = Number (this.clientId); wi.WiUser = this.user; wi.WiOpenDate = new Date(); wi.WiCloseDate = new Date(); wi.WiKey= 0; console.log("Creation Wizard: OpenDate: " + wi.WiOpenDate + "CloseDate" + wi.WiCloseDate); var response = this.was.postWizardStart(wi); response.subscribe(res => { this.idWizard = res.headers.get('idWizard'); console.log("OK 200 Server - Idwizard is: " + this.idWizard); this.valueChanged.emit(this.idWizard); this.clientId = clientID.toString(); }, err => { console.log(err); }); } this.hideSearchCtrl = true; } emitValue(value:string){ // setInterval( ()=>{ // if((Number(value))> 0){ // this.valueChanged.emit(value); // console.log("emitvalueToParent WIZARD ID" + value); // } // },15000 // ); } emitValue2(){ this.ref.detectChanges(); this.ref.markForCheck(); this.valueChanged.emit(this.idWizard); console.log("------------------------------->" + " " + this.idWizard); } ngDoCheck(){ //setInterval( ()=>{ // if((Number(this.idWizard))> 0){ // this.valueChanged.emit(this.idWizard); // console.log("ngdoCheck" + this.idWizard); // //this.ngDoCheck(); // } // },15000 // ); } // ngAfterContentInit(){ // this.ref.markForCheck(); // if(this.emitflag) // { // console.log(" ngAfterContentInit: START " + " " + this.idWizard); // this.valueChanged.emit(this.idWizard); // } // console.log(" ngAfterContentInit: END "); // } ngAfterContentChecked(){ if(Number(this.idWizard)> 0){ console.log("ngAfterContentChecked this id " + this.idWizard); this.valueChanged.emit(this.idWizard); } } // ngAfterViewInit(){ // this.ref.markForCheck() // if(this.emitflag) // { // console.log(" ngAfterViewInit: START " + " " + this.idWizard); // this.valueChanged.emit(this.idWizard); // } // console.log(" ngAfterViewInit: END "); // } // ngAfterViewChecked(){ // if(this.emitflag) // { // console.log(" ngAfterViewChecked: START " + " " + this.idWizard); // this.valueChanged.emit(this.idWizard); // } // console.log(" ngAfterViewChecked: END "); // } }