profiles-admin.component.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { Router } from '@angular/router';
  2. import { ProfilesResponse, ProfileResponse } from './../../../interfaces/profiles.interface';
  3. import { UsersProfilesService } from './../../../services/users-profiles.service';
  4. import { Component, OnInit } from '@angular/core';
  5. @Component({
  6. selector: 'app-profiles-admin',
  7. templateUrl: './profiles-admin.component.html',
  8. styleUrls: ['./profiles-admin.component.css']
  9. })
  10. export class ProfilesAdminComponent implements OnInit {
  11. isLoading: boolean;
  12. hasError: boolean;
  13. errorStr: string;
  14. profiles: Array<ProfileResponse>;
  15. profilesFinded: Array<ProfileResponse>;
  16. searching: boolean;
  17. constructor(private usersProfilesService: UsersProfilesService, private router: Router) {
  18. this.isLoading = true;
  19. this.hasError = false;
  20. this.errorStr = "";
  21. this.profiles = [];
  22. this.profilesFinded = [];
  23. this.searching = false;
  24. }
  25. ngOnInit(): void {
  26. this.usersProfilesService.getProfiles().subscribe((data: ProfilesResponse) => {
  27. this.isLoading = false;
  28. this.hasError = data.error;
  29. this.errorStr = data.msg;
  30. if(!this.hasError){
  31. this.profiles = data.response;
  32. this.profilesFinded = this.profiles;
  33. }
  34. }, error => {
  35. this.isLoading = false;
  36. this.hasError = true;
  37. this.errorStr = error.error.msg;
  38. });
  39. }
  40. search(value: string){}
  41. clearSearch(){}
  42. openPermissions(profile: number, profileName: string, action: string){
  43. this.router.navigate(['permissions'], {
  44. queryParams: {
  45. profile: profile,
  46. profileName: profileName,
  47. action: action
  48. }
  49. });
  50. }
  51. }