Move FAQ HTML to angular templates

fixes #1783
This commit is contained in:
softsimon
2022-06-12 22:52:49 +02:00
parent 5314eb2d45
commit 24ffc97317
5 changed files with 105 additions and 27 deletions

View File

@@ -1,16 +1,17 @@
import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
import { Component, OnInit, Input, QueryList, AfterViewInit, ViewChildren } from '@angular/core';
import { Env, StateService } from '../../services/state.service';
import { Observable, merge, of } from 'rxjs';
import { tap } from 'rxjs/operators';
import { ActivatedRoute } from "@angular/router";
import { faqData, restApiDocsData, wsApiDocsData } from './api-docs-data';
import { FaqTemplateDirective } from '../faq-template/faq-template.component';
@Component({
selector: 'app-api-docs',
templateUrl: './api-docs.component.html',
styleUrls: ['./api-docs.component.scss']
})
export class ApiDocsComponent implements OnInit {
export class ApiDocsComponent implements OnInit, AfterViewInit {
hostname = document.location.hostname;
network$: Observable<string>;
active = 0;
@@ -25,6 +26,9 @@ export class ApiDocsComponent implements OnInit {
screenWidth: number;
officialMempoolInstance: boolean;
@ViewChildren(FaqTemplateDirective) faqTemplates: QueryList<FaqTemplateDirective>;
dict = {};
constructor(
private stateService: StateService,
private route: ActivatedRoute,
@@ -40,6 +44,7 @@ export class ApiDocsComponent implements OnInit {
window.addEventListener('scroll', function() {
that.desktopDocsNavPosition = ( window.pageYOffset > 182 ) ? "fixed" : "relative";
}, { passive: true} );
this.faqTemplates.forEach((x) => this.dict[x.type] = x.template);
}, 1 );
}