2017-10-10 02:26:46 +00:00
|
|
|
import { Component } from "@angular/core";
|
2017-12-21 04:28:43 +00:00
|
|
|
import { ApiService } from "../../shared/services/legacy/api.service";
|
2017-10-10 02:26:46 +00:00
|
|
|
import { ActivatedRoute } from "@angular/router";
|
|
|
|
import { DomSanitizer, SafeUrl } from "@angular/platform-browser";
|
|
|
|
|
|
|
|
@Component({
|
2017-10-10 02:49:26 +00:00
|
|
|
selector: "my-generic-widget-wrapper",
|
|
|
|
templateUrl: "generic.component.html",
|
|
|
|
styleUrls: ["generic.component.scss"],
|
2017-10-10 02:26:46 +00:00
|
|
|
})
|
2017-10-10 02:49:26 +00:00
|
|
|
export class GenericWidgetWrapperComponent {
|
2017-10-10 02:26:46 +00:00
|
|
|
|
|
|
|
public isLoading = true;
|
|
|
|
public canEmbed = false;
|
|
|
|
public embedUrl: SafeUrl = null;
|
|
|
|
|
|
|
|
constructor(api: ApiService, activatedRoute: ActivatedRoute, sanitizer: DomSanitizer) {
|
|
|
|
let params: any = activatedRoute.snapshot.queryParams;
|
|
|
|
|
|
|
|
api.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;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|