2020-01-03 20:04:00 +00:00
|
|
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
2022-05-17 02:53:13 +00:00
|
|
|
import { Router, ResolveEnd, Event } from '@angular/router';
|
2020-01-03 20:04:00 +00:00
|
|
|
import { Subject } from 'rxjs';
|
|
|
|
import { takeUntil, filter } from 'rxjs/operators';
|
|
|
|
import { faMapSigns } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
|
|
|
|
@Component({
|
2022-05-01 17:35:20 +00:00
|
|
|
selector: 'rtl-cln-routing',
|
2020-01-03 20:04:00 +00:00
|
|
|
templateUrl: './routing.component.html',
|
|
|
|
styleUrls: ['./routing.component.scss']
|
|
|
|
})
|
2022-05-01 17:35:20 +00:00
|
|
|
export class CLNRoutingComponent implements OnInit, OnDestroy {
|
2021-08-28 21:03:18 +00:00
|
|
|
|
2020-01-03 20:04:00 +00:00
|
|
|
public faMapSigns = faMapSigns;
|
2022-03-05 15:58:15 +00:00
|
|
|
public links = [{ link: 'forwardinghistory', name: 'Forwarding History' }, { link: 'routingpeers', name: 'Routing Peers' }, { link: 'failedtransactions', name: 'Failed Transactions' }, { link: 'localfail', name: 'Local Failed Transactions' }];
|
2020-12-20 23:36:04 +00:00
|
|
|
public activeLink = this.links[0].link;
|
2020-01-03 20:04:00 +00:00
|
|
|
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject()];
|
|
|
|
|
2022-03-05 15:58:15 +00:00
|
|
|
constructor(private router: Router) { }
|
2020-01-03 20:04:00 +00:00
|
|
|
|
|
|
|
ngOnInit() {
|
2021-08-28 21:03:18 +00:00
|
|
|
const linkFound = this.links.find((link) => this.router.url.includes(link.link));
|
2020-12-20 23:36:04 +00:00
|
|
|
this.activeLink = linkFound ? linkFound.link : this.links[0].link;
|
2021-08-28 21:03:18 +00:00
|
|
|
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-08-28 21:03:18 +00:00
|
|
|
});
|
2020-01-03 20:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
2021-08-28 21:03:18 +00:00
|
|
|
this.unSubs.forEach((completeSub) => {
|
2022-08-11 09:17:43 +00:00
|
|
|
completeSub.next(<any>null);
|
2020-01-03 20:04:00 +00:00
|
|
|
completeSub.complete();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|