|
|
@ -20,38 +20,38 @@ import { CompleterService } from '../typescripts/pro';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: 'app-book',
|
|
|
|
selector: 'app-book',
|
|
|
|
templateUrl: './book.component.html',
|
|
|
|
templateUrl: './book.component.html',
|
|
|
|
styleUrls: ['./book.component.css']
|
|
|
|
styleUrls: ['./book.component.css']
|
|
|
|
})
|
|
|
|
})
|
|
|
|
export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
@Input() socialIdUser: String;
|
|
|
|
@Input() socialIdUser: String;
|
|
|
|
@Output() setAllUserAppFolder = new EventEmitter<String>();
|
|
|
|
@Output() setAllUserAppFolder = new EventEmitter<String>();
|
|
|
|
|
|
|
|
|
|
|
|
message: string = 'Hola Mundo!';
|
|
|
|
message: string = 'Hola Mundo!';
|
|
|
|
sizeFile:any;
|
|
|
|
sizeFile:any;
|
|
|
|
@Output() messageEvent = new EventEmitter<string>();
|
|
|
|
@Output() messageEvent = new EventEmitter<string>();
|
|
|
|
currentUser: any;
|
|
|
|
currentUser: any;
|
|
|
|
allUserFile: any;
|
|
|
|
allUserFile: any;
|
|
|
|
allUserFolder: any;
|
|
|
|
allUserFolder: any;
|
|
|
|
//socialIdUser: String;
|
|
|
|
//socialIdUser: String;
|
|
|
|
filterAllUserFolder: any;
|
|
|
|
filterAllUserFolder: any;
|
|
|
|
allUserAppFolder: any;
|
|
|
|
allUserAppFolder: any;
|
|
|
|
allUserAppFile: any;
|
|
|
|
allUserAppFile: any;
|
|
|
|
mainFolder: any;
|
|
|
|
mainFolder: any;
|
|
|
|
books: any;
|
|
|
|
books: any;
|
|
|
|
filesToUpload: Array<File>;
|
|
|
|
filesToUpload: Array<File>;
|
|
|
|
fileChooseName: string;
|
|
|
|
fileChooseName: string;
|
|
|
|
httpOptions: any;
|
|
|
|
httpOptions: any;
|
|
|
|
isClickCreateFolder: boolean;
|
|
|
|
isClickCreateFolder: boolean;
|
|
|
|
inputCreateFolder: String;
|
|
|
|
inputCreateFolder: String;
|
|
|
|
reader: FileReader;
|
|
|
|
reader: FileReader;
|
|
|
|
test: String;
|
|
|
|
test: String;
|
|
|
|
previewNode:any;
|
|
|
|
previewNode:any;
|
|
|
|
previewTemplate:any;
|
|
|
|
previewTemplate:any;
|
|
|
|
// config: DropzoneConfigInterface;
|
|
|
|
// config: DropzoneConfigInterface;
|
|
|
|
//myDropzone: Dropzone;
|
|
|
|
//myDropzone: Dropzone;
|
|
|
|
droptestt:any;
|
|
|
|
droptestt:any;
|
|
|
|
allItems: any;
|
|
|
|
allItems: any;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -85,7 +85,7 @@ export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
this.test = '';
|
|
|
|
this.test = '';
|
|
|
|
this.sizeFile = 0;
|
|
|
|
this.sizeFile = 0;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
copyLink(val) {
|
|
|
|
copyLink(val) {
|
|
|
|
|
|
|
|
|
|
|
|
let selBox = document.createElement('textarea');
|
|
|
|
let selBox = document.createElement('textarea');
|
|
|
@ -94,7 +94,7 @@ export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
selBox.style.left = '0';
|
|
|
|
selBox.style.left = '0';
|
|
|
|
selBox.style.top = '0';
|
|
|
|
selBox.style.top = '0';
|
|
|
|
selBox.style.opacity = '0';
|
|
|
|
selBox.style.opacity = '0';
|
|
|
|
selBox.value = 'http://localhost:3000/' + val;
|
|
|
|
selBox.value = 'https://localhost:3000/download/' + val;
|
|
|
|
|
|
|
|
|
|
|
|
document.body.appendChild(selBox);
|
|
|
|
document.body.appendChild(selBox);
|
|
|
|
selBox.focus();
|
|
|
|
selBox.focus();
|
|
|
@ -161,30 +161,30 @@ export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
ngOnInit() {
|
|
|
|
this.httpOptions = {
|
|
|
|
this.httpOptions = {
|
|
|
|
headers: new HttpHeaders({
|
|
|
|
headers: new HttpHeaders({
|
|
|
|
'Authorization': localStorage.getItem('jwtToken'),
|
|
|
|
'Authorization': localStorage.getItem('jwtToken'),
|
|
|
|
'Access-Control-Allow-Origin' : '*',
|
|
|
|
'Access-Control-Allow-Origin' : '*',
|
|
|
|
'Access-Control-Allow-Methods' : 'GET, POST, OPTIONS, PUT, PATCH, DELETE',
|
|
|
|
'Access-Control-Allow-Methods' : 'GET, POST, OPTIONS, PUT, PATCH, DELETE',
|
|
|
|
'Access-Control-Allow-Headers' : 'Origin, X-Requested-With, Content-Type, Accept'
|
|
|
|
'Access-Control-Allow-Headers' : 'Origin, X-Requested-With, Content-Type, Accept'
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
pathFolder: ''
|
|
|
|
pathFolder: ''
|
|
|
|
};
|
|
|
|
};
|
|
|
|
// this.httpOptions = {
|
|
|
|
// this.httpOptions = {
|
|
|
|
// headers: new HttpHeaders({ 'Authorization': localStorage.getItem('jwtToken'), 'Access-Control-Allow-Origin' : '*'}),
|
|
|
|
// headers: new HttpHeaders({ 'Authorization': localStorage.getItem('jwtToken'), 'Access-Control-Allow-Origin' : '*'}),
|
|
|
|
// pathFolder: ''
|
|
|
|
// pathFolder: ''
|
|
|
|
// };
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
this.http.get('/api/getCurrentUser', this.httpOptions).subscribe(user => {
|
|
|
|
this.http.get('/api/getCurrentUser', this.httpOptions).subscribe(user => {
|
|
|
|
this.currentUser = user;
|
|
|
|
this.currentUser = user;
|
|
|
|
this.openFolder('Home');
|
|
|
|
this.openFolder('Home');
|
|
|
|
}, err => {
|
|
|
|
}, err => {
|
|
|
|
if (err.status === 401) {
|
|
|
|
if (err.status === 401) {
|
|
|
|
this.router.navigate(['login']);
|
|
|
|
this.router.navigate(['login']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
deleteFile(fileToDelete) {
|
|
|
|
deleteFile(fileToDelete) {
|
|
|
|
this.http.post('/api/deleteFileMongo', fileToDelete).subscribe(file => {
|
|
|
|
this.http.post('/api/deleteFileMongo', fileToDelete).subscribe(file => {
|
|
|
@ -213,7 +213,7 @@ export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
saveURLFileMongo(fileToCreateURL){
|
|
|
|
saveURLFileMongo(fileToCreateURL){
|
|
|
|
fileToCreateURL.url = '../../../public/' + fileToCreateURL._id.toString() + this.getStringExtention(fileToCreateURL);
|
|
|
|
fileToCreateURL.url = '../../../public/' + fileToCreateURL._id.toString() + this.getStringExtention(fileToCreateURL);
|
|
|
|
|
|
|
|
|
|
|
|
this.http.post('/api/saveURLFileMongo', fileToCreateURL).subscribe(data => {
|
|
|
|
this.http.post('/api/saveURLFileMongo', fileToCreateURL).subscribe(data => {
|
|
|
|
console.log('data : ' + data);
|
|
|
|
console.log('data : ' + data);
|
|
|
@ -242,59 +242,59 @@ export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getfiles() {
|
|
|
|
getfiles() {
|
|
|
|
//var preview = document.querySelector('img');
|
|
|
|
//var preview = document.querySelector('img');
|
|
|
|
|
|
|
|
|
|
|
|
this.sizeFile = 0;
|
|
|
|
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 => {
|
|
|
|
if (files) {
|
|
|
|
if (files) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.allUserFile = files;
|
|
|
|
this.allUserFile = files;
|
|
|
|
for (let f of this.allUserFile) {
|
|
|
|
for (let f of this.allUserFile) {
|
|
|
|
|
|
|
|
|
|
|
|
this.sizeFile += +f.taille;
|
|
|
|
this.sizeFile += +f.taille;
|
|
|
|
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 {
|
|
|
|
this.allUserFile = [];
|
|
|
|
this.allUserFile = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getfolders() {
|
|
|
|
getfolders() {
|
|
|
|
this.http.post('/api/getFolderList', {mainPath : this.mainFolder.path, owner: this.currentUser.username.toString()}).subscribe(folders => {
|
|
|
|
this.http.post('/api/getFolderList', {mainPath : this.mainFolder.path, owner: this.currentUser.username.toString()}).subscribe(folders => {
|
|
|
|
if (folders) {
|
|
|
|
if (folders) {
|
|
|
|
this.allUserFolder = folders;
|
|
|
|
this.allUserFolder = folders;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.allUserFolder = [];
|
|
|
|
this.allUserFolder = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getAllUserAppFolder(){
|
|
|
|
getAllUserAppFolder(){
|
|
|
|
this.message = '';
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
this.setAllUserAppFolder.emit(this.currentUser.username.toString());
|
|
|
|
this.setAllUserAppFolder.emit(this.currentUser.username.toString());
|
|
|
|
|
|
|
|
|
|
|
|
this.getAllUserAppFiles();
|
|
|
|
this.getAllUserAppFiles();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.allUserAppFolder = [];
|
|
|
|
this.allUserAppFolder = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
moveFile(fileToMove, folderDest){
|
|
|
|
moveFile(fileToMove, folderDest){
|
|
|
|
fileToMove.path = folderDest.path;
|
|
|
|
fileToMove.path = folderDest.path;
|
|
|
@ -322,110 +322,110 @@ export class BookComponent implements OnInit, OnDestroy {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
backToParentFolder(){
|
|
|
|
backToParentFolder(){
|
|
|
|
this.openFolder(this.mainFolder.parent);
|
|
|
|
this.openFolder(this.mainFolder.parent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openFolder(path: String) {
|
|
|
|
openFolder(path: String) {
|
|
|
|
|
|
|
|
|
|
|
|
if(this.searchStr !== undefined ? path === 'searchStr' : false){
|
|
|
|
if(this.searchStr !== undefined ? path === 'searchStr' : false){
|
|
|
|
path = this.searchStr;
|
|
|
|
path = this.searchStr;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.httpOptions.pathFolder = path;
|
|
|
|
this.httpOptions.pathFolder = path;
|
|
|
|
this.isClickCreateFolder = false;
|
|
|
|
this.isClickCreateFolder = false;
|
|
|
|
|
|
|
|
|
|
|
|
this.http.post('/api/getMainFolder', {path: path, owner: this.currentUser.username.toString()}).subscribe(folder => {
|
|
|
|
this.http.post('/api/getMainFolder', {path: path, owner: this.currentUser.username.toString()}).subscribe(folder => {
|
|
|
|
if (folder) {
|
|
|
|
if (folder) {
|
|
|
|
this.mainFolder = folder;
|
|
|
|
this.mainFolder = folder;
|
|
|
|
this.getfolders();
|
|
|
|
this.getfolders();
|
|
|
|
this.getAllUserAppFolder();
|
|
|
|
this.getAllUserAppFolder();
|
|
|
|
this.getfiles();
|
|
|
|
this.getfiles();
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (path === 'Home'){
|
|
|
|
if (path === 'Home'){
|
|
|
|
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('err open Folder : ' + err);
|
|
|
|
console.log('err open Folder : ' + err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
createBool() {
|
|
|
|
createBool() {
|
|
|
|
this.isClickCreateFolder = true;
|
|
|
|
this.isClickCreateFolder = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
createFolder() {
|
|
|
|
createFolder() {
|
|
|
|
var newPath = this.mainFolder.path + '/' + this.inputCreateFolder;
|
|
|
|
var newPath = this.mainFolder.path + '/' + this.inputCreateFolder;
|
|
|
|
this.isClickCreateFolder = false;
|
|
|
|
this.isClickCreateFolder = false;
|
|
|
|
|
|
|
|
|
|
|
|
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.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.getfolders();
|
|
|
|
this.getAllUserAppFolder();
|
|
|
|
this.getAllUserAppFolder();
|
|
|
|
}, err => {
|
|
|
|
}, err => {
|
|
|
|
console.log('err create Folder : ' + err);
|
|
|
|
console.log('err create Folder : ' + err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
ngOnDestroy() {
|
|
|
|
localStorage.removeItem('jwtToken');
|
|
|
|
localStorage.removeItem('jwtToken');
|
|
|
|
this.httpOptions = null;
|
|
|
|
this.httpOptions = null;
|
|
|
|
this.currentUser = null;
|
|
|
|
this.currentUser = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
upload() {
|
|
|
|
upload() {
|
|
|
|
var me = this;
|
|
|
|
var me = this;
|
|
|
|
if(this.mainFolder !== undefined){
|
|
|
|
if(this.mainFolder !== undefined){
|
|
|
|
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 => {
|
|
|
|
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);
|
|
|
|
me.saveURLFileMongo(resp);
|
|
|
|
var mee = this;
|
|
|
|
var mee = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////
|
|
|
|
////////
|
|
|
|
me.makeFileRequest('https://localhost:3000/api/upload', [], this.filesToUpload, resp).then((result) => {
|
|
|
|
me.makeFileRequest('https://localhost:3000/api/upload', [], this.filesToUpload, resp).then((result) => {
|
|
|
|
mee.getfiles();
|
|
|
|
mee.getfiles();
|
|
|
|
mee.filesToUpload = null;
|
|
|
|
mee.filesToUpload = null;
|
|
|
|
mee.fileChooseName = 'None';
|
|
|
|
mee.fileChooseName = 'None';
|
|
|
|
}, (error) => {
|
|
|
|
}, (error) => {
|
|
|
|
console.error(error);
|
|
|
|
console.error(error);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}, err => {
|
|
|
|
}, err => {
|
|
|
|
console.error(err);
|
|
|
|
console.error(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fileChangeEvent(fileInput: any){
|
|
|
|
|
|
|
|
this.filesToUpload = <Array<File>> fileInput.target.files;
|
|
|
|
|
|
|
|
this.fileChooseName = this.filesToUpload[0].name;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
makeFileRequest(url: string, params: Array<string>, files: Array<File>, monFile: any) {
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
|
|
var formData: any = new FormData();
|
|
|
|
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
formData.append("public[]", files[0], monFile._id + this.getStringExtention(monFile));
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
|
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
|
|
|
|
resolve(JSON.parse(xhr.response));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
reject(xhr.response);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fileChangeEvent(fileInput: any){
|
|
|
|
|
|
|
|
this.filesToUpload = <Array<File>> fileInput.target.files;
|
|
|
|
|
|
|
|
this.fileChooseName = this.filesToUpload[0].name;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.open("POST", url, true);
|
|
|
|
makeFileRequest(url: string, params: Array<string>, files: Array<File>, monFile: any) {
|
|
|
|
xhr.send(formData);
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
});
|
|
|
|
var formData: any = new FormData();
|
|
|
|
}
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
formData.append("public[]", files[0], monFile._id + this.getStringExtention(monFile));
|
|
|
|
|
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
|
|
|
|
if (xhr.readyState == 4) {
|
|
|
|
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
|
|
|
|
resolve(JSON.parse(xhr.response));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
reject(xhr.response);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.open("POST", url, true);
|
|
|
|
|
|
|
|
xhr.send(formData);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getStringExtention(monFile: any){
|
|
|
|
getStringExtention(monFile: any){
|
|
|
|