Changeset 993189e
- Timestamp:
- 10/30/20 02:04:06 (4 years ago)
- Branches:
- master
- Children:
- 1f4846d
- Parents:
- 6f203af
- Location:
- Farmatiko/ClientApp/src/app
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/ClientApp/src/app/admin/admin.component.ts
r6f203af r993189e 18 18 public heads: IPharmacyHead[] = []; 19 19 public requests: IPharmacyHeadRequest[] = []; 20 public head: IPharmacyHead; 20 public head: IPharmacyHead = { 21 id: '', 22 PharmacyMedicines: null, 23 Pharmacy: null, 24 Email: '', 25 Passwd: '', 26 Name: '' 27 }; 21 28 22 29 constructor(private dataService: DataService, private dialog: MatDialog, private snackBar: MatSnackBar, private router: Router) { … … 50 57 (err: any) => console.log(err), 51 58 () => console.log("PharmacyHead inserted")); 52 this.head = null; 59 this.head = { 60 id: '', 61 PharmacyMedicines: null, 62 Pharmacy: null, 63 Email: '', 64 Passwd: '', 65 Name: '' 66 }; 53 67 } 54 68 -
Farmatiko/ClientApp/src/app/app.module.ts
r6f203af r993189e 25 25 import { EditPharmacyHeadDialogComponent } from './dialogs/edit-pharmacy-head-dialog/edit-pharmacy-head-dialog.component'; 26 26 import { PharmacyHeadDialogComponent } from './nav-menu/dialogs/pharmacy-head-dialog/pharmacy-head-dialog.component'; 27 import { AuthGuard } from './shared/auth.guard'; 27 28 28 29 @NgModule({ … … 53 54 { path: 'koronavirus', component: KoronaComponent }, 54 55 { path: 'admin', component: AdminComponent }, 55 { path: 'dashboard', component: DashboardComponent }, 56 { path: 'dashboard/:token', component: DashboardComponent }, 56 { path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuard] }, 57 57 { path: 'login', component: LoginComponent } 58 58 ]), -
Farmatiko/ClientApp/src/app/dashboard/dashboard.component.ts
r6f203af r993189e 8 8 import { MedicineDialogComponent } from '../dialogs/medicine-dialog/medicine-dialog.component'; 9 9 import { ActivatedRoute, Router } from '@angular/router'; 10 import { AuthService } from '../shared/auth.service'; 10 11 11 12 @Component({ … … 20 21 public filteredMedicines: IMedicine[] = []; 21 22 public request: IPharmacyHeadRequest; 22 public token: string;23 23 24 constructor(private dataService: DataService, private dialog: MatDialog, private snackBar: MatSnackBar, private router: Router, private route: ActivatedRoute) {24 constructor(private dataService: DataService, private authService: AuthService, private dialog: MatDialog, private snackBar: MatSnackBar, private router: Router, private route: ActivatedRoute) { 25 25 26 26 } 27 27 28 28 ngOnInit(): void { 29 this.token = this.route.snapshot.params['token']; 30 this.dataService.getPharmacyHead(this.token) 31 .subscribe((hd: IPharmacyHead) => { 32 this.head = hd; 33 }, 34 (err: any) => console.log(err), 35 () => console.log('Head data retrieved')); 36 29 this.head = this.authService.headValue; 37 30 this.dataService.getPharmacies() 38 31 .subscribe((pharmacy: IPharmacy[]) => { -
Farmatiko/ClientApp/src/app/korona/korona.component.html
r6f203af r993189e 5 5 <br /> 6 6 <div class="col text-center"> 7 <h2>{{korona [0].name}}</h2>7 <h2>{{korona.name}}</h2> 8 8 <p>статистика</p> 9 9 </div> … … 12 12 <div class="col"> 13 13 <div class="counter" *ngIf="korona"> 14 <i class="fa fa-code fa-2x">{{korona [0].totalMK}}</i>14 <i class="fa fa-code fa-2x">{{korona.totalMK}}</i> 15 15 <h2 class="timer count-title count-number"></h2> 16 16 <p class="count-text ">Вкупно случаи во земјата</p> … … 19 19 <div class="col"> 20 20 <div class="counter" *ngIf="korona"> 21 <i class="fa fa-coffee fa-2x">{{korona [0].activeMK}}</i>21 <i class="fa fa-coffee fa-2x">{{korona.activeMK}}</i> 22 22 <h2 class="timer count-title count-number"></h2> 23 23 <p class="count-text ">Активни случаи во земјата</p> … … 26 26 <div class="col"> 27 27 <div class="counter" *ngIf="korona"> 28 <i class="fa fa-lightbulb-o fa-2x">{{korona [0].deathsMK}}</i>28 <i class="fa fa-lightbulb-o fa-2x">{{korona.deathsMK}}</i> 29 29 <h2 class="timer count-title count-number"></h2> 30 30 <p class="count-text ">Смртни случаи во земјата</p> … … 33 33 <div class="col"> 34 34 <div class="counter" *ngIf="korona"> 35 <i class="fa fa-bug fa-2x">{{korona [0].newMK}}</i>35 <i class="fa fa-bug fa-2x">{{korona.newMK}}</i> 36 36 <h2 class="timer count-title count-number"></h2> 37 37 <p class="count-text ">Нови случаи во земјата</p> … … 42 42 <div class="col"> 43 43 <div class="counter" *ngIf="korona"> 44 <i class="fa fa-bug fa-2x">{{korona [0].totalGlobal}}</i>44 <i class="fa fa-bug fa-2x">{{korona.totalGlobal}}</i> 45 45 <h2 class="timer count-title count-number"></h2> 46 46 <p class="count-text ">Вкупно случаи глобално</p> … … 49 49 <div class="col"> 50 50 <div class="counter" *ngIf="korona"> 51 <i class="fa fa-bug fa-2x">{{korona [0].activeGlobal}}</i>51 <i class="fa fa-bug fa-2x">{{korona.activeGlobal}}</i> 52 52 <h2 class="timer count-title count-number"></h2> 53 53 <p class="count-text ">Активни случаи глобално</p> … … 56 56 <div class="col"> 57 57 <div class="counter" *ngIf="korona"> 58 <i class="fa fa-bug fa-2x">{{korona [0].deathsGlobal}}</i>58 <i class="fa fa-bug fa-2x">{{korona.deathsGlobal}}</i> 59 59 <h2 class="timer count-title count-number"></h2> 60 60 <p class="count-text ">Смртни случаи глобално</p> -
Farmatiko/ClientApp/src/app/korona/korona.component.ts
r6f203af r993189e 9 9 }) 10 10 export class KoronaComponent implements OnInit { 11 public korona: IPandemic [];11 public korona: IPandemic; 12 12 13 13 constructor(private dataService: DataService) { … … 17 17 ngOnInit(): void { 18 18 this.dataService.getPandemic() 19 .subscribe((res: IPandemic []) => {19 .subscribe((res: IPandemic) => { 20 20 this.korona = res; 21 21 console.log(this.korona); -
Farmatiko/ClientApp/src/app/login/login.component.ts
r6f203af r993189e 2 2 import { FormGroup, FormControl, Validators } from '@angular/forms'; 3 3 import { Router, ActivatedRoute } from '@angular/router'; 4 import { DataService } from '../shared/data.service'; 4 import { first } from 'rxjs/operators'; 5 import { AuthService } from '../shared/auth.service'; 5 6 6 7 @Component({ … … 15 16 errorMessage: string; 16 17 17 constructor(private dataService: DataService,private router: Router, private route: ActivatedRoute) {18 constructor(private authService: AuthService,private router: Router, private route: ActivatedRoute) { 18 19 this.loginForm = new FormGroup({ 19 20 email: new FormControl('', [Validators.required, Validators.email]), … … 26 27 27 28 loginPharmacyHead() { 28 this.dataService.loginPharmacyHead(this.email, this.passwd) 29 .subscribe((id: Number) => { 30 if(id) { 31 this.router.navigate(['/dashboard/' + id]); 32 } 33 else { 34 this.errorMessage = 'There was a problem signing in!'; 35 console.log(this.errorMessage); 36 } 37 }, 38 (err: any) => console.log(err)); 29 this.authService.login(this.email,this.passwd) 30 .pipe(first()) 31 .subscribe((data) => { 32 if(data) { 33 this.router.navigate(['/dashboard']); 34 }}, 35 (err: any) => { 36 this.errorMessage = err.toString(); 37 }); 38 this.loginForm.reset(); 39 39 } 40 40 } -
Farmatiko/ClientApp/src/app/shared/data.service.ts
r6f203af r993189e 1 import { Injectable ,} from '@angular/core';1 import { Injectable } from '@angular/core'; 2 2 import { HttpClient, HttpErrorResponse } from '@angular/common/http'; 3 3 … … 95 95 96 96 97 getPandemic() : Observable<IPandemic []> {98 return this.http.get<IPandemic []>(this.basePandemicUrl)97 getPandemic() : Observable<IPandemic> { 98 return this.http.get<IPandemic>(this.basePandemicUrl) 99 99 .pipe(catchError(this.handleError)); 100 100 } … … 143 143 catchError(this.handleError) 144 144 ); 145 }146 loginPharmacyHead(email: string, passwd: string) : Observable<any> {147 let postData = {email : email ,password :passwd};148 return this.http.post<any>(this.basePharmacyHead + '/login', postData)149 .pipe(150 map((data) => {151 return data;152 }),153 catchError(this.handleError)154 );155 }156 getPharmacyHead(id: string) : Observable<IPharmacyHead> {157 return this.http.get<IPharmacyHead>(this.basePharmacyHead + '/' + id)158 .pipe(catchError(this.handleError));159 145 } 160 146 //PharmacyHead POST -
Farmatiko/ClientApp/src/app/shared/interfaces.ts
r6f203af r993189e 29 29 30 30 export interface IPandemic { 31 id?: string; 31 32 name?: string; 32 33 totalMK?: number;
Note:
See TracChangeset
for help on using the changeset viewer.