Files

235 lines
6.3 KiB
JavaScript
Raw Permalink Normal View History

/* global APP, config */
2016-11-11 09:00:54 -06:00
const UI = {};
2015-01-07 16:54:03 +02:00
import Logger from '@jitsi/logger';
2015-12-14 14:26:50 +02:00
import {
conferenceWillInit
} from '../../react/features/base/conference/actions';
import { isMobileBrowser } from '../../react/features/base/environment/utils';
import { setColorAlpha } from '../../react/features/base/util/helpers';
import { sanitizeUrl } from '../../react/features/base/util/uri';
2023-03-31 14:04:33 +03:00
import { setDocumentUrl } from '../../react/features/etherpad/actions';
import {
setNotificationsEnabled,
showNotification
2023-03-31 14:04:33 +03:00
} from '../../react/features/notifications/actions';
import { NOTIFICATION_TIMEOUT_TYPE } from '../../react/features/notifications/constants';
2023-04-27 07:56:43 -05:00
import { joinLeaveNotificationsDisabled } from '../../react/features/notifications/functions';
2017-02-16 17:02:40 -06:00
import {
2017-04-01 00:52:40 -05:00
dockToolbox,
feat(recording): frontend logic can support live streaming and recording (#2952) * feat(recording): frontend logic can support live streaming and recording Instead of either live streaming or recording, now both can live together. The changes to facilitate such include the following: - Killing the state storing in Recording.js. Instead state is stored in the lib and updated in redux for labels to display the necessary state updates. - Creating a new container, Labels, for recording labels. Previously labels were manually created and positioned. The container can create a reasonable number of labels and only the container itself needs to be positioned with CSS. The VideoQualityLabel has been shoved into the container as well because it moves along with the recording labels. - The action for updating recording state has been modified to enable updating an array of recording sessions to support having multiple sessions. - Confirmation dialogs for stopping and starting a file recording session have been created, as they previously were jquery modals opened by Recording.js. - Toolbox.web displays live streaming and recording buttons based on configuration instead of recording availability. - VideoQualityLabel and RecordingLabel have been simplified to remove any positioning logic, as the Labels container handles such. - Previous recording state update logic has been moved into the RecordingLabel component. Each RecordingLabel is in charge of displaying state for a recording session. The display UX has been left alone. - Sipgw availability is no longer broadcast so remove logic depending on its state. Some moving around of code was necessary to get around linting errors about the existing code being too deeply nested (even though I didn't touch it). * work around lib-jitsi-meet circular dependency issues * refactor labels to use html base * pass in translation keys to video quality label * add video quality classnames for torture tests * break up, rearrange recorder session update listener * add comment about disabling startup resize animation * rename session to sessionData * chore(deps): update to latest lib for recording changes
2018-05-16 07:00:16 -07:00
setToolboxEnabled,
2017-04-01 00:52:40 -05:00
showToolbox
2020-07-24 14:14:33 +02:00
} from '../../react/features/toolbox/actions.web';
2020-05-20 12:57:03 +02:00
import EtherpadManager from './etherpad/Etherpad';
import UIUtil from './util/UIUtil';
import VideoLayout from './videolayout/VideoLayout';
2017-02-16 17:02:40 -06:00
const logger = Logger.getLogger('ui:core');
2015-12-25 18:55:45 +02:00
let etherpadManager;
Restructures the analytics events (#2333) * ref: Restructures the pinned/unpinned events. * ref: Refactors the "audio only disabled" event. * ref: Refactors the "stream switch delay" event. * ref: Refactors the "select participant failed" event. * ref: Refactors the "initially muted" events. * ref: Refactors the screen sharing started/stopped events. * ref: Restructures the "device list changed" events. * ref: Restructures the "shared video" events. * ref: Restructures the "start muted" events. * ref: Restructures the "start audio only" event. * ref: Restructures the "sync track state" event. * ref: Restructures the "callkit" events. * ref: Restructures the "replace track". * ref: Restructures keyboard shortcuts events. * ref: Restructures most of the toolbar events. * ref: Refactors the API events. * ref: Restructures the video quality, profile button and invite dialog events. * ref: Refactors the "device changed" events. * ref: Refactors the page reload event. * ref: Removes an unused function. * ref: Removes a method which is needlessly exposed under a different name. * ref: Refactors the events from the remote video menu. * ref: Refactors the events from the profile pane. * ref: Restructures the recording-related events. Removes events fired when recording with something other than jibri (which isn't currently supported anyway). * ref: Cleans up AnalyticsEvents.js. * ref: Removes an unused function and adds documentation. * feat: Adds events for all API calls. * fix: Addresses feedback. * fix: Brings back mistakenly removed code. * fix: Simplifies code and fixes a bug in toggleFilmstrip when the 'visible' parameter is defined. * feat: Removes the resolution change application log. * ref: Uses consistent naming for events' attributes. Uses "_" as a separator instead of camel case or ".". * ref: Don't add the user agent and conference name as permanent properties. The library does this on its own now. * ref: Adapts the GA handler to changes in lib-jitsi-meet. * ref: Removes unused fields from the analytics handler initializaiton. * ref: Renames the google analytics file and add docs. * fix: Fixes the push-to-talk events and logs. * npm: Updates lib-jitsi-meet to 515374c8d383cb17df8ed76427e6f0fb5ea6ff1e. * fix: Fixes a recently introduced bug in the google analytics handler. * ref: Uses "value" instead of "delay" since this is friendlier to GA.
2018-01-03 15:24:07 -06:00
/**
* Indicates if we're currently in full screen mode.
*
* @return {boolean} {true} to indicate that we're currently in full screen
* mode, {false} otherwise
*/
UI.isFullScreen = function() {
return UIUtil.isFullScreen();
};
2016-06-20 16:13:17 -05:00
/**
* Initialize conference UI.
2016-01-15 16:59:35 +02:00
*/
UI.initConference = function() {
UI.showToolbar();
2015-11-30 17:24:42 +02:00
};
/**
* Starts the UI module and initializes all related components.
*/
UI.start = function() {
APP.store.dispatch(conferenceWillInit());
2015-12-25 18:55:45 +02:00
if (isMobileBrowser()) {
document.body.classList.add('mobile-browser');
} else {
document.body.classList.add('desktop-browser');
}
if (config.backgroundAlpha !== undefined) {
const backgroundColor = getComputedStyle(document.body).getPropertyValue('background-color');
const alphaColor = setColorAlpha(backgroundColor, config.backgroundAlpha);
document.body.style.backgroundColor = alphaColor;
}
if (config.iAmRecorder) {
// in case of iAmSipGateway keep local video visible
if (!config.iAmSipGateway) {
APP.store.dispatch(setNotificationsEnabled(false));
feat(recording): frontend logic can support live streaming and recording (#2952) * feat(recording): frontend logic can support live streaming and recording Instead of either live streaming or recording, now both can live together. The changes to facilitate such include the following: - Killing the state storing in Recording.js. Instead state is stored in the lib and updated in redux for labels to display the necessary state updates. - Creating a new container, Labels, for recording labels. Previously labels were manually created and positioned. The container can create a reasonable number of labels and only the container itself needs to be positioned with CSS. The VideoQualityLabel has been shoved into the container as well because it moves along with the recording labels. - The action for updating recording state has been modified to enable updating an array of recording sessions to support having multiple sessions. - Confirmation dialogs for stopping and starting a file recording session have been created, as they previously were jquery modals opened by Recording.js. - Toolbox.web displays live streaming and recording buttons based on configuration instead of recording availability. - VideoQualityLabel and RecordingLabel have been simplified to remove any positioning logic, as the Labels container handles such. - Previous recording state update logic has been moved into the RecordingLabel component. Each RecordingLabel is in charge of displaying state for a recording session. The display UX has been left alone. - Sipgw availability is no longer broadcast so remove logic depending on its state. Some moving around of code was necessary to get around linting errors about the existing code being too deeply nested (even though I didn't touch it). * work around lib-jitsi-meet circular dependency issues * refactor labels to use html base * pass in translation keys to video quality label * add video quality classnames for torture tests * break up, rearrange recorder session update listener * add comment about disabling startup resize animation * rename session to sessionData * chore(deps): update to latest lib for recording changes
2018-05-16 07:00:16 -07:00
}
2015-01-22 18:02:37 +02:00
APP.store.dispatch(setToolboxEnabled(false));
}
};
2016-06-13 16:11:44 -05:00
/**
* Handles etherpad click.
*/
UI.onEtherpadClicked = function() {
etherpadManager && etherpadManager.toggleEtherpad();
};
/**
*
*/
function onResize() {
VideoLayout.onResize();
}
/**
* Setup some DOM event listeners.
*/
UI.bindEvents = () => {
// Resize and reposition videos in full screen mode.
document.addEventListener('webkitfullscreenchange', onResize);
document.addEventListener('mozfullscreenchange', onResize);
document.addEventListener('fullscreenchange', onResize);
window.addEventListener('resize', onResize);
};
/**
* Unbind some DOM event listeners.
*/
UI.unbindEvents = () => {
document.removeEventListener('webkitfullscreenchange', onResize);
document.removeEventListener('mozfullscreenchange', onResize);
document.removeEventListener('fullscreenchange', onResize);
window.removeEventListener('resize', onResize);
2015-01-07 16:54:03 +02:00
};
2016-01-15 16:59:35 +02:00
/**
* Setup and show Etherpad.
* @param {string} name etherpad id
*/
UI.initEtherpad = name => {
const { getState, dispatch } = APP.store;
const configState = getState()['features/base/config'];
const etherpadBaseUrl = sanitizeUrl(configState.etherpad_base);
if (etherpadManager || !etherpadBaseUrl || !name) {
2015-12-25 18:55:45 +02:00
return;
}
2016-11-11 09:00:54 -06:00
logger.log('Etherpad is enabled');
2017-02-16 17:02:40 -06:00
etherpadManager = new EtherpadManager();
const url = new URL(name, etherpadBaseUrl);
dispatch(setDocumentUrl(url.toString()));
if (configState.openSharedDocumentOnJoin) {
etherpadManager.toggleEtherpad();
}
2015-12-25 18:55:45 +02:00
};
2015-01-07 16:54:03 +02:00
/**
* Returns the shared document manager object.
* @return {EtherpadManager} the shared document manager object
*/
UI.getSharedDocumentManager = () => etherpadManager;
2016-01-15 16:59:35 +02:00
/**
* Show user on UI.
* @param {JitsiParticipant} user
2016-01-15 16:59:35 +02:00
*/
UI.addUser = function(user) {
const status = user.getStatus();
if (status) {
// FIXME: move updateUserStatus in participantPresenceChanged action
UI.updateUserStatus(user, status);
}
2015-11-30 17:24:42 +02:00
};
2017-05-19 10:12:24 -05:00
/**
* Updates the user status.
*
* @param {JitsiParticipant} user - The user which status we need to update.
* @param {string} status - The new status.
*/
UI.updateUserStatus = (user, status) => {
2018-06-26 17:56:22 -05:00
const reduxState = APP.store.getState() || {};
const { calleeInfoVisible } = reduxState['features/invite'] || {};
// We hide status updates when join/leave notifications are disabled,
// as jigasi is the component with statuses and they are seen as join/leave notifications.
if (!status || calleeInfoVisible || joinLeaveNotificationsDisabled()) {
return;
}
const displayName = user.getDisplayName();
APP.store.dispatch(showNotification({
titleKey: `${displayName} connected`,
descriptionKey: 'dialOut.statusMessage'
}, NOTIFICATION_TIMEOUT_TYPE.SHORT));
2017-05-19 10:12:24 -05:00
};
2016-01-06 16:39:13 -06:00
/**
* Sets muted video state for participant
*/
UI.setVideoMuted = function(id) {
VideoLayout._updateLargeVideoIfDisplayed(id, true);
if (APP.conference.isLocalId(id)) {
APP.conference.updateVideoIconEnabled();
}
};
UI.updateLargeVideo = (id, forceUpdate) => VideoLayout.updateLargeVideo(id, forceUpdate);
2017-04-01 00:52:40 -05:00
// Used by torture.
UI.showToolbar = timeout => APP.store.dispatch(showToolbox(timeout));
2015-02-09 10:12:55 +02:00
2017-04-01 00:52:40 -05:00
// Used by torture.
UI.dockToolbar = dock => APP.store.dispatch(dockToolbox(dock));
2015-02-09 10:12:55 +02:00
UI.handleLastNEndpoints = function(leavingIds, enteringIds) {
VideoLayout.onLastNEndpointsChanged(leavingIds, enteringIds);
2015-11-30 13:54:54 +02:00
};
2016-01-15 16:59:35 +02:00
/**
* Update audio level visualization for specified user.
* @param {string} id user id
* @param {number} lvl audio level
*/
UI.setAudioLevel = (id, lvl) => VideoLayout.setAudioLevel(id, lvl);
2015-11-30 13:54:54 +02:00
/**
* Returns the id of the current video shown on large.
2016-01-15 16:59:35 +02:00
* Currently used by tests (torture).
*/
UI.getLargeVideoID = function() {
return VideoLayout.getLargeVideoID();
};
/**
* Returns the current video shown on large.
* Currently used by tests (torture).
*/
UI.getLargeVideo = function() {
return VideoLayout.getLargeVideo();
};
// TODO: Export every function separately. For now there is no point of doing
// this because we are importing everything.
export default UI;