|
|
|
@ -25,6 +25,7 @@ export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
|
currentUser: any;
|
|
|
|
|
allUserFile: any;
|
|
|
|
|
allUserFolder: any;
|
|
|
|
|
allUserAppFolder: any;
|
|
|
|
|
mainFolder: any;
|
|
|
|
|
books: any;
|
|
|
|
|
filesToUpload: Array<File>;
|
|
|
|
@ -61,27 +62,6 @@ export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
|
this.fileChooseName = 'None';
|
|
|
|
|
this.filesToUpload = [];
|
|
|
|
|
this.test = '';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if(document){
|
|
|
|
|
var myDropzone = new Dropzone('div#madrop', { url: '../../../public/'});
|
|
|
|
|
// "myAwesomeDropzone" is the camelized version of the HTML element's ID
|
|
|
|
|
myDropzone.options.madrop = {
|
|
|
|
|
paramName: "file", // The name that will be used to transfer the file
|
|
|
|
|
maxFilesize: 2, // MB
|
|
|
|
|
accept: function(file, done) {
|
|
|
|
|
console.log('Naha, you don\'t.');
|
|
|
|
|
|
|
|
|
|
if (file.name == "justinbieber.jpg") {
|
|
|
|
|
console.log('Naha, you don\'t.');
|
|
|
|
|
done('Naha, you don\'t.');
|
|
|
|
|
}
|
|
|
|
|
else { console.log('done();') }
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public toggleType(): void {
|
|
|
|
@ -119,19 +99,18 @@ export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public onUploadSuccess(args: any): void {
|
|
|
|
|
console.log('onUploadSuccess:', JSON.stringify(args[0]));
|
|
|
|
|
this.filesToUpload = args;
|
|
|
|
|
this.fileChooseName = args[0].name;
|
|
|
|
|
console.log('this.fileChooseName:', this.fileChooseName);
|
|
|
|
|
|
|
|
|
|
this.upload();
|
|
|
|
|
this.resetDropzoneUploads();
|
|
|
|
|
this.openFolder(this.mainFolder.path);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this.httpOptions = {
|
|
|
|
|
headers: new HttpHeaders({ 'Authorization': localStorage.getItem('jwtToken') }),
|
|
|
|
|
headers: new HttpHeaders({ 'Authorization': localStorage.getItem('jwtToken'), 'Access-Control-Allow-Origin' : '*'}),
|
|
|
|
|
pathFolder: ''
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -194,17 +173,11 @@ export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
|
this.allUserFile = files;
|
|
|
|
|
for (let f of this.allUserFile) {
|
|
|
|
|
if(f.type === ('image/jpeg') || f.type === ('image/png')){
|
|
|
|
|
console.log('f : ' + JSON.stringify(f));
|
|
|
|
|
f.data = f.url;
|
|
|
|
|
console.log('f.url : ' + f.url);
|
|
|
|
|
f.urlSafe = this.sanitizer.bypassSecurityTrustUrl(f.url);
|
|
|
|
|
console.log('f.urlSafe : ' + JSON.stringify(f.urlSafe));
|
|
|
|
|
}else{
|
|
|
|
|
console.log('f : ' + JSON.stringify(f));
|
|
|
|
|
f.data = f.url;
|
|
|
|
|
console.log('f.url : ' + f.url);
|
|
|
|
|
f.urlSafe = this.sanitizer.bypassSecurityTrustResourceUrl(f.url);
|
|
|
|
|
console.log('f.urlSafe : ' + JSON.stringify(f.urlSafe));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -223,6 +196,41 @@ export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
getAllUserAppFolder(){
|
|
|
|
|
this.http.post('/api/getFolderAppList', {owner: this.currentUser.username.toString()}).subscribe(folders => {
|
|
|
|
|
if (folders) {
|
|
|
|
|
this.allUserAppFolder = folders;
|
|
|
|
|
} else {
|
|
|
|
|
this.allUserAppFolder = [];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
moveFile(fileToMove, folderDest){
|
|
|
|
|
fileToMove.path = folderDest.path;
|
|
|
|
|
|
|
|
|
|
this.http.post('/api/moveFile', fileToMove).subscribe(data => {
|
|
|
|
|
console.log('data : ' + data);
|
|
|
|
|
this.getfiles();
|
|
|
|
|
//this.openFolder(this.mainFolder.path)
|
|
|
|
|
// this.getAllUserAppFolder();
|
|
|
|
|
// this.getfiles();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
moveFolder(folderToMove, folderDest){
|
|
|
|
|
var newPath = folderDest.path + '/' + folderToMove.parent.name;
|
|
|
|
|
folderToMove.path = newPath;
|
|
|
|
|
folderToMove.parent = folderDest.path;
|
|
|
|
|
|
|
|
|
|
this.http.post('/api/moveFolder', folderToMove).subscribe(data => {
|
|
|
|
|
console.log('data : ' + data);
|
|
|
|
|
this.getfolders();
|
|
|
|
|
//this.openFolder(this.mainFolder.path)
|
|
|
|
|
// this.getAllUserAppFolder();
|
|
|
|
|
// this.getfiles();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
backToParentFolder(){
|
|
|
|
|
this.openFolder(this.mainFolder.parent);
|
|
|
|
@ -238,6 +246,7 @@ export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
|
if (folder) {
|
|
|
|
|
this.mainFolder = folder;
|
|
|
|
|
this.getfolders();
|
|
|
|
|
this.getAllUserAppFolder();
|
|
|
|
|
this.getfiles();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
@ -262,6 +271,7 @@ export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
|
|
this.http.post('api/createFolder', { name: this.inputCreateFolder.toString(), parent: this.mainFolder.path, path: newPath.toString(), taille: 'taiile', idUser: this.currentUser._id.toString(), fileList: [], folderList: [], owner: this.currentUser.username.toString() }).subscribe(resp => {
|
|
|
|
|
this.getfolders();
|
|
|
|
|
this.getAllUserAppFolder();
|
|
|
|
|
}, err => {
|
|
|
|
|
console.log('errrrr folllder : ' + err);
|
|
|
|
|
});
|
|
|
|
|