affiche taille all file restant

anis
Tmadkaud 6 years ago
parent 2cd2ee75e0
commit dbdbd5fe39

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

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

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

@ -111,15 +111,15 @@ router.post('/createFolder', function(req, res, next) {
/* DELETE FILE */ /* DELETE FILE */
router.post('/deleteFileMongo', function(req, res, next) { 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) { FileMongo.remove({_id : req.body._id, name: req.body.name, owner: req.body.owner}, function (err, post) {
if (err){ if (err){
console.log('nana err : ' + err); console.log('err deleteF ileMongo : ' + err);
return next(err); return next(err);
} }
//Delete file multer dans Public //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)); fs.unlink('./public/' + req.body._id + getStringExtention(req.body));
res.json(post); res.json(post);
@ -259,7 +259,7 @@ router.post('/signin', function(req, res) {
// check if password matches // check if password matches
user.comparePassword(req.body.password, function (err, isMatch) { user.comparePassword(req.body.password, function (err, isMatch) {
if (isMatch && !err) { 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 // if user is found and password is right create a token
var token = jwt.sign(user.toJSON(), config.secret); var token = jwt.sign(user.toJSON(), config.secret);
// return the information including token as JSON // return the information including token as JSON

@ -4,6 +4,7 @@
<div class="container-fluid"> <div class="container-fluid">
<div *ngIf="mainFolder"> <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> Path : {{mainFolder.path}}</p>
<p> Vous êtes dans le dossier : {{mainFolder.name}}</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> <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>

@ -25,7 +25,7 @@ export class BookComponent implements OnInit, OnDestroy {
@Output() setAllUserAppFolder = new EventEmitter<String>(); @Output() setAllUserAppFolder = new EventEmitter<String>();
message: string = 'Hola Mundo!'; message: string = 'Hola Mundo!';
sizeFile:any;
@Output() messageEvent = new EventEmitter<string>(); @Output() messageEvent = new EventEmitter<string>();
currentUser: any; currentUser: any;
allUserFile: 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) { constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute, public sanitizer: DomSanitizer) {
this.isClickCreateFolder = false; this.isClickCreateFolder = false;
this.fileChooseName = 'None'; this.fileChooseName = 'None';
this.filesToUpload = []; this.filesToUpload = [];
this.test = ''; this.test = '';
this.sizeFile = 0;
} }
sendMessage() { sendMessage() {
console.log('caca'); console.log('caca');
@ -178,7 +179,7 @@ export class BookComponent implements OnInit, OnDestroy {
getfiles() { getfiles() {
//var preview = document.querySelector('img'); //var preview = document.querySelector('img');
this.sizeFile = 0;
var meee = this; var meee = this;
this.http.post('/api/getFileList', {mainPath : this.mainFolder.path, owner: this.currentUser.username.toString()}).subscribe(files => { 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; this.allUserFile = files;
for (let f of this.allUserFile) { 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')){ if(f.type === ('image/jpeg') || f.type === ('image/png')){
f.data = f.url; f.data = f.url;
f.urlSafe = this.sanitizer.bypassSecurityTrustUrl(f.url); f.urlSafe = this.sanitizer.bypassSecurityTrustUrl(f.url);
}else{ }else{
f.data = f.url; f.data = f.url;
f.urlSafe = this.sanitizer.bypassSecurityTrustResourceUrl(f.url); f.urlSafe = this.sanitizer.bypassSecurityTrustResourceUrl(f.url);
} }
} }
} else { } else {
@ -212,12 +216,12 @@ export class BookComponent implements OnInit, OnDestroy {
}); });
} }
getAllUserAppFolder(){ getAllUserAppFolder(){
this.message = 'caca'; this.message = '';
this.sendMessage(); this.sendMessage();
this.http.post('/api/getFolderAppList', {owner: this.currentUser.username.toString()}).subscribe(folders => { this.http.post('/api/getFolderAppList', {owner: this.currentUser.username.toString()}).subscribe(folders => {
if (folders) { if (folders) {
this.allUserAppFolder = folders; this.allUserAppFolder = folders;
console.log('yuuuuuuuuuu' + this.currentUser.username.toString()); console.log(this.currentUser.username.toString());
this.setAllUserAppFolder.emit(this.currentUser.username.toString()); this.setAllUserAppFolder.emit(this.currentUser.username.toString());
} else { } 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.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; this.mainFolder = resp;
}, err => { }, 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.getfolders();
this.getAllUserAppFolder(); this.getAllUserAppFolder();
}, err => { }, err => {
console.log('errrrr folllder : ' + err); console.log('err create Folder : ' + err);
}); });
} }

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

@ -13,6 +13,7 @@ export class MainComponent implements OnInit {
allUserAppFile: any; allUserAppFile: any;
mainFolder: any; mainFolder: any;
currentUser: any; currentUser: any;
constructor(private router: Router, private route: ActivatedRoute, private http: HttpClient) { } constructor(private router: Router, private route: ActivatedRoute, private http: HttpClient) { }
logout() { logout() {
@ -40,7 +41,7 @@ export class MainComponent implements OnInit {
} }
getAllUserAppFiles() { getAllUserAppFiles() {
console.log(this.currentUser.username.toString());
this.http.post('/api/getFileAppList', {owner: this.currentUser.username.toString()}).subscribe(files => { this.http.post('/api/getFileAppList', {owner: this.currentUser.username.toString()}).subscribe(files => {
if (files) { if (files) {
this.allUserAppFile = files; this.allUserAppFile = files;
@ -57,7 +58,11 @@ export class MainComponent implements OnInit {
getItems(path) { 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(){ getAllUserAppFolder(){

Loading…
Cancel
Save