2017-05-29 00:51:04 -04:00
|
|
|
import { Injectable } from "@angular/core";
|
2017-12-20 23:28:43 -05:00
|
|
|
import { LegacyIntegration } from "../../models/legacyintegration";
|
|
|
|
import { RssConfigComponent } from "../../../configs/rss/rss-config.component";
|
2017-08-27 01:26:00 -04:00
|
|
|
import { ContainerContent } from "ngx-modialog";
|
2017-12-20 23:28:43 -05:00
|
|
|
import { IrcConfigComponent } from "../../../configs/irc/irc-config.component";
|
|
|
|
import { TravisCiConfigComponent } from "../../../configs/travisci/travisci-config.component";
|
|
|
|
import { CustomWidgetConfigComponent } from "../../../configs/widget/custom_widget/custom_widget-config.component";
|
|
|
|
import { YoutubeWidgetConfigComponent } from "../../../configs/widget/youtube/youtube-config.component";
|
|
|
|
import { TwitchWidgetConfigComponent } from "../../../configs/widget/twitch/twitch-config.component";
|
|
|
|
import { EtherpadWidgetConfigComponent } from "../../../configs/widget/etherpad/etherpad-config.component";
|
|
|
|
import { JitsiWidgetConfigComponent } from "../../../configs/widget/jitsi/jitsi-config.component";
|
2017-12-10 04:35:24 -05:00
|
|
|
import {
|
2017-12-14 00:44:20 -05:00
|
|
|
WIDGET_CUSTOM, WIDGET_ETHERPAD, WIDGET_GOOGLE_CALENDAR, WIDGET_GOOGLE_DOCS, WIDGET_JITSI, WIDGET_TWITCH,
|
|
|
|
WIDGET_YOUTUBE
|
2017-12-20 23:28:43 -05:00
|
|
|
} from "../../models/widget";
|
|
|
|
import { GoogleDocsWidgetConfigComponent } from "../../../configs/widget/googledocs/googledocs-config.component";
|
|
|
|
import { GoogleCalendarWidgetConfigComponent } from "../../../configs/widget/googlecalendar/googlecalendar-config.component";
|
|
|
|
import { CircleCiConfigComponent } from "../../../configs/circleci/circleci-config.component";
|
2017-05-29 00:51:04 -04:00
|
|
|
|
|
|
|
@Injectable()
|
2017-12-20 23:28:43 -05:00
|
|
|
export class LegacyIntegrationService {
|
2017-05-29 00:51:04 -04:00
|
|
|
|
2017-12-10 04:35:24 -05:00
|
|
|
private static supportedIntegrationsMap = {
|
|
|
|
"bot": {}, // empty == supported
|
2017-05-29 00:51:04 -04:00
|
|
|
"complex-bot": {
|
2017-12-10 04:35:24 -05:00
|
|
|
"rss": {
|
|
|
|
component: RssConfigComponent,
|
|
|
|
},
|
|
|
|
"travisci": {
|
|
|
|
component: TravisCiConfigComponent,
|
|
|
|
},
|
2017-12-15 08:12:25 -05:00
|
|
|
"circleci": {
|
|
|
|
component: CircleCiConfigComponent,
|
|
|
|
},
|
2017-06-04 23:31:31 -04:00
|
|
|
},
|
|
|
|
"bridge": {
|
2017-12-10 04:35:24 -05:00
|
|
|
"irc": {
|
|
|
|
component: IrcConfigComponent,
|
|
|
|
},
|
2017-08-29 00:08:32 -04:00
|
|
|
},
|
|
|
|
"widget": {
|
2017-12-10 04:35:24 -05:00
|
|
|
"customwidget": {
|
|
|
|
component: CustomWidgetConfigComponent,
|
2017-12-14 00:44:20 -05:00
|
|
|
types: WIDGET_CUSTOM,
|
2017-12-10 04:35:24 -05:00
|
|
|
},
|
|
|
|
"youtube": {
|
|
|
|
component: YoutubeWidgetConfigComponent,
|
2017-12-14 00:44:20 -05:00
|
|
|
types: WIDGET_YOUTUBE
|
2017-12-10 04:35:24 -05:00
|
|
|
},
|
|
|
|
"etherpad": {
|
|
|
|
component: EtherpadWidgetConfigComponent,
|
2017-12-14 00:44:20 -05:00
|
|
|
types: WIDGET_ETHERPAD,
|
2017-12-10 04:35:24 -05:00
|
|
|
},
|
|
|
|
"twitch": {
|
|
|
|
component: TwitchWidgetConfigComponent,
|
2017-12-14 00:44:20 -05:00
|
|
|
types: WIDGET_TWITCH,
|
2017-12-10 04:35:24 -05:00
|
|
|
},
|
|
|
|
"jitsi": {
|
|
|
|
component: JitsiWidgetConfigComponent,
|
2017-12-14 00:44:20 -05:00
|
|
|
types: WIDGET_JITSI,
|
2017-12-10 04:35:24 -05:00
|
|
|
},
|
2017-12-11 18:43:50 -05:00
|
|
|
"googledocs": {
|
|
|
|
component: GoogleDocsWidgetConfigComponent,
|
2017-12-14 00:44:20 -05:00
|
|
|
types: WIDGET_GOOGLE_DOCS,
|
2017-12-11 19:29:57 -05:00
|
|
|
},
|
|
|
|
"googlecalendar": {
|
|
|
|
component: GoogleCalendarWidgetConfigComponent,
|
2017-12-14 00:44:20 -05:00
|
|
|
types: WIDGET_GOOGLE_CALENDAR,
|
2017-12-11 18:43:50 -05:00
|
|
|
},
|
2017-08-29 00:08:32 -04:00
|
|
|
},
|
2017-05-29 00:51:04 -04:00
|
|
|
};
|
|
|
|
|
2017-12-10 04:35:24 -05:00
|
|
|
static getAllConfigComponents(): ContainerContent[] {
|
|
|
|
const components = [];
|
|
|
|
|
2017-12-20 23:28:43 -05:00
|
|
|
for (const iType of Object.keys(LegacyIntegrationService.supportedIntegrationsMap)) {
|
|
|
|
for (const iiType of Object.keys(LegacyIntegrationService.supportedIntegrationsMap[iType])) {
|
|
|
|
const component = LegacyIntegrationService.supportedIntegrationsMap[iType][iiType].component;
|
2017-12-10 04:35:24 -05:00
|
|
|
if (component) components.push(component);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return components;
|
|
|
|
}
|
2017-05-29 00:51:04 -04:00
|
|
|
|
2017-12-20 23:28:43 -05:00
|
|
|
static isSupported(integration: LegacyIntegration): boolean {
|
|
|
|
const forType = LegacyIntegrationService.supportedIntegrationsMap[integration.type];
|
2017-12-10 04:35:24 -05:00
|
|
|
if (!forType) return false;
|
|
|
|
|
|
|
|
if (Object.keys(forType).length === 0) return true;
|
|
|
|
|
|
|
|
return forType[integration.integrationType]; // has sub type
|
2017-05-29 00:51:04 -04:00
|
|
|
}
|
|
|
|
|
2017-12-20 23:28:43 -05:00
|
|
|
static hasConfig(integration: LegacyIntegration): boolean {
|
2017-05-29 00:51:04 -04:00
|
|
|
return integration.type !== "bot";
|
|
|
|
}
|
|
|
|
|
2017-12-20 23:28:43 -05:00
|
|
|
static getConfigComponent(integration: LegacyIntegration): ContainerContent {
|
|
|
|
return LegacyIntegrationService.supportedIntegrationsMap[integration.type][integration.integrationType].component;
|
2017-12-10 04:35:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static getIntegrationForScreen(screen: string): { type: string, integrationType: string } {
|
2017-12-20 23:28:43 -05:00
|
|
|
for (const iType of Object.keys(LegacyIntegrationService.supportedIntegrationsMap)) {
|
|
|
|
for (const iiType of Object.keys(LegacyIntegrationService.supportedIntegrationsMap[iType])) {
|
|
|
|
const integrationTypes = LegacyIntegrationService.supportedIntegrationsMap[iType][iiType].types;
|
2017-12-14 00:44:20 -05:00
|
|
|
const integrationScreens = integrationTypes.map(t => "type_" + t);
|
|
|
|
if (integrationScreens.includes(screen)) return {type: iType, integrationType: iiType};
|
2017-12-10 04:35:24 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2017-05-29 00:51:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
}
|
|
|
|
}
|