From b797cbc97ba1b1da4df81581e36621b3b3d2c569 Mon Sep 17 00:00:00 2001 From: Deyan Nenov Date: Wed, 3 Jul 2024 14:15:12 +0100 Subject: [PATCH] Dyn-7190: videos from backend (#25) * serve training video from backend * 1.0.16 --- package-lock.json | 4 ++-- package.json | 2 +- src/components/Learning/PageLearning.jsx | 21 ++++++++++++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2f16a4c..d2e4e11 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dynamods/dynamo-home", - "version": "1.0.15", + "version": "1.0.16", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@dynamods/dynamo-home", - "version": "1.0.15", + "version": "1.0.16", "license": "MIT", "dependencies": { "react": "^18.2.0", diff --git a/package.json b/package.json index 73b0194..11f7674 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dynamods/dynamo-home", - "version": "1.0.15", + "version": "1.0.16", "description": "Dynamo Home", "author": "Autodesk Inc.", "main": "index.js", diff --git a/src/components/Learning/PageLearning.jsx b/src/components/Learning/PageLearning.jsx index f03ac46..830dce4 100644 --- a/src/components/Learning/PageLearning.jsx +++ b/src/components/Learning/PageLearning.jsx @@ -7,15 +7,18 @@ import { GuideGridItem } from "./GuideGridItem.jsx"; import { FormattedMessage } from 'react-intl'; export function LearningPage(){ - // Set a placeholder for the guides which will be used differently during dev and prod + // Set a placeholder for the guides, and videos which will be used differently during dev and prod let initialGuides = []; + let initialVideos = []; // If we are under development, we will load the graphs from the local asset folder if (process.env.NODE_ENV === 'development') { initialGuides = require('../../assets/learning.js').guides; + initialVideos = require('../../assets/learning.js').videos; } const [guides, setGuides] = useState(initialGuides); + const [videos, setVideos] = useState(initialVideos); // A method exposed to the backend used to set the interactive guides data coming from Dynamo const receiveInteractiveGuidesDataFromDotNet = (jsonData) => { @@ -24,7 +27,18 @@ export function LearningPage(){ const data = jsonData; setGuides(data); } catch (error) { - console.error('Error processing data:', error); + console.error('Error processing guides data:', error); + } + }; + + // A method exposed to the backend used to set the training video data coming from Dynamo + const receiveTrainingVideoDataFromDotNet = (jsonData) => { + try { + // jsonData is already an object, so no need to parse it + const data = jsonData; + setVideos(data); + } catch (error) { + console.error('Error processing videos data:', error); } }; @@ -32,13 +46,14 @@ export function LearningPage(){ // If we are under production, we will override the graphs with the actual data sent from Dynamo if (process.env.NODE_ENV !== 'development') { window.receiveInteractiveGuidesDataFromDotNet = receiveInteractiveGuidesDataFromDotNet; + window.receiveTrainingVideoDataFromDotNet = receiveTrainingVideoDataFromDotNet; } - // Cleanup function (optional) return () => { if (process.env.NODE_ENV !== 'development') { delete window.receiveInteractiveGuidesDataFromDotNet; + delete window.receiveTrainingVideoDataFromDotNet; } }; }, []);