Skip to content

Commit

Permalink
Dyn-7190: videos from backend (#25)
Browse files Browse the repository at this point in the history
* serve training video from backend

* 1.0.16
  • Loading branch information
dnenov authored Jul 3, 2024
1 parent 9ece841 commit b797cbc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
21 changes: 18 additions & 3 deletions src/components/Learning/PageLearning.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -24,21 +27,33 @@ 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);
}
};

useEffect(() => {
// 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;
}
};
}, []);
Expand Down

0 comments on commit b797cbc

Please sign in to comment.