Broker System for Supercredit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.7KB

  1. import { Component, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
  2. import { Subscription } from 'rxjs';
  3. import { LoanEditComponent } from './loan-edit/loan-edit.component';
  4. import { mainMenuItems } from './main-menu-items';
  5. import { AuthService } from './service/auth.service';
  6. import { MenuService } from './service/menu.service';
  7. @Component({
  8. selector: 'app-root',
  9. templateUrl: './app.component.html',
  10. styleUrls: ['./app.component.scss'],
  11. encapsulation: ViewEncapsulation.None
  12. })
  13. export class AppComponent implements OnInit , OnDestroy {
  14. title = 'SFM broker';
  15. public login :boolean = false;
  16. public items: any[] = mainMenuItems;
  17. kendokaAvatar = "./assets/img/avatar.png"
  18. @ViewChild('loanEditComponent', {static: true}) loanEdit: LoanEditComponent;
  19. private loginSub: Subscription;
  20. constructor(private menuService: MenuService, private authService: AuthService){
  21. }
  22. //check menuItem has fontawesome
  23. public menuItemHasFontawesome (item: any) : boolean {
  24. return item.hasOwnProperty('fa');
  25. }
  26. //menuItem clicked
  27. public onSelect({ item }): void {
  28. if (!item.items) {
  29. this.menuService.itemClicked.emit(item);
  30. //console.log("emit on select : " + item.text);
  31. if ( item.popup == "loanEdit"){
  32. this.loanEdit.somedata = "" + Math.random() + "changed";
  33. this.loanEdit.open('dialog');
  34. }
  35. if (item.text == "Logout"){
  36. this.authService.logout();
  37. this.login = false;
  38. //this.authService.loginSuccess.emit("loggedout");
  39. }
  40. }
  41. }
  42. ngOnInit (){
  43. this.loginSub = this.authService.loginSuccess.subscribe(
  44. (success: boolean) => {
  45. this.login = success;
  46. }
  47. )
  48. }
  49. ngOnDestroy (){
  50. this.loginSub.unsubscribe();
  51. }
  52. }