2021-08-16 18:00:59 -04:00
|
|
|
import { Component, OnInit } 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";
|
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";
|
2021-08-16 18:00:59 -04:00
|
|
|
import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";
|
2017-12-23 23:40:01 -05:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
templateUrl: "./jitsi.component.html",
|
|
|
|
styleUrls: ["./jitsi.component.scss", "../config-dialog.scss"],
|
|
|
|
})
|
2021-08-16 18:00:59 -04:00
|
|
|
export class AdminWidgetJitsiConfigComponent implements OnInit {
|
2017-12-23 23:40:01 -05:00
|
|
|
|
|
|
|
public isUpdating = false;
|
2017-12-24 04:02:57 -05:00
|
|
|
public widget: FE_JitsiWidget;
|
2021-08-16 18:00:59 -04:00
|
|
|
private originalWidget = <FE_JitsiWidget>{};
|
2017-12-23 23:40:01 -05:00
|
|
|
|
2021-08-16 18:00:59 -04:00
|
|
|
constructor(public modal: NgbActiveModal,
|
|
|
|
private adminIntegrationsApi: AdminIntegrationsApiService,
|
|
|
|
private toaster: ToasterService,
|
|
|
|
public translate: TranslateService) {
|
|
|
|
this.translate = translate;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.originalWidget = this.widget;
|
2017-12-23 23:40:01 -05:00
|
|
|
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); });
|
2021-08-16 18:00:59 -04:00
|
|
|
this.modal.close();
|
2017-12-23 23:40:01 -05:00
|
|
|
}).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
|
|
|
}
|