2019-10-24 06:37:33 +00:00
|
|
|
import { Component, OnInit, Inject, OnDestroy } from '@angular/core';
|
|
|
|
import {
|
|
|
|
UCAP_NATIVE_SERVICE,
|
|
|
|
NativeService,
|
|
|
|
WindowState
|
|
|
|
} from '@ucap-webmessenger/native';
|
2019-11-25 01:47:44 +00:00
|
|
|
import { Observable, Subscription } from 'rxjs';
|
|
|
|
import { Store, select } from '@ngrx/store';
|
2019-11-25 00:41:15 +00:00
|
|
|
|
2019-11-25 01:47:44 +00:00
|
|
|
import * as AppStore from '@app/store';
|
2019-11-25 00:41:15 +00:00
|
|
|
import * as AuthenticationStore from '@app/store/account/authentication';
|
|
|
|
import * as SettingsStore from '@app/store/messenger/settings';
|
2019-10-24 06:37:33 +00:00
|
|
|
|
2019-11-25 01:47:44 +00:00
|
|
|
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
|
|
|
import { tap } from 'rxjs/operators';
|
|
|
|
|
2019-10-24 06:37:33 +00:00
|
|
|
@Component({
|
|
|
|
selector: 'app-layout-native-top-bar',
|
|
|
|
templateUrl: './top-bar.component.html',
|
|
|
|
styleUrls: ['./top-bar.component.scss']
|
|
|
|
})
|
|
|
|
export class TopBarComponent implements OnInit, OnDestroy {
|
|
|
|
windowStateChanged$: Observable<WindowState>;
|
|
|
|
|
|
|
|
WindowState = WindowState;
|
2019-11-25 01:47:44 +00:00
|
|
|
loginRes: LoginResponse;
|
|
|
|
loginResSubscription: Subscription;
|
2019-10-24 06:37:33 +00:00
|
|
|
|
|
|
|
constructor(
|
2019-11-25 00:41:15 +00:00
|
|
|
private store: Store<any>,
|
2019-10-24 06:37:33 +00:00
|
|
|
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService
|
|
|
|
) {}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.windowStateChanged$ = this.nativeService.windowStateChanged();
|
2019-11-25 01:47:44 +00:00
|
|
|
|
|
|
|
this.loginResSubscription = this.store
|
|
|
|
.pipe(
|
|
|
|
select(AppStore.AccountSelector.AuthenticationSelector.loginRes),
|
|
|
|
tap(loginRes => {
|
|
|
|
this.loginRes = loginRes;
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.subscribe();
|
2019-10-24 06:37:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy(): void {}
|
|
|
|
|
|
|
|
onClickClose() {
|
|
|
|
this.nativeService.windowClose();
|
|
|
|
}
|
|
|
|
|
|
|
|
onClickMinimize() {
|
|
|
|
this.nativeService.windowMinimize();
|
|
|
|
}
|
|
|
|
|
|
|
|
onClickMaxmize() {
|
|
|
|
this.nativeService.windowMaximize();
|
|
|
|
}
|
2019-11-25 00:41:15 +00:00
|
|
|
|
|
|
|
onClickSettings(): void {
|
|
|
|
this.store.dispatch(SettingsStore.showDialog());
|
|
|
|
}
|
|
|
|
|
|
|
|
onClickLogout(): void {
|
2019-11-25 01:47:44 +00:00
|
|
|
this.store.dispatch(AuthenticationStore.logoutConfirmation());
|
2019-11-25 00:41:15 +00:00
|
|
|
}
|
2019-10-24 06:37:33 +00:00
|
|
|
}
|