matrix-dimension/web/app/widget_wrappers/generic/generic.component.ts

32 lines
1 KiB
TypeScript
Raw Normal View History

import { Component } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { DomSanitizer, SafeUrl } from "@angular/platform-browser";
2017-12-23 20:15:54 +00:00
import { DimensionApiService } from "../../shared/services/dimension-api.service";
@Component({
selector: "my-generic-widget-wrapper",
templateUrl: "generic.component.html",
styleUrls: ["generic.component.scss"],
})
export class GenericWidgetWrapperComponent {
public isLoading = true;
public canEmbed = false;
public embedUrl: SafeUrl = null;
2017-12-23 20:15:54 +00:00
constructor(api: DimensionApiService, 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;
});
}
}