2020-07-23 16:59:48 -04:00
|
|
|
import { WidgetComponent, DISABLE_AUTOMATIC_WRAPPING } from "../widget.component";
|
|
|
|
import { WIDGET_BIGBLUEBUTTON, EditableWidget } from "../../../shared/models/widget";
|
|
|
|
import { Component } from "@angular/core";
|
|
|
|
import { FE_BigBlueButtonWidget } from "../../../shared/models/integration";
|
|
|
|
import { SessionStorage } from "../../../shared/SessionStorage";
|
|
|
|
import * as url from "url";
|
2020-12-28 22:49:24 -05:00
|
|
|
import { TranslateService } from "@ngx-translate/core";
|
2020-07-23 16:59:48 -04:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
templateUrl: "bigbluebutton.widget.component.html",
|
|
|
|
styleUrls: ["bigbluebutton.widget.component.scss"],
|
|
|
|
})
|
|
|
|
|
|
|
|
// Configuration of BigBlueButton widgets
|
|
|
|
export class BigBlueButtonConfigComponent extends WidgetComponent {
|
|
|
|
private bigBlueButtonWidget: FE_BigBlueButtonWidget = <FE_BigBlueButtonWidget>SessionStorage.editIntegration;
|
|
|
|
|
2020-12-28 22:49:24 -05:00
|
|
|
constructor(public translate: TranslateService) {
|
|
|
|
super(WIDGET_BIGBLUEBUTTON, "BigBlueButton Conference", DISABLE_AUTOMATIC_WRAPPING, translate);
|
2020-07-23 16:59:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected OnWidgetsDiscovered(widgets: EditableWidget[]) {
|
|
|
|
for (const widget of widgets) {
|
|
|
|
widget.data.conferenceUrl = this.templateUrl(widget.url, widget.data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected OnNewWidgetPrepared(widget: EditableWidget): void {
|
|
|
|
widget.dimension.newData["conferenceUrl"] = this.bigBlueButtonWidget.options.conferenceUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected OnWidgetBeforeAdd(widget: EditableWidget) {
|
|
|
|
this.setWidgetOptions(widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected OnWidgetBeforeEdit(widget: EditableWidget) {
|
|
|
|
this.setWidgetOptions(widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
private setWidgetOptions(widget: EditableWidget) {
|
|
|
|
widget.dimension.newData.url = widget.dimension.newData.conferenceUrl;
|
|
|
|
|
|
|
|
let widgetQueryString = url.format({
|
|
|
|
query: {
|
|
|
|
"conferenceUrl": "$conferenceUrl",
|
|
|
|
"displayName": "$matrix_display_name",
|
|
|
|
"avatarUrl": "$matrix_avatar_url",
|
|
|
|
"userId": "$matrix_user_id",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
widgetQueryString = this.decodeParams(widgetQueryString, Object.keys(widget.dimension.newData).map(k => "$" + k));
|
|
|
|
widget.dimension.newUrl = window.location.origin + "/widgets/bigbluebutton" + widgetQueryString;
|
2021-05-04 04:38:44 -04:00
|
|
|
console.log("URL ended up as:", widget.dimension.newUrl);
|
2020-07-23 16:59:48 -04:00
|
|
|
}
|
|
|
|
}
|