2017-12-10 02:59:36 -05:00
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
import { ActivatedRoute } from "@angular/router";
|
|
|
|
import * as $ from "jquery";
|
2017-12-24 04:02:57 -05:00
|
|
|
import { FE_JitsiWidget } from "../../shared/models/integration";
|
|
|
|
import { WidgetApiService } from "../../shared/services/integrations/widget-api.service";
|
2018-07-30 23:55:57 -04:00
|
|
|
import { CapableWidget } from "../capable-widget";
|
2017-12-10 02:59:36 -05:00
|
|
|
|
|
|
|
declare var JitsiMeetExternalAPI: any;
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: "my-jitsi-widget-wrapper",
|
|
|
|
templateUrl: "jitsi.component.html",
|
|
|
|
styleUrls: ["jitsi.component.scss"],
|
|
|
|
})
|
2018-07-30 23:55:57 -04:00
|
|
|
export class JitsiWidgetWrapperComponent extends CapableWidget implements OnInit {
|
2017-12-10 02:59:36 -05:00
|
|
|
|
|
|
|
public isJoined = false;
|
|
|
|
|
|
|
|
private domain: string;
|
|
|
|
private conferenceId: string;
|
|
|
|
private displayName: string;
|
|
|
|
private avatarUrl: string;
|
|
|
|
private userId: string;
|
|
|
|
private jitsiApiObj: any;
|
|
|
|
|
2017-12-24 04:02:57 -05:00
|
|
|
constructor(activatedRoute: ActivatedRoute, private widgetApi: WidgetApiService) {
|
2018-07-30 23:55:57 -04:00
|
|
|
super();
|
|
|
|
this.supportsAlwaysOnScreen = true;
|
|
|
|
|
2017-12-10 02:59:36 -05:00
|
|
|
let params: any = activatedRoute.snapshot.queryParams;
|
|
|
|
|
2018-07-30 23:55:57 -04:00
|
|
|
this.domain = params.domain || "jitsi.riot.im"; // Riot doesn't supply a domain, so we default
|
2017-12-14 00:57:13 -05:00
|
|
|
this.conferenceId = params.confId || params.conferenceId;
|
2017-12-10 02:59:36 -05:00
|
|
|
this.displayName = params.displayName;
|
|
|
|
this.avatarUrl = params.avatarUrl;
|
2018-07-30 23:55:57 -04:00
|
|
|
this.userId = params.userId || params.email; // Riot uses `email` when placing a conference call
|
2017-12-10 02:59:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnInit() {
|
2018-07-30 23:55:57 -04:00
|
|
|
super.ngOnInit();
|
2017-12-24 04:02:57 -05:00
|
|
|
this.widgetApi.getWidget("jitsi").then(integration => {
|
|
|
|
const widget = <FE_JitsiWidget>integration;
|
2017-12-23 15:15:54 -05:00
|
|
|
$.getScript(widget.options.scriptUrl);
|
2017-12-10 02:59:36 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public joinConference() {
|
|
|
|
$(".join-conference-wrapper").hide();
|
|
|
|
$("#jitsiContainer").show();
|
|
|
|
|
|
|
|
this.jitsiApiObj = new JitsiMeetExternalAPI(this.domain, {
|
|
|
|
width: "100%",
|
|
|
|
height: "100%",
|
|
|
|
parentNode: document.querySelector("#jitsiContainer"),
|
|
|
|
roomName: this.conferenceId,
|
|
|
|
interfaceConfigOverwrite: {
|
|
|
|
SHOW_JITSI_WATERMARK: false,
|
|
|
|
SHOW_WATERMARK_FOR_GUESTS: false,
|
|
|
|
MAIN_TOOLBAR_BUTTONS: [],
|
|
|
|
VIDEO_LAYOUT_FIT: "height",
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (this.displayName) this.jitsiApiObj.executeCommand("displayName", this.displayName);
|
|
|
|
if (this.avatarUrl) this.jitsiApiObj.executeCommand("avatarUrl", this.avatarUrl.toString());
|
|
|
|
if (this.userId) this.jitsiApiObj.executeCommand("email", this.userId);
|
|
|
|
|
|
|
|
this.jitsiApiObj.on("readyToClose", () => {
|
|
|
|
this.isJoined = false;
|
|
|
|
$(".join-conference-wrapper").show();
|
|
|
|
$("#jitsiContainer").hide().html("");
|
|
|
|
});
|
|
|
|
|
|
|
|
this.isJoined = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|