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

This commit is contained in:
Viiciouss 2018-06-04 21:07:04 +02:00
commit f0bc36a327
5 changed files with 99 additions and 16 deletions

View File

@ -226,6 +226,15 @@ router.post('/getFolderAppList', function(req, res) {
});
});
/* Get tout les files du user */
router.post('/getFileAppList', function(req, res) {
FileMongo.find({
owner: req.body.owner
}, function(err, file) {
res.json(file);
});
});
/* Get tout les files du mainFolder */
router.post('/getFileList', function(req, res) {
FileMongo.find({
@ -263,7 +272,7 @@ router.post('/signin', function(req, res) {
});
});
//////////
/* Multer upload */
router.post('/upload' , multer({storage: storage, limits: {fileSize: 30000000000}}).array("public[]", 12) ,function(req,res,next){
res.send(req.files);

View File

@ -1,4 +1,4 @@
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { Component, OnInit, OnDestroy, ViewChild, Output, EventEmitter } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Router, ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs/Observable';
@ -10,7 +10,7 @@ import * as formData from 'form-data';
import {forEach} from '@angular/router/src/utils/collection';
import {type} from 'os';
import { DomSanitizer } from '@angular/platform-browser';
//import { Dropzone } from 'dropzone';
// import { Dropzone } from 'dropzone';
import { DropzoneComponent , DropzoneDirective,
DropzoneConfigInterface } from 'ngx-dropzone-wrapper';
@ -22,6 +22,11 @@ import { DropzoneComponent , DropzoneDirective,
styleUrls: ['./book.component.css']
})
export class BookComponent implements OnInit, OnDestroy {
@Output() setAllUserAppFolder = new EventEmitter<String>();
message: string = 'Hola Mundo!';
@Output() messageEvent = new EventEmitter<string>();
currentUser: any;
allUserFile: any;
allUserFolder: any;
@ -63,7 +68,10 @@ export class BookComponent implements OnInit, OnDestroy {
this.filesToUpload = [];
this.test = '';
}
sendMessage() {
console.log('caca');
this.messageEvent.emit('caca')
}
public toggleType(): void {
this.type = (this.type === 'component') ? 'directive' : 'component';
}
@ -204,9 +212,14 @@ export class BookComponent implements OnInit, OnDestroy {
});
}
getAllUserAppFolder(){
this.message = 'caca';
this.sendMessage();
this.http.post('/api/getFolderAppList', {owner: this.currentUser.username.toString()}).subscribe(folders => {
if (folders) {
this.allUserAppFolder = folders;
console.log('yuuuuuuuuuu' + this.currentUser.username.toString());
this.setAllUserAppFolder.emit(this.currentUser.username.toString());
} else {
this.allUserAppFolder = [];
}
@ -297,6 +310,9 @@ export class BookComponent implements OnInit, OnDestroy {
this.http.post('api/uploadFileMongo', { name: this.fileChooseName.toString(), path: this.mainFolder.path.toString(), type: this.filesToUpload[0].type.toString(), taille: this.filesToUpload[0].size.toString(), idUser: this.currentUser._id.toString(), owner: this.currentUser.username.toString(), lastDate: Date.now().toString(), url: ''}).subscribe(resp => {
me.saveURLFileMongo(resp);
var mee = this;
////////
me.makeFileRequest('http://localhost:3000/api/upload', [], this.filesToUpload, resp).then((result) => {
mee.getfiles();
mee.filesToUpload = null;

View File

@ -50,6 +50,8 @@
<!--Header-->
<div class="text-center">
<h3 class="white-text"><i class="fa fa-user white-text"></i> Log in:</h3>
titi@caille.com
caille
<hr class="hr-light">
</div>

View File

@ -42,24 +42,23 @@
<ul class="collapsible collapsible-accordion">
<mdb-squeezebox [multiple]="false" aria-multiselectable="false">
<!-- Collapsible link -->
<mdb-item>
<mdb-item-head mdbWavesEffect><i class="fa fa-chevron-right"></i> Collapsible menu</mdb-item-head>
<!-- Collapsible link onclick="function(){ getAllUserAppFolder(); }" -->
<mdb-item *ngFor="let folder of allUserAppFolder; let i = index;">
<mdb-item-head mdbWavesEffect><i class="fa fa-chevron-right"></i>{{folder.name}}</mdb-item-head>
<mdb-item-body>
<ul>
<li><a href="#" class="waves-effect" mdbWavesEffect>Link 1</a></li>
<li><a href="#" class="waves-effect" mdbWavesEffect>Link 2</a></li>
<li><a class="waves-effect" *ngFor="let file of getItems(folder.path); let i = index;" mdbWavesEffect>{{file.name}}</a></li>
</ul>
</mdb-item-body>
</mdb-item>
<!-- Simple link -->
<!-- Simple link
<mdb-item class="no-collase">
<mdb-item-head mdbWavesEffect><i class="fa fa-hand-pointer-o"></i> Simple link</mdb-item-head>
<mdb-item-body></mdb-item-body>
</mdb-item>
<!-- Collapsible link -->
<mdb-item>
<mdb-item-head mdbWavesEffect><i class="fa fa-eye"></i> Collapsible menu 2</mdb-item-head>
<mdb-item-body>
@ -70,11 +69,11 @@
</mdb-item-body>
</mdb-item>
<!-- Simple link -->
<mdb-item class="no-collase">
<mdb-item-head mdbWavesEffect><i class="fa fa-diamond"></i> Simple link 2</mdb-item-head>
<mdb-item-body></mdb-item-body>
</mdb-item>
</mdb-item>-->
</mdb-squeezebox>
</ul>

View File

@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { HttpClient, HttpHeaders } from '@angular/common/http';
@Component({
selector: 'app-main',
@ -7,8 +8,12 @@ import { Router, ActivatedRoute } from '@angular/router';
styleUrls: ['./main.component.scss']
})
export class MainComponent implements OnInit {
constructor(private router: Router, private route: ActivatedRoute) { }
httpOptions: any;
allUserAppFolder: any;
allUserAppFile: any;
mainFolder: any;
currentUser: any;
constructor(private router: Router, private route: ActivatedRoute, private http: HttpClient) { }
logout() {
localStorage.removeItem('jwtToken');
@ -16,6 +21,58 @@ export class MainComponent implements OnInit {
}
ngOnInit() {
}
this.httpOptions = {
headers: new HttpHeaders({ 'Authorization': localStorage.getItem('jwtToken'), 'Access-Control-Allow-Origin' : '*'}),
pathFolder: ''
};
this.http.get('/api/getCurrentUser', this.httpOptions).subscribe(user => {
this.currentUser = user;
if (user) {
this.getAllUserAppFolder();
}
}, err => {
if (err.status === 401) {
this.router.navigate(['login']);
}
});
}
getAllUserAppFiles() {
this.http.post('/api/getFileAppList', {owner: this.currentUser.username.toString()}).subscribe(files => {
if (files) {
this.allUserAppFile = files;
for (let f of this.allUserAppFile){
console.log(f.name);
//f.fileTab = this.getfiles(f);
}
// return files;
} else {
this.allUserAppFile = [];
}
});
}
getItems(path) {
return this.allUserAppFile.filter((file) => file.path === path);
}
getAllUserAppFolder(){
this.http.post('/api/getFolderAppList', {owner: this.currentUser.username.toString()}).subscribe(folders => {
if (folders) {
this.allUserAppFolder = folders;
this.getAllUserAppFiles();
// for (let f of this.allUserAppFolder){
// console.log(f.name);
// //f.fileTab = this.getfiles(f);
// console.log(f.fileTab);
// }
} else {
this.allUserAppFolder = [];
}
});
}
}