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