diff --git a/public/23460.jpg b/public/23460.jpg deleted file mode 100644 index 0604e79..0000000 Binary files a/public/23460.jpg and /dev/null differ diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 9c94e00..43325a1 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -16,10 +16,16 @@ import { SignupComponent } from './signup/signup.component'; import { BookComponent } from './book/book.component'; import { RouterModule, Routes } from '@angular/router'; +import { MainComponent } from './main/main.component'; const appRoutes: Routes = [ { - path: 'books/:tokenFromLogin', + path: 'main', + component: MainComponent, + data: { title: 'Home Main' } + }, + { + path: 'books', component: BookComponent, data: { title: 'Book List' } }, @@ -44,6 +50,7 @@ const appRoutes: Routes = [ AppComponent, LoginComponent, SignupComponent, + MainComponent, BookComponent ], imports: [ diff --git a/src/app/book/book.component.html b/src/app/book/book.component.html index 82cf781..1452cc9 100644 --- a/src/app/book/book.component.html +++ b/src/app/book/book.component.html @@ -1,54 +1,47 @@ -
-

File Listttt

- +
+ + + + + + +
+
- - - - + + + + + - - - - - + + + + + + +
ISBNTitleAuthorPublisher#NomTailleTypeDate d'ajout
{{ book.isbn }}{{ book.title }}{{ book.author }}{{ book.publisher }}
{{ i + 1 }}{{ file.name }}{{ file.taille / ( 1024 * 1024 ) | number : '1.2-2'}} Mo{{ file.extention }}{{ file.path }}
-
- - - -

- Hey here, Upload a file here -

- + - -

Vous avez choisi : {{fileChooseName}}

+ -
- Votre liste de fichier ci-dessous: -
  • - nom : {{ file.name }} / owner: {{ file.owner }} / path : {{ file.path }} - -
  • -
    - diff --git a/src/app/book/book.component.ts b/src/app/book/book.component.ts index 6f9b66f..30bcdca 100644 --- a/src/app/book/book.component.ts +++ b/src/app/book/book.component.ts @@ -20,7 +20,7 @@ export class BookComponent implements OnInit, OnDestroy { filesToUpload: Array; fileChooseName: string; httpOptions: any; - tokenFromLogin: any; + // tokenFromLogin: any; constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute) { this.fileChooseName = 'None'; @@ -30,7 +30,7 @@ export class BookComponent implements OnInit, OnDestroy { ngOnInit() { this.route.params.subscribe(params => { - this.tokenFromLogin = params['tokenFromLogin']; + // this.tokenFromLogin = params['tokenFromLogin']; this.httpOptions = { headers: new HttpHeaders({ 'Authorization': localStorage.getItem('jwtToken') }) @@ -44,22 +44,23 @@ export class BookComponent implements OnInit, OnDestroy { this.router.navigate(['login']); } }); + }); + this.getfile(); + } + getfile() { this.http.get('/api/allUserFile', this.httpOptions).subscribe(files => { - this.allUserFile = files; - console.log('mothafuka cureent user : ' + JSON.stringify(this.allUserFile)); + this.allUserFile = files; + console.log('mothafuka cureent user : ' + JSON.stringify(this.allUserFile)); }, err => { - if (err.status === 401) { - this.router.navigate(['login']); - } + if (err.status === 401) { + this.router.navigate(['login']); + } }); - }); - - } ngOnDestroy() { localStorage.removeItem('jwtToken'); - this.tokenFromLogin = ''; + // this.tokenFromLogin = ''; this.httpOptions = null; this.currentUser = null; } @@ -77,6 +78,7 @@ export class BookComponent implements OnInit, OnDestroy { if(this.currentUser.username) this.http.post('api/uploadFileMongo', { name: result[0].filename.toString(), path: result[0].path.toString(), extention: this.filesToUpload[0].type.toString(), taille: this.filesToUpload[0].size.toString(), idUser: this.currentUser._id.toString(), owner: this.currentUser.username.toString() }).subscribe(resp => { console.log('ok db !!' + resp.toString()); + this.getfile(); }, err => { console.log('errrrr : ' + err); message = err.error.msg; diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index 07898e2..4f97a07 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -17,10 +17,10 @@ export class LoginComponent implements OnInit { constructor(private http: HttpClient, private router: Router) { } login() { - this.http.post('/api/signin',this.loginData).subscribe(resp => { + this.http.post('/api/signin', this.loginData).subscribe(resp => { this.data = resp; localStorage.setItem('jwtToken', this.data.token); - this.router.navigate(['books', this.data.token]); + this.router.navigate(['main']); }, err => { this.message = err.error.msg; }); diff --git a/src/app/main/main.component.html b/src/app/main/main.component.html new file mode 100644 index 0000000..b350571 --- /dev/null +++ b/src/app/main/main.component.html @@ -0,0 +1,144 @@ + + + + +
    + + + + + + +
  • +
    + +
    +
  • + +
    + + + +
  • + +
  • + + +
  • + +
  • + + +
  • +
      + + + + + Collapsible menu + + + + + + + + Simple link + + + + + + Collapsible menu 2 + + + + + + + + Simple link 2 + + + + +
    +
  • + +
    +
    +
    + + + + + + + +
    + +
    + +
    + + + + + + + + + + +
    + + +
    + + + +
    +
    + +
    + + +
    + diff --git a/src/app/main/main.component.scss b/src/app/main/main.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/main/main.component.spec.ts b/src/app/main/main.component.spec.ts new file mode 100644 index 0000000..0878044 --- /dev/null +++ b/src/app/main/main.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MainComponent } from './main.component'; + +describe('MainComponent', () => { + let component: MainComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MainComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MainComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts new file mode 100644 index 0000000..54878e2 --- /dev/null +++ b/src/app/main/main.component.ts @@ -0,0 +1,21 @@ +import { Component, OnInit } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; + +@Component({ + selector: 'app-main', + templateUrl: './main.component.html', + styleUrls: ['./main.component.scss'] +}) +export class MainComponent implements OnInit { + + constructor(private router: Router, private route: ActivatedRoute) { } + + logout() { + localStorage.removeItem('jwtToken'); + this.router.navigate(['login']); + } + + ngOnInit() { + } + +}