File

app/dxa/dxa-entity/views/product-config-views/product-config-main/product-config-main.component.ts

Implements

OnInit AfterViewInit OnDestroy

Metadata

selector div[product-config-main]
styleUrls ./product-config-main.component.scss
templateUrl ./product-config-main.component.html

Index

Properties
Methods
Inputs
HostBindings

Constructor

constructor(sanitizer: DomSanitizer, idService: IdGeneratorService, util: UtilService, document)
Parameters :
Name Type Optional
sanitizer DomSanitizer No
idService IdGeneratorService No
util UtilService No
document No

Inputs

entity
Type : any

HostBindings

class

Methods

ngAfterViewInit
ngAfterViewInit()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
onLoad
onLoad(e)
Parameters :
Name Optional
e No
Returns : void

Properties

Readonly CAD_ORIGIN
Type : string
Default value : 'https://webassistants.partcommunity.com'
iframe
iframeId
Type : string
setHeight
Type : any
subscription
Type : Subscription
title
Type : string
url
import { Component, OnInit, Input, Inject, AfterViewInit, ChangeDetectionStrategy, HostListener, OnDestroy, HostBinding, ChangeDetectorRef } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { DOCUMENT } from '@angular/common';
import { IdGeneratorService } from 'src/app/core/services/id-generator.service';
import { UtilService } from 'src/app/core/services/util-service/util.service';
import { fromEvent, Subscription } from 'rxjs';
import { map } from 'rxjs/operators';

@Component({
	selector: 'div[product-config-main]',
	templateUrl: './product-config-main.component.html',
	styleUrls: ['./product-config-main.component.scss']
})
export class ProductConfigMainComponent implements OnInit, AfterViewInit, OnDestroy {

	@Input() entity: any;
	setHeight: any;
	iframeId: string;
	title: string;
	iframe;
	subscription: Subscription;
	url;
	readonly CAD_ORIGIN = 'https://webassistants.partcommunity.com';

	@HostBinding('class') get class() { return 'col-md-8 space-between'; }

	constructor(private sanitizer: DomSanitizer,
		private idService: IdGeneratorService,
		private util: UtilService,
		@Inject(DOCUMENT) private document) { }

	ngOnInit() {
		this.title = this.util.extract(this.entity, 'Title') || '';
		this.iframeId = `iframe-id-${this.idService.getId()}`;
		this.url = this.sanitizer.bypassSecurityTrustResourceUrl(`${this.CAD_ORIGIN}/23d-libs/us_configurator/sa2/skf/index.vbb?info=${this.entity.ProductFamilyId}`);
	}


	ngAfterViewInit() {
		this.iframe = this.document.getElementById(this.iframeId);
		const source = fromEvent(window, 'message');
		const example = source.pipe(map(event => this.onLoad(event)));
		this.subscription = example.subscribe(() => {});
	}

	ngOnDestroy() {
		this.subscription.unsubscribe();
	}

	onLoad(e) {
		console.log('onload');
		
		if (e.origin === this.CAD_ORIGIN) {
			console.log('change height');
			
			this.iframe.height = e.data.conf_height;
		}
	}

}
<p *ngIf="title">
  {{title}}
</p>

<div>
  <iframe [id]="iframeId" [src]="url"></iframe>
</div>

./product-config-main.component.scss

@import "src/app/styles/helpers";

p {
	@include font-size(40);
}

iframe {
	border: none;
	width: calc-rem(440);
}
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""