bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/plugins-engine/manager.tsx
Guilherme Pereira Leme ccb2e74bc1
feat(plugin): Added sendGenericDataForLearningAnalyticsDashboard for plugins (#20628)
* [data-channel-analytics-options]  - Added data-channel analytics and record options and added a parameter options for the useDataChannel function

* Update bigbluebutton-html5/public/locales/en.json

Co-authored-by: Gustavo Trott <gustavo@trott.com.br>

* [data-channel-analytics-options] -created new sendDataAnalytics for plugin and change presentation toolbar button

* [data-channel-analytics-options]  - QUICK FIX

* [update-data-channel-function] - fix action metadata

* [data-channel-analytics-options] - changes in review

* [data-channel-analytics-options]  - changes in review

* [captionLocale] - Changes in review

* [data-channel-analytics-options]  - update SDK

* [data-channel-analytics-options]  Changes in review

* [data-channel-analytics-options] - changes in review

* [data-channel-analytics-options] - changes in review

* [data-channel-analytics-options] - changes in review

* Refactor learning dashboard json structure with genericData

* fix typo

* [data-channel-analytics-options] - changes according to new json structure

* changes in review

---------

Co-authored-by: Anton Georgiev <antobinary@users.noreply.github.com>
Co-authored-by: Gustavo Trott <gustavo@trott.com.br>
2024-07-05 16:49:45 -03:00

99 lines
3.2 KiB
TypeScript

import React, {
useEffect, useRef, useState, useMemo,
} from 'react';
import logger from '/imports/startup/client/logger';
import {
BbbPluginSdk,
} from 'bigbluebutton-html-plugin-sdk';
import * as PluginSdk from 'bigbluebutton-html-plugin-sdk';
import * as uuidLib from 'uuid';
import PluginDataConsumptionManager from './data-consumption/manager';
import PluginsEngineComponent from './component';
import { PluginConfig, EffectivePluginConfig } from './types';
import PluginLoaderManager from './loader/manager';
import ExtensibleAreaStateManager from './extensible-areas/manager';
import PluginDataChannelManager from './data-channel/manager';
import PluginUiCommandsHandler from './ui-commands/handler';
import PluginDomElementManipulationManager from './dom-element-manipulation/manager';
import PluginServerCommandsHandler from './server-commands/handler';
import PluginLearningAnalyticsDashboardManager from './learning-analytics-dashboard/manager';
const PluginsEngineManager = () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - temporary, while meteor exists in the project
const PLUGINS_CONFIG = window.meetingClientSettings.public.plugins;
// If there is no plugin to load, the engine simply returns null
if (!PLUGINS_CONFIG) return null;
const containerRef = useRef<HTMLDivElement>(null);
const [lastLoadedPlugin, setLastLoadedPlugin] = useState<HTMLScriptElement | undefined>();
const loadedPlugins = useRef<number>(0);
const effectivePluginsConfig: EffectivePluginConfig[] = useMemo<EffectivePluginConfig[]>(
() => PLUGINS_CONFIG.map((p: PluginConfig) => ({
...p,
uuid: uuidLib.v4(),
} as EffectivePluginConfig)), [
PLUGINS_CONFIG,
],
);
const totalNumberOfPlugins = PLUGINS_CONFIG?.length;
window.React = React;
useEffect(() => {
logger.info(`${loadedPlugins.current}/${totalNumberOfPlugins} plugins loaded`);
},
[loadedPlugins.current, lastLoadedPlugin]);
return (
<>
<PluginsEngineComponent
{...{
containerRef,
}}
/>
<PluginDataConsumptionManager />
<PluginServerCommandsHandler />
<PluginUiCommandsHandler />
<PluginDomElementManipulationManager />
{
effectivePluginsConfig.map((effectivePluginConfig: EffectivePluginConfig) => {
const { uuid, name: pluginName } = effectivePluginConfig;
const pluginApi: PluginSdk.PluginApi = BbbPluginSdk.getPluginApi(uuid, pluginName);
return (
<div key={uuid}>
<PluginLoaderManager
{...{
uuid,
containerRef,
loadedPlugins,
setLastLoadedPlugin,
pluginConfig: effectivePluginConfig,
}}
/>
<PluginLearningAnalyticsDashboardManager
pluginName={pluginName}
/>
<PluginDataChannelManager
{...{
pluginApi,
}}
/>
<ExtensibleAreaStateManager
{...{
pluginApi,
uuid,
}}
/>
</div>
);
})
}
</>
);
};
export default PluginsEngineManager;