2017-12-09 18:34:59 -05:00
|
|
|
import { Component, EventEmitter, Input, Output } from "@angular/core";
|
2017-05-28 02:35:40 -04:00
|
|
|
import { Integration } from "../shared/models/integration";
|
2017-08-27 01:26:00 -04:00
|
|
|
import { overlayConfigFactory } from "ngx-modialog";
|
2017-12-09 18:34:59 -05:00
|
|
|
import { BSModalContext, Modal } from "ngx-modialog/plugins/bootstrap";
|
2017-05-29 00:51:04 -04:00
|
|
|
import { IntegrationService } from "../shared/integration.service";
|
|
|
|
|
|
|
|
export class ConfigModalContext extends BSModalContext {
|
|
|
|
public integration: Integration;
|
|
|
|
public roomId: string;
|
|
|
|
public scalarToken: string;
|
2017-10-09 23:55:45 -04:00
|
|
|
public integrationId: string;
|
2017-05-29 00:51:04 -04:00
|
|
|
}
|
2017-05-28 02:35:40 -04:00
|
|
|
|
|
|
|
@Component({
|
2017-08-27 01:26:00 -04:00
|
|
|
selector: "my-integration",
|
|
|
|
templateUrl: "./integration.component.html",
|
|
|
|
styleUrls: ["./integration.component.scss"],
|
2017-05-28 02:35:40 -04:00
|
|
|
})
|
|
|
|
export class IntegrationComponent {
|
|
|
|
|
|
|
|
@Input() integration: Integration;
|
2017-05-29 00:51:04 -04:00
|
|
|
@Input() roomId: string;
|
|
|
|
@Input() scalarToken: string;
|
2017-05-28 02:35:40 -04:00
|
|
|
@Output() updated: EventEmitter<any> = new EventEmitter();
|
|
|
|
|
2017-10-09 23:55:45 -04:00
|
|
|
constructor(public modal: Modal) {
|
2017-05-28 02:35:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public update(): void {
|
|
|
|
this.integration.isEnabled = !this.integration.isEnabled;
|
|
|
|
this.updated.emit();
|
|
|
|
}
|
2017-05-29 00:51:04 -04:00
|
|
|
|
2017-10-10 00:00:29 -04:00
|
|
|
public configureIntegration(integrationId: string = null): void {
|
2017-05-29 00:51:04 -04:00
|
|
|
this.modal.open(IntegrationService.getConfigComponent(this.integration), overlayConfigFactory({
|
|
|
|
integration: this.integration,
|
|
|
|
roomId: this.roomId,
|
|
|
|
scalarToken: this.scalarToken,
|
|
|
|
isBlocking: false,
|
2017-10-09 23:55:45 -04:00
|
|
|
integrationId: integrationId,
|
2017-08-27 01:26:00 -04:00
|
|
|
size: "lg"
|
2017-05-29 00:51:04 -04:00
|
|
|
}, BSModalContext));
|
|
|
|
}
|
2017-12-10 04:35:24 -05:00
|
|
|
|
|
|
|
public canHaveErrors(integration: Integration): boolean {
|
|
|
|
return integration.type === 'bridge' || integration.type === "widget";
|
|
|
|
}
|
2017-05-28 02:35:40 -04:00
|
|
|
}
|