|
- import { Component, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
- import { Subscription } from 'rxjs';
- import { LoanEditComponent } from './loan-edit/loan-edit.component';
-
- import { mainMenuItems } from './main-menu-items';
- import { AuthService } from './service/auth.service';
- import { MenuService } from './service/menu.service';
-
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.scss'],
- encapsulation: ViewEncapsulation.None
- })
- export class AppComponent implements OnInit , OnDestroy {
- title = 'SFM broker';
- public login :boolean = false;
- public items: any[] = mainMenuItems;
- kendokaAvatar = "./assets/img/avatar.png"
- @ViewChild('loanEditComponent', {static: true}) loanEdit: LoanEditComponent;
-
- private loginSub: Subscription;
-
- constructor(private menuService: MenuService, private authService: AuthService){
- }
-
- //check menuItem has fontawesome
- public menuItemHasFontawesome (item: any) : boolean {
- return item.hasOwnProperty('fa');
- }
-
- //menuItem clicked
- public onSelect({ item }): void {
- if (!item.items) {
- this.menuService.itemClicked.emit(item);
- //console.log("emit on select : " + item.text);
- if ( item.popup == "loanEdit"){
- this.loanEdit.somedata = "" + Math.random() + "changed";
- this.loanEdit.open('dialog');
- }
-
- if (item.text == "Logout"){
- this.authService.logout();
- this.login = false;
- //this.authService.loginSuccess.emit("loggedout");
- }
- }
- }
-
- ngOnInit (){
- this.loginSub = this.authService.loginSuccess.subscribe(
- (success: boolean) => {
- this.login = success;
- }
- )
- }
-
- ngOnDestroy (){
- this.loginSub.unsubscribe();
- }
-
- }
|