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";
|
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
|
|
|
|
2017-12-24 04:02:57 -05:00
|
|
|
constructor(public dialog: DialogRef<WidgetConfigDialogContext>, private adminIntegrationsApi: AdminIntegrationsApiService, private toaster: ToasterService) {
|
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;
|
|
|
|
this.toaster.pop("success", "Widget updated");
|
|
|
|
this.dialog.close();
|
|
|
|
}).catch(err => {
|
|
|
|
this.isUpdating = false;
|
|
|
|
console.error(err);
|
|
|
|
this.toaster.pop("error", "Error updating widget");
|
|
|
|
});
|
|
|
|
}
|
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
|
|
|
}
|