From 62b950f0ec62884c663b489e82c8ad340a00c813 Mon Sep 17 00:00:00 2001 From: Guilherme Leme Date: Mon, 25 Nov 2024 10:23:38 -0300 Subject: [PATCH 1/2] [asset-persistence] - asset-persistence feature created for front-end. --- .../manifest.json | 6 ++++- .../component.tsx | 14 +++++++++-- src/asset-persistence/enums.ts | 7 ++++++ src/asset-persistence/hook.ts | 23 +++++++++++++++++++ src/asset-persistence/types.ts | 14 +++++++++++ src/core/api/BbbPluginSdk.ts | 12 ++++++++++ src/core/api/types.ts | 8 +++++++ 7 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 src/asset-persistence/enums.ts create mode 100644 src/asset-persistence/hook.ts create mode 100644 src/asset-persistence/types.ts diff --git a/samples/sample-action-button-dropdown-plugin/manifest.json b/samples/sample-action-button-dropdown-plugin/manifest.json index bbb6ec40..2be150f3 100644 --- a/samples/sample-action-button-dropdown-plugin/manifest.json +++ b/samples/sample-action-button-dropdown-plugin/manifest.json @@ -3,5 +3,9 @@ "name": "SampleActionButtonDropdownPlugin", "javascriptEntrypointUrl": "SampleActionButtonDropdownPlugin.js", "localesBaseUrl": "https://cdn.dominio.com/pluginabc/", - "enabledForBreakoutRooms": true + "assetPersistence": { + "enabled": true, + "maxFileSize": 10, + "maxUploadSizePerUser": 100 + } } diff --git a/samples/sample-action-button-dropdown-plugin/src/components/sample-action-button-dropdown-plugin-item/component.tsx b/samples/sample-action-button-dropdown-plugin/src/components/sample-action-button-dropdown-plugin-item/component.tsx index 26f3ca19..f1d8948b 100644 --- a/samples/sample-action-button-dropdown-plugin/src/components/sample-action-button-dropdown-plugin-item/component.tsx +++ b/samples/sample-action-button-dropdown-plugin/src/components/sample-action-button-dropdown-plugin-item/component.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; import { useState, useEffect } from 'react'; +import { AssetType } from 'bigbluebutton-html-plugin-sdk/dist/cjs/asset-persistence/enums'; import * as ReactModal from 'react-modal'; import './style.css'; @@ -45,13 +46,22 @@ function SampleActionButtonDropdownPlugin( IsMeetingBreakoutGraphqlResponse>(IS_MEETING_BREAKOUT); useEffect(() => { + // This line is commented once it will upload a + // PDF everytime you enter a meeting + // (if you have presenter role). + // Uncomment them to test this feature! + pluginApi.persistAsset( + 'https://pdfobject.com/pdf/sample.pdf', + AssetType.PRESENTATION, + 'my-presentation.pdf', + ); pluginApi.uiCommands.notification.send({ message: 'Notification message', icon: 'presentation', type: NotificationTypeUiCommand.INFO, options: { - // helpLabel: 'teste help label', // this is not necessary - // helpLink: 'teste help link', + // helpLabel: 'test help label', // this is not necessary + // helpLink: 'test help link', autoClose: 20000, }, content: 'Content of my notification', diff --git a/src/asset-persistence/enums.ts b/src/asset-persistence/enums.ts new file mode 100644 index 00000000..ebe5e97b --- /dev/null +++ b/src/asset-persistence/enums.ts @@ -0,0 +1,7 @@ +export enum AssetPersistenceEvents { + ASSET_PERSISTED = 'PLUGIN_ASSET_PERSISTED', +} + +export enum AssetType { + PRESENTATION = 'PLUGIN_ASSET_PERSISTENCE_TYPE_PRESENTATION' +} diff --git a/src/asset-persistence/hook.ts b/src/asset-persistence/hook.ts new file mode 100644 index 00000000..bd8cdafe --- /dev/null +++ b/src/asset-persistence/hook.ts @@ -0,0 +1,23 @@ +import { + AssetPersistenceDetails, +} from './types'; +import { AssetPersistenceEvents, AssetType } from './enums'; + +export const persistAssetFunctionWrapper = ( + pluginName: string, + assetUrl: string, + typeOfAsset: AssetType, + assetName?: string, +) => { + window.dispatchEvent( + new CustomEvent< + AssetPersistenceDetails>(AssetPersistenceEvents.ASSET_PERSISTED, { + detail: { + pluginName, + assetUrl, + typeOfAsset, + assetName, + }, + }), + ); +}; diff --git a/src/asset-persistence/types.ts b/src/asset-persistence/types.ts new file mode 100644 index 00000000..0a90fca7 --- /dev/null +++ b/src/asset-persistence/types.ts @@ -0,0 +1,14 @@ +import { AssetType } from './enums'; + +export interface AssetPersistenceDetails { + pluginName: string; + assetUrl: string; + typeOfAsset: AssetType; + assetName?: string; +} + +export type PersistAssetFunction = ( + assetUrl: string, + typeOfAsset: AssetType, + assetName?: string, +) => void; diff --git a/src/core/api/BbbPluginSdk.ts b/src/core/api/BbbPluginSdk.ts index 33402820..c556344c 100644 --- a/src/core/api/BbbPluginSdk.ts +++ b/src/core/api/BbbPluginSdk.ts @@ -48,6 +48,8 @@ import { sendGenericDataForLearningAnalyticsDashboard } from '../../learning-ana import { GenericDataForLearningAnalyticsDashboard } from '../../learning-analytics-dashboard/types'; import { getRemoteData } from '../../remote-data/utils'; import { persistEventFunctionWrapper } from '../../event-persistence/hooks'; +import { persistAssetFunctionWrapper } from '../../asset-persistence/hook'; +import { AssetType } from '../../asset-persistence/enums'; declare const window: PluginBrowserWindow; @@ -123,6 +125,16 @@ export abstract class BbbPluginSdk { eventName, payload, ); + pluginApi.persistAsset = ( + assetUrl: string, + typeOfAsset: AssetType, + assetName?: string, + ) => persistAssetFunctionWrapper( + pluginName, + assetUrl, + typeOfAsset, + assetName, + ); } else { throw new Error('Plugin name not set'); } diff --git a/src/core/api/types.ts b/src/core/api/types.ts index 65515682..7ca76d56 100644 --- a/src/core/api/types.ts +++ b/src/core/api/types.ts @@ -32,6 +32,7 @@ import { UseUserCameraDomElementsFunction } from '../../dom-element-manipulation import { ScreenshareHelperInterface, UserCameraHelperInterface } from '../../extensible-areas'; import { GetDataSource } from '../../remote-data/types'; import { PersistEventFunction } from '../../event-persistence/types'; +import { PersistAssetFunction } from '../../asset-persistence/types'; // Setter Functions for the API export type SetPresentationToolbarItems = (presentationToolbarItem: @@ -259,6 +260,13 @@ export interface PluginApi { * */ persistEvent?: PersistEventFunction; + /** + * Persists assets to the current meeting, e.g.: presentation. + * + * @param payload - payload to be persisted in `events.xml` + * + */ + persistAsset?: PersistAssetFunction; } export interface PluginBrowserWindow extends Window { From 7278bdd8d93685e70094eb0a8a22e99dbff90c2b Mon Sep 17 00:00:00 2001 From: Guilherme Leme Date: Thu, 28 Nov 2024 10:18:05 -0300 Subject: [PATCH 2/2] samples/sample-action-button-dropdown-plugin/manifest.json --- samples/sample-action-button-dropdown-plugin/manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/sample-action-button-dropdown-plugin/manifest.json b/samples/sample-action-button-dropdown-plugin/manifest.json index 2be150f3..a04ff4f8 100644 --- a/samples/sample-action-button-dropdown-plugin/manifest.json +++ b/samples/sample-action-button-dropdown-plugin/manifest.json @@ -5,7 +5,7 @@ "localesBaseUrl": "https://cdn.dominio.com/pluginabc/", "assetPersistence": { "enabled": true, - "maxFileSize": 10, - "maxUploadSizePerUser": 100 + "maxFileSize": 10000000, + "maxUploadSizePerUser": 100000000 } }