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";
|
|
|
|
import { ContainerContent } from "angular2-modal";
|
2017-06-04 23:31:31 -04:00
|
|
|
import { IrcConfigComponent } from "../configs/irc/irc-config.component";
|
2017-05-29 00:51:04 -04:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class IntegrationService {
|
|
|
|
|
|
|
|
private static supportedTypeMap = {
|
|
|
|
"bot": true,
|
|
|
|
"complex-bot": {
|
|
|
|
"rss": true
|
2017-06-04 23:31:31 -04:00
|
|
|
},
|
|
|
|
"bridge": {
|
|
|
|
"irc": true
|
2017-05-29 00:51:04 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
private static components = {
|
|
|
|
"complex-bot": {
|
|
|
|
"rss": RssConfigComponent
|
2017-06-04 23:31:31 -04:00
|
|
|
},
|
|
|
|
"bridge": {
|
|
|
|
"irc": IrcConfigComponent
|
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() {
|
|
|
|
}
|
|
|
|
}
|