|
|
|
@ -1,17 +1,22 @@
|
|
|
|
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
|
|
|
|
import { Component, OnInit, OnDestroy, Input } from '@angular/core';
|
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { Observable } from 'rxjs/Observable';
|
|
|
|
|
|
|
|
|
|
import { OperationCommerciale } from '../../../../models/OperationCommerciale';
|
|
|
|
|
// import { AngularFire, FirebaseListObservable } from 'angularfire2';
|
|
|
|
|
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 { AngularFireAuthModule } from 'angularfire2/auth';
|
|
|
|
|
import { OpCommercialService } from '../../../services/opCommercial/op-commercial.service';
|
|
|
|
|
|
|
|
|
|
import { Image } from '../../../../models/Image';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-creation-op-com',
|
|
|
|
|
templateUrl: './creation-op-com.component.html',
|
|
|
|
@ -19,11 +24,18 @@ import { OpCommercialService } from '../../../services/opCommercial/op-commercia
|
|
|
|
|
providers: [AuthService, OpCommercialService]
|
|
|
|
|
})
|
|
|
|
|
export class CreationOpComComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Input() folder: string;
|
|
|
|
|
fileList: FirebaseListObservable<Image[]>;
|
|
|
|
|
// imageList: Observable<Image[]>;
|
|
|
|
|
|
|
|
|
|
opComm: OperationCommerciale;
|
|
|
|
|
|
|
|
|
|
// selectedFiles: FileList;
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
@ -48,9 +60,11 @@ export class CreationOpComComponent implements OnInit, OnDestroy {
|
|
|
|
|
console.log('element.uid: ' + element.uid);
|
|
|
|
|
this.opComm.idCommercant = element.uid;
|
|
|
|
|
this.opComm.status = "Non active";
|
|
|
|
|
|
|
|
|
|
// let file = this.selectedFiles.item(0);
|
|
|
|
|
// this.opComm.carteTemplate = file;
|
|
|
|
|
// this.upload();
|
|
|
|
|
console.log('element.uid: ' + element.uid);
|
|
|
|
|
this.opComService.saveOpComm(element, this.opComm);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -60,9 +74,36 @@ export class CreationOpComComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
}
|
|
|
|
|
goToOpComm(){
|
|
|
|
|
goToOpComm() {
|
|
|
|
|
this.router.navigate(['/opCommercial']);
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
ngOnChanges() {
|
|
|
|
|
console.log('new values for folder');
|
|
|
|
|
let storage = firebase.storage();
|
|
|
|
|
|
|
|
|
|
this.fileList = this.afDb.list(`/${this.folder}/images`);
|
|
|
|
|
console.log('Rendering all images in ', `/${this.folder}/images`)
|
|
|
|
|
this.imageList = this.fileList.map( itemList =>
|
|
|
|
|
itemList.map( item => {
|
|
|
|
|
var pathReference = storage.ref(item.path);
|
|
|
|
|
let result = {$key: item.$key, downloadURL: pathReference.getDownloadURL(), path: item.path, filename: item.filename};
|
|
|
|
|
console.log(result);
|
|
|
|
|
return result;
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
upload() {
|
|
|
|
|
this.opComService.upload();
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
delete(image: Image){
|
|
|
|
|
this.opComService.delete(image);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
|
this.opComm = {
|
|
|
|
|
uid : '',
|
|
|
|
@ -70,7 +111,7 @@ export class CreationOpComComponent implements OnInit, OnDestroy {
|
|
|
|
|
idCommercant : '',
|
|
|
|
|
dateDebut : new Date(),
|
|
|
|
|
dateFin : new Date(),
|
|
|
|
|
carteTemplate : '',
|
|
|
|
|
carteTemplate : new Image(),
|
|
|
|
|
avantageParrain : '',
|
|
|
|
|
deviseAvantageParrain : '',
|
|
|
|
|
tarifXJCParrain : '',
|
|
|
|
|