-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AdminGuard Global Search
- Loading branch information
Showing
16 changed files
with
500 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router'; | ||
import { Observable } from 'rxjs'; | ||
import { UsersService } from '../services/users.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class AdminGuard implements CanActivate { | ||
constructor( | ||
private usersService: UsersService, | ||
private router: Router | ||
) {} | ||
canActivate( | ||
next: ActivatedRouteSnapshot, | ||
state: RouterStateSnapshot): boolean { | ||
console.log('AdminGuard'); | ||
if(this.usersService.role === 'ADMIN_ROLE') { | ||
return true | ||
} else { | ||
this.router.navigateByUrl('/dashboard'); | ||
return false; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<div class="row animated fadeIn fast"> | ||
<div class="col-4"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h3>Users</h3> | ||
|
||
<div class="alert alert-info" *ngIf="users.length === 0"> | ||
<p class="md-o">There are no users with that value</p> | ||
</div> | ||
|
||
<div class="table-responsive" *ngIf="users.length > 0"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Avatar</th> | ||
<th>Name</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let item of users" class="animated fadeIn fast"> | ||
<td> | ||
<img class="img-avatar w75 h75" | ||
[src]="item.img | image:'users'" | ||
alt="Avatar"> | ||
</td> | ||
<td>{{item.name}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="col-4"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h3>Doctors</h3> | ||
|
||
<div class="alert alert-info" *ngIf="doctors.length === 0"> | ||
<p class="md-o">There are no doctors with that value</p> | ||
</div> | ||
|
||
<div class="table-responsive" *ngIf="doctors.length > 0"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Avatar</th> | ||
<th>Name</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let item of doctors" class="animated fadeIn fast"> | ||
<td> | ||
<img class="img-avatar w75 h75" | ||
[src]="item.img | image:'doctors'" | ||
alt="Avatar"> | ||
</td> | ||
<td> | ||
<a [routerLink]="['/dashboard/doctors', item._id]">{{item.name}}</a> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="col-4"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h3>Hospitals</h3> | ||
|
||
<div class="alert alert-info" *ngIf="hospitals.length === 0"> | ||
<p class="md-o">There are no hospitals with that value</p> | ||
</div> | ||
|
||
<div class="table-responsive" *ngIf="hospitals.length > 0"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Avatar</th> | ||
<th>Name</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let item of hospitals" | ||
class="animated fadeIn fast"> | ||
<td> | ||
<img class="img-avatar w75 h75" | ||
[src]="item.img | image:'hospitals'" | ||
alt="Avatar"> | ||
</td> | ||
<td>{{item.name}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
import { Doctors } from 'src/app/models/doctors.model'; | ||
import { Hospitals } from 'src/app/models/hospitals.model'; | ||
import { Users } from 'src/app/models/users.model'; | ||
import { SearchingService } from 'src/app/services/searching.service'; | ||
|
||
@Component({ | ||
selector: 'app-search', | ||
templateUrl: './search.component.html', | ||
styles: [] | ||
}) | ||
export class SearchComponent implements OnInit { | ||
public users: Users[] = []; | ||
public hospitals: Hospitals[] = []; | ||
public doctors: Doctors[] = []; | ||
|
||
constructor( | ||
private router: Router, | ||
private activateRoute: ActivatedRoute, | ||
private searchingService: SearchingService | ||
) { } | ||
|
||
ngOnInit() { | ||
this.activateRoute.params | ||
.subscribe(({value}) => { | ||
this.search(value); | ||
}) | ||
} | ||
|
||
search(value:string) { | ||
this.searchingService.searchAll(value) | ||
.subscribe((resp:any) => { | ||
console.log('resp==>', resp); | ||
this.users = resp.users; | ||
this.hospitals = resp.hospitals; | ||
this.doctors = resp.doctors; | ||
}); | ||
} | ||
|
||
openDoctor(doctor: Doctors) { | ||
this.router.navigateByUrl(`/dashboard/doctors/${doctor._id}`); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.