[mirotalk] - add room rules, update dep.
This commit is contained in:
+3
-3
@@ -29,11 +29,11 @@
|
||||
"crypto-js": "^4.1.1",
|
||||
"dotenv": "^16.0.1",
|
||||
"express": "^4.18.1",
|
||||
"ngrok": "^4.3.1",
|
||||
"ngrok": "^4.3.3",
|
||||
"qs": "^6.11.0",
|
||||
"socket.io": "^4.5.1",
|
||||
"@sentry/node": "^7.10.0",
|
||||
"@sentry/integrations": "^7.10.0",
|
||||
"@sentry/node": "^7.11.1",
|
||||
"@sentry/integrations": "^7.11.1",
|
||||
"swagger-ui-express": "^4.5.0",
|
||||
"uuid": "8.3.2",
|
||||
"yamljs": "^0.3.0"
|
||||
|
||||
+107
-37
@@ -67,20 +67,39 @@ const chatInputEmoji = {
|
||||
}; // https://github.com/wooorm/gemoji/blob/main/support.md
|
||||
|
||||
// show desired buttons
|
||||
const showShareRoomBtn = true;
|
||||
const showAudioBtn = true;
|
||||
const showVideoBtn = true;
|
||||
const showSwapCameraBtn = true;
|
||||
const showScreenShareBtn = true;
|
||||
const showRecordStreamBtn = true;
|
||||
const showFullScreenBtn = true;
|
||||
const showChatRoomBtn = true;
|
||||
const showCaptionBtn = true;
|
||||
const showMyHandBtn = true;
|
||||
const showWhiteboardBtn = true;
|
||||
const showFileShareBtn = true;
|
||||
const showMySettingsBtn = true;
|
||||
const showAboutBtn = true;
|
||||
const buttons = {
|
||||
main: {
|
||||
showShareRoomBtn: true,
|
||||
showAudioBtn: true,
|
||||
showVideoBtn: true,
|
||||
showSwapCameraBtn: true,
|
||||
showScreenShareBtn: true,
|
||||
showRecordStreamBtn: true,
|
||||
showFullScreenBtn: true,
|
||||
showChatRoomBtn: true,
|
||||
showCaptionBtn: true,
|
||||
showMyHandBtn: true,
|
||||
showWhiteboardBtn: true,
|
||||
showFileShareBtn: true,
|
||||
showMySettingsBtn: true,
|
||||
showAboutBtn: true, // Please keep me always true, Thank you!
|
||||
},
|
||||
settings: {
|
||||
showTabRoomParticipants: true,
|
||||
showTabRoomSecurity: true,
|
||||
showMuteEveryoneBtn: true,
|
||||
showHideEveryoneBtn: true,
|
||||
showLockRoomBtn: true,
|
||||
showUnlockRoomBtn: true,
|
||||
},
|
||||
remote: {
|
||||
audioBtnClickAllowed: true,
|
||||
videoBtnClickAllowed: true,
|
||||
showKickOutBtn: true,
|
||||
},
|
||||
};
|
||||
|
||||
const isRulesActive = true; // Presenter can do anything, guest is slightly moderate, if false no Rules for the room.
|
||||
|
||||
const surveyActive = true; // when leaving the room give a feedback, if false will be redirected to newcall page
|
||||
|
||||
@@ -90,6 +109,8 @@ const forceCamMaxResolutionAndFps = false; // This force the webCam to max resol
|
||||
|
||||
let thisRoomPassword = null;
|
||||
|
||||
let isPresenter = false; // Who init the room (aka first peer joined)
|
||||
|
||||
let myPeerId; // socket.id
|
||||
let peerInfo = {}; // Some peer info
|
||||
let userAgent; // User agent info
|
||||
@@ -229,6 +250,8 @@ let themeSelect;
|
||||
let videoObjFitSelect;
|
||||
let btnsBarSelect;
|
||||
let selectors;
|
||||
let tabRoomParticipants;
|
||||
let tabRoomSecurity;
|
||||
// my video element
|
||||
let myVideo;
|
||||
let myVideoWrap;
|
||||
@@ -383,6 +406,8 @@ function getHtmlElementsById() {
|
||||
themeSelect = getId('mirotalkTheme');
|
||||
videoObjFitSelect = getId('videoObjFitSelect');
|
||||
btnsBarSelect = getId('mirotalkBtnsBar');
|
||||
tabRoomParticipants = getId('tabRoomParticipants');
|
||||
tabRoomSecurity = getId('tabRoomSecurity');
|
||||
// my conference name, hand, video - audio status
|
||||
myVideoParagraph = getId('myVideoParagraph');
|
||||
myHandStatusIcon = getId('myHandStatusIcon');
|
||||
@@ -756,6 +781,13 @@ async function handleConnect() {
|
||||
function handleServerInfo(config) {
|
||||
let peers_count = config.peers_count;
|
||||
console.log('13. Peers count', peers_count);
|
||||
|
||||
// Let start with some basic rules
|
||||
isPresenter = peers_count == 1 ? true : false;
|
||||
if (isRulesActive) {
|
||||
handleRules(isPresenter);
|
||||
}
|
||||
|
||||
if (notify && peers_count == 1) {
|
||||
welcomeUser();
|
||||
} else {
|
||||
@@ -763,6 +795,62 @@ function handleServerInfo(config) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Presenter can do anything, for others you can limit
|
||||
* some functions by hidden the buttons etc.
|
||||
*
|
||||
* @param {boolean} isPresenter true/false
|
||||
*/
|
||||
function handleRules(isPresenter) {
|
||||
console.log('14. Peer isPresenter: ' + isPresenter);
|
||||
if (!isPresenter) {
|
||||
buttons.settings.showTabRoomParticipants = false;
|
||||
buttons.settings.showTabRoomSecurity = false;
|
||||
buttons.remote.audioBtnClickAllowed = false;
|
||||
buttons.remote.videoBtnClickAllowed = false;
|
||||
buttons.remote.showKickOutBtn = false;
|
||||
//...
|
||||
|
||||
handleButtonsRule();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide not desired buttons
|
||||
*/
|
||||
function handleButtonsRule() {
|
||||
// Main
|
||||
if (!buttons.main.showShareRoomBtn) displayNone(shareRoomBtn);
|
||||
if (!buttons.main.showAudioBtn) displayNone(audioBtn);
|
||||
if (!buttons.main.showVideoBtn) displayNone(videoBtn);
|
||||
if (!buttons.main.showSwapCameraBtn) displayNone(swapCameraBtn);
|
||||
if (!buttons.main.showScreenShareBtn) displayNone(screenShareBtn);
|
||||
if (!buttons.main.showRecordStreamBtn) displayNone(recordStreamBtn);
|
||||
if (!buttons.main.showFullScreenBtn) displayNone(fullScreenBtn);
|
||||
if (!buttons.main.showChatRoomBtn) displayNone(chatRoomBtn);
|
||||
if (!buttons.main.showCaptionBtn) displayNone(captionBtn);
|
||||
if (!buttons.main.showMyHandBtn) displayNone(myHandBtn);
|
||||
if (!buttons.main.showWhiteboardBtn) displayNone(whiteboardBtn);
|
||||
if (!buttons.main.showFileShareBtn) displayNone(fileShareBtn);
|
||||
if (!buttons.main.showMySettingsBtn) displayNone(mySettingsBtn);
|
||||
if (!buttons.main.showAboutBtn) displayNone(aboutBtn);
|
||||
// Settings
|
||||
if (!buttons.settings.showMuteEveryoneBtn) displayNone(muteEveryoneBtn);
|
||||
if (!buttons.settings.showHideEveryoneBtn) displayNone(hideEveryoneBtn);
|
||||
if (!buttons.settings.showLockRoomBtn) displayNone(lockRoomBtn);
|
||||
if (!buttons.settings.showUnlockRoomBtn) displayNone(unlockRoomBtn);
|
||||
if (!buttons.settings.showTabRoomParticipants) displayNone(tabRoomParticipants);
|
||||
if (!buttons.settings.showTabRoomSecurity) displayNone(tabRoomSecurity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Element style display none
|
||||
* @param {object} elem
|
||||
*/
|
||||
function displayNone(elem) {
|
||||
elem.style.display = 'none';
|
||||
}
|
||||
|
||||
/**
|
||||
* set your name for the conference
|
||||
*/
|
||||
@@ -1669,7 +1757,7 @@ async function loadLocalMedia(stream) {
|
||||
getHtmlElementsById();
|
||||
setButtonsToolTip();
|
||||
manageLeftButtons();
|
||||
hideLeftButtons();
|
||||
handleButtonsRule();
|
||||
setupMySettings();
|
||||
setupVideoUrlPlayer();
|
||||
startCountTime();
|
||||
@@ -1842,7 +1930,7 @@ async function loadRemoteMediaStream(stream, peers, peer_id) {
|
||||
remoteStatusMenu.appendChild(remoteFileShareBtn);
|
||||
remoteStatusMenu.appendChild(remoteVideoAudioUrlBtn);
|
||||
remoteStatusMenu.appendChild(remoteVideoToImgBtn);
|
||||
remoteStatusMenu.appendChild(remotePeerKickOut);
|
||||
if (buttons.remote.showKickOutBtn) remoteStatusMenu.appendChild(remotePeerKickOut);
|
||||
remoteStatusMenu.appendChild(remoteVideoFullScreenBtn);
|
||||
|
||||
remoteMedia.setAttribute('id', peer_id + '_video');
|
||||
@@ -2302,26 +2390,6 @@ function manageLeftButtons() {
|
||||
setLeaveRoomBtn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide not desired buttons
|
||||
*/
|
||||
function hideLeftButtons() {
|
||||
if (!showShareRoomBtn) shareRoomBtn.style.display = 'none';
|
||||
if (!showAudioBtn) audioBtn.style.display = 'none';
|
||||
if (!showVideoBtn) videoBtn.style.display = 'none';
|
||||
if (!showSwapCameraBtn) swapCameraBtn.style.display = 'none';
|
||||
if (!showScreenShareBtn) screenShareBtn.style.display = 'none';
|
||||
if (!showRecordStreamBtn) recordStreamBtn.style.display = 'none';
|
||||
if (!showFullScreenBtn) fullScreenBtn.style.display = 'none';
|
||||
if (!showChatRoomBtn) chatRoomBtn.style.display = 'none';
|
||||
if (!showCaptionBtn) captionBtn.style.display = 'none';
|
||||
if (!showMyHandBtn) myHandBtn.style.display = 'none';
|
||||
if (!showWhiteboardBtn) whiteboardBtn.style.display = 'none';
|
||||
if (!showFileShareBtn) fileShareBtn.style.display = 'none';
|
||||
if (!showMySettingsBtn) mySettingsBtn.style.display = 'none';
|
||||
if (!showAboutBtn) aboutBtn.style.display = 'none';
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy - share room url button click event
|
||||
*/
|
||||
@@ -4567,6 +4635,7 @@ function setPeerAudioStatus(peer_id, status) {
|
||||
* @param {string} peer_id socket.id
|
||||
*/
|
||||
function handlePeerAudioBtn(peer_id) {
|
||||
if (!buttons.remote.audioBtnClickAllowed) return;
|
||||
let peerAudioBtn = getId(peer_id + '_audioStatus');
|
||||
peerAudioBtn.onclick = () => {
|
||||
if (peerAudioBtn.className === 'fas fa-microphone') disablePeer(peer_id, 'audio');
|
||||
@@ -4578,7 +4647,7 @@ function handlePeerAudioBtn(peer_id) {
|
||||
* @param {string} peer_id socket.id
|
||||
*/
|
||||
function handlePeerVideoBtn(peer_id) {
|
||||
if (!useVideo) return;
|
||||
if (!useVideo || !buttons.remote.videoBtnClickAllowed) return;
|
||||
let peerVideoBtn = getId(peer_id + '_videoStatus');
|
||||
peerVideoBtn.onclick = () => {
|
||||
if (peerVideoBtn.className === 'fas fa-video') disablePeer(peer_id, 'video');
|
||||
@@ -6049,6 +6118,7 @@ function handleVideoPlayer(config) {
|
||||
* @param {string} peer_id socket.id
|
||||
*/
|
||||
function handlePeerKickOutBtn(peer_id) {
|
||||
if (!buttons.remote.showKickOutBtn) return;
|
||||
let peerKickOutBtn = getId(peer_id + '_kickOut');
|
||||
peerKickOutBtn.addEventListener('click', (e) => {
|
||||
kickOut(peer_id);
|
||||
|
||||
@@ -277,12 +277,14 @@ access to use this app.
|
||||
<button id="myPeerNameSetBtn"><i class="fas fa-user-edit"></i> Change</button>
|
||||
</div>
|
||||
<br />
|
||||
<div>
|
||||
<div id="tabRoomParticipants">
|
||||
<label>Participants</label><br />
|
||||
<button id="muteEveryoneBtn"><i class="fas fa-microphone"></i> Mute everyone</button
|
||||
>
|
||||
<button id="hideEveryoneBtn"><i class="fas fa-video"></i> Hide everyone</button>
|
||||
<br /><br />
|
||||
</div>
|
||||
<br />
|
||||
<div id="tabRoomSecurity">
|
||||
<label>Security</label><br />
|
||||
<button id="lockRoomBtn"><i class="fas fa-lock-open"></i> Lock room</button>
|
||||
<button id="unlockRoomBtn" class="hidden"><i class="fas fa-lock"></i> Unlock room</button>
|
||||
|
||||
Reference in New Issue
Block a user