Also support editing Jitsi widgets

This commit is contained in:
Travis Ralston 2017-12-10 01:08:32 -07:00
parent 993dcdac21
commit eb59940907

View File

@ -60,8 +60,24 @@ export class JitsiWidgetConfigComponent extends WidgetComponent implements Modal
} }
public validateAndAddWidget() { public validateAndAddWidget() {
const conferenceUrl = "https://" + this.integration.jitsiDomain + "/" + this.newWidgetName; const jitsiConfig = this.getJitsiConfig(this.integration.jitsiDomain, this.newWidgetName);
const conferenceId = this.newWidgetName;
this.newWidgetUrl = jitsiConfig.url;
this.newWidgetName = "Jitsi Video Conference";
this.addWidget(jitsiConfig.data);
}
public validateAndSaveWidget(widget: Widget) {
const jitsiUrl = url.parse(widget.data.dimConferenceUrl);
const jitsiConfig = this.getJitsiConfig(jitsiUrl.host, jitsiUrl.path.substring(1));
widget.newUrl = jitsiConfig.url;
widget.data = jitsiConfig.data;
this.saveWidget(widget);
}
private getJitsiConfig(domain: string, conferenceId: string): {url: string, data: any} {
const conferenceUrl = "https://" + domain + "/" + encodeURIComponent(conferenceId);
const data = { const data = {
dimOriginalConferenceUrl: conferenceUrl, dimOriginalConferenceUrl: conferenceUrl,
dimConferenceUrl: conferenceUrl, dimConferenceUrl: conferenceUrl,
@ -70,7 +86,7 @@ export class JitsiWidgetConfigComponent extends WidgetComponent implements Modal
let widgetQueryString = url.format({ let widgetQueryString = url.format({
query: { query: {
//"scriptUrl": this.integration.scriptUrl, // handled in wrapper //"scriptUrl": this.integration.scriptUrl, // handled in wrapper
"domain": this.integration.jitsiDomain, "domain": domain,
"conferenceId": conferenceId, "conferenceId": conferenceId,
"displayName": "$matrix_display_name", "displayName": "$matrix_display_name",
"avatarUrl": "$matrix_avatar_url", "avatarUrl": "$matrix_avatar_url",
@ -79,13 +95,10 @@ export class JitsiWidgetConfigComponent extends WidgetComponent implements Modal
}); });
widgetQueryString = this.unformatParams(widgetQueryString, data); widgetQueryString = this.unformatParams(widgetQueryString, data);
this.newWidgetUrl = window.location.origin + "/widgets/jitsi" + widgetQueryString; return {
this.newWidgetName = "Jitsi Video Conference"; url: window.location.origin + "/widgets/jitsi" + widgetQueryString,
this.addWidget(data); data: data,
} };
public validateAndSaveWidget(widget: Widget) {
console.log(widget);
} }
protected widgetAdded() { protected widgetAdded() {