Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 Frontend fixes for meeting panel #1035

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/api/views/meeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
meeting = Blueprint("meeting", __name__)

API_KEY = os.environ.get("EIGHT_X_EIGHT_API_KEY")
APP_ID = os.environ.get("REACT_APP_EIGHT_X_EIGHT_APP_ID")
APP_ID = os.environ.get("EIGHT_X_EIGHT_APP_ID")
ENCODED_PRIVATE_KEY = os.environ.get('EIGHT_X_EIGHT_ENCODED_PRIVATE_KEY')

@meeting.route("/generateToken", methods=["GET"])
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ function App() {
<CreateMeetingLink />
</PrivateRoute>
</Content>
<MeetingPanel />
</Layout>
<MeetingPanel />
</Router>
</ConfigProvider>
</>
Expand Down
78 changes: 20 additions & 58 deletions frontend/src/components/CreateMeetingLink.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { useState, useEffect , useRef} from "react";
import React, { useState, useEffect, useRef } from "react";
import { Modal, Button, Input, Typography, message } from "antd";
import { CopyOutlined } from "@ant-design/icons";
import { useTranslation } from "react-i18next";
import { generateToken } from "utils/api";
import { useDispatch } from 'react-redux';
import { setPanel, removePanel } from 'features/meetingPanelSlice';
import { JaaSMeeting } from '@jitsi/react-sdk';
import { useHistory } from "react-router-dom";

const { Title } = Typography;
Expand All @@ -16,16 +15,13 @@ function Meeting() {
const [RoomName, setRoomName] = useState("");
const [Token, setToken] = useState("");
const [AppID, setAppID] = useState("");
const [reloadFlag, setReloadFlag] = useState(false);
const history = useHistory();
const dispatch = useDispatch();
const { t } = useTranslation();

// const ReactAppID = process.env.REACT_APP_EIGHT_X_EIGHT_APP_ID;

const copyToClipboard = () => {
try {
navigator.clipboard.writeText(RoomName);;
navigator.clipboard.writeText(RoomName);
message.success(t("meeting.copyMessage"));
} catch (error) {
console.error(t("meeting.errorCopy"), error);
Expand All @@ -47,67 +43,31 @@ function Meeting() {
}
};

const createSidePanel = () => {
return (
<div>
<JaaSMeeting
getIFrameRef={iframeRef => {
iframeRef.style.position = 'fixed';
iframeRef.style.bottom = 0;
iframeRef.style.right = 0;
iframeRef.style.width = '30%';
iframeRef.style.height = 'calc(100vh - 50px)';
}}
appId={AppID}
roomName={{AppID} + '/' + RoomName}
jwt={Token}
configOverwrite={{
disableThirdPartyRequests: true,
disableLocalVideoFlip: true,
backgroundAlpha: 0.5
}}
interfaceConfigOverwrite={{
VIDEO_LAYOUT_FIT: 'nocrop',
MOBILE_APP_PROMO: false,
TILE_VIEW_MAX_COLUMNS: 4
}}
/>
</div>
);
};

const joinMeeting = () => {
const joinMeeting = async () => {
try {
if (!RoomName) {
console.error(t("meeting.roomName"));
message.error(t("meeting.roomName"));
return;
}
getToken();

const response = await getToken();
dispatch(removePanel());
document.body.style.marginRight = "30%";
document.body.style.transition = "margin-right 0.3s";
dispatch(setPanel(createSidePanel()));
setTimeout(() => {
dispatch(setPanel({ app_id: response.appID, room_name: RoomName, token: response.token }));
}, 500);
} catch (error) {
console.error("Error: ", error);
message.error(t("meeting.getToken"));
}
};

const getToken = () => {
const getToken = async () => {
try {
if (reloadFlag) {
localStorage.setItem("roomName", RoomName);
window.location.reload();
}
setReloadFlag(true);
generateToken().then(resp => {
setToken(resp.token);
setAppID(resp.appID);
}).catch(error => {
console.error('Error:', error);
message.error(t("meeting.generateToken"));
});
const resp = await generateToken();
setToken(resp.token);
setAppID(resp.appID);
return resp
} catch (error) {
console.error('Error:', error);
message.error(t("meeting.generateToken"));
Expand All @@ -131,15 +91,17 @@ function Meeting() {
}
}, []);

const handleCancel = () => {
setUrlModalVisible(false);
redirectBack();
};

return (
<>
<Modal
title={t("meeting.title")}
visible={urlModalVisible}
onCancel={() => {
setUrlModalVisible(false);
redirectBack();
}}
onCancel={handleCancel}
footer={[
<div key="left-buttons" style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<Button key="generate" style={{ color: 'red', borderColor: 'red', backgroundColor: 'white' }} onClick={getRoomName}>
Expand All @@ -149,7 +111,7 @@ function Meeting() {
<Button ref={joinButtonRef} key="join" type="primary" onClick={joinMeeting}>
{t("meeting.joinMeeting")}
</Button>,
<Button key="cancel" style={{ marginLeft: '8px' }} onClick={redirectBack}>
<Button key="cancel" style={{ marginLeft: '8px' }} onClick={handleCancel}>
{t("meeting.cancelButton")}
</Button>,
</div>
Expand Down
61 changes: 54 additions & 7 deletions frontend/src/components/MeetingPanel.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,64 @@
import { useSelector, useDispatch } from 'react-redux';
import { setPanel } from 'features/meetingPanelSlice';
import { JaaSMeeting, JitsiMeeting } from '@jitsi/react-sdk';
import React, { useRef, useState } from 'react';
import { setPanel, removePanel } from 'features/meetingPanelSlice';

const MeetingPanel = () => {
const panelComponent = useSelector((state) => state.meetingPanel.panelComponent);
const dispatch = useDispatch();
var panelComponent = useSelector((state) => state.meetingPanel.panelComponent);

return (
<div>
{panelComponent}
</div>
);
const ClosePanel = (event) => {
if (event === undefined) {
dispatch(removePanel());
}
};

if (panelComponent)
{
return (
<div style={{ position:'relative', width:'30%'}}>
<JaaSMeeting
getIFrameRef={iframeRef => {
iframeRef.style.position = 'fixed';
iframeRef.style.bottom = 0;
iframeRef.style.right = 0;
iframeRef.style.width = '30%';
iframeRef.style.height = '100%';
}}
appId={panelComponent.app_id}
roomName={panelComponent.room_name}
jwt={panelComponent.token}
configOverwrite={{
disableThirdPartyRequests: true,
disableLocalVideoFlip: true,
backgroundAlpha: 0.5
}}
interfaceConfigOverwrite={{
VIDEO_LAYOUT_FIT: 'nocrop',
MOBILE_APP_PROMO: false,
TILE_VIEW_MAX_COLUMNS: 4
}}
onReadyToClose={ClosePanel}
/>
<button
style={{
position: 'fixed',
top: '0',
right: '27.5%',
background: 'transparent',
border: 'none',
color: 'white',
fontSize: '2em',
zIndex: '100',
}}
onClick={() => ClosePanel()}
>
x
</button>
</div>
);
}
else {return <div></div>}
};

export default MeetingPanel;
Loading