correction bug envoyer carte et validation date file register creation opcom

thierry
Tmadkaud 7 years ago
parent 4fb99acc1d
commit f4040c6ef7

@ -22,12 +22,9 @@
</div>
</div>
<div class="md-form">
<i class="fa fa-file-picture-o prefix grey-text"></i>
<input type="file" id="orangeForm-File" name="file" style="padding-top: 1%;">
<input type="file" id="orangeForm-File" accept="image/jpeg, image/png" (click)="fileOKOpCom()" name="file" style="padding-top: 1%;">
</div>
<div class="md-form">
<div class="nav-item dropdown" dropdown>
@ -60,7 +57,7 @@
</div>
<div class="text-center" style="margin-top:5%">
<button class="btn btn-light-green waves-light" [disabled]="(opComm.name === '') || (opComm.avantageParrain === '') || (opComm.avantageFilleul === '')" (click)="creerOpComm()">Creer opération</button>
<button class="btn btn-light-green waves-light" [disabled]="!dateDeb.touched || (dateDeb.touched && validationDateDebut()) || !dateFin.touched || (dateFin.touched && validationDateFin()) || fileOpCom || (opComm.name === '') || (opComm.avantageParrain === '') || (opComm.avantageFilleul === '')" (click)="creerOpComm()">Creer opération</button>
<button class="btn btn-cyan" (click)="goToOpComm()">Retour</button>
</div>
</div>

@ -45,12 +45,21 @@ export class CreationOpComComponent implements OnInit, OnDestroy {
todayDateTimeTest: Date;
devise: string;
devise2: string;
fileOpCom: boolean;
dateDebutVal: boolean;
dateFinVal: boolean;
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private authService: AuthService, private opComService: OpCommercialService, private toastrService: ToastrService) {
private router: Router, private authService: AuthService,
private opComService: OpCommercialService, private toastrService: ToastrService) {
this.dateFinVal = false;
this.dateDebutVal = false;
this.opComm = new OperationCommerciale();
this.devise = 'euro';
this.devise2 = 'euro';
this.fileOpCom = true;
console.log(this.fileOpCom);
this.user = afAuth.authState;
this.minDateTimeTest = new Date('1917-01-01');
this.maxDateTimeTest = new Date('2117-01-01');
@ -59,7 +68,9 @@ export class CreationOpComComponent implements OnInit, OnDestroy {
this.todayDateTimeTest = new Date(Date.now());
}
fileOKOpCom(){
this.fileOpCom = false;
}
creerOpComm() {
this.user.subscribe(
@ -99,9 +110,12 @@ export class CreationOpComComponent implements OnInit, OnDestroy {
this.debutDateTimeTest = new Date(this.opComm.dateDebut);
this.finDateTimeTest = new Date(this.opComm.dateFin);
this.todayDateTimeTest = new Date(Date.now());
//console.log(this.dateDebutVal);
this.todayDateTimeTest = new Date(this.todayDateTimeTest.getTime() - 100000000);
if (this.debutDateTimeTest.getTime() <= (this.todayDateTimeTest.getTime())
|| this.debutDateTimeTest.getTime() >= this.maxDateTimeTest.getTime()) {
this.dateDebutVal = true;
return true;
} else {
return false;
@ -114,9 +128,10 @@ export class CreationOpComComponent implements OnInit, OnDestroy {
this.debutDateTimeTest = new Date(this.opComm.dateDebut);
this.finDateTimeTest = new Date(this.opComm.dateFin);
this.todayDateTimeTest = new Date(Date.now());
if (this.finDateTimeTest.getTime() <= this.debutDateTimeTest.getTime()
//console.log(this.dateFinVal);
if (this.finDateTimeTest.getTime() < this.debutDateTimeTest.getTime()
|| this.finDateTimeTest.getTime() >= this.maxDateTimeTest.getTime()) {
this.dateFinVal = true;
return true;
} else {
return false;

@ -74,6 +74,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
filteredCartePars: any;
filters = {};
secondaryApp: any;
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private route: ActivatedRoute,
private authService: AuthService, private opComService: OpCommercialService, private toastrService: ToastrService) {
@ -95,6 +96,14 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
this.parrainDateTimeTest = new Date(this.parrain.birthday);
this.yearTest = this.parrain.birthday.getFullYear();
this.databaseRef = firebase.database().ref();
const config = {apiKey: 'AIzaSyD2O5MxwZ4BRWvVc77FZliBvtj0pmcdzos',
authDomain: 'webappparrain.firebaseapp.com',
databaseURL: 'https://webappparrain.firebaseio.com'};
this.secondaryApp = null;
this.secondaryApp = firebase.apps.length <= 1 ? firebase.initializeApp(config, 'Secondary') : firebase.app('Secondary');
this.user.subscribe(
(auth) => {
if (auth) {
@ -224,10 +233,12 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
regiPar(){
const config = {apiKey: 'AIzaSyD2O5MxwZ4BRWvVc77FZliBvtj0pmcdzos',
/*const config = {apiKey: 'AIzaSyD2O5MxwZ4BRWvVc77FZliBvtj0pmcdzos',
authDomain: 'webappparrain.firebaseapp.com',
databaseURL: 'https://webappparrain.firebaseio.com'};
const secondaryApp = firebase.initializeApp(config, 'Secondary');
let secondaryApp = null;
secondaryApp = firebase.initializeApp(config, 'Secondary');*/
let parrainTemp = new Parrain();
this.carteEnvoieOK = false;
this.parrain.status = 'Parrain';
@ -236,7 +247,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
this.parrain.password = this.getRandomArbitrary(111111, 999999).toString();
// this.authService.signUp(this.parrain);
parrainTemp = this.parrain;
secondaryApp.auth().createUserWithEmailAndPassword(parrainTemp.email, parrainTemp.password).then(function(userCreate) {
this.secondaryApp.auth().createUserWithEmailAndPassword(parrainTemp.email, parrainTemp.password).then(function(userCreate) {
console.log('User ' + userCreate.uid + ' created successfully!');
// I don't know if the next statement is necessary
const imagePath = 'profilImage/' + userCreate.uid + '/userPic.jpg';
@ -256,11 +267,11 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
secondaryApp.auth().sendPasswordResetEmail(userCreate.email);
this.secondaryApp.auth().sendPasswordResetEmail(userCreate.email);
userCreate.sendEmailVerification();
console.log('avant logout firebase.auth().currentUser.uid: ');
secondaryApp.auth().signOut();
this.secondaryApp.auth().signOut();
console.log('avant logout firebase.auth().currentUser.uid: ');
} catch (e) {
@ -271,7 +282,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
// this.router.navigate(['/']);
}
//fin
// secondaryApp.auth().signOut();
// this.secondaryApp.auth().signOut();
});
@ -532,9 +543,10 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
const offsets = document.getElementById('subCard1').getBoundingClientRect();
const imgTop = offsets.top;
const imgLeft = offsets.left;
//canvas.width = document.getElementById('subCard1').offsetWidth;
//canvas.height = document.getElementById('subCard1').offsetHeight;
img.onload = function () {
context.drawImage(img, imgLeft, imgTop);
context.drawImage(img, imgLeft, imgTop, 1920, 1200);
};
img.crossOrigin = 'Anonymous';
canvas.crossOrigin = 'Anonymous';
@ -568,6 +580,72 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
});
}
sectionToImage2(maCarteP: CarteParrainage) {
html2canvas(document.getElementById('subCard1'), {
// allowTaint: true,
useCORS: true,
logging: true,
width: 750,
height: 1050,
onrendered: function (canvas) {
const context = canvas.getContext('2d');
context.scale(2, 2);
const img = new Image();
const offsets = document.getElementById('subCard1').getBoundingClientRect();
const imgTop = offsets.top;
const imgLeft = offsets.left;
const w = offsets.width;
const h = offsets.height;
// var w = 1000;
// var h = 1000;
//canvas.width = w * 2;
//canvas.height = h * 2;
// canvas.style.width = offsets.width + 'px';
// canvas.style.height = offsets.height + 'px';
img.onload = function () {
context.drawImage(img, imgLeft, imgTop);
};
img.crossOrigin = 'Anonymous';
canvas.crossOrigin = 'Anonymous';
canvas.id = 'canvas';
var imgg = canvas.toDataURLHD('image/png', 1);
window.open(imgg);
document.body.appendChild(canvas);
console.log('avant blob');
/*canvas.toBlob(blob => {
const nouvelleImg = new Image();
const storageRef = firebase.storage().ref();
nouvelleImg.setAttribute('crossOrigin', 'anonymous');
nouvelleImg.src = blob;
console.log('blob : ' + blob);
console.log('maCarteP.uid: ' + maCarteP.uid);
storageRef.child('CarteParrainage/' + maCarteP.uid + '/carteTemplate.jpg').put(blob).then((snapshot) => {
const updates = {};
maCarteP.carteTemplate.path = 'CarteParrainage/' + maCarteP.uid + '/carteTemplate.jpg';
maCarteP.carteTemplate.filename = maCarteP.name;
maCarteP.carteTemplate.downloadURL = snapshot.downloadURL;
console.log('maCarteP.carteTemplate.filename : ' + maCarteP.carteTemplate.filename);
console.log('maCarteP.uid: ' + maCarteP.uid);
updates['CarteParrainage/' + maCarteP.uid] = maCarteP;
console.log('updates[\'CarteParrainage/\' + maCarteP.uid].name ' + updates['CarteParrainage/' + maCarteP.uid].name);
firebase.database().ref().update(updates);
console.log('fin du blob');
});
}, 'image/jpeg', 20);*/
}
});
}
goToOpComm() {
this.router.navigate(['/opCommercial']);
}

@ -28,7 +28,7 @@
</div>
<div class="md-form">
<i class="fa fa-file-picture-o prefix grey-text"></i>
<input type="file" id="orangeForm-File" name="file" style="padding-top: 1%;">
<input type="file" id="orangeForm-File" accept="image/jpeg, image/png" name="file" (click)="fileOKPar()" style="padding-top: 1%;">
</div>
<form class="form-inline">
<div class="md-form" style="padding-left: 2%;">
@ -90,7 +90,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 || (parrain.password != ConfirmPasswordParrain) || parrain.familyname == '' || parrain.firstname == '' || parrain.sex == '' || test" (click)="register()">S'inscrire</button>
<button class="btn btn-deep-orange" [disabled]="filePar || !birthday.touched || (birthday.touched && validationBirthdayParrain()) || 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>{{parrain.email}}</i></strong> !
@ -113,7 +113,7 @@
</div>
<div class="md-form">
<i class="fa fa-file-picture-o prefix grey-text"></i>
<input type="file" id="orangeForm-File" name="file" style="padding-top: 1%;">
<input type="file" id="orangeForm-File" accept="image/jpeg, image/png" (click)="fileOKCom()" required style="padding-top: 1%;">
</div>
<div class="md-form">
<i class="fa fa-info prefix grey-text"></i>
@ -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]="fileCom || 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> !

@ -24,8 +24,13 @@ export class RegisterComponent implements OnInit, OnDestroy {
minDateTimeTest: Date;
maxDateTimeTest: Date;
parrainDateTimeTest: Date;
fileCom: boolean;
filePar: boolean;
constructor(private router: Router, private authService: AuthService) {
// this.fileTest = new File();
this.fileCom = true;
this.filePar = true;
this.currentUser = new User();
this.parrain = new Parrain();
this.commercant = new Commercant();
@ -35,6 +40,15 @@ export class RegisterComponent implements OnInit, OnDestroy {
this.parrainDateTimeTest = new Date(this.parrain.birthday);
}
fileOKCom(){
this.fileCom = false;
}
fileOKPar(){
this.filePar = false;
}
keyDownFunctionParrain(event) {
console.log('you just clicked parrain');
console.log((<HTMLInputElement>document.getElementById('orangeForm-File')).value === '');
@ -76,7 +90,7 @@ export class RegisterComponent implements OnInit, OnDestroy {
this.test = true;
}else if (this.currentUser.status === 'Commercant') {
this.commercant.status = this.currentUser.status;
this.commercant.dateInscription = new Date (Date.now());
this.commercant.dateInscription = new Date();
this.authService.signUp(this.commercant);
/*if ((<HTMLInputElement>document.getElementById('orangeForm-File')).value !== '') {
this.clean();

Loading…
Cancel
Save