Changeset ad60966


Ignore:
Timestamp:
11/05/20 08:53:48 (4 years ago)
Author:
Mile Jankuloski <mile.jankuloski@…>
Branches:
master
Children:
1db5673
Parents:
afc9a9a
Message:

Auth fixes, bug fixes etc.

Location:
Farmatiko/ClientApp/src/app
Files:
1 added
1 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • Farmatiko/ClientApp/src/app/admin/admin.component.ts

    rafc9a9a rad60966  
    44import { Router } from '@angular/router';
    55import { IPharmacyHead, IPharmacyHeadRequest, IPharmacy } from '../shared/interfaces';
    6 import { DataService } from '../shared/services/data.service';
     6import { DataService } from '../shared/data.service';
    77import { EditPharmacyHeadDialogComponent } from '../dialogs/edit-pharmacy-head-dialog/edit-pharmacy-head-dialog.component';
    88import { PharmacyDialogComponent } from '../dialogs/pharmacy-dialog/pharmacy-dialog.component';
  • Farmatiko/ClientApp/src/app/app.module.ts

    rafc9a9a rad60966  
    1010
    1111import { AuthGuard } from './shared/guards/auth.guard';
    12 import { DataService } from './shared/services/data.service';
     12import { DataService } from './shared/data.service';
    1313import { AppComponent } from './app.component';
    1414import { NavMenuComponent } from './nav-menu/nav-menu.component';
  • Farmatiko/ClientApp/src/app/counter/counter.component.ts

    rafc9a9a rad60966  
    11import { Component, OnInit } from '@angular/core';
    22import { IHealthFacilities, IHealthcareWorkers } from '../shared/interfaces';
    3 import { DataService } from '../shared/services/data.service';
     3import { DataService } from '../shared/data.service';
    44import { MatDialog } from '@angular/material/dialog';
    55import { FacilityDialogComponent } from '../dialogs/facility-dialog/facility-dialog.component';
  • Farmatiko/ClientApp/src/app/dashboard/dashboard.component.html

    rafc9a9a rad60966  
    1212        <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
    1313          <ul class="navbar-nav flex-grow">
    14             <li>Logged as ...<p *ngIf="head">{{head.Name}}</p> </li>
     14            <li>Logged as <p *ngIf="head">{{head.Name}}</p> </li>
     15            <li (click)="logout()" class="btn btn-link"><a>Logout</a></li>
    1516          </ul>
    1617        </div>
  • Farmatiko/ClientApp/src/app/dashboard/dashboard.component.ts

    rafc9a9a rad60966  
    33import { MatSnackBar, MatSnackBarRef, SimpleSnackBar } from '@angular/material/snack-bar';
    44import { IPharmacy, IMedicine, IPharmacyHead, IPharmacyHeadRequest } from '../shared/interfaces';
    5 import { DataService } from '../shared/services/data.service';
     5import { DataService } from '../shared/data.service';
    66import { PharmacyDialogComponent } from '../dialogs/pharmacy-dialog/pharmacy-dialog.component';
    77import { EditPharmacyDialogComponent } from '../dialogs/edit-pharmacy-dialog/edit-pharmacy-dialog.component';
     
    2727
    2828  ngOnInit(): void {
    29     this.authService.getUser().subscribe((data : IPharmacyHead) => {
    30         this.head = data;
    31     });
     29    this.authService.getUser()
     30        .subscribe((data) => {
     31          console.log(data);
     32          this.head = data;
     33        },
     34        (err: any) => console.log(err),
     35        () => console.log('User data retrieved'));
    3236    this.dataService.getPharmacies()
    3337        .subscribe((pharmacy: IPharmacy[]) => {
     
    102106  }
    103107
     108  logout() {
     109    this.authService.logout();
     110  }
     111
    104112  openPharmacyDialog(pharmacy: IPharmacy): void {
    105113    this.dialog.open(PharmacyDialogComponent, {
  • Farmatiko/ClientApp/src/app/home/home.component.ts

    rafc9a9a rad60966  
    11import { Component, OnInit } from '@angular/core';
    22import { IMedicine, IPharmacy } from '../shared/interfaces';
    3 import { DataService } from '../shared/services/data.service';
     3import { DataService } from '../shared/data.service';
    44import { MatDialog } from '@angular/material/dialog';
    55import { MedicineDialogComponent } from '../dialogs/medicine-dialog/medicine-dialog.component';
  • Farmatiko/ClientApp/src/app/korona/korona.component.ts

    rafc9a9a rad60966  
    11import { Component, OnInit } from '@angular/core';
    2 import { DataService } from '../shared/services/data.service';
     2import { DataService } from '../shared/data.service';
    33import { IPandemic } from '../shared/interfaces';
    44
  • Farmatiko/ClientApp/src/app/login/login.component.ts

    rafc9a9a rad60966  
    5353      .pipe(finalize(() => (this.busy = false)))
    5454      .subscribe(
    55         () => {
    56           this.router.navigate(['/dashboard']);
     55        (data) => {
     56          if(data.role == 'Admin') {
     57            this.router.navigate(['/admin']);
     58          }
     59          else {
     60            this.router.navigate(['/dashboard']);
     61          }
    5762        },
    5863        () => {
  • Farmatiko/ClientApp/src/app/shared/data.service.ts

    rafc9a9a rad60966  
    9595
    9696
    97     getPandemic() : Observable<IPandemic[]> {
    98         return this.http.get<IPandemic[]>(this.basePandemicUrl)
     97    getPandemic() : Observable<IPandemic> {
     98        return this.http.get<IPandemic>(this.basePandemicUrl)
    9999                   .pipe(catchError(this.handleError));
    100100    }
  • Farmatiko/ClientApp/src/app/shared/interceptors/jwt.interceptor.ts

    rafc9a9a rad60966  
    77} from '@angular/common/http';
    88import { Observable } from 'rxjs';
     9import { environment } from '../../../environments/environment';
    910import { AuthService } from '../services/auth.service';
    10 import { environment } from '../../../environments/environment';
    1111
    1212@Injectable()
  • Farmatiko/ClientApp/src/app/shared/interfaces.ts

    rafc9a9a rad60966  
    5353    Pharmacy?: IPharmacy[];
    5454    Email: string;
     55    Name: string;
    5556    Passwd: string;
    56     Name: string;
    5757    originalUserName?: string;
    5858    Role?: string;
  • Farmatiko/ClientApp/src/app/shared/services/auth.service.ts

    rafc9a9a rad60966  
    3636        this.http.get<LoginResult>(`${this.apiUrl}/user`).subscribe((x) => {
    3737          this._user.next({
    38             Email: x.head.Email,
    39             Role: x.head.Role,
    40             originalUserName: x.head.originalUserName,
     38            Email: x.username,
    4139            Passwd: x.head.Passwd,
     40            Role: x.role,
     41            originalUserName: x.originalUserName,
    4242            Name: x.head.Name,
    4343            PharmacyMedicines: x.head.PharmacyMedicines,
     
    6464        map((x) => {
    6565          this._user.next({
    66             Email: x.head.Email,
    67             Role: x.head.Role,
    68             originalUserName: x.head.originalUserName,
     66            Email: x.username,
    6967            Passwd: x.head.Passwd,
     68            Role: x.role,
     69            originalUserName: x.originalUserName,
    7070            Name: x.head.Name,
    7171            PharmacyMedicines: x.head.PharmacyMedicines,
     
    105105        map((x) => {
    106106          this._user.next({
    107             Email: x.head.Email,
    108             Role: x.head.Role,
    109             originalUserName: x.head.originalUserName,
     107            Email: x.username,
    110108            Passwd: x.head.Passwd,
     109            Role: x.role,
     110            originalUserName: x.originalUserName,
    111111            Name: x.head.Name,
    112112            PharmacyMedicines: x.head.PharmacyMedicines,
Note: See TracChangeset for help on using the changeset viewer.