From b455613d179a4edf054cd809d96ec3d8cdb36bbf Mon Sep 17 00:00:00 2001 From: Tmadkaud Date: Mon, 9 Oct 2017 17:08:17 +0200 Subject: [PATCH] indexON erreur OK bug list carte envoyer de admin OK --- .../list-carte-envoyer.component.ts | 2 +- .../liste-op-commercial.component.ts | 2 +- .../edit-profil/edit-profil.component.ts | 8 ++-- src/app/services/auth/auth.service.ts | 46 +++++++++++-------- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/app/components/admin/list-carte-envoyer/list-carte-envoyer.component.ts b/src/app/components/admin/list-carte-envoyer/list-carte-envoyer.component.ts index a14c74a..07140f1 100644 --- a/src/app/components/admin/list-carte-envoyer/list-carte-envoyer.component.ts +++ b/src/app/components/admin/list-carte-envoyer/list-carte-envoyer.component.ts @@ -32,7 +32,7 @@ export class ListCarteEnvoyerComponent implements OnInit, OnDestroy { this.route.params.subscribe(params => { this.carteParList = this.afDb.list('/CarteParrainage/', { query: { - orderByChild: 'operationCommercialID', + orderByChild: 'operationCommercialCarte/uid', equalTo: params['idOp'] } }); diff --git a/src/app/components/admin/liste-op-commercial/liste-op-commercial.component.ts b/src/app/components/admin/liste-op-commercial/liste-op-commercial.component.ts index d4df59c..528a538 100644 --- a/src/app/components/admin/liste-op-commercial/liste-op-commercial.component.ts +++ b/src/app/components/admin/liste-op-commercial/liste-op-commercial.component.ts @@ -157,7 +157,7 @@ export class ListeOpCommercialComponent implements OnInit, OnDestroy { carteEnvoyer(op: OperationCommerciale){ this.opCommData = this.afDb.list('/CarteParrainage/',{ query: { - orderByChild: 'operationCommercialID', + orderByChild: 'operationCommercialCarte/uid', equalTo: op.uid } }).map((array) => array.reverse()) as FirebaseListObservable; diff --git a/src/app/components/profil/edit-profil/edit-profil.component.ts b/src/app/components/profil/edit-profil/edit-profil.component.ts index 1476d12..ec6c82b 100644 --- a/src/app/components/profil/edit-profil/edit-profil.component.ts +++ b/src/app/components/profil/edit-profil/edit-profil.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, EventEmitter } from '@angular/core'; +import { Component, OnInit, OnDestroy, EventEmitter } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { Router } from '@angular/router'; @@ -18,7 +18,7 @@ import { Commercant } from '../../../../models/Commercant'; styleUrls: ['./edit-profil.component.scss'], providers: [AuthService] }) -export class EditProfilComponent implements OnInit { +export class EditProfilComponent implements OnInit, OnDestroy { user: Observable; localUser: any; @@ -49,7 +49,7 @@ export class EditProfilComponent implements OnInit { this.parrainDateTimeTest = new Date(this.parrain.birthday); this.user.subscribe( (auth) => { - console.log(auth.displayName); + // console.log(auth.displayName); if (auth) { this.profileData = this.afDb.list('/' + auth.displayName + '/', { query: { @@ -124,7 +124,7 @@ export class EditProfilComponent implements OnInit { goToProfil() { this.router.navigate(['/profil']); } - + ngOnDestroy(){} ngOnInit() { var inputs = document.querySelectorAll( '.inputfile' ); Array.prototype.forEach.call( inputs, function( input ) diff --git a/src/app/services/auth/auth.service.ts b/src/app/services/auth/auth.service.ts index 1c5e63a..cf98a35 100644 --- a/src/app/services/auth/auth.service.ts +++ b/src/app/services/auth/auth.service.ts @@ -119,10 +119,12 @@ export class AuthService { console.log('salut le ' + this.utilisateur.email + ' ' + this.utilisateur.status + ' has signed!'); firebase.auth().onAuthStateChanged(function (userUpdate) { - userUpdate.updateProfile({ - displayName: elementParrain.status, - photoURL: elementParrain.image.downloadURL - }); + if(userUpdate !== null){ + userUpdate.updateProfile({ + displayName: elementParrain.status, + photoURL: elementParrain.image.downloadURL + }); + } }); if (this.utilisateur.status === 'Parrain') { this.router.navigate(['/carteParrainageComponent']); @@ -152,10 +154,12 @@ export class AuthService { if (/*user.emailVerified*/true){ console.log('salut le ' + this.utilisateur.email + ' ' + this.utilisateur.status + ' has signed!'); firebase.auth().onAuthStateChanged(function (userUpdate) { - userUpdate.updateProfile({ - displayName: elementCommercant.status, - photoURL: elementCommercant.image.downloadURL - }); + if (userUpdate !== null){ + userUpdate.updateProfile({ + displayName: elementCommercant.status, + photoURL: elementCommercant.image.downloadURL + }); + } }); if (this.utilisateur.status === 'Parrain') { this.router.navigate(['/carteParrainageComponent']); @@ -257,13 +261,15 @@ export class AuthService { }); } firebase.auth().onAuthStateChanged(function (userUpdate) { - userUpdate.updateProfile({ - displayName: info.status, - photoURL: info.image.downloadURL - }).then(al => { - console.log('userUpdate.dispppp : ' + al); - // firebase.auth().signOut(); - }); + if (userUpdate !== null){ + userUpdate.updateProfile({ + displayName: info.status, + photoURL: info.image.downloadURL + }).then(al => { + console.log('userUpdate.dispppp : ' + al); + // firebase.auth().signOut(); + }); + } }); return true; @@ -291,10 +297,12 @@ export class AuthService { }); } firebase.auth().onAuthStateChanged(function (userUpdate) { - userUpdate.updateProfile({ - displayName: info.status, - photoURL: info.image.downloadURL - }); + if (userUpdate !== null){ + userUpdate.updateProfile({ + displayName: info.status, + photoURL: info.image.downloadURL + }); + } if (userUpdate) { console.log('userUpdate: ' + userUpdate); } else {