2021-12-29 23:08:41 +00:00
|
|
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
2022-05-17 02:53:13 +00:00
|
|
|
import { Router, ResolveEnd, Event } from '@angular/router';
|
2021-12-29 23:08:41 +00:00
|
|
|
import { Subject } from 'rxjs';
|
|
|
|
import { takeUntil, filter } from 'rxjs/operators';
|
|
|
|
import { faSearch } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'rtl-ecl-graph',
|
|
|
|
templateUrl: './graph.component.html',
|
|
|
|
styleUrls: ['./graph.component.scss']
|
|
|
|
})
|
|
|
|
export class ECLGraphComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
faSearch = faSearch;
|
|
|
|
public links = [{ link: 'lookups', name: 'Lookup' }, { link: 'queryroutes', name: 'Query Routes' }];
|
|
|
|
public activeLink = this.links[0].link;
|
|
|
|
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
|
|
|
|
|
|
|
|
constructor(private router: Router) { }
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
const linkFound = this.links.find((link) => this.router.url.includes(link.link));
|
|
|
|
this.activeLink = linkFound ? linkFound.link : this.links[0].link;
|
|
|
|
this.router.events.pipe(takeUntil(this.unSubs[0]), filter((e) => e instanceof ResolveEnd)).
|
2022-05-17 02:53:13 +00:00
|
|
|
subscribe({
|
|
|
|
next: (value: ResolveEnd | Event) => {
|
|
|
|
const linkFound = this.links.find((link) => (<ResolveEnd>value).urlAfterRedirects.includes(link.link));
|
|
|
|
this.activeLink = linkFound ? linkFound.link : this.links[0].link;
|
|
|
|
}
|
2021-12-29 23:08:41 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
this.unSubs.forEach((completeSub) => {
|
2022-08-11 09:17:43 +00:00
|
|
|
completeSub.next(<any>null);
|
2021-12-29 23:08:41 +00:00
|
|
|
completeSub.complete();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|