affiche taille all file restant

This commit is contained in:
Tmadkaud 2018-06-05 02:04:54 +02:00
parent 2cd2ee75e0
commit dbdbd5fe39
8 changed files with 157 additions and 24 deletions

View File

@ -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');

View File

@ -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');

63
models/FileSaveMongo.js Normal file
View File

@ -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');

View File

@ -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

View File

@ -4,6 +4,7 @@
<div class="container-fluid">
<div *ngIf="mainFolder">
<p> Espace utilisé : {{sizeFile.toString() === '0' ? '0' : (sizeFile/ ( 1024 * 1024 ) | number : '1.2-2')}} / 30 Mo</p>
<p> Path : {{mainFolder.path}}</p>
<p> Vous êtes dans le dossier : {{mainFolder.name}}</p>
<button type="button" class="btn btn-sm btn-warning" mdbTooltip="Retour à : {{mainFolder.parent}}" placement="top" (click)="backToParentFolder()" *ngIf="mainFolder.path !== 'Home'"><i class="fa fa-chevron-left" aria-hidden="true"></i> {{mainFolder.parent}}</button>

View File

@ -25,7 +25,7 @@ export class BookComponent implements OnInit, OnDestroy {
@Output() setAllUserAppFolder = new EventEmitter<String>();
message: string = 'Hola Mundo!';
sizeFile:any;
@Output() messageEvent = new EventEmitter<string>();
currentUser: any;
allUserFile: any;
@ -67,6 +67,7 @@ export class BookComponent implements OnInit, OnDestroy {
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,6 +188,9 @@ 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);
@ -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);
});
}

View File

@ -50,8 +50,7 @@
<!--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>
@ -95,11 +94,11 @@
</div>
<!--Body-->
<div class="md-form">
<i class="fa fa-user prefix white-text"></i>
<input type="text" id="form3" class="form-control" data-success=" " data-error=" " mdbInputDirective>
<label for="form3">Your name</label>
</div>
<!--<div class="md-form">-->
<!--<i class="fa fa-user prefix white-text"></i>-->
<!--<input type="text" id="form3" class="form-control" data-success=" " data-error=" " mdbInputDirective>-->
<!--<label for="form3">Your name</label>-->
<!--</div>-->
<div class="md-form">
<i class="fa fa-envelope prefix white-text"></i>
<input type="email" id="form2" data-error="wrong email" data-success=" " data-error=" " [(ngModel)]="signupData.username" class="form-control" mdbInputDirective>

View File

@ -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(){