diff --git a/models/ChuckFileSaveMongo.js b/models/ChuckFileSaveMongo.js new file mode 100644 index 0000000..7c97913 --- /dev/null +++ b/models/ChuckFileSaveMongo.js @@ -0,0 +1,31 @@ +var mongoose = require('mongoose'); +var Schema = mongoose.Schema; + +var ChunkFileSaveMongo = new Schema({ + uid: { + type: String, + unique: false + }, + fieldname: { + type: String, + unique: false + }, + files_id: { + type: String, + unique: false + }, + n: { + type: String, + unique: false + }, + data: { + type: String, + unique: false + }, + id: { + type: String, + unique: false + } +}); + +module.exports = mongoose.model('ChunkFileSaveMongo', ChunkFileSaveMongo, 'fs.chunks'); diff --git a/models/ChunkFileSaveMongo.js b/models/ChunkFileSaveMongo.js new file mode 100644 index 0000000..eefb6b2 --- /dev/null +++ b/models/ChunkFileSaveMongo.js @@ -0,0 +1,30 @@ +var mongoose = require('mongoose'); +var Schema = mongoose.Schema; + +var ChunkFileSaveMongo = new Schema({ + uid: { + type: String, + unique: false + }, + fieldname: { + type: String, + unique: false + }, + files_id: { + type: String, + unique: false + }, + n: { + type: String, + unique: false + }, + data: [{ + type: String + }], + id: { + type: String, + unique: false + } +}); + +module.exports = mongoose.model('ChunkFileSaveMongo', ChunkFileSaveMongo, 'fs.chunks'); diff --git a/models/FileSaveMongo.js b/models/FileSaveMongo.js new file mode 100644 index 0000000..2236ac6 --- /dev/null +++ b/models/FileSaveMongo.js @@ -0,0 +1,63 @@ +var mongoose = require('mongoose'); +var Schema = mongoose.Schema; + +var FileSaveMongoShema = new Schema({ + uid: { + type: String, + unique: false + }, + fieldname: { + type: String, + unique: false + }, + originalname: { + type: String, + unique: false + }, + encoding: { + type: String, + unique: false + }, + mimetype: { + type: String, + unique: false + }, + id: { + type: String, + unique: false + }, + filename: { + type: String, + unique: false + }, + metadata: { + type: String, + unique: false + }, + bucketName: { + type: String, + unique: false + }, + chunkSize: { + type: String, + unique: false + }, + size: { + type: String, + unique: false + }, + md5: { + type: String, + unique: false + }, + uploadDate: { + type: String, + unique: false + }, + contentType: { + type: String, + unique: false + } +}); + +module.exports = mongoose.model('FileSaveMongo', FileSaveMongoShema, 'fs.files'); diff --git a/routes/api.js b/routes/api.js index 8140cb4..ce1f29e 100644 --- a/routes/api.js +++ b/routes/api.js @@ -111,15 +111,15 @@ router.post('/createFolder', function(req, res, next) { /* DELETE FILE */ router.post('/deleteFileMongo', function(req, res, next) { - console.log('nana : ' + JSON.stringify(req.body)); + console.log(JSON.stringify(req.body)); FileMongo.remove({_id : req.body._id, name: req.body.name, owner: req.body.owner}, function (err, post) { if (err){ - console.log('nana err : ' + err); + console.log('err deleteF ileMongo : ' + err); return next(err); } //Delete file multer dans Public - console.log('this.getStringExtention(req.body) : ' + getStringExtention(req.body)); + //console.log('this.getStringExtention(req.body) : ' + getStringExtention(req.body)); fs.unlink('./public/' + req.body._id + getStringExtention(req.body)); res.json(post); @@ -259,7 +259,7 @@ router.post('/signin', function(req, res) { // check if password matches user.comparePassword(req.body.password, function (err, isMatch) { if (isMatch && !err) { - console.log('req.user.username log : ' + JSON.stringify(user)); + console.log('user logged : ' + JSON.stringify(user)); // if user is found and password is right create a token var token = jwt.sign(user.toJSON(), config.secret); // return the information including token as JSON diff --git a/src/app/book/book.component.html b/src/app/book/book.component.html index e8a84a5..8497094 100644 --- a/src/app/book/book.component.html +++ b/src/app/book/book.component.html @@ -4,6 +4,7 @@
+

Espace utilisé : {{sizeFile.toString() === '0' ? '0' : (sizeFile/ ( 1024 * 1024 ) | number : '1.2-2')}} / 30 Mo

Path : {{mainFolder.path}}

Vous êtes dans le dossier : {{mainFolder.name}}

diff --git a/src/app/book/book.component.ts b/src/app/book/book.component.ts index 2c9a64a..374a4e1 100644 --- a/src/app/book/book.component.ts +++ b/src/app/book/book.component.ts @@ -25,7 +25,7 @@ export class BookComponent implements OnInit, OnDestroy { @Output() setAllUserAppFolder = new EventEmitter(); message: string = 'Hola Mundo!'; - + sizeFile:any; @Output() messageEvent = new EventEmitter(); currentUser: any; allUserFile: any; @@ -63,10 +63,11 @@ export class BookComponent implements OnInit, OnDestroy { constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute, public sanitizer: DomSanitizer) { - this.isClickCreateFolder = false; - this.fileChooseName = 'None'; - this.filesToUpload = []; - this.test = ''; + this.isClickCreateFolder = false; + this.fileChooseName = 'None'; + this.filesToUpload = []; + this.test = ''; + this.sizeFile = 0; } sendMessage() { console.log('caca'); @@ -178,7 +179,7 @@ export class BookComponent implements OnInit, OnDestroy { getfiles() { //var preview = document.querySelector('img'); - + this.sizeFile = 0; var meee = this; this.http.post('/api/getFileList', {mainPath : this.mainFolder.path, owner: this.currentUser.username.toString()}).subscribe(files => { @@ -187,13 +188,16 @@ export class BookComponent implements OnInit, OnDestroy { this.allUserFile = files; for (let f of this.allUserFile) { + + this.sizeFile += +f.taille; + console.log('this.sizeFile : ' + this.sizeFile); if(f.type === ('image/jpeg') || f.type === ('image/png')){ f.data = f.url; f.urlSafe = this.sanitizer.bypassSecurityTrustUrl(f.url); }else{ f.data = f.url; f.urlSafe = this.sanitizer.bypassSecurityTrustResourceUrl(f.url); - } + } } } else { @@ -212,12 +216,12 @@ export class BookComponent implements OnInit, OnDestroy { }); } getAllUserAppFolder(){ - this.message = 'caca'; + this.message = ''; 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()); + console.log(this.currentUser.username.toString()); this.setAllUserAppFolder.emit(this.currentUser.username.toString()); } else { @@ -274,7 +278,7 @@ export class BookComponent implements OnInit, OnDestroy { this.http.post('api/createFolder', { name: 'Home', parent: '', path: 'Home', taille: 'taiile', idUser: this.currentUser._id.toString(), fileList: [], folderList: [], owner: this.currentUser.username.toString() }).subscribe(resp => { this.mainFolder = resp; }, err => { - console.log('errrrr folllder : ' + err); + console.log('err open Folder : ' + err); }); } } @@ -293,7 +297,7 @@ export class BookComponent implements OnInit, OnDestroy { this.getfolders(); this.getAllUserAppFolder(); }, err => { - console.log('errrrr folllder : ' + err); + console.log('err create Folder : ' + err); }); } diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html index c3aa8a0..7cbbc90 100644 --- a/src/app/home/home.component.html +++ b/src/app/home/home.component.html @@ -50,8 +50,7 @@

Log in:

- titi@caille.com - caille +
@@ -95,11 +94,11 @@
-
- - - -
+ + + + +
diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index 3572fe5..cfd1f6c 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -13,6 +13,7 @@ export class MainComponent implements OnInit { allUserAppFile: any; mainFolder: any; currentUser: any; + constructor(private router: Router, private route: ActivatedRoute, private http: HttpClient) { } logout() { @@ -40,7 +41,7 @@ export class MainComponent implements OnInit { } getAllUserAppFiles() { - + console.log(this.currentUser.username.toString()); this.http.post('/api/getFileAppList', {owner: this.currentUser.username.toString()}).subscribe(files => { if (files) { this.allUserAppFile = files; @@ -57,7 +58,11 @@ export class MainComponent implements OnInit { getItems(path) { - return this.allUserAppFile.filter((file) => file.path === path); + var test = []; + if(this.allUserAppFile !== undefined){ + test = this.allUserAppFile.filter((file) => file.path === path); + } + return test; } getAllUserAppFolder(){