desgin prototype v1

anis
Anis Vicious 6 years ago
parent eb4a5e2e5b
commit 5b4595a032

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 KiB

@ -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: [

@ -1,54 +1,47 @@
<div class="container">
<h1>File Listttt <button class="btn btn-success" (click)="logout()">Logout</button></h1>
<table class="table">
<div class="container-fluid">
<label class="btn btn-danger col-sm-2 col-md-2" >
Fichier à ajouter<input type="file" style="display: none;" #myPicture name="myPicture" (change)="fileChangeEvent($event)">
</label>
<button type="button" class="btn btn-warning" (click)="upload()">Ajouter le fichier {{fileChooseName}}</button>
<label> Vous avez choisi : {{fileChooseName}}</label>
</div>
<table class="table table-striped">
<thead>
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Author</th>
<th>Publisher</th>
<th>#</th>
<th>Nom</th>
<th>Taille</th>
<th>Type</th>
<th>Date d'ajout</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let book of books">
<td>{{ book.isbn }}</td>
<td>{{ book.title }}</td>
<td>{{ book.author }}</td>
<td>{{ book.publisher }}</td>
<tr *ngFor="let file of allUserFile; let i = index;">
<th scope="row">{{ i + 1 }}</th>
<td>{{ file.name }}</td>
<td>{{ file.taille / ( 1024 * 1024 ) | number : '1.2-2'}} Mo</td>
<td>{{ file.extention }}</td>
<td>{{ file.path }}</td>
</tr>
</tbody>
</table>
</div>
<h1>
Hey here, Upload a file here
</h1>
<label class="btn btn-info col-sm-2 col-md-2" >
Fichier à ajouter<input type="file" style="display: none;" #myPicture name="myPicture" (change)="fileChangeEvent($event)">
</label>
<img src="../../../public/23460.jpg" class="img-fluid flex-center">
<button type="button" class="btn btn-success" (click)="upload()">Ajouter le fichier {{fileChooseName}}</button>
<h3> Vous avez choisi : {{fileChooseName}}</h3>
<!--
<form enctype="multipart/form-data" method="post" name="fileinfo">
<label>Fichier à mettre de côté :</label>
<input type="file" name="file" (change)="fileChangeEvent($event)" required />
<input type="submit" (click)="upload2()" value="Mettez le fichier de côté." />
</form>
<div></div>
-->
<div *ngIf="allUserFile">
Votre <strong>liste de fichier</strong> ci-dessous:
<li *ngFor="let file of allUserFile">
nom : {{ file.name }} / owner: {{ file.owner }} / path : {{ file.path }}
<!--<img src="../../../public/GOPR0034.jpg">-->
</li>
</div>
<!--
<form enctype="multipart/form-data" method="post" name="fileinfo">
<label>Fichier à mettre de côté :</label>
<input type="file" name="file" (change)="fileChangeEvent($event)" required />
<input type="submit" (click)="upload2()" value="Mettez le fichier de côté." />
</form>
<div></div>
-->

@ -20,7 +20,7 @@ export class BookComponent implements OnInit, OnDestroy {
filesToUpload: Array<File>;
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;

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

@ -0,0 +1,144 @@
<body class="grey-skin">
<!--Double navigation-->
<header>
<!-- Sidebar navigation -->
<mdb-sidenav #sidenav class="sn-bg-1 fixed" [fixed]="true">
<logo>
<!-- Logo -->
<li>
<div class="logo-wrapper waves-light">
<a href="#"><img style="height: 90px; margin-left: 13%;"src="https://openclipart.org/image/2400px/svg_to_png/190248/slogonormal.png" class="img-fluid flex-center"></a>
</div>
</li>
<!--/. Logo -->
</logo>
<links>
<!--Social-->
<li>
<ul class="social">
<li><a class="icons-sm fb-ic"><i class="fa fa-facebook"> </i></a></li>
<li><a class="icons-sm pin-ic"><i class="fa fa-pinterest"> </i></a></li>
<li><a class="icons-sm gplus-ic"><i class="fa fa-google-plus"> </i></a></li>
<li><a class="icons-sm tw-ic"><i class="fa fa-twitter"> </i></a></li>
</ul>
</li>
<!--/Social-->
<!--Search Form-->
<li>
<form class="search-form" role="search">
<div class="form-group md-form mt-0 pt-1 waves-light" mdbWavesEffect>
<input type="text" class="form-control" placeholder="Search">
</div>
</form>
</li>
<!--/.Search Form-->
<!-- Side navigation links -->
<li>
<ul class="collapsible collapsible-accordion">
<mdb-squeezebox [multiple]="false" aria-multiselectable="false">
<!-- Collapsible link -->
<mdb-item>
<mdb-item-head mdbWavesEffect><i class="fa fa-chevron-right"></i> Collapsible menu</mdb-item-head>
<mdb-item-body>
<ul>
<li><a href="#" class="waves-effect" mdbWavesEffect>Link 1</a></li>
<li><a href="#" class="waves-effect" mdbWavesEffect>Link 2</a></li>
</ul>
</mdb-item-body>
</mdb-item>
<!-- Simple link -->
<mdb-item class="no-collase">
<mdb-item-head mdbWavesEffect><i class="fa fa-hand-pointer-o"></i> Simple link</mdb-item-head>
<mdb-item-body></mdb-item-body>
</mdb-item>
<!-- Collapsible link -->
<mdb-item>
<mdb-item-head mdbWavesEffect><i class="fa fa-eye"></i> Collapsible menu 2</mdb-item-head>
<mdb-item-body>
<ul>
<li><a href="#" class="waves-effect" mdbWavesEffect>Link 1</a></li>
<li><a href="#" class="waves-effect" mdbWavesEffect>Link 2</a></li>
</ul>
</mdb-item-body>
</mdb-item>
<!-- Simple link -->
<mdb-item class="no-collase">
<mdb-item-head mdbWavesEffect><i class="fa fa-diamond"></i> Simple link 2</mdb-item-head>
<mdb-item-body></mdb-item-body>
</mdb-item>
</mdb-squeezebox>
</ul>
</li>
<!--/. Side navigation links -->
</links>
<div class="sidenav-bg mask-strong"></div>
</mdb-sidenav>
<!--/. Sidebar navigation -->
<!-- Navbar -->
<mdb-navbar SideClass="navbar fixed-top navbar-toggleable-md navbar-expand-lg scrolling-navbar double-nav" [containerInside]="false">
<navlinks class="navbar-container">
<!-- SideNav slide-out button -->
<div class="float-left">
<a (click)="sidenav.show()" class="button-collapse"><i class="fa fa-bars"></i></a>
</div>
<!--/. SideNav slide-out button -->
</navlinks>
<logo>
<!-- Breadcrumb-->
<div class="breadcrumbs breadcrumb-dn mr-auto">
<p>Welcome</p>
</div>
<!--/. Breadcrumb-->
</logo>
<navlinks>
<ul class="nav navbar-nav nav-flex-icons ml-auto ie-double-nav">
<li class="nav-item">
<a class="nav-link waves-light" mdbWavesEffect><i class="fa fa-envelope"></i> <span class="clearfix d-none d-sm-inline-block">Contact</span></a>
</li>
<li class="nav-item">
<a class="nav-link waves-light" mdbWavesEffect><i class="fa fa-user"></i> <span class="clearfix d-none d-sm-inline-block">Account</span></a>
</li>
<li class="nav-item" (click)="logout()">
<a class="nav-link waves-light" mdbWavesEffect><i class="fa fa-sign-out mr-1"></i> <span class="clearfix d-none d-sm-inline-block">Log out</span></a>
</li>
<!--<li class="nav-item dropdown btn-group" dropdown>-->
<!--<a dropdownToggle type="button" class="nav-link dropdown-toggle waves-light" mdbWavesEffect>-->
<!--Dropdown-->
<!--</a>-->
<!--<div class="dropdown-menu dropdown-primary dropdown-menu-right" role="menu">-->
<!--<a class="dropdown-item" href="#">Action</a>-->
<!--<a class="dropdown-item" href="#">Another action</a>-->
<!--<a class="dropdown-item" href="#">Something else here</a>-->
<!--</div>-->
<!--</li>-->
</ul>
</navlinks>
</mdb-navbar>
<!--/. Navbar -->
</header>
<!--/.Double navigation-->
<!--Main Layout-->
<main style="margin-left: 0%; margin-right: 0%;">
<div class="container-fluid" style="margin:0%; padding: 0%">
<app-book></app-book>
</div>
</main>
<!--/Main layout-->

@ -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<MainComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MainComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(MainComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -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() {
}
}
Loading…
Cancel
Save