matrix-dimension/web/app/widget-wrappers/generic/generic.component.ts

37 lines
1.2 KiB
TypeScript
Raw Normal View History

2018-05-12 18:46:08 -04:00
import { Component } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { DomSanitizer, SafeUrl } from "@angular/platform-browser";
import { WidgetApiService } from "../../shared/services/integrations/widget-api.service";
@Component({
2021-09-01 19:29:24 -04:00
selector: "my-generic-widget-wrapper",
templateUrl: "generic.component.html",
styleUrls: ["generic.component.scss"],
})
2018-05-12 18:46:08 -04:00
export class GenericWidgetWrapperComponent {
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;
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;
});
}
}