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

thierry
Viiciouss 7 years ago
commit 47945e77de

@ -14,7 +14,7 @@
<div class="card-block row no-margin">
<div class="col-md-8" id="subCard2Part1">
<div id="opTitle">
<label>Operation Commerciale: {{crt.operationCommercialID}}</label>
<label>Operation Commerciale: {{crt.operationCommercialCarte.name}}</label>
<label>Nom: {{crt.parrainCarte.familyname}}</label>
<label>Prénom: {{crt.parrainCarte.firstname}}</label>
<label>ID: {{crt.uid}}</label>

@ -10,7 +10,7 @@ import { AngularFireAuth } from 'angularfire2/auth';
import { AuthService } from '../../../services/auth/auth.service';
import { OpCommercialService } from '../../../services/opCommercial/op-commercial.service';
import { Commercant } from '../../../../models/Commercant';
import {CarteParrainage} from "../../../../models/CarteParrainage";
import {CarteParrainage} from '../../../../models/CarteParrainage';
@Component({
selector: 'app-carte-envoyer',

@ -59,6 +59,7 @@ export class LoginComponent implements OnInit, OnDestroy {
ngOnInit() {
// firebase.auth().signOut();
/*try {
this.user.subscribe(
(auth) => {

@ -198,7 +198,7 @@ export class DebiterCarteComponent implements OnInit, OnDestroy {
name: '',
parrainCarte: new Parrain(),
commercantCarte: new Commercant(),
operationCommercialID: '',
operationCommercialCarte: new OperationCommerciale(),
dateDebut: new Date(),
dateFin: new Date(),
avantageCumule: '',

@ -115,7 +115,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
this.cartePar.name = this.opComm.name;
this.cartePar.commercantCarte = this.opComm.commercantOpCom;
this.cartePar.operationCommercialID = this.opComm.uid;
this.cartePar.operationCommercialCarte = this.opComm;
this.cartePar.dateDebut = this.opComm.dateDebut;
this.cartePar.dateFin = this.opComm.dateFin;
@ -148,7 +148,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
// si parrain affilié
this.carteParList = this.afDb.list('/CarteParrainage/', {
query: {
orderByChild: 'operationCommercialID',
orderByChild: 'operationCommercialCarte/uid',
equalTo: params['idOp']
}
}
@ -319,7 +319,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
// console.log('this.birthday parrain : ' + this.parrain.birthday);
console.log('this.cartePar.commercantCarte.uid : ' + this.cartePar.commercantCarte.uid);
console.log('this.cartePar..parrainCarte.uid : ' + this.cartePar.parrainCarte.uid);
console.log('this.cartePar.operationCommercialID : ' + this.cartePar.operationCommercialID);
console.log('this.cartePar.operationCommercial.uid : ' + this.cartePar.operationCommercialCarte.uid);
console.log('this.cartePar.dateDebut : ' + this.cartePar.dateDebut);
console.log('this.cartePar.dateFin : ' + this.cartePar.dateFin);
}
@ -413,7 +413,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
name: '',
parrainCarte: new Parrain(),
commercantCarte: new Commercant(),
operationCommercialID: '',
operationCommercialCarte: new OperationCommerciale(),
dateDebut: new Date(),
dateFin: new Date(),
avantageCumule: '',

@ -17,16 +17,16 @@
<button class="btn btn-primary btn-rounded waves-light" id="nouvelleOp" (click)="goToCreaOpCom()">Nouvelle opération commerciale</button>
<!--<button class="btn btn-primary btn-rounded waves-light" (click)="goToCarteEnvoyer()">Historique carte envoyer</button>-->
<!--<button class="btn btn-default btn-rounded waves-light" (click)="goToProfil()">Profil</button>-->
<div *ngIf="(opCommData | async)?.length == 0" class="alert alert-danger">
Cher,<strong><i> {{commercant.commercialName}} </i></strong>
<p>Le principe est simple :</p>
<ul>
<li>- Crées tes opérations commerciales ici</li>
<li>- Envoie-les à tes client, ils deviendront tes parrains affiliés</li>
<li>- Gagne des clients à chaque fois qu'un de tes parrains envoie sa carte à ses amis</li>
</ul>
<p>N'attends plus, crées tes opérations commerciale et envoie les aux futurs parrains affiliés de ton choix !</p>
</div>
</div>
<div *ngIf="(opCommData | async)?.length == 0" class="alert alert-danger">
Cher,<strong><i> {{commercant.commercialName}} </i></strong>
<p>Le principe est simple :</p>
<ul>
<li>- Crées tes opérations commerciales ici</li>
<li>- Envoie-les à tes clients, ils deviendront tes parrains affiliés</li>
<li>- Gagne des clients à chaque fois qu'un de tes parrains envoie sa carte à ses amis</li>
</ul>
<p>N'attends plus, crées tes opérations commerciale et envoie les aux futurs parrains affiliés de ton choix !</p>
</div>
<div class="list-group wow fadeInUpBig">

@ -303,7 +303,7 @@ export class ScannerCarteComponent implements OnInit, OnDestroy {
name: '',
parrainCarte: new Parrain(),
commercantCarte: new Commercant(),
operationCommercialID: '',
operationCommercialCarte: new OperationCommerciale(),
dateDebut: new Date(),
dateFin: new Date(),
avantageCumule: '',

@ -50,7 +50,7 @@
</div>-->
<div class="btn-block">
<button class="btn btn-orange btn-rounded waves-light" (click)="goToEditProfile()">Editer profile</button>
<button class="btn btn-orange btn-rounded waves-light" (click)="goToEditProfile()">Editer profil</button>
<button class="btn btn-default btn-rounded waves-light" (click)="goToCarte()">Retour</button>
</div>

@ -90,10 +90,10 @@
données, y compris notre Utilisation des cookies.
</label>
<div class="text-center" style="margin-top:5%">
<button class="btn btn-deep-orange" [disabled]="email.errors || password.errors || (parrain.password != ConfirmPasswordParrain) || parrain.familyname == '' || parrain.firstname == '' || parrain.sex == '' || !test" (click)="register()">S'inscrire</button>
<button class="btn btn-deep-orange" [disabled]="email.errors || password.errors || (parrain.password != ConfirmPasswordParrain) || parrain.familyname == '' || parrain.firstname == '' || parrain.sex == '' || test" (click)="register()">S'inscrire</button>
<!--<button class="btn btn-cyan" (click)="loadHomeComponent()">Back</button>-->
<div *ngIf="test" class="alert alert-danger">
<strong><i>{{parrain.familyname}} {{parrain.firstname}}, </i></strong> votre compte à bien été créé, un email de validation vient de vous être envoyé à l'adresse <strong><i>{{commercant.email}}</i></strong> !
<strong><i>{{parrain.familyname}} {{parrain.firstname}}, </i></strong> votre compte à bien été créé, un email de validation vient de vous être envoyé à l'adresse <strong><i>{{parrain.email}}</i></strong> !
</div>
</div>
</form>
@ -117,7 +117,7 @@
</div>
<div class="md-form">
<i class="fa fa-info prefix grey-text"></i>
<input type="number" id="orangeForm-Username" [(ngModel)]="commercant.siret" placeholder="Siret" required pattern=".{14,}" minlength="14" name="siret" #siret="ngModel">
<input type="number" id="orangeForm-Username" [(ngModel)]="commercant.siret" placeholder="Siret" required pattern=".{13,}" minlength="14" name="siret" #siret="ngModel">
<div *ngIf="siret.errors && siret.errors.pattern && (siret.dirty || siret.touched)" class="alert alert-danger">
Votre <strong>siret</strong> doit avoir 14 chiffres au minimum.
</div>
@ -154,7 +154,7 @@
données, y compris notre Utilisation des cookies.
</label>
<div class="text-center" style="margin-top:5%">
<button class="btn btn-deep-orange" [disabled]="email.errors || password.errors || siret.errors || commercant.raisonSociale == '' || commercant.commercialName == '' || (commercant.password != ConfirmPasswordCommercant) || !test" (click)="register()">S'inscrire</button>
<button class="btn btn-deep-orange" [disabled]="email.errors || password.errors || siret.errors || commercant.raisonSociale == '' || commercant.commercialName == '' || (commercant.password != ConfirmPasswordCommercant) || test" (click)="register()">S'inscrire</button>
<!--<button class="btn btn-cyan" (click)="loadHomeComponent()">Back</button>-->
<div *ngIf="test" class="alert alert-danger">
<strong><i>{{commercant.commercialName}}, </i></strong> votre compte à bien été créé, un email de validation vient de vous être envoyé à l'adresse <strong><i>{{commercant.email}}</i></strong> !

@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from '../../services/auth/auth.service';
import * as firebase from 'firebase/app';
import { User } from '../../../models/User';
import { Parrain } from '../../../models/Parrain';
import { Commercant } from '../../../models/Commercant';
@ -70,17 +70,17 @@ export class RegisterComponent implements OnInit, OnDestroy {
this.parrain.status = this.currentUser.status;
this.parrain.secretCode = this.getRandomArbitrary(1111, 9999).toString();
this.authService.signUp(this.parrain);
if ((<HTMLInputElement>document.getElementById('orangeForm-File')).value !== '') {
/*if ((<HTMLInputElement>document.getElementById('orangeForm-File')).value !== '') {
this.clean();
}
}*/
this.test = true;
}else if (this.currentUser.status === 'Commercant') {
this.commercant.status = this.currentUser.status;
this.commercant.dateInscription = new Date (Date.now());
this.authService.signUp(this.commercant);
if ((<HTMLInputElement>document.getElementById('orangeForm-File')).value !== '') {
/*if ((<HTMLInputElement>document.getElementById('orangeForm-File')).value !== '') {
this.clean();
}
}*/
this.test = true;
}
}
@ -157,6 +157,7 @@ export class RegisterComponent implements OnInit, OnDestroy {
}
ngOnDestroy() {
this.test = false;
this.ConfirmPasswordParrain = '';
this.ConfirmPasswordCommercant = '';
this.currentUser = {

@ -30,16 +30,26 @@ export class AuthService {
userModel: User;
parrain: Parrain;
commercant: Commercant;
utilisateur: any;
test: string;
uti: firebase.User;
profileData: FirebaseListObservable<any[]>;
profileDataParrain: FirebaseListObservable<any[]>;
profileDataCommercant: FirebaseListObservable<any[]>;
boolUpdate: boolean;
boolSetData: boolean;
authState: firebase.User;
@Input() folder: string;
//fileList: FirebaseListObservable<Image[]>;
constructor(private http: HttpModule, private afAuth: AngularFireAuth, private afDb: AngularFireDatabase, private router: Router) {
this.parrain = new Parrain();
this.commercant = new Commercant();
afAuth.authState.subscribe(
(auth) => {
this.authState = auth;
@ -51,23 +61,23 @@ export class AuthService {
get authenticated(): boolean {
return this.authState !== null;
}
saveInfo(user: firebase.User, infoUser: any) {
saveInfo(user: firebase.User, infoUser: any): boolean {
if (infoUser.status === 'Parrain') {
const userRef = this.databaseRef.child('Parrain').child(user.uid);
const userRef = this.databaseRef.child('Parrain').child(infoUser.uid);
// var parrainInfo = infoUser;
infoUser.uid = user.uid;
// infoUser.uid = user.uid;
userRef.set(infoUser);
this.upload(infoUser);
firebase.auth().signOut();
//this.router.navigate(['/carteParrainageComponent']);
return true;
// this.router.navigate(['/carteParrainageComponent']);
}else if (infoUser.status === 'Commercant') {
const userReff = this.databaseRef.child('Commercant').child(user.uid);
const userReff = this.databaseRef.child('Commercant').child(infoUser.uid);
// var commercantInfo = infoUser;
infoUser.uid = user.uid;
// infoUser.uid = user.uid;
userReff.set(infoUser);
this.upload(infoUser);
firebase.auth().signOut();
//this.router.navigate(['/opCommercial']);
return true;
// this.router.navigate(['/opCommercial']);
}else {
return false;
}
}
@ -75,28 +85,97 @@ export class AuthService {
signIn(email: string, password: string) {
firebase.auth().signInWithEmailAndPassword(email, password).then(user => {
if (user) {
if (/*user.emailVerified*/true){
console.log('salut le ' + user.displayName + ' ' + user.email + ' has signed!');
if (user.displayName === 'Parrain') {
this.router.navigate(['/carteParrainageComponent']);
this.profileDataParrain = this.afDb.list('/Parrain/', {
query: {
orderByChild: 'uid',
equalTo: user.uid.toString()
}
}
);
this.profileDataParrain.subscribe(snapshot => {
if (snapshot.length > 0) {
this.profileDataParrain.forEach(Parrain => {
Parrain.forEach(elementParrain => {
this.parrain = elementParrain;
this.utilisateur = elementParrain;
if (/*user.emailVerified*/true){
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 (this.utilisateur.status === 'Parrain') {
this.router.navigate(['/carteParrainageComponent']);
} else if (this.utilisateur.status === 'Commercant') {
this.router.navigate(['/opCommercial']);
}
}/*else{
console.log('email non verifié!!');
}*/
});
});
}
else if (user.displayName === 'Commercant') {
this.router.navigate(['/opCommercial']);
});
this.profileDataCommercant = this.afDb.list('/Commercant/', {
query: {
orderByChild: 'uid',
equalTo: user.uid.toString()
}
}
else if (user.email === 'xjc@gmail.com') {
this.router.navigate(['/demandeOpCommercialAdmin']);
);
this.profileDataCommercant.subscribe(snapshot => {
if (snapshot.length > 0) {
this.profileDataCommercant.forEach(Commercant => {
Commercant.forEach(elementCommercant => {
this.commercant = elementCommercant;
this.utilisateur = elementCommercant;
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 (this.utilisateur.status === 'Parrain') {
this.router.navigate(['/carteParrainageComponent']);
} else if (this.utilisateur.status === 'Commercant') {
this.router.navigate(['/opCommercial']);
}
}/*else{
console.log('email non verifié!!');
}*/
});
});
}
}/*else{
console.log('email non verifié!!');
}*/
});
if (user.email === 'xjc@gmail.com') {
this.router.navigate(['/demandeOpCommercialAdmin']);
}
/*
let userTest: any;
this.profileData = this.afDb.list('/' + this.utilisateur + '/', {
query: {
orderByChild: 'uid',
equalTo: user.uid.toString()
}
}
);
*/
}else {
console.log('error!!');
}
});
}
setUserInfo(user: firebase.User, infoUser: any) {
/*
setUserInfo(user: firebase.User, infoUser: any): boolean {
const imagePath = 'profilImage/' + user.uid + '/userPic.jpg';
firebase.auth().onAuthStateChanged(function (userUpdate) {
userUpdate.updateProfile({
@ -104,23 +183,35 @@ export class AuthService {
photoURL: imagePath
});
if (userUpdate) {
console.log('userUpdate: ' + userUpdate);
console.log('userUpdateee: ' + userUpdate);
} else {
console.log('pas user');
}
});
this.saveInfo(user, infoUser);
return true;
}
*/
signUp(infoUser: any) {
firebase.auth().createUserWithEmailAndPassword(infoUser.email, infoUser.password).then(userCreate => {
firebase.auth().createUserWithEmailAndPassword(infoUser.email, infoUser.password)
.then(userCreate => {
userCreate.sendEmailVerification().then(res => {
console.log('res : ');
});
this.setUserInfo(userCreate, infoUser);
infoUser.uid = userCreate.uid;
// this.setUserInfo(userCreate, infoUser);
if (this.saveInfo(userCreate, infoUser)) {
if (this.upload(infoUser)) {
console.log('youhoo!!!!');
}else {
console.log('upload failed !!! ');
}
}else {
console.log('save info failed !!! ');
}
});
})
}
@ -129,7 +220,41 @@ export class AuthService {
}
upload(info: any) {
upload(info: any): boolean {
const storageRef = firebase.storage().ref();
let success = false;
this.folder = '/' + info.status + '/' + info.uid + '/image';
for (const selectedFile of [(<HTMLInputElement>document.getElementById('orangeForm-File')).files[0]]) {
console.log(selectedFile);
const folder = this.folder;
const path = `${this.folder}`;
const iRef = storageRef.child(path);
iRef.put(selectedFile).then((snapshot) => {
const updates = {};
info.image.path = path;
info.image.filename = 'Profil picture';
info.image.downloadURL = snapshot.downloadURL;
updates[folder] = info.image;
firebase.database().ref().update(updates);
});
}
firebase.auth().onAuthStateChanged(function (userUpdate) {
userUpdate.updateProfile({
displayName: info.status,
photoURL: info.image.downloadURL
}).then(al => {
console.log('userUpdate.dispppp : ' + al);
// firebase.auth().signOut();
});
});
return true;
}
uploadModify(info: any) {
const storageRef = firebase.storage().ref();
const success = false;
this.folder = '/' + info.status + '/' + info.uid + '/image';
@ -190,13 +315,13 @@ export class AuthService {
// var parrainInfo = infoUser;
infoUser.uid = user.uid;
userRef.update(infoUser);
this.upload(infoUser);
this.uploadModify(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);
this.uploadModify(infoUser);
}
}

@ -9,7 +9,7 @@ export class CarteParrainage
name: string;
parrainCarte: Parrain;
commercantCarte: Commercant;
operationCommercialID: string;
operationCommercialCarte: OperationCommerciale;
dateDebut: Date;
dateFin: Date;
avantageCumule: string;
@ -23,7 +23,7 @@ export class CarteParrainage
this.name = '';
this.parrainCarte = new Parrain();
this.commercantCarte = new Commercant();
this.operationCommercialID = '';
this.operationCommercialCarte = new OperationCommerciale();
this.dateDebut = new Date();
this.dateFin = new Date();
this.avantageCumule = '';

Loading…
Cancel
Save