2017-12-22 23:08:10 -05:00
|
|
|
import { Injectable } from "@angular/core";
|
2017-12-10 04:35:24 -05:00
|
|
|
import {
|
2018-10-21 17:17:21 -04:00
|
|
|
WIDGET_CUSTOM,
|
|
|
|
WIDGET_ETHERPAD,
|
|
|
|
WIDGET_GOOGLE_CALENDAR,
|
|
|
|
WIDGET_GOOGLE_DOCS,
|
|
|
|
WIDGET_GRAFANA,
|
2018-10-21 19:00:10 -04:00
|
|
|
WIDGET_JITSI, WIDGET_SPOTIFY,
|
2018-10-21 18:19:36 -04:00
|
|
|
WIDGET_TRADINGVIEW,
|
2018-10-21 17:17:21 -04:00
|
|
|
WIDGET_TWITCH,
|
2017-12-14 00:44:20 -05:00
|
|
|
WIDGET_YOUTUBE
|
2017-12-15 01:46:17 -05:00
|
|
|
} from "../models/widget";
|
2017-12-24 04:02:57 -05:00
|
|
|
import { FE_Integration } from "../models/integration";
|
2017-05-29 00:51:04 -04:00
|
|
|
|
|
|
|
@Injectable()
|
2017-12-24 04:02:57 -05:00
|
|
|
export class IntegrationsRegistry {
|
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-22 23:08:10 -05:00
|
|
|
"rss": {},
|
|
|
|
"travisci": {},
|
|
|
|
"circleci": {},
|
2017-06-04 23:31:31 -04:00
|
|
|
},
|
|
|
|
"bridge": {
|
2017-12-22 23:08:10 -05:00
|
|
|
"irc": {},
|
2018-10-17 23:09:19 -04:00
|
|
|
"telegram": {},
|
2018-10-20 20:33:01 -04:00
|
|
|
"webhooks": {},
|
2018-10-21 16:20:37 -04:00
|
|
|
"gitter": {},
|
2017-08-29 00:08:32 -04:00
|
|
|
},
|
|
|
|
"widget": {
|
2017-12-20 23:47:35 -05:00
|
|
|
"custom": {
|
2017-12-14 00:44:20 -05:00
|
|
|
types: WIDGET_CUSTOM,
|
2017-12-10 04:35:24 -05:00
|
|
|
},
|
|
|
|
"youtube": {
|
2017-12-14 00:44:20 -05:00
|
|
|
types: WIDGET_YOUTUBE
|
2017-12-10 04:35:24 -05:00
|
|
|
},
|
|
|
|
"etherpad": {
|
2017-12-14 00:44:20 -05:00
|
|
|
types: WIDGET_ETHERPAD,
|
2017-12-10 04:35:24 -05:00
|
|
|
},
|
|
|
|
"twitch": {
|
2017-12-14 00:44:20 -05:00
|
|
|
types: WIDGET_TWITCH,
|
2017-12-10 04:35:24 -05:00
|
|
|
},
|
|
|
|
"jitsi": {
|
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": {
|
2017-12-14 00:44:20 -05:00
|
|
|
types: WIDGET_GOOGLE_DOCS,
|
2017-12-11 19:29:57 -05:00
|
|
|
},
|
|
|
|
"googlecalendar": {
|
2017-12-14 00:44:20 -05:00
|
|
|
types: WIDGET_GOOGLE_CALENDAR,
|
2017-12-11 18:43:50 -05:00
|
|
|
},
|
2018-10-21 17:17:21 -04:00
|
|
|
"grafana": {
|
|
|
|
types: WIDGET_GRAFANA,
|
2018-10-21 18:19:36 -04:00
|
|
|
},
|
|
|
|
"tradingview": {
|
|
|
|
types: WIDGET_TRADINGVIEW,
|
|
|
|
},
|
2018-10-21 19:00:10 -04:00
|
|
|
"spotify": {
|
|
|
|
types: WIDGET_SPOTIFY,
|
|
|
|
},
|
2017-08-29 00:08:32 -04:00
|
|
|
},
|
2017-05-29 00:51:04 -04:00
|
|
|
};
|
|
|
|
|
2017-12-24 04:02:57 -05:00
|
|
|
static isSupported(integration: FE_Integration): boolean {
|
|
|
|
const forType = IntegrationsRegistry.supportedIntegrationsMap[integration.category];
|
2017-12-10 04:35:24 -05:00
|
|
|
if (!forType) return false;
|
|
|
|
|
|
|
|
if (Object.keys(forType).length === 0) return true;
|
|
|
|
|
2017-12-20 23:28:43 -05:00
|
|
|
return forType[integration.type]; // has sub type
|
2017-05-29 00:51:04 -04:00
|
|
|
}
|
|
|
|
|
2017-12-20 23:28:43 -05:00
|
|
|
static getIntegrationForScreen(screen: string): { category: string, type: string } {
|
2017-12-24 04:02:57 -05:00
|
|
|
for (const category of Object.keys(IntegrationsRegistry.supportedIntegrationsMap)) {
|
|
|
|
for (const type of Object.keys(IntegrationsRegistry.supportedIntegrationsMap[category])) {
|
|
|
|
const integrationTypes = IntegrationsRegistry.supportedIntegrationsMap[category][type].types;
|
2017-12-22 23:42:43 -05:00
|
|
|
if (!integrationTypes) continue;
|
|
|
|
|
2017-12-14 00:44:20 -05:00
|
|
|
const integrationScreens = integrationTypes.map(t => "type_" + t);
|
2017-12-22 23:42:43 -05:00
|
|
|
if (integrationScreens.includes(screen)) return {category: category, type: type};
|
2017-12-10 04:35:24 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2017-05-29 00:51:04 -04:00
|
|
|
}
|
|
|
|
|
2017-12-20 23:28:43 -05:00
|
|
|
private constructor() {
|
2017-05-29 00:51:04 -04:00
|
|
|
}
|
|
|
|
}
|