creation et affichage op comm carte et login regist perfectionner

thierry
Tmadkaud 7 years ago
parent 0b3df7fae3
commit 895ceea448

@ -20,6 +20,9 @@ import { LoginComponent } from './components/login/login.component';
import { RegisterComponent } from './components/register/register.component';
import { NavigationBarComponent } from './components/navigationBar/navigationBar.component';
import { ProfilComponent } from './components/profil/profil.component';
import { OpCommercialComponent } from './components/opCommercial/op-commercial/op-commercial.component';
import { CreationOpComComponent } from './components/opCommercial/creation-op-com/creation-op-com.component';
import { CarteParrainageComponent } from './components/carteParrainage/carte-parrainage/carte-parrainage.component';
@NgModule({
@ -29,7 +32,10 @@ import { ProfilComponent } from './components/profil/profil.component';
NavigationBarComponent,
LoginComponent,
RegisterComponent,
ProfilComponent
ProfilComponent,
OpCommercialComponent,
CreationOpComComponent,
CarteParrainageComponent
],
imports: [
BrowserModule,

@ -2,10 +2,16 @@ import { LoginComponent } from './components/login/login.component';
import { RegisterComponent } from './components/register/register.component';
import { HomeComponent } from './components/home/home.component';
import { ProfilComponent } from './components/profil/profil.component';
import { OpCommercialComponent } from './components/opCommercial/op-commercial/op-commercial.component';
import { CreationOpComComponent } from './components/opCommercial/creation-op-com/creation-op-com.component';
import { CarteParrainageComponent } from './components/carteParrainage/carte-parrainage/carte-parrainage.component';
export const AppRoutes = [
{path: '', component: HomeComponent},
{path: 'login', component: LoginComponent},
{path: 'register', component: RegisterComponent},
{path: 'profil', component: ProfilComponent}
{path: 'profil', component: ProfilComponent},
{path: 'opCommercial', component: OpCommercialComponent},
{path: 'creationOpCommercial', component: CreationOpComComponent},
{path: 'carteParrainageComponent', component: CarteParrainageComponent},
];

@ -0,0 +1,6 @@
<div class="card">
<div class="well">
<p class="h5 text-center mb-4">Liste de vos cartes de parrainage</p>
</div>
</div>
<button (click)="goToProfil()">Back</button>

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

@ -0,0 +1,18 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'app-carte-parrainage',
templateUrl: './carte-parrainage.component.html',
styleUrls: ['./carte-parrainage.component.scss']
})
export class CarteParrainageComponent implements OnInit {
constructor(private router: Router) { }
ngOnInit() {
}
goToProfil(){
this.router.navigate(['/profil']);
}
}

@ -11,14 +11,14 @@
<div class="col-md-12 mb-3">
<div class="intro-info-content text-center">
<h1 class="display-3 mb-5 wow fadeInDown" data-wow-delay="0.3s">Parrain <a class="indigo-text font-bold">App</a></h1>
<h5 class="font-up mb-5 mt-1 font-bold wow fadeInDown" data-wow-delay="0.3s">Cum et anno in nono quadriennio imperatoris nono Rufini Massa aetatis.</h5>
<h5 class="font-up mb-5 mt-1 font-bold wow fadeInDown" data-wow-delay="0.3s">La Grosse Remise !</h5>
<button class="btn btn-light-blue btn-lg wow fadeInDown waves-light" data-wow-delay="0.3s" mdbRippleRadius (click)="loadRegisterComponent();">Sign In</button>
<button class="btn btn-light-blue btn-lg wow fadeInDown waves-light" data-wow-delay="0.3s" mdbRippleRadius (click)="loadRegisterComponent();">S'inscrire</button>
<div *ngIf='loadComponentRegister'>
<app-register></app-register>
</div>
<button class="btn btn-indigo btn-lg wow fadeInDown waves-light" data-wow-delay="0.3s" mdbRippleRadius (click)="loadLoginComponent();">Login</button>
<button class="btn btn-indigo btn-lg wow fadeInDown waves-light" data-wow-delay="0.3s" mdbRippleRadius (click)="loadLoginComponent();">Se connecter</button>
<div *ngIf='loadComponentLogin'>
<login></login>
</div>

@ -6,17 +6,22 @@
<div class="md-form">
<i class="fa fa-envelope prefix grey-text"></i>
<input type="email" [(ngModel)]="email" placeholder="Your email">
<input type="email" [(ngModel)]="email" placeholder="Email" name="mail" required pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" #mail="ngModel">
<div *ngIf="mail.errors && mail.errors.pattern && (mail.dirty || mail.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 type="password" [(ngModel)]="password" placeholder="Password">
<input type="password" [(ngModel)]="password" placeholder="Password" name="pass" #pass= "ngModel" required minlength="5">
<div *ngIf="pass.errors && (pass.dirty || pass.touched)" class="alert alert-danger">
<strong>Password</strong> must have more than 5 caracteres
</div>
</div>
<div class="text-center" style="margin-top:5%">
<button class="btn btn-dark-green" (click)="login()">Login <i class="fa fa-paper-plane-o ml-1"></i></button>
<button class="btn btn-dark-green" [disabled]="mail.errors || pass.errors" (click)="login()">Login <i class="fa fa-paper-plane-o ml-1"></i></button>
<button class="btn btn-cyan" (click)="loadHomeComponent()">Back</button>
</div>
</div>

@ -28,6 +28,7 @@ export class LoginComponent implements OnInit, OnDestroy {
commercant: Commercant;
user: Observable<firebase.User>;
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private authService: AuthService) {
@ -40,10 +41,6 @@ export class LoginComponent implements OnInit, OnDestroy {
this.authService.signIn(this.email, this.password);
}
logout() {
this.authService.logout();
}
loadHomeComponent() {
this.router.navigate(['/']);
}

@ -0,0 +1,34 @@
<div class="card">
<div class="well">
<p class="h5 text-center mb-4">creation-op-com</p>
<div class="md-form">
<i class="fa fa-address-card prefix grey-text"></i>
<input type="text" id="orangeForm-Familyname" [(ngModel)]="opComm.name" placeholder="Name">
</div>
<div class="md-form">
<i class="fa fa-calendar-check-o prefix grey-text"></i>
<input type="date" id="orangeForm-Date" placeholder="Date debut">
</div>
<div class="md-form">
<i class="fa fa-calendar-times-o prefix grey-text"></i>
<input type="date" id="orangeForm-Date" placeholder="Date fin">
</div>
<div class="md-form">
<i class="fa fa-file-picture-o prefix grey-text"></i>
<input type="file" id="orangeForm-File" [(ngModel)]="opComm.carteTemplate" placeholder="Carte vierge">
</div>
<div class="md-form">
<i class="fa fa-euro prefix grey-text"></i>
<input type="text" id="orangeForm-Avantage" [(ngModel)]="opComm.avantageParrain" placeholder="Avantage parrain">
</div>
<div class="md-form">
<i class="fa fa-euro prefix grey-text"></i>
<input type="text" id="orangeForm-Avantage" [(ngModel)]="opComm.avantageFilleul" placeholder="Avantage filleul">
</div>
</div>
</div>
<button (click)="creerOpComm()">Creer opération</button>
<button (click)="goToOpComm()">Back</button>

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

@ -0,0 +1,83 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { OperationCommerciale } from '../../../../models/OperationCommerciale';
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 { OpCommercialService } from '../../../services/opCommercial/op-commercial.service';
@Component({
selector: 'app-creation-op-com',
templateUrl: './creation-op-com.component.html',
styleUrls: ['./creation-op-com.component.scss'],
providers: [AuthService, OpCommercialService]
})
export class CreationOpComComponent implements OnInit, OnDestroy {
opComm: OperationCommerciale;
user: Observable<firebase.User>;
opCommData: FirebaseListObservable<any[]>;
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private authService: AuthService, private opComService: OpCommercialService) {
this.opComm = new OperationCommerciale();
this.user = afAuth.authState;
}
creerOpComm() {
this.user.subscribe(
(auth) => {
if (auth) {
this.opCommData = this.afDb.list('/' + auth.displayName + '/', {
query: {
orderByChild: 'uid',
equalTo: auth.uid.toString()
}
}
);
this.opCommData.forEach(utilisateur => {
utilisateur.forEach(element => {
console.log('element.uid: ' + element.uid);
this.opComm.idCommercant = element.uid;
this.opComm.status = "Non active";
this.opComService.saveOpComm(element, this.opComm);
});
});
}
}
);
}
ngOnInit() {
}
goToOpComm(){
this.router.navigate(['/opCommercial']);
}
ngOnDestroy() {
this.opComm = {
uid : '',
name : '',
idCommercant : '',
dateDebut : new Date(),
dateFin : new Date(),
carteTemplate : '',
avantageParrain : '',
deviseAvantageParrain : '',
tarifXJCParrain : '',
avantageFilleul : '',
deviseAvantageFilleul : '',
tarifXJCFilleul : '',
status : ''
};
}
}

@ -0,0 +1,11 @@
<div class="card">
<div class="well">
<p class="h5 text-center mb-4">Liste de vos operations commercials</p>
</div>
</div>
<ul *ngFor="let op of opCommData | async">
<li>Operation Commerciale: {{op.name}}</li>
</ul>
<button (click)="goToCreaOpCom()">Nouvelle opération Commercial</button>
<button (click)="goToProfil()">Back</button>

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

@ -0,0 +1,61 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { OperationCommerciale } from '../../../../models/OperationCommerciale';
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 { OpCommercialService } from '../../../services/opCommercial/op-commercial.service';
@Component({
selector: 'app-op-commercial',
templateUrl: './op-commercial.component.html',
styleUrls: ['./op-commercial.component.scss'],
providers: [AuthService, OpCommercialService]
})
export class OpCommercialComponent implements OnInit, OnDestroy {
opComm: OperationCommerciale;
user: Observable<firebase.User>;
opCommData: FirebaseListObservable<any[]>;
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private authService: AuthService, private opComService: OpCommercialService) {
this.opComm = new OperationCommerciale();
this.user = afAuth.authState;
this.user.subscribe(
(auth) => {
if (auth) {
this.opCommData = this.afDb.list('/OperationCommercial/', {
query: {
orderByChild: 'idCommercant',
equalTo: auth.uid.toString()
}
}
);
}
}
);
}
goToCreaOpCom(){
this.router.navigate(['/creationOpCommercial']);
}
goToProfil(){
this.router.navigate(['/profil']);
}
ngOnInit() {
}
ngOnDestroy() {}
}

@ -25,10 +25,10 @@
</ul>
</div>
<div *ngFor="let user of profileData | async">
<div *ngFor="let user of opCommData | async">
User is {{user.firstname}}
</div>
<button (click)="goToCarte()">Cartes</button>
</div>
<div *ngIf="(user | async)?.displayName === 'Commercant'" class="alert alert-danger">
@ -48,7 +48,7 @@
<div *ngFor="let user of profileData | async">
User is {{user.commercialName}}
</div>
<button (click)="goToOpCom()">Opération Commerciales</button>
</div>
<button (click)="logout()">Logout</button>
<button>Cartes</button>

@ -41,28 +41,28 @@ export class ProfilComponent implements OnInit, OnDestroy {
this.user.subscribe(
(auth) => {
console.log('bouyaka auth.uid: ' + auth.uid.toString());
this.profileData = this.afDb.list('/' + auth.displayName + '/', {
query: {
orderByChild: 'uid',
equalTo: auth.uid.toString()
}
}
);
this.profileData.forEach(utilisateur => {
utilisateur.forEach( element => {
if (auth.displayName === 'Parrain') {
this.localUser = new Parrain();
this.localUser = element;
this.parrain = element;
}else if (auth.displayName === 'Commercant') {
this.localUser = new Commercant();
this.localUser = element;
this.commercant = element;
if (auth) {
this.profileData = this.afDb.list('/' + auth.displayName + '/', {
query: {
orderByChild: 'uid',
equalTo: auth.uid.toString()
}
}
);
this.profileData.forEach(utilisateur => {
utilisateur.forEach(element => {
if (auth.displayName === 'Parrain') {
this.localUser = new Parrain();
this.localUser = element;
this.parrain = element;
} else if (auth.displayName === 'Commercant') {
this.localUser = new Commercant();
this.localUser = element;
this.commercant = element;
}
});
});
});
}
}
);
}
@ -72,6 +72,13 @@ export class ProfilComponent implements OnInit, OnDestroy {
this.router.navigate(['/']);
}
goToOpCom(){
this.router.navigate(['/opCommercial']);
}
goToCarte(){
this.router.navigate(['/carteParrainageComponent']);
}
ngOnInit() {
}

@ -131,7 +131,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 || (commercant.password != ConfirmPasswordCommercant)" (click)="register()">Sign up</button>
<button class="btn btn-deep-orange" [disabled]="email.errors || password.errors || (commercant.password != ConfirmPasswordCommercant)" (click)="register()">S'inscrire</button>
<button class="btn btn-cyan" (click)="loadHomeComponent()">Back</button>
</div>
</div>

@ -6,6 +6,7 @@ import { AuthService } from '../../services/auth/auth.service';
import { User } from '../../../models/User';
import { Parrain } from '../../../models/Parrain';
import { Commercant } from '../../../models/Commercant';
import {tryCatch} from "rxjs/util/tryCatch";
@Component({
selector: 'app-register',

@ -0,0 +1,15 @@
import { TestBed, inject } from '@angular/core/testing';
import { CarteParrainageService } from './carte-parrainage.service';
describe('CarteParrainageService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [CarteParrainageService]
});
});
it('should ...', inject([CarteParrainageService], (service: CarteParrainageService) => {
expect(service).toBeTruthy();
}));
});

@ -0,0 +1,8 @@
import { Injectable } from '@angular/core';
@Injectable()
export class CarteParrainageService {
constructor() { }
}

@ -0,0 +1,15 @@
import { TestBed, inject } from '@angular/core/testing';
import { OpCommercialService } from './op-commercial.service';
describe('OpCommercialService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [OpCommercialService]
});
});
it('should ...', inject([OpCommercialService], (service: OpCommercialService) => {
expect(service).toBeTruthy();
}));
});

@ -0,0 +1,37 @@
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { HttpModule, Headers } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import * as firebase from 'firebase/app';
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
import { User } from '../../../models/User';
import { Parrain } from '../../../models/Parrain';
import { Commercant } from '../../../models/Commercant';
import { OperationCommerciale } from '../../../models/OperationCommerciale';
@Injectable()
export class OpCommercialService {
databaseRef: any;
changeRequest: any;
userModel: User;
parrain: Parrain;
commercant: Commercant;
test: string;
constructor(private http: HttpModule, public router: Router) {
this.databaseRef = firebase.database().ref();
}
saveOpComm(user: firebase.User, infoOpComm: OperationCommerciale) {
const userRef = this.databaseRef.child('OperationCommercial').child(user.uid);
userRef.set(infoOpComm);
}
}
Loading…
Cancel
Save