2018-05-12 18:46:08 -04:00
|
|
|
import { Component } from "@angular/core";
|
2017-10-09 22:26:46 -04:00
|
|
|
import { ActivatedRoute } from "@angular/router";
|
|
|
|
import { DomSanitizer, SafeUrl } from "@angular/platform-browser";
|
2017-12-24 04:02:57 -05:00
|
|
|
import { WidgetApiService } from "../../shared/services/integrations/widget-api.service";
|
2017-10-09 22:26:46 -04:00
|
|
|
|
|
|
|
@Component({
|
2021-09-01 19:01:01 -04:00
|
|
|
selector: "app-generic-widget-wrapper",
|
2017-10-09 22:49:26 -04:00
|
|
|
templateUrl: "generic.component.html",
|
|
|
|
styleUrls: ["generic.component.scss"],
|
2017-10-09 22:26:46 -04:00
|
|
|
})
|
2018-05-12 18:46:08 -04:00
|
|
|
export class GenericWidgetWrapperComponent {
|
2017-10-09 22:26:46 -04:00
|
|
|
public isLoading = true;
|
|
|
|
public canEmbed = false;
|
|
|
|
public embedUrl: SafeUrl = null;
|
|
|
|
|
2021-09-01 19:01:01 -04:00
|
|
|
constructor(
|
|
|
|
widgetApi: WidgetApiService,
|
|
|
|
activatedRoute: ActivatedRoute,
|
|
|
|
sanitizer: DomSanitizer
|
|
|
|
) {
|
|
|
|
const params: any = activatedRoute.snapshot.queryParams;
|
2017-10-09 22:26:46 -04:00
|
|
|
|
2021-09-01 19:01:01 -04:00
|
|
|
widgetApi
|
|
|
|
.isEmbeddable(params.url)
|
|
|
|
.then((result) => {
|
|
|
|
this.canEmbed = result.canEmbed;
|
|
|
|
this.isLoading = false;
|
|
|
|
this.embedUrl = sanitizer.bypassSecurityTrustResourceUrl(params.url);
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
console.error(err);
|
|
|
|
this.canEmbed = false;
|
|
|
|
this.isLoading = false;
|
|
|
|
});
|
2017-10-09 22:26:46 -04:00
|
|
|
}
|
|
|
|
}
|