argos/dmp-frontend/src/app/ui/faq/faq-content/faq-content.component.ts

44 lines
1.7 KiB
TypeScript

import { Component, OnInit, Input } from '@angular/core';
import { SafeResourceUrl, DomSanitizer } from '@angular/platform-browser';
import { LanguageService } from '@app/core/services/language/language.service';
import { MatomoService } from '@app/core/services/matomo/matomo-service';
import { SupportiveMaterialService } from '@app/core/services/supportive-material/supportive-material.service';
import { BaseComponent } from '@common/base/base.component';
import { takeUntil } from 'rxjs/operators';
import { SupportiveMaterialFieldType } from '@app/core/common/enum/supportive-material-field-type';
@Component({
selector: 'app-faq-content',
templateUrl: './faq-content.component.html',
styleUrls: ['./faq-content.component.scss']
})
export class FaqContentComponent extends BaseComponent implements OnInit {
@Input() isDialog: boolean;
faqHTMLUrl: SafeResourceUrl;
sanitizedGuideUrl: any;
constructor(
private supportiveMaterialService: SupportiveMaterialService,
private sanitizer: DomSanitizer,
private languageService: LanguageService,
private matomoService: MatomoService
) { super(); }
ngOnInit() {
this.matomoService.trackPageView('FAQ');
const lookup = SupportiveMaterialService.DefaultSupportiveMaterialLookup();
lookup.languageCodes = [this.languageService.getCurrentLanguage()];
lookup.types = [SupportiveMaterialFieldType.Faq];
this.supportiveMaterialService.queryPublic(lookup)
.pipe(takeUntil(this._destroyed))
.subscribe(response => {
const blob = new Blob([response.body], { type: 'text/html' });
this.faqHTMLUrl = this.sanitizer.bypassSecurityTrustResourceUrl((window.URL ? URL : webkitURL).createObjectURL(blob));
});
}
}