Skip to content

Commit 9b316bd

Browse files
muhammadadeeltajamuladeel.tajamul
andauthored
feat: added live tab (#923)
Co-authored-by: adeel.tajamul <adeel.tajamul@arbisoft.com>
1 parent 7e7eb83 commit 9b316bd

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

src/course-home/data/api.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,20 @@ export async function getProctoringInfoData(courseId, username) {
297297
}
298298
}
299299

300+
export async function getLiveTabIframe(courseId) {
301+
const url = `${getConfig().LMS_BASE_URL}/api/course_live/iframe/${courseId}/`;
302+
try {
303+
const { data } = await getAuthenticatedHttpClient().get(url);
304+
return data;
305+
} catch (error) {
306+
const { httpErrorStatus } = error && error.customAttributes;
307+
if (httpErrorStatus === 404) {
308+
return {};
309+
}
310+
throw error;
311+
}
312+
}
313+
300314
export function getTimeOffsetMillis(headerDate, requestTime, responseTime) {
301315
// Time offset computation should move down into the HttpClient wrapper to maintain a global time correction reference
302316
// Requires 'Access-Control-Expose-Headers: Date' on the server response per https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#access-control-expose-headers

src/course-home/data/thunks.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
postWeeklyLearningGoal,
1212
postDismissWelcomeMessage,
1313
postRequestCert,
14+
getLiveTabIframe,
1415
} from './api';
1516

1617
import {
@@ -79,6 +80,10 @@ export function fetchOutlineTab(courseId) {
7980
return fetchTab(courseId, 'outline', getOutlineTabData);
8081
}
8182

83+
export function fetchLiveTab(courseId) {
84+
return fetchTab(courseId, 'live', getLiveTabIframe);
85+
}
86+
8287
export function fetchDiscussionTab(courseId) {
8388
return fetchTab(courseId, 'discussion');
8489
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React, { useEffect } from 'react';
2+
import { useSelector } from 'react-redux';
3+
4+
function LiveTab() {
5+
const { courseId } = useSelector(state => state.courseHome);
6+
const liveModel = useSelector(state => state.models.live);
7+
useEffect(() => {
8+
const iframe = document.getElementById('lti-tab-embed');
9+
if (iframe) {
10+
iframe.className += ' vh-100 w-100 border-0';
11+
}
12+
}, []);
13+
return (
14+
<div
15+
id="live_tab"
16+
// eslint-disable-next-line react/no-danger
17+
dangerouslySetInnerHTML={{ __html: liveModel[courseId]?.iframe }}
18+
/>
19+
);
20+
}
21+
22+
export default LiveTab;

src/index.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Switch } from 'react-router-dom';
1212

1313
import { messages as footerMessages } from '@edx/frontend-component-footer';
1414
import { messages as headerMessages } from '@edx/frontend-component-header';
15-
import { fetchDiscussionTab } from './course-home/data/thunks';
15+
import { fetchDiscussionTab, fetchLiveTab } from './course-home/data/thunks';
1616
import DiscussionTab from './course-home/discussion-tab/DiscussionTab';
1717

1818
import appMessages from './i18n';
@@ -33,6 +33,7 @@ import { fetchCourse } from './courseware/data';
3333
import initializeStore from './store';
3434
import NoticesProvider from './generic/notices';
3535
import PathFixesProvider from './generic/path-fixes';
36+
import LiveTab from './course-home/live-tab/LiveTab';
3637

3738
subscribe(APP_READY, () => {
3839
ReactDOM.render(
@@ -48,6 +49,11 @@ subscribe(APP_READY, () => {
4849
<OutlineTab />
4950
</TabContainer>
5051
</PageRoute>
52+
<PageRoute path="/course/:courseId/live">
53+
<TabContainer tab="live" fetch={fetchLiveTab} slice="courseHome">
54+
<LiveTab />
55+
</TabContainer>
56+
</PageRoute>
5157
<PageRoute path="/course/:courseId/dates">
5258
<TabContainer tab="dates" fetch={fetchDatesTab} slice="courseHome">
5359
<DatesTab />

0 commit comments

Comments
 (0)