2017-12-23 23:40:01 -05:00
|
|
|
import { Component } from "@angular/core";
|
2017-12-24 04:02:57 -05:00
|
|
|
import { FE_JitsiWidget } from "../../../shared/models/integration";
|
2017-12-23 23:40:01 -05:00
|
|
|
import { ToasterService } from "angular2-toaster";
|
|
|
|
import { DialogRef, ModalComponent } from "ngx-modialog";
|
|
|
|
import { WidgetConfigDialogContext } from "../widgets.component";
|
2017-12-24 04:02:57 -05:00
|
|
|
import { AdminIntegrationsApiService } from "../../../shared/services/admin/admin-integrations-api.service";
|
2020-10-23 07:30:20 -04:00
|
|
|
import { TranslateService } from "@ngx-translate/core";
|
2017-12-23 23:40:01 -05:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
templateUrl: "./jitsi.component.html",
|
|
|
|
styleUrls: ["./jitsi.component.scss", "../config-dialog.scss"],
|
|
|
|
})
|
|
|
|
export class AdminWidgetJitsiConfigComponent implements ModalComponent<WidgetConfigDialogContext> {
|
|
|
|
|
|
|
|
public isUpdating = false;
|
2017-12-24 04:02:57 -05:00
|
|
|
public widget: FE_JitsiWidget;
|
|
|
|
private originalWidget: FE_JitsiWidget;
|
2017-12-23 23:40:01 -05:00
|
|
|
|
2020-10-23 07:30:20 -04:00
|
|
|
constructor(public dialog: DialogRef<WidgetConfigDialogContext>, private adminIntegrationsApi: AdminIntegrationsApiService, private toaster: ToasterService, public translate: TranslateService) {
|
|
|
|
this.translate = translate;
|
2017-12-23 23:40:01 -05:00
|
|
|
this.originalWidget = dialog.context.widget;
|
|
|
|
this.widget = JSON.parse(JSON.stringify(this.originalWidget));
|
2018-12-22 21:30:25 -05:00
|
|
|
|
|
|
|
// Fix the ui-switch not picking up a boolean value
|
|
|
|
this.widget.options.useDomainAsDefault = !!this.widget.options.useDomainAsDefault;
|
2017-12-23 23:40:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public save() {
|
|
|
|
this.isUpdating = true;
|
2017-12-24 04:02:57 -05:00
|
|
|
this.adminIntegrationsApi.setIntegrationOptions(this.widget.category, this.widget.type, this.widget.options).then(() => {
|
2017-12-23 23:40:01 -05:00
|
|
|
this.originalWidget.options = this.widget.options;
|
2020-10-23 07:30:20 -04:00
|
|
|
this.translate.get('Widget updated').subscribe((res: string) => {this.toaster.pop("success", res); });
|
2017-12-23 23:40:01 -05:00
|
|
|
this.dialog.close();
|
|
|
|
}).catch(err => {
|
|
|
|
this.isUpdating = false;
|
|
|
|
console.error(err);
|
2020-10-23 07:30:20 -04:00
|
|
|
this.translate.get('Error updating widget').subscribe((res: string) => {this.toaster.pop("error", res); });
|
2017-12-23 23:40:01 -05:00
|
|
|
});
|
|
|
|
}
|
2018-12-22 21:30:25 -05:00
|
|
|
|
|
|
|
public toggleForcedJitsi() {
|
|
|
|
this.widget.options.useDomainAsDefault = !this.widget.options.useDomainAsDefault;
|
|
|
|
}
|
2017-12-23 23:40:01 -05:00
|
|
|
}
|