2022-03-11 19:06:06 -05:00
|
|
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
2024-10-22 21:05:01 +09:00
|
|
|
import { Env, StateService } from '@app/services/state.service';
|
2025-05-13 19:31:31 -04:00
|
|
|
import { Subject, Subscription } from 'rxjs';
|
|
|
|
|
import { takeUntil } from 'rxjs/operators';
|
2024-12-22 20:16:07 +01:00
|
|
|
import { restApiDocsData, wsApiDocsData } from '@app/docs/api-docs/api-docs-data';
|
2024-10-23 11:34:59 +09:00
|
|
|
import { faqData } from '@app/docs/api-docs/api-docs-data';
|
2021-12-16 19:11:54 -05:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-api-docs-nav',
|
|
|
|
|
templateUrl: './api-docs-nav.component.html',
|
2025-11-03 00:27:08 +08:00
|
|
|
styleUrls: ['./api-docs-nav.component.scss'],
|
|
|
|
|
standalone: false,
|
2021-12-16 19:11:54 -05:00
|
|
|
})
|
|
|
|
|
export class ApiDocsNavComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
@Input() network: any;
|
2022-03-26 09:09:37 -04:00
|
|
|
@Input() whichTab: string;
|
2022-03-11 19:06:06 -05:00
|
|
|
@Output() navLinkClickEvent: EventEmitter<any> = new EventEmitter();
|
2025-05-13 19:31:31 -04:00
|
|
|
private destroy$: Subject<any> = new Subject<any>();
|
2023-02-13 20:12:31 -05:00
|
|
|
env: Env;
|
2022-03-26 09:09:37 -04:00
|
|
|
tabData: any[];
|
2023-02-15 01:27:43 -05:00
|
|
|
auditEnabled: boolean;
|
2023-03-17 08:24:37 -04:00
|
|
|
officialMempoolInstance: boolean;
|
2025-05-13 18:25:39 -04:00
|
|
|
runningElectrs: boolean;
|
2021-12-16 19:11:54 -05:00
|
|
|
|
2023-02-13 20:12:31 -05:00
|
|
|
constructor(
|
|
|
|
|
private stateService: StateService
|
|
|
|
|
) { }
|
2021-12-16 19:11:54 -05:00
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
2023-02-13 20:12:31 -05:00
|
|
|
this.env = this.stateService.env;
|
2023-03-17 08:24:37 -04:00
|
|
|
this.officialMempoolInstance = this.env.OFFICIAL_MEMPOOL_SPACE;
|
2025-05-13 19:31:31 -04:00
|
|
|
this.stateService.backend$.pipe(takeUntil(this.destroy$)).subscribe((backend) => {
|
|
|
|
|
this.runningElectrs = !!(backend == 'esplora');
|
|
|
|
|
});
|
2023-02-15 01:27:43 -05:00
|
|
|
this.auditEnabled = this.env.AUDIT;
|
2022-07-05 04:30:05 -07:00
|
|
|
if (this.whichTab === 'rest') {
|
2022-03-26 09:09:37 -04:00
|
|
|
this.tabData = restApiDocsData;
|
2024-12-22 20:16:07 +01:00
|
|
|
} else if (this.whichTab === 'websocket') {
|
|
|
|
|
this.tabData = wsApiDocsData;
|
2022-07-05 04:30:05 -07:00
|
|
|
} else if (this.whichTab === 'faq') {
|
2022-03-26 09:09:37 -04:00
|
|
|
this.tabData = faqData;
|
|
|
|
|
}
|
2021-12-16 19:11:54 -05:00
|
|
|
}
|
2022-07-05 04:30:05 -07:00
|
|
|
|
2024-04-01 18:53:38 +09:00
|
|
|
navLinkClick(event, fragment) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
this.navLinkClickEvent.emit({event: event, fragment: fragment});
|
2022-03-11 19:06:06 -05:00
|
|
|
}
|
2021-12-16 19:11:54 -05:00
|
|
|
|
2025-05-13 19:31:31 -04:00
|
|
|
ngOnDestroy(): void {
|
|
|
|
|
this.destroy$.next(true);
|
|
|
|
|
this.destroy$.complete();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-16 19:11:54 -05:00
|
|
|
}
|