| @@ -1,13 +1,12 @@ | |||
| import { Component, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; | |||
| import { Subscription } from 'rxjs'; | |||
| import { LoanEditComponent } from './loan-edit/loan-edit.component'; | |||
| import { AuthService } from './service/auth.service'; | |||
| import { MenuService } from './service/menu.service'; | |||
| import {WebSocketService} from './websocket'; | |||
| import {AppConfig} from './app.config'; | |||
| import {Title} from '@angular/platform-browser'; | |||
| import {WsLoginEventModel} from './models/websocket/ws.login.event.model'; | |||
| import {SessionService} from './service/session.service'; | |||
| @Component({ | |||
| selector: 'app-root', | |||
| @@ -25,7 +24,7 @@ export class AppComponent implements OnInit , OnDestroy { | |||
| constructor(private menuService: MenuService, | |||
| private authService: AuthService, | |||
| private config: AppConfig, | |||
| private ss: SessionService, | |||
| private wsService: WebSocketService, | |||
| private titleService: Title){ | |||
| this.webSocketSubscription = wsService.subscribe(m => { | |||
| @@ -33,7 +32,7 @@ export class AppComponent implements OnInit , OnDestroy { | |||
| }); | |||
| this.wsLoginSub = this.wsService.LoginEvent.subscribe( m => { | |||
| console.log('login event ', m); | |||
| this.onWSLogin(m); | |||
| }); | |||
| this.titleService.setTitle(this.title); | |||
| @@ -48,15 +47,12 @@ export class AppComponent implements OnInit , OnDestroy { | |||
| listenToMenuEvent(): void { | |||
| this.menuItemSub = this.menuService.itemClicked.subscribe( | |||
| (item:any) =>{ | |||
| (item: any) => { | |||
| // console.log("emit on select : " + item.text); | |||
| if ( item.popup === 'loanEdit'){ | |||
| // this.loanEdit.somedata = '' + Math.random() + 'changed'; | |||
| // this.loanEdit.open('dialog'); | |||
| } | |||
| } | |||
| ); | |||
| } | |||
| ngOnDestroy(): void { | |||
| @@ -64,4 +60,12 @@ export class AppComponent implements OnInit , OnDestroy { | |||
| this.wsLoginSub.unsubscribe(); | |||
| } | |||
| onWSLogin(e: WsLoginEventModel): void { | |||
| if ( e.Mid === this.ss.loggedIn.machineId && e.Sid === this.ss.loggedIn.session ){ | |||
| if ( e.Uid !== this.ss.loggedIn.User.Id && e.Uid !== '') { | |||
| this.ss.logout(); | |||
| } | |||
| } | |||
| } | |||
| } | |||