From d110992f8143c41bbba6e6b530a1ea6dde4176c9 Mon Sep 17 00:00:00 2001 From: Sebastian Rettig Date: Fri, 23 Oct 2020 15:07:56 +0200 Subject: [PATCH 1/3] fix(player): missing fullscreen button now shown --- src/H5PPlayer.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/H5PPlayer.ts b/src/H5PPlayer.ts index 100d6bc37..350bc7368 100644 --- a/src/H5PPlayer.ts +++ b/src/H5PPlayer.ts @@ -118,6 +118,16 @@ export default class H5PPlayer { const libraries = await this.getMetadataRecursive(dependencies); const assets = this.aggregateAssetsRecursive(dependencies, libraries); + const mainLibrarySupportsFullscreen = !metadata.mainLibrary + ? false + : libraries[ + LibraryName.toUberName( + metadata.preloadedDependencies.find( + (dep) => dep.machineName === metadata.mainLibrary + ) + ) + ].fullscreen === 1; + const model: IPlayerModel = { contentId, downloadPath: this.getDownloadPath(contentId), @@ -125,7 +135,8 @@ export default class H5PPlayer { contentId, parameters, metadata, - assets + assets, + mainLibrarySupportsFullscreen ), scripts: this.listCoreScripts() .concat(this.globalCustomScripts) @@ -236,7 +247,8 @@ export default class H5PPlayer { contentId: ContentId, parameters: ContentParameters, metadata: IContentMetadata, - assets: IAssets + assets: IAssets, + supportsFullscreen: boolean ): IIntegration { // see https://h5p.org/creating-your-own-h5p-plugin log.info(`generating integration for ${contentId}`); @@ -251,7 +263,7 @@ export default class H5PPlayer { frame: false, icon: false }, - fullScreen: '0', + fullScreen: supportsFullscreen ? '1' : '0', jsonContent: JSON.stringify(parameters), library: ContentMetadata.toUbername(metadata), contentUrl: this.config.contentFilesUrlPlayerOverride?.replace( From 59eabcb91d665af5e5e1675b527af959b97e565f Mon Sep 17 00:00:00 2001 From: Sebastian Rettig Date: Fri, 23 Oct 2020 15:14:44 +0200 Subject: [PATCH 2/3] feat(configuration): added option to disable fullscreen --- examples/config.json | 1 + src/H5PEditor.ts | 1 + src/H5PPlayer.ts | 1 + src/implementation/H5PConfig.ts | 3 +++ src/types.ts | 4 ++++ 5 files changed, 10 insertions(+) diff --git a/examples/config.json b/examples/config.json index 43aada7c8..f3fb0d373 100644 --- a/examples/config.json +++ b/examples/config.json @@ -1,4 +1,5 @@ { + "disableFullscreen": false, "fetchingDisabled": 0, "uuid": "8de62c47-f335-42f6-909d-2d8f4b7fb7f5", "siteType": "local", diff --git a/src/H5PEditor.ts b/src/H5PEditor.ts index 32104672c..cf6037a71 100644 --- a/src/H5PEditor.ts +++ b/src/H5PEditor.ts @@ -881,6 +881,7 @@ export default class H5PEditor { libraryUrl: this.urlGenerator.coreFile('js'), pluginCacheBuster: '', // TODO make dynamic url: this.config.baseUrl, + fullscreenDisabled: this.config.disableFullscreen ? 1 : 0, user: { mail: '', name: '' diff --git a/src/H5PPlayer.ts b/src/H5PPlayer.ts index 350bc7368..9873ea0ca 100644 --- a/src/H5PPlayer.ts +++ b/src/H5PPlayer.ts @@ -295,6 +295,7 @@ export default class H5PPlayer { saveFreq: false, url: this.config.baseUrl, hubIsEnabled: true, + fullscreenDisabled: this.config.disableFullscreen ? 1 : 0, ...this.integrationObjectDefaults }; } diff --git a/src/implementation/H5PConfig.ts b/src/implementation/H5PConfig.ts index 9f560d5ff..d2d3e05ca 100644 --- a/src/implementation/H5PConfig.ts +++ b/src/implementation/H5PConfig.ts @@ -32,6 +32,7 @@ export default class H5PConfig implements IH5PConfig { minor: 24 }; public coreUrl: string = '/core'; + public disableFullscreen: boolean = false; public downloadUrl: string = '/download'; public editorAddons?: { [machineName: string]: string[]; @@ -76,6 +77,7 @@ export default class H5PConfig implements IH5PConfig { await this.loadSettingFromStorage('contentWhitelist'); await this.loadSettingFromStorage('editorAddons'); await this.loadSettingFromStorage('enableLrsContentTypes'); + await this.loadSettingFromStorage('disableFullscreen'); await this.loadSettingFromStorage('fetchingDisabled'); await this.loadSettingFromStorage('hubContentTypesEndpoint'); await this.loadSettingFromStorage('hubRegistrationEndpoint'); @@ -100,6 +102,7 @@ export default class H5PConfig implements IH5PConfig { await this.saveSettingToStorage('contentWhitelist'); await this.saveSettingToStorage('editorAddons'); await this.saveSettingToStorage('enableLrsContentTypes'); + await this.saveSettingToStorage('disableFullscreen'); await this.saveSettingToStorage('fetchingDisabled'); await this.saveSettingToStorage('hubContentTypesEndpoint'); await this.saveSettingToStorage('hubRegistrationEndpoint'); diff --git a/src/types.ts b/src/types.ts index 55fc58120..5b18bd35b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1323,6 +1323,10 @@ export interface IH5PConfig { * Path to the H5P core files directory. */ coreUrl: string; + /** + * If true, the fullscreen button will not be shown to the user. + */ + disableFullscreen: boolean; /** * Path to the downloadable H5P packages. */ From 1c93051daac242f365ca3dc0306cb72db40823c2 Mon Sep 17 00:00:00 2001 From: Sebastian Rettig Date: Fri, 23 Oct 2020 15:17:52 +0200 Subject: [PATCH 3/3] test(configuration): corrected test --- test/H5PPlayer.renderHtmlPage.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/H5PPlayer.renderHtmlPage.test.ts b/test/H5PPlayer.renderHtmlPage.test.ts index 15bb32f6e..057066537 100644 --- a/test/H5PPlayer.renderHtmlPage.test.ts +++ b/test/H5PPlayer.renderHtmlPage.test.ts @@ -158,7 +158,8 @@ describe('Rendering the HTML page', () => { "postUserStatistics": false, "saveFreq": false, "url": "/h5p", - "hubIsEnabled": true + "hubIsEnabled": true, + "fullscreenDisabled": 0 }; @@ -414,7 +415,8 @@ describe('Rendering the HTML page', () => { "postUserStatistics": false, "saveFreq": false, "url": "/h5p", - "hubIsEnabled": true + "hubIsEnabled": true, + "fullscreenDisabled": 0 };