2017-05-29 00:51:04 -04:00
|
|
|
import { Injectable } from "@angular/core";
|
|
|
|
import { Integration } from "./models/integration";
|
|
|
|
import { RssConfigComponent } from "../configs/rss/rss-config.component";
|
2017-08-27 01:26:00 -04:00
|
|
|
import { ContainerContent } from "ngx-modialog";
|
2017-06-04 23:31:31 -04:00
|
|
|
import { IrcConfigComponent } from "../configs/irc/irc-config.component";
|
2017-08-27 21:05:38 -04:00
|
|
|
import { TravisCiConfigComponent } from "../configs/travisci/travisci-config.component";
|
2017-08-29 00:08:32 -04:00
|
|
|
import { CustomWidgetConfigComponent } from "../configs/widget/custom_widget/custom_widget-config.component";
|
2017-05-29 00:51:04 -04:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class IntegrationService {
|
|
|
|
|
|
|
|
private static supportedTypeMap = {
|
|
|
|
"bot": true,
|
|
|
|
"complex-bot": {
|
2017-08-27 21:05:38 -04:00
|
|
|
"rss": true,
|
|
|
|
"travisci": true,
|
2017-06-04 23:31:31 -04:00
|
|
|
},
|
|
|
|
"bridge": {
|
2017-08-27 21:05:38 -04:00
|
|
|
"irc": true,
|
2017-08-29 00:08:32 -04:00
|
|
|
},
|
|
|
|
"widget": {
|
|
|
|
"customwidget": true
|
|
|
|
},
|
2017-05-29 00:51:04 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
private static components = {
|
|
|
|
"complex-bot": {
|
2017-08-27 21:05:38 -04:00
|
|
|
"rss": RssConfigComponent,
|
|
|
|
"travisci": TravisCiConfigComponent,
|
2017-06-04 23:31:31 -04:00
|
|
|
},
|
|
|
|
"bridge": {
|
2017-08-27 21:05:38 -04:00
|
|
|
"irc": IrcConfigComponent,
|
2017-08-29 00:08:32 -04:00
|
|
|
},
|
|
|
|
"widget": {
|
|
|
|
"customwidget": CustomWidgetConfigComponent,
|
|
|
|
},
|
2017-05-29 00:51:04 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static isSupported(integration: Integration): boolean {
|
|
|
|
if (IntegrationService.supportedTypeMap[integration.type] === true) return true;
|
|
|
|
if (!IntegrationService.supportedTypeMap[integration.type]) return false;
|
|
|
|
return IntegrationService.supportedTypeMap[integration.type][integration.integrationType] === true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static hasConfig(integration: Integration): boolean {
|
|
|
|
return integration.type !== "bot";
|
|
|
|
}
|
|
|
|
|
|
|
|
static getConfigComponent(integration: Integration): ContainerContent {
|
|
|
|
return IntegrationService.components[integration.type][integration.integrationType];
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
}
|
|
|
|
}
|