version stable

anis
Viicious 6 years ago
commit 11929a80b8

@ -56,7 +56,7 @@ app.use('/home', express.static(path.join(__dirname, 'dist')));
app.use('/main/:id', express.static(path.join(__dirname, 'dist')));
app.use('/login', express.static(path.join(__dirname, 'dist')));
app.use('/signup', express.static(path.join(__dirname, 'dist')));
app.use('/download/:id', express.static(path.join(__dirname, 'dist')));
app.use('/api', api);
app.set('view engine', 'pug');

@ -35,8 +35,8 @@ var credentials = {
passphrase: 'titi'
};
//var server = https.createServer(credentials, app);
var server = http.createServer(app);
var server = https.createServer(credentials, app);
//var server = http.createServer(app);

@ -249,6 +249,15 @@ router.post('/getUserById', function(req, res) {
});
});
router.post('/getFileById', function(req, res) {
console.log('yaa' + req.body.id);
FileMongo.find({
_id: req.body.id
}, function (err, file) {
res.json(file);
});
});
/* Login */
router.post('/signin', function(req, res) {
User.findOne({

@ -68,56 +68,56 @@ const appRoutes: Routes = [
data: { title: 'Sign Up' }
},
{
path: 'download',
path: 'download/:id',
component: DownloadLinkComponent ,
data: { title: 'download' }
},
{ path: '',
redirectTo: '/home',
pathMatch: 'full'
redirectTo: '/home',
pathMatch: 'full'
}
];
@NgModule({
declarations: [
AppComponent,
HomeComponent,
LoginComponent,
SignupComponent,
MainComponent,
BookComponent,
DownloadLinkComponent
],
imports: [
BrowserModule,
DropzoneModule,
VgCoreModule,
VgControlsModule,
VgOverlayPlayModule,
VgBufferingModule,
BrowserAnimationsModule,
FormsModule,
HttpModule,
HttpClientModule,
RouterModule.forRoot(
appRoutes,
{ enableTracing: false } // <-- debugging purposes only
),
ToastModule.forRoot(),
MDBBootstrapModule.forRoot(),
MDBBootstrapModulePro.forRoot(),
AgmCoreModule.forRoot({
// https://developers.google.com/maps/documentation/javascript/get-api-key?hl=en#key
apiKey: 'Your_api_key'
})
],
providers: [
MDBSpinningPreloader,
{
provide: DROPZONE_CONFIG,
useValue: DEFAULT_DROPZONE_CONFIG
}],
bootstrap: [AppComponent],
schemas: [ NO_ERRORS_SCHEMA ]
declarations: [
AppComponent,
HomeComponent,
LoginComponent,
SignupComponent,
MainComponent,
BookComponent,
DownloadLinkComponent
],
imports: [
BrowserModule,
DropzoneModule,
VgCoreModule,
VgControlsModule,
VgOverlayPlayModule,
VgBufferingModule,
BrowserAnimationsModule,
FormsModule,
HttpModule,
HttpClientModule,
RouterModule.forRoot(
appRoutes,
{ enableTracing: false } // <-- debugging purposes only
),
ToastModule.forRoot(),
MDBBootstrapModule.forRoot(),
MDBBootstrapModulePro.forRoot(),
AgmCoreModule.forRoot({
// https://developers.google.com/maps/documentation/javascript/get-api-key?hl=en#key
apiKey: 'Your_api_key'
})
],
providers: [
MDBSpinningPreloader,
{
provide: DROPZONE_CONFIG,
useValue: DEFAULT_DROPZONE_CONFIG
}],
bootstrap: [AppComponent],
schemas: [ NO_ERRORS_SCHEMA ]
})
export class AppModule { }

@ -51,17 +51,17 @@
<div class="col-md-4 align-middle l-flex--center">
<!--<form class="md-form active-pink active-pink-2 mb-3">-->
<!--<div class="row">-->
<!--<i class="fa fa-search" aria-hidden="true"></i>-->
<!--<input #query (keyup)="filter(query.value)" type="text" class="form-control form-control-sm ml-3 w-75" placeholder="Search File" aria-label="Search">-->
<!--<div class="list-group" *ngFor="let folder of filterAllUserFolder">-->
<!--<a class="list-group-item list-group-item-action waves-light" (click)="openFolder(folder.path)" mdbWavesEffect>-->
<!--{{folder.name}}-->
<!--<br>-->
<!--{{folder?.path}}-->
<!--</a>-->
<!--</div>-->
<!--</div>-->
<!--<div class="row">-->
<!--<i class="fa fa-search" aria-hidden="true"></i>-->
<!--<input #query (keyup)="filter(query.value)" type="text" class="form-control form-control-sm ml-3 w-75" placeholder="Search File" aria-label="Search">-->
<!--<div class="list-group" *ngFor="let folder of filterAllUserFolder">-->
<!--<a class="list-group-item list-group-item-action waves-light" (click)="openFolder(folder.path)" mdbWavesEffect>-->
<!--{{folder.name}}-->
<!--<br>-->
<!--{{folder?.path}}-->
<!--</a>-->
<!--</div>-->
<!--</div>-->
<!--</form>-->
<mdb-completer [label]="'Find folder'" initialValue="Find folder" (selected)="openFolder('searchStr')" name="autocomplete" [(ngModel)]="searchStr" [datasource]="dataService" [minSearchLength]="0">
</mdb-completer>
@ -345,14 +345,14 @@
<i class="fa unlock-alt" aria-hidden="true"></i>
<i class="fa unlock" aria-hidden="true"></i>
<div class="md-form">
<input value="http://localhost:3000/{{file.url}}" disabled="disabled" type="text" id="shareLink" class="form-control" mdbInputDirective>
<input value="https://localhost:3000/download/{{file._id.toString()}}" disabled="disabled" type="text" id="shareLink" class="form-control" mdbInputDirective>
<label for="shareLink">Link</label>
</div>
</div>
</div>
</div>
<div class="modal-footer justify-content-center">
<a type="button" class="btn btn-secondary waves-light" (click)="copyLink(file.url)" mdbWavesEffect>Copy Link <i class="fa fa-copy ml-1" aria-hidden="true"></i></a>
<a type="button" class="btn btn-secondary waves-light" (click)="copyLink(file._id.toString())" mdbWavesEffect>Copy Link <i class="fa fa-copy ml-1" aria-hidden="true"></i></a>
</div>
</div>
</div>

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

@ -3,6 +3,10 @@
<logo>
<a class="logo navbar-brand waves-light" mdbWavesEffect href="#"><strong>SupFile</strong></a>
</logo>
<links>
<ul class="navbar-nav mr-auto">
</ul>
</links>
</mdb-navbar>
<section class="view intro-2 mask rgba-gradient">
@ -14,11 +18,11 @@
<div class="card text-white card-cascade narrower card-image">
<div class="text-white text-center align-items-center">
<!--Card image-->
<div class="card-header text-center">
<h2 class="h2-responsive">File Download</h2>
</div>
<!--/Card image-->
<!--Card image-->
<div class="card-header text-center">
<h2 class="h2-responsive">File Download</h2>
</div>
<!--/Card image-->
<!--Card content-->
@ -29,16 +33,15 @@
<i class="fa fa-file fa-4x" aria-hidden="true"></i>
</div>
<div class="col-md-6">
<p><strong>Name</strong></p>
<p>Lenght</p>
<p><strong>{{file?.name}}</strong></p>
<p>{{ file?.taille / ( 1024 * 1024 ) | number : '1.2-2'}} Mo</p>
</div>
</div>
</div>
<hr class="hr-light mb-3 mt-4">
<button class="btn btn-outline-white wow fadeInleft waves-light">Download</button>
<button class="btn btn-outline-white wow fadeInleft waves-light"><a class="text-white" href="{{file?.url}}" download="{{ file?.name.toString()}}">Download</a></button>
</div>
<!--/.Card content-->
</div>

@ -1,15 +1,40 @@
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import {HttpClient} from '@angular/common/http';
@Component({
selector: 'app-download-link',
templateUrl: './download-link.component.html',
styleUrls: ['./download-link.component.scss']
selector: 'app-download-link',
templateUrl: './download-link.component.html',
styleUrls: ['./download-link.component.scss']
})
export class DownloadLinkComponent implements OnInit {
idFile: String;
urlFile: String;
file: any;
constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute) {
this.idFile = '';
this.urlFile = '';
this.route.params.subscribe(params => {
this.idFile = params['id'];
this.urlFile = 'http://localhost:3000/' + this.idFile;
console.log('this.idFile : ' + this.idFile );
this.http.post('/api/getFileById', {id: this.idFile.toString()}).subscribe(file => {
if (file) {
this.file = file[0];
console.log(this.file)
} else {
this.file = [];
}
});
constructor() { }
});
}
ngOnInit() {
}
ngOnInit() {
}
}

@ -73,8 +73,8 @@ export class HomeComponent implements OnInit {
ngOnInit() {
setTimeout(() =>
{
this.showCookies(););
}, 1000);
this.showCookies();
}, 1000); ;
}
}

@ -13,7 +13,7 @@
<!-- Logo -->
<li>
<div class="logo-wrapper flex-center waves-light" style="padding-bottom: 5%">
<a href="#"><img style="height: 90px; margin-left: 13%;"src="../../assets/logo%20supfile.png" class="img-fluid flex-center"></a>
<a href="#"><img style="height: 90px; margin-left: 13%;"src="../../assets/logoSupfile.png" class="img-fluid flex-center"></a>
</div>
</li>
<!--/. Logo -->

Loading…
Cancel
Save