2017-12-22 23:08:10 -05:00
|
|
|
import { Injectable } from "@angular/core";
|
2017-12-10 04:35:24 -05:00
|
|
|
import {
|
2020-07-23 16:59:48 -04:00
|
|
|
WIDGET_BIGBLUEBUTTON,
|
2021-11-30 21:27:37 -05:00
|
|
|
WIDGET_CUSTOM,
|
2018-10-21 17:17:21 -04:00
|
|
|
WIDGET_ETHERPAD,
|
|
|
|
WIDGET_GOOGLE_CALENDAR,
|
|
|
|
WIDGET_GOOGLE_DOCS,
|
|
|
|
WIDGET_GRAFANA,
|
2019-07-11 00:17:16 -04:00
|
|
|
WIDGET_JITSI,
|
|
|
|
WIDGET_SPOTIFY,
|
|
|
|
WIDGET_STICKER_PICKER,
|
2018-10-21 18:19:36 -04:00
|
|
|
WIDGET_TRADINGVIEW,
|
2018-10-21 17:17:21 -04:00
|
|
|
WIDGET_TWITCH,
|
2021-11-30 21:27:37 -05:00
|
|
|
WIDGET_WHITEBOARD,
|
|
|
|
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-25 00:49:29 -04:00
|
|
|
"slack": {},
|
2021-11-25 18:24:36 -05:00
|
|
|
"hookshot_github": {},
|
2021-11-30 21:25:35 -05:00
|
|
|
"hookshot_jira": {},
|
2021-12-02 21:07:22 -05:00
|
|
|
"hookshot_webhook": {},
|
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
|
|
|
},
|
2020-07-23 16:59:48 -04:00
|
|
|
"bigbluebutton": {
|
|
|
|
types: WIDGET_BIGBLUEBUTTON,
|
|
|
|
},
|
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,
|
|
|
|
},
|
2018-10-24 01:55:29 -04:00
|
|
|
"stickerpicker": {
|
|
|
|
types: WIDGET_STICKER_PICKER,
|
|
|
|
},
|
2020-09-02 03:56:08 -04:00
|
|
|
"whiteboard": {
|
|
|
|
type: WIDGET_WHITEBOARD,
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|