2020-05-09 15:37:50 +02:00
|
|
|
import { Component, OnInit, HostListener } from '@angular/core';
|
2020-02-16 16:15:07 +01:00
|
|
|
import { StateService } from '../../services/state.service';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-master-page',
|
|
|
|
templateUrl: './master-page.component.html',
|
|
|
|
styleUrls: ['./master-page.component.scss']
|
|
|
|
})
|
|
|
|
export class MasterPageComponent implements OnInit {
|
2020-05-09 15:37:50 +02:00
|
|
|
network = '';
|
|
|
|
tvViewRoute = '/tv';
|
2020-05-02 12:52:26 +02:00
|
|
|
|
2020-02-16 16:15:07 +01:00
|
|
|
navCollapsed = false;
|
2020-03-09 11:53:54 +01:00
|
|
|
connectionState = 2;
|
2020-02-16 16:15:07 +01:00
|
|
|
|
2020-05-09 15:37:50 +02:00
|
|
|
networkDropdownHidden = true;
|
|
|
|
|
2020-02-16 16:15:07 +01:00
|
|
|
constructor(
|
|
|
|
private stateService: StateService,
|
|
|
|
) { }
|
|
|
|
|
2020-05-09 15:37:50 +02:00
|
|
|
@HostListener('document:click', ['$event'])
|
|
|
|
documentClick(event: any): void {
|
|
|
|
if (!event.target.classList.contains('dropdown-toggle')) {
|
|
|
|
this.networkDropdownHidden = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-16 16:15:07 +01:00
|
|
|
ngOnInit() {
|
2020-03-09 11:53:54 +01:00
|
|
|
this.stateService.connectionState$
|
2020-02-16 16:15:07 +01:00
|
|
|
.subscribe((state) => {
|
2020-03-09 11:53:54 +01:00
|
|
|
this.connectionState = state;
|
2020-02-16 16:15:07 +01:00
|
|
|
});
|
2020-05-09 15:37:50 +02:00
|
|
|
|
|
|
|
this.stateService.networkChanged$
|
|
|
|
.subscribe((network) => {
|
|
|
|
this.network = network;
|
|
|
|
|
|
|
|
if (network === 'testnet') {
|
|
|
|
this.tvViewRoute = '/testnet-tv';
|
|
|
|
} else if (network === 'liquid') {
|
|
|
|
this.tvViewRoute = '/liquid-tv';
|
|
|
|
} else {
|
|
|
|
this.tvViewRoute = '/tv';
|
|
|
|
}
|
|
|
|
});
|
2020-02-16 16:15:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
collapse(): void {
|
|
|
|
this.navCollapsed = !this.navCollapsed;
|
|
|
|
}
|
|
|
|
}
|