Merge branch 'anis' of ssh://git.marbelium.com:10023/Viiciouss/XJC into thierry

thierry
Tmadkaud 7 years ago
commit d3e6263405

@ -24,6 +24,7 @@ import { OpCommercialComponent } from './components/opCommercial/op-commercial/o
import { CreationOpComComponent } from './components/opCommercial/creation-op-com/creation-op-com.component';
import { CarteParrainageComponent } from './components/carteParrainage/carte-parrainage/carte-parrainage.component';
import { EnvoyerCarteComponent } from './components/opCommercial/envoyer-carte/envoyer-carte.component';
import { EditProfilComponent } from './components/profil/edit-profil/edit-profil.component'
@NgModule({
@ -37,7 +38,8 @@ import { EnvoyerCarteComponent } from './components/opCommercial/envoyer-carte/e
OpCommercialComponent,
CreationOpComComponent,
CarteParrainageComponent,
EnvoyerCarteComponent
EnvoyerCarteComponent,
EditProfilComponent
],
imports: [
BrowserModule,

@ -6,6 +6,7 @@ import { OpCommercialComponent } from './components/opCommercial/op-commercial/o
import { CreationOpComComponent } from './components/opCommercial/creation-op-com/creation-op-com.component';
import { CarteParrainageComponent } from './components/carteParrainage/carte-parrainage/carte-parrainage.component';
import { EnvoyerCarteComponent } from './components/opCommercial/envoyer-carte/envoyer-carte.component';
import { EditProfilComponent } from './components/profil/edit-profil/edit-profil.component'
export const AppRoutes = [
{path: '', component: HomeComponent},
@ -16,4 +17,5 @@ export const AppRoutes = [
{path: 'creationOpCommercial', component: CreationOpComComponent},
{path: 'carteParrainageComponent', component: CarteParrainageComponent},
{path: 'EnvoyerCarte/:idOp', component: EnvoyerCarteComponent},
{path: 'editProfil', component: EditProfilComponent}
];

@ -0,0 +1,145 @@
<div class="container">
<!--Grid column-->
<div class="col-md-12" style="padding-right: 2%; padding-left: 2%;">
<!--Card-->
<div class="card testimonial-card">
<!--Bacground color-->
<div class="card-up aqua-gradient">
</div>
<!--Avatar-->
<div class="avatar"><img src="{{imageProfil}}" class="rounded-circle img-responsive">
</div>
<div class="card-body" style="padding-left: 20%; padding-right: 20%;">
<!--Name-->
<div *ngIf="(user | async)?.displayName === 'Parrain'" >
<button class="btn btn-deep-orange" (click)="modifyPasswordSection()">Modifier Email/Mot de passe</button>
<div class="card" *ngIf="modifiermdp">
<div class="md-form">
<i class="fa fa-lock prefix grey-text"></i>
<input id="orangeForm-passC" type="password" [(ngModel)]="confirmOldPassword" placeholder="Tapez votre ancien mot de passe" name="confirmOldPasswordPar" #confirmOldPasswordPar="ngModel">
<div *ngIf="(parrain.password != confirmOldPassword) && (confirmOldPasswordPar.touched)" class="alert alert-danger">
Mot de passe <strong><i>incorrect</i></strong>.
</div>
</div>
<div *ngIf="modifiermdp && (parrain.password === confirmOldPassword)">
<div class="md-form">
<i class="fa fa-envelope prefix grey-text"></i>
<input type="email" id="orangeForm-email" [(ngModel)]="parrain.email" placeholder="{{parrain.email}}" name="email" required pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" #email="ngModel">
<div *ngIf="email.errors && email.errors.pattern && (email.dirty || email.touched)" class="alert alert-danger">
Email is required and format should be <strong><i>john@parrain.fr</i></strong>.
</div>
</div>
<div class="md-form">
<i class="fa fa-lock prefix grey-text"></i>
<input id="orangeForm-pass" type="password" [(ngModel)]="newPassword" placeholder="Nouveau mot de passe" name="password" #password= "ngModel" required minlength="5">
<div *ngIf="password.errors && (password.dirty || password.touched)" class="alert alert-danger">
Le<strong> mot de passe</strong> doit avoir au moins 5 caractéres
</div>
</div>
<div class="md-form">
<i class="fa fa-lock prefix grey-text"></i>
<input id="orangeForm-passC" type="password" [(ngModel)]="ConfirmPassword" placeholder="Confirmer le nouveau mot de passe" name="confirmPassword" #confirmPassword="ngModel">
<div *ngIf="(parrain.password != ConfirmPassword) && (confirmPassword.touched)" class="alert alert-danger">
Tapez le méme <strong><i>mot de passe</i></strong>.
</div>
</div>
</div>
</div>
<div class="md-form">
<i class="fa fa-user prefix grey-text"></i>
<input type="text" id="orangeForm-Familyname" [(ngModel)]="parrain.familyname" placeholder="{{parrain.firstname}}">
</div>
<div class="md-form">
<i class="fa fa-user prefix grey-text"></i>
<input type="text" id="orangeForm-Familyname" [(ngModel)]="parrain.firstname" placeholder="{{parrain.firstname}}">
</div>
<form class="form-inline">
<div class="md-form">
<i class="fa fa-venus-mars prefix grey-text"></i>
<input name="group3" type="radio" class="with-gap" id="homme" value="Homme" [(ngModel)]="parrain.sex">
<label for="homme">Homme</label>
</div>
<div class="md-form">
<input name="group3" type="radio" class="with-gap" id="femme" value="Femme" [(ngModel)]="parrain.sex">
<label for="femme">Femme</label>
</div>
</form>
<div class="md-form">
<i class="fa fa-birthday-cake prefix grey-text"></i>
<input type="date" id="orangeForm-Birthday" [(ngModel)]="parrain.birthday" placeholder="Birthday">
</div>
<div class="md-form">
<i class="fa fa-user prefix grey-text"></i>
<input type="text" id="orangeForm-Familyname" [(ngModel)]="parrain.telephone" placeholder="{{parrain.telephone}}">
</div>
<button class="btn btn-green btn-rounded waves-light" [disabled]="(newPassword != '') && (newPassword != ConfirmPassword)" (click)="modifyProfile()">Modifier Profil</button>
</div>
<div *ngIf="(user | async)?.displayName === 'Commercant'" >
<button class="btn btn-deep-orange" (click)="modifyPasswordSection()">Modifier Email/Mot de passe</button>
<div class="card" *ngIf="modifiermdp">
<div class="md-form">
<i class="fa fa-lock prefix grey-text"></i>
<input id="orangeForm-passC" type="password" [(ngModel)]="confirmOldPassword" placeholder="Tapez votre ancien mot de passe" name="confirmOldPasswordPar" #confirmOldPasswordCommer="ngModel">
<div *ngIf="(commercant.password != confirmOldPassword) && (confirmOldPasswordCommer.touched)" class="alert alert-danger">
Mot de passe <strong><i>incorrect</i></strong>.
</div>
</div>
<div *ngIf="modifiermdp && (commercant.password === confirmOldPassword)">
<div class="md-form">
<i class="fa fa-envelope prefix grey-text"></i>
<input type="email" id="orangeForm-email" [(ngModel)]="commercant.email" placeholder="{{commercant.email}}" name="email" required pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" #email="ngModel">
<div *ngIf="email.errors && email.errors.pattern && (email.dirty || email.touched)" class="alert alert-danger">
Email is required and format should be <strong><i>john@parrain.fr</i></strong>.
</div>
</div>
<div class="md-form">
<i class="fa fa-lock prefix grey-text"></i>
<input id="orangeForm-pass" type="password" [(ngModel)]="newPassword" placeholder="Nouveau mot de passe" name="password" #password= "ngModel" required minlength="5">
<div *ngIf="password.errors && (password.dirty || password.touched)" class="alert alert-danger">
Le<strong> mot de passe</strong> doit avoir au moins 5 caractéres
</div>
</div>
<div class="md-form">
<i class="fa fa-lock prefix grey-text"></i>
<input id="orangeForm-passC" type="password" [(ngModel)]="ConfirmPassword" placeholder="Confirmer le nouveau mot de passe" name="confirmPassword" #confirmPassword="ngModel">
<div *ngIf="(parrain.password != ConfirmPassword) && (confirmPassword.touched)" class="alert alert-danger">
Tapez le méme <strong><i>mot de passe</i></strong>.
</div>
</div>
</div>
</div>
<div class="md-form">
<i class="fa fa-user prefix grey-text"></i>
<input type="text" id="orangeForm-Firstname" [(ngModel)]="commercant.commercialName" placeholder="{{commercant.commercialName}}">
</div>
<div class="md-form">
<i class="fa fa-institution prefix grey-text"></i>
<input type="text" id="orangeForm-Familyname" [(ngModel)]="commercant.raisonSociale" placeholder="{{commercant.raisonSociale}}">
</div>
<div class="md-form">
<i class="fa fa-info prefix grey-text"></i>
<input type="text" id="orangeForm-Familyname" [(ngModel)]="commercant.siret" placeholder="{{commercant.siret}}">
</div>
<button class="btn btn-green btn-rounded waves-light" [disabled]="(newPassword != '') && (newPassword != ConfirmPassword)" (click)="modifyProfile()">Modifier Profil</button>
</div>
<button class="btn btn-default btn-rounded waves-light" (click)="goToProfil()">Retour</button>
</div>
</div>
<!--/.Card-->
</div>
<!--Grid column-->
<!--Grid row-->
</div>

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { EditProfilComponent } from './edit-profil.component';
describe('EditProfilComponent', () => {
let component: EditProfilComponent;
let fixture: ComponentFixture<EditProfilComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditProfilComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(EditProfilComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,117 @@
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Router } from '@angular/router';
import { AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';
import * as firebase from 'firebase/app';
import { AngularFireAuth } from 'angularfire2/auth';
import { AuthService } from '../../../services/auth/auth.service';
import { User } from '../../../../models/User';
import { Parrain } from '../../../../models/Parrain';
import { Commercant } from '../../../../models/Commercant';
import { Image } from '../../../../models/Image';
@Component({
selector: 'app-edit-profil',
templateUrl: './edit-profil.component.html',
styleUrls: ['./edit-profil.component.scss'],
providers: [AuthService]
})
export class EditProfilComponent implements OnInit {
user: Observable<firebase.User>;
localUser: any;
parrain: Parrain;
commercant: Commercant;
profileData: FirebaseListObservable<any[]>;
imageProfil: string;
modifiermdp: boolean;
confirmOldPassword: string;
newPassword: string;
ConfirmPassword: string;
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private authService: AuthService ) {
this.localUser = new User();
this.parrain = new Parrain();
this.commercant = new Commercant();
this.modifiermdp = false;
this.confirmOldPassword = '';
this.newPassword = '';
this.ConfirmPassword = '';
this.imageProfil = 'https://ssl.prcdn.com/uk/people/default-profile.png?1406639312';
this.user = afAuth.authState;
this.user.subscribe(
(auth) => {
console.log(auth.displayName);
if (auth) {
this.profileData = this.afDb.list('/' + auth.displayName + '/', {
query: {
orderByChild: 'uid',
equalTo: auth.uid.toString()
}
}
);
this.profileData.forEach(utilisateur => {
utilisateur.forEach(element => {
console.log('blabla : ' + auth.displayName);
if (auth.displayName === 'Parrain') {
this.localUser = new Parrain();
this.localUser = element;
this.parrain = element;
this.imageProfil = this.parrain.image.downloadURL;
} else if (auth.displayName === 'Commercant') {
this.localUser = new Commercant();
this.localUser = element;
this.commercant = element;
this.imageProfil = this.commercant.image.downloadURL;
}
});
});
}
}
);
}
modifyPasswordSection() {
if (this.modifiermdp === false) {
this.modifiermdp = true;
} else if (this.modifiermdp === true) {
this.modifiermdp = false;
this.confirmOldPassword = '';
this.newPassword = '';
this.ConfirmPassword = '';
}
}
modifyProfile() {
if (this.newPassword === '') {
if (this.localUser.status === 'Parrain') {
this.authService.modifyProfile(this.localUser, this.parrain);
} else if (this.localUser.status === 'Commercant') {
this.authService.modifyProfile(this.localUser, this.commercant);
}
console.log('erreur mot de passe pas changer');
} else {
if (this.localUser.status === 'Parrain') {
this.parrain.password = this.newPassword;
this.authService.modifyProfile(this.localUser, this.parrain);
} else if (this.localUser.status === 'Commercant') {
this.commercant.password = this.newPassword;
this.authService.modifyProfile(this.localUser, this.commercant);
}
}
}
goToProfil() {
this.router.navigate(['/profil']);
}
ngOnInit() {
}
}

@ -74,6 +74,7 @@
<!--<p><i class="fa fa-quote-left"></i> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eos, adipisci</p>-->
<button class="btn btn-primary btn-rounded waves-light" (click)="goToOpCom()">Opération Commerciales</button>
</div>
<button class="btn btn-orange btn-rounded waves-light" (click)="goToEditProfile()">Editer profile</button>
<button class="btn btn-default btn-rounded waves-light" (click)="logout()"> <!--*ngIf="(user | async)?.uid"-->Logout</button>
</div>

@ -84,6 +84,9 @@ export class ProfilComponent implements OnInit, OnDestroy {
goToCarte(){
this.router.navigate(['/carteParrainageComponent']);
}
goToEditProfile() {
this.router.navigate(['/editProfil']);
}
ngOnInit() {

@ -133,21 +133,38 @@ export class AuthService {
console.log('delete');
/*
let storagePath = image.path;
let referencePath = `${this.folder}/images/` + image.key;
let storagePath = image.path;
let referencePath = `${this.folder}/images/` + image.key;
// Do these as two separate steps so you can still try delete ref if file no longer exists
// Do these as two separate steps so you can still try delete ref if file no longer exists
// Delete from Storage
firebase.storage().ref().child(storagePath).delete()
.then(
() => {},
(error) => console.error('Error deleting stored file', storagePath)
);
// Delete from Storage
firebase.storage().ref().child(storagePath).delete()
.then(
() => {},
(error) => console.error('Error deleting stored file', storagePath)
);
// Delete references
this.afDb.object(referencePath).remove();
*/
}
modifyProfile(user: User, infoUser: any) {
if (infoUser.status === 'Parrain') {
const userRef = this.databaseRef.child('Parrain').child(user.uid);
// var parrainInfo = infoUser;
infoUser.uid = user.uid;
userRef.update(infoUser);
// this.upload(infoUser);
}else if (infoUser.status === 'Commercant') {
const userReff = this.databaseRef.child('Commercant').child(user.uid);
// var commercantInfo = infoUser;
infoUser.uid = user.uid;
userReff.update(infoUser);
// this.upload(infoUser);
}
// Delete references
this.afDb.object(referencePath).remove();
*/
}
}

Loading…
Cancel
Save