Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

UI.js 41KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474
  1. /* global APP, JitsiMeetJS, $, config, interfaceConfig, toastr */
  2. const logger = require("jitsi-meet-logger").getLogger(__filename);
  3. var UI = {};
  4. import Chat from "./side_pannels/chat/Chat";
  5. import SidePanels from "./side_pannels/SidePanels";
  6. import Avatar from "./avatar/Avatar";
  7. import SideContainerToggler from "./side_pannels/SideContainerToggler";
  8. import UIUtil from "./util/UIUtil";
  9. import UIEvents from "../../service/UI/UIEvents";
  10. import EtherpadManager from './etherpad/Etherpad';
  11. import SharedVideoManager from './shared_video/SharedVideo';
  12. import Recording from "./recording/Recording";
  13. import VideoLayout from "./videolayout/VideoLayout";
  14. import Filmstrip from "./videolayout/Filmstrip";
  15. import SettingsMenu from "./side_pannels/settings/SettingsMenu";
  16. import Profile from "./side_pannels/profile/Profile";
  17. import Settings from "./../settings/Settings";
  18. import RingOverlay from "./ring_overlay/RingOverlay";
  19. import UIErrors from './UIErrors';
  20. import { debounce } from "../util/helpers";
  21. import {
  22. updateDeviceList
  23. } from '../../react/features/base/devices';
  24. import {
  25. setAudioMuted,
  26. setVideoMuted
  27. } from '../../react/features/base/media';
  28. import {
  29. openDeviceSelectionDialog
  30. } from '../../react/features/device-selection';
  31. import {
  32. checkAutoEnableDesktopSharing,
  33. dockToolbox,
  34. setAudioIconEnabled,
  35. setToolbarButton,
  36. setVideoIconEnabled,
  37. showDialPadButton,
  38. showEtherpadButton,
  39. showSharedVideoButton,
  40. showDialOutButton,
  41. showToolbox
  42. } from '../../react/features/toolbox';
  43. var EventEmitter = require("events");
  44. UI.messageHandler = require("./util/MessageHandler");
  45. var messageHandler = UI.messageHandler;
  46. var JitsiPopover = require("./util/JitsiPopover");
  47. import Feedback from "./feedback/Feedback";
  48. import FollowMe from "../FollowMe";
  49. var eventEmitter = new EventEmitter();
  50. UI.eventEmitter = eventEmitter;
  51. /**
  52. * Whether an overlay is visible or not.
  53. *
  54. * FIXME: This is temporary solution. Don't use this variable!
  55. * Should be removed when all the code is move to react.
  56. *
  57. * @type {boolean}
  58. * @public
  59. */
  60. UI.overlayVisible = false;
  61. let etherpadManager;
  62. let sharedVideoManager;
  63. let followMeHandler;
  64. let deviceErrorDialog;
  65. const TrackErrors = JitsiMeetJS.errors.track;
  66. const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
  67. microphone: {},
  68. camera: {}
  69. };
  70. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.UNSUPPORTED_RESOLUTION]
  71. = "dialog.cameraUnsupportedResolutionError";
  72. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  73. = "dialog.cameraUnknownError";
  74. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.PERMISSION_DENIED]
  75. = "dialog.cameraPermissionDeniedError";
  76. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NOT_FOUND]
  77. = "dialog.cameraNotFoundError";
  78. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.CONSTRAINT_FAILED]
  79. = "dialog.cameraConstraintFailedError";
  80. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NO_DATA_FROM_SOURCE]
  81. = "dialog.cameraNotSendingData";
  82. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  83. = "dialog.micUnknownError";
  84. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.PERMISSION_DENIED]
  85. = "dialog.micPermissionDeniedError";
  86. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NOT_FOUND]
  87. = "dialog.micNotFoundError";
  88. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.CONSTRAINT_FAILED]
  89. = "dialog.micConstraintFailedError";
  90. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NO_DATA_FROM_SOURCE]
  91. = "dialog.micNotSendingData";
  92. /**
  93. * Toggles the application in and out of full screen mode
  94. * (a.k.a. presentation mode in Chrome).
  95. */
  96. UI.toggleFullScreen = function() {
  97. (UIUtil.isFullScreen())
  98. ? UIUtil.exitFullScreen()
  99. : UIUtil.enterFullScreen();
  100. };
  101. /**
  102. * Notify user that server has shut down.
  103. */
  104. UI.notifyGracefulShutdown = function () {
  105. messageHandler.openMessageDialog(
  106. 'dialog.serviceUnavailable',
  107. 'dialog.gracefulShutdown'
  108. );
  109. };
  110. /**
  111. * Notify user that reservation error happened.
  112. */
  113. UI.notifyReservationError = function (code, msg) {
  114. var message = APP.translation.generateTranslationHTML(
  115. "dialog.reservationErrorMsg", {code: code, msg: msg});
  116. messageHandler.openDialog(
  117. "dialog.reservationError", message, true, {}, () => false);
  118. };
  119. /**
  120. * Notify user that he has been kicked from the server.
  121. */
  122. UI.notifyKicked = function () {
  123. messageHandler.openMessageDialog(
  124. "dialog.sessTerminated",
  125. "dialog.kickMessage");
  126. };
  127. /**
  128. * Notify user that conference was destroyed.
  129. * @param reason {string} the reason text
  130. */
  131. UI.notifyConferenceDestroyed = function (reason) {
  132. //FIXME: use Session Terminated from translation, but
  133. // 'reason' text comes from XMPP packet and is not translated
  134. messageHandler.openDialog(
  135. "dialog.sessTerminated", reason, true, {}, () => false);
  136. };
  137. /**
  138. * Show chat error.
  139. * @param err the Error
  140. * @param msg
  141. */
  142. UI.showChatError = function (err, msg) {
  143. if (interfaceConfig.filmStripOnly) {
  144. return;
  145. }
  146. Chat.chatAddError(err, msg);
  147. };
  148. /**
  149. * Change nickname for the user.
  150. * @param {string} id user id
  151. * @param {string} displayName new nickname
  152. */
  153. UI.changeDisplayName = function (id, displayName) {
  154. if (UI.ContactList)
  155. UI.ContactList.onDisplayNameChange(id, displayName);
  156. VideoLayout.onDisplayNameChanged(id, displayName);
  157. if (APP.conference.isLocalId(id) || id === 'localVideoContainer') {
  158. Profile.changeDisplayName(displayName);
  159. Chat.setChatConversationMode(!!displayName);
  160. }
  161. };
  162. /**
  163. * Shows/hides the indication about local connection being interrupted.
  164. *
  165. * @param {boolean} isInterrupted <tt>true</tt> if local connection is
  166. * currently in the interrupted state or <tt>false</tt> if the connection
  167. * is fine.
  168. */
  169. UI.showLocalConnectionInterrupted = function (isInterrupted) {
  170. VideoLayout.showLocalConnectionInterrupted(isInterrupted);
  171. };
  172. /**
  173. * Sets the "raised hand" status for a participant.
  174. */
  175. UI.setRaisedHandStatus = (participant, raisedHandStatus) => {
  176. VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus);
  177. if (raisedHandStatus) {
  178. messageHandler.notify(participant.getDisplayName(), 'notify.somebody',
  179. 'connected', 'notify.raisedHand');
  180. }
  181. };
  182. /**
  183. * Sets the local "raised hand" status.
  184. */
  185. UI.setLocalRaisedHandStatus
  186. = raisedHandStatus =>
  187. VideoLayout.setRaisedHandStatus(
  188. APP.conference.getMyUserId(),
  189. raisedHandStatus);
  190. /**
  191. * Initialize conference UI.
  192. */
  193. UI.initConference = function () {
  194. let id = APP.conference.getMyUserId();
  195. // Add myself to the contact list.
  196. if (UI.ContactList)
  197. UI.ContactList.addContact(id, true);
  198. // Update default button states before showing the toolbar
  199. // if local role changes buttons state will be again updated.
  200. UI.updateLocalRole(APP.conference.isModerator);
  201. UI.showToolbar();
  202. let displayName = config.displayJids ? id : Settings.getDisplayName();
  203. if (displayName) {
  204. UI.changeDisplayName('localVideoContainer', displayName);
  205. }
  206. // Make sure we configure our avatar id, before creating avatar for us
  207. let email = Settings.getEmail();
  208. if (email) {
  209. UI.setUserEmail(id, email);
  210. } else {
  211. UI.setUserAvatarID(id, Settings.getAvatarId());
  212. }
  213. APP.store.dispatch(checkAutoEnableDesktopSharing());
  214. if(!interfaceConfig.filmStripOnly) {
  215. Feedback.init(eventEmitter);
  216. }
  217. // FollowMe attempts to copy certain aspects of the moderator's UI into the
  218. // other participants' UI. Consequently, it needs (1) read and write access
  219. // to the UI (depending on the moderator role of the local participant) and
  220. // (2) APP.conference as means of communication between the participants.
  221. followMeHandler = new FollowMe(APP.conference, UI);
  222. UIUtil.activateTooltips();
  223. };
  224. UI.mucJoined = function () {
  225. VideoLayout.mucJoined();
  226. };
  227. /***
  228. * Handler for toggling filmstrip
  229. */
  230. UI.handleToggleFilmstrip = () => UI.toggleFilmstrip();
  231. /**
  232. * Sets tooltip defaults.
  233. *
  234. * @private
  235. */
  236. function _setTooltipDefaults() {
  237. $.fn.tooltip.defaults = {
  238. opacity: 1, //defaults to 1
  239. offset: 1,
  240. delayIn: 0, //defaults to 500
  241. hoverable: true,
  242. hideOnClick: true,
  243. aria: true
  244. };
  245. }
  246. /**
  247. * Returns the shared document manager object.
  248. * @return {EtherpadManager} the shared document manager object
  249. */
  250. UI.getSharedVideoManager = function () {
  251. return sharedVideoManager;
  252. };
  253. /**
  254. * Starts the UI module and initializes all related components.
  255. *
  256. * @returns {boolean} true if the UI is ready and the conference should be
  257. * esablished, false - otherwise (for example in the case of welcome page)
  258. */
  259. UI.start = function () {
  260. document.title = interfaceConfig.APP_NAME;
  261. // Set the defaults for prompt dialogs.
  262. $.prompt.setDefaults({persistent: false});
  263. // Set the defaults for tooltips.
  264. _setTooltipDefaults();
  265. SideContainerToggler.init(eventEmitter);
  266. Filmstrip.init(eventEmitter);
  267. // By default start with remote videos hidden and rely on other logic to
  268. // make them visible.
  269. UI.setRemoteThumbnailsVisibility(false);
  270. VideoLayout.init(eventEmitter);
  271. if (!interfaceConfig.filmStripOnly) {
  272. VideoLayout.initLargeVideo();
  273. }
  274. VideoLayout.resizeVideoArea(true, true);
  275. sharedVideoManager = new SharedVideoManager(eventEmitter);
  276. if (!interfaceConfig.filmStripOnly) {
  277. let debouncedShowToolbar
  278. = debounce(
  279. () => UI.showToolbar(),
  280. 100,
  281. { leading: true, trailing: false });
  282. $("#videoconference_page").mousemove(debouncedShowToolbar);
  283. // Initialise the recording module.
  284. if (config.enableRecording) {
  285. Recording.init(eventEmitter, config.recordingType);
  286. }
  287. // Initialize side panels
  288. SidePanels.init(eventEmitter);
  289. } else {
  290. $("body").addClass("filmstrip-only");
  291. UI.showToolbar();
  292. Filmstrip.setFilmstripOnly();
  293. messageHandler.enableNotifications(false);
  294. JitsiPopover.enabled = false;
  295. }
  296. if (interfaceConfig.VERTICAL_FILMSTRIP) {
  297. $("body").addClass("vertical-filmstrip");
  298. }
  299. document.title = interfaceConfig.APP_NAME;
  300. if (!interfaceConfig.filmStripOnly) {
  301. toastr.options = {
  302. "closeButton": true,
  303. "debug": false,
  304. "positionClass": "notification-bottom-right",
  305. "onclick": null,
  306. "showDuration": "300",
  307. "hideDuration": "1000",
  308. "timeOut": "2000",
  309. "extendedTimeOut": "1000",
  310. "showEasing": "swing",
  311. "hideEasing": "linear",
  312. "showMethod": "fadeIn",
  313. "hideMethod": "fadeOut",
  314. "newestOnTop": false,
  315. // this is the default toastr close button html, just adds tabIndex
  316. "closeHtml": '<button type="button" tabIndex="-1">&times;</button>'
  317. };
  318. }
  319. const { callee } = APP.store.getState()['features/jwt'];
  320. callee && UI.showRingOverlay();
  321. };
  322. /**
  323. * Invokes cleanup of any deferred execution within relevant UI modules.
  324. *
  325. * @returns {void}
  326. */
  327. UI.stopDaemons = () => {
  328. VideoLayout.resetLargeVideo();
  329. };
  330. /**
  331. * Setup some UI event listeners.
  332. */
  333. UI.registerListeners
  334. = () => UIListeners.forEach((value, key) => UI.addListener(key, value));
  335. /**
  336. * Unregister some UI event listeners.
  337. */
  338. UI.unregisterListeners
  339. = () => UIListeners.forEach((value, key) => UI.removeListener(key, value));
  340. /**
  341. * Setup some DOM event listeners.
  342. */
  343. UI.bindEvents = () => {
  344. function onResize() {
  345. SideContainerToggler.resize();
  346. VideoLayout.resizeVideoArea();
  347. }
  348. // Resize and reposition videos in full screen mode.
  349. $(document).on(
  350. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  351. () => {
  352. eventEmitter.emit(
  353. UIEvents.FULLSCREEN_TOGGLED,
  354. UIUtil.isFullScreen());
  355. onResize();
  356. });
  357. $(window).resize(onResize);
  358. };
  359. /**
  360. * Unbind some DOM event listeners.
  361. */
  362. UI.unbindEvents = () => {
  363. $(document).off(
  364. 'webkitfullscreenchange mozfullscreenchange fullscreenchange');
  365. $(window).off('resize');
  366. };
  367. /**
  368. * Show local stream on UI.
  369. * @param {JitsiTrack} track stream to show
  370. */
  371. UI.addLocalStream = track => {
  372. switch (track.getType()) {
  373. case 'audio':
  374. VideoLayout.changeLocalAudio(track);
  375. break;
  376. case 'video':
  377. VideoLayout.changeLocalVideo(track);
  378. break;
  379. default:
  380. logger.error("Unknown stream type: " + track.getType());
  381. break;
  382. }
  383. };
  384. /**
  385. * Show remote stream on UI.
  386. * @param {JitsiTrack} track stream to show
  387. */
  388. UI.addRemoteStream = track => VideoLayout.onRemoteStreamAdded(track);
  389. /**
  390. * Removed remote stream from UI.
  391. * @param {JitsiTrack} track stream to remove
  392. */
  393. UI.removeRemoteStream = track => VideoLayout.onRemoteStreamRemoved(track);
  394. /**
  395. * Update chat subject.
  396. * @param {string} subject new chat subject
  397. */
  398. UI.setSubject = subject => Chat.setSubject(subject);
  399. /**
  400. * Setup and show Etherpad.
  401. * @param {string} name etherpad id
  402. */
  403. UI.initEtherpad = name => {
  404. if (etherpadManager || !config.etherpad_base || !name) {
  405. return;
  406. }
  407. logger.log('Etherpad is enabled');
  408. etherpadManager
  409. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  410. APP.store.dispatch(showEtherpadButton());
  411. };
  412. /**
  413. * Returns the shared document manager object.
  414. * @return {EtherpadManager} the shared document manager object
  415. */
  416. UI.getSharedDocumentManager = () => etherpadManager;
  417. /**
  418. * Show user on UI.
  419. * @param {JitsiParticipant} user
  420. */
  421. UI.addUser = function (user) {
  422. var id = user.getId();
  423. var displayName = user.getDisplayName();
  424. UI.hideRingOverlay();
  425. if (UI.ContactList)
  426. UI.ContactList.addContact(id);
  427. messageHandler.notify(
  428. displayName,'notify.somebody', 'connected', 'notify.connected'
  429. );
  430. if (!config.startAudioMuted ||
  431. config.startAudioMuted > APP.conference.membersCount)
  432. UIUtil.playSoundNotification('userJoined');
  433. // Add Peer's container
  434. VideoLayout.addParticipantContainer(user);
  435. // Configure avatar
  436. UI.setUserEmail(id);
  437. // set initial display name
  438. if(displayName)
  439. UI.changeDisplayName(id, displayName);
  440. };
  441. /**
  442. * Remove user from UI.
  443. * @param {string} id user id
  444. * @param {string} displayName user nickname
  445. */
  446. UI.removeUser = function (id, displayName) {
  447. if (UI.ContactList)
  448. UI.ContactList.removeContact(id);
  449. messageHandler.notify(
  450. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  451. );
  452. if (!config.startAudioMuted
  453. || config.startAudioMuted > APP.conference.membersCount) {
  454. UIUtil.playSoundNotification('userLeft');
  455. }
  456. VideoLayout.removeParticipantContainer(id);
  457. };
  458. /**
  459. * Update videotype for specified user.
  460. * @param {string} id user id
  461. * @param {string} newVideoType new videotype
  462. */
  463. UI.onPeerVideoTypeChanged
  464. = (id, newVideoType) => VideoLayout.onVideoTypeChanged(id, newVideoType);
  465. /**
  466. * Update local user role and show notification if user is moderator.
  467. * @param {boolean} isModerator if local user is moderator or not
  468. */
  469. UI.updateLocalRole = isModerator => {
  470. VideoLayout.showModeratorIndicator();
  471. APP.store.dispatch(showDialOutButton(isModerator));
  472. APP.store.dispatch(showSharedVideoButton());
  473. Recording.showRecordingButton(isModerator);
  474. SettingsMenu.showStartMutedOptions(isModerator);
  475. SettingsMenu.showFollowMeOptions(isModerator);
  476. if (isModerator) {
  477. if (!interfaceConfig.DISABLE_FOCUS_INDICATOR)
  478. messageHandler
  479. .notify(null, "notify.me", 'connected', "notify.moderator");
  480. Recording.checkAutoRecord();
  481. }
  482. };
  483. /**
  484. * Check the role for the user and reflect it in the UI, moderator ui indication
  485. * and notifies user who is the moderator
  486. * @param user to check for moderator
  487. */
  488. UI.updateUserRole = user => {
  489. VideoLayout.showModeratorIndicator();
  490. // We don't need to show moderator notifications when the focus (moderator)
  491. // indicator is disabled.
  492. if (!user.isModerator() || interfaceConfig.DISABLE_FOCUS_INDICATOR) {
  493. return;
  494. }
  495. var displayName = user.getDisplayName();
  496. if (displayName) {
  497. messageHandler.notify(
  498. displayName, 'notify.somebody',
  499. 'connected', 'notify.grantedTo', {
  500. to: UIUtil.escapeHtml(displayName)
  501. }
  502. );
  503. } else {
  504. messageHandler.notify(
  505. '', 'notify.somebody',
  506. 'connected', 'notify.grantedToUnknown');
  507. }
  508. };
  509. /**
  510. * Updates the user status.
  511. *
  512. * @param {JitsiParticipant} user - The user which status we need to update.
  513. * @param {string} status - The new status.
  514. */
  515. UI.updateUserStatus = (user, status) => {
  516. let displayName = user.getDisplayName();
  517. messageHandler.notify(
  518. displayName, '', 'connected', "dialOut.statusMessage",
  519. {
  520. status: UIUtil.escapeHtml(status)
  521. });
  522. };
  523. /**
  524. * Toggles smileys in the chat.
  525. */
  526. UI.toggleSmileys = () => Chat.toggleSmileys();
  527. /**
  528. * Toggles filmstrip.
  529. */
  530. UI.toggleFilmstrip = function () {
  531. var self = Filmstrip;
  532. self.toggleFilmstrip.apply(self, arguments);
  533. VideoLayout.resizeVideoArea(true, false);
  534. };
  535. /**
  536. * Indicates if the filmstrip is currently visible or not.
  537. * @returns {true} if the filmstrip is currently visible, otherwise
  538. */
  539. UI.isFilmstripVisible = () => Filmstrip.isFilmstripVisible();
  540. /**
  541. * Toggles chat panel.
  542. */
  543. UI.toggleChat = () => UI.toggleSidePanel("chat_container");
  544. /**
  545. * Toggles contact list panel.
  546. */
  547. UI.toggleContactList = () => UI.toggleSidePanel("contacts_container");
  548. /**
  549. * Toggles the given side panel.
  550. *
  551. * @param {String} sidePanelId the identifier of the side panel to toggle
  552. */
  553. UI.toggleSidePanel = sidePanelId => SideContainerToggler.toggle(sidePanelId);
  554. /**
  555. * Handle new user display name.
  556. */
  557. UI.inputDisplayNameHandler = function (newDisplayName) {
  558. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
  559. };
  560. /**
  561. * Show custom popup/tooltip for a specified button.
  562. * @param popupSelectorID the selector id of the popup to show
  563. * @param show true or false/show or hide the popup
  564. * @param timeout the time to show the popup
  565. */
  566. UI.showCustomToolbarPopup = function (popupSelectorID, show, timeout) {
  567. eventEmitter.emit(UIEvents.SHOW_CUSTOM_TOOLBAR_BUTTON_POPUP,
  568. popupSelectorID, show, timeout);
  569. };
  570. /**
  571. * Return the type of the remote video.
  572. * @param jid the jid for the remote video
  573. * @returns the video type video or screen.
  574. */
  575. UI.getRemoteVideoType = function (jid) {
  576. return VideoLayout.getRemoteVideoType(jid);
  577. };
  578. UI.connectionIndicatorShowMore = function(id) {
  579. VideoLayout.showMore(id);
  580. return false;
  581. };
  582. // FIXME check if someone user this
  583. UI.showLoginPopup = function(callback) {
  584. logger.log('password is required');
  585. let message = (
  586. `<input name="username" type="text"
  587. placeholder="user@domain.net"
  588. class="input-control" autofocus>
  589. <input name="password" type="password"
  590. data-i18n="[placeholder]dialog.userPassword"
  591. class="input-control"
  592. placeholder="user password">`
  593. );
  594. let submitFunction = (e, v, m, f) => {
  595. if (v) {
  596. if (f.username && f.password) {
  597. callback(f.username, f.password);
  598. }
  599. }
  600. };
  601. messageHandler.openTwoButtonDialog({
  602. titleKey : "dialog.passwordRequired",
  603. msgString: message,
  604. leftButtonKey: 'dialog.Ok',
  605. submitFunction,
  606. focus: ':input:first'
  607. });
  608. };
  609. UI.askForNickname = function () {
  610. return window.prompt('Your nickname (optional)');
  611. };
  612. /**
  613. * Sets muted audio state for participant
  614. */
  615. UI.setAudioMuted = function (id, muted) {
  616. VideoLayout.onAudioMute(id, muted);
  617. if (APP.conference.isLocalId(id)) {
  618. APP.store.dispatch(setAudioMuted(muted));
  619. APP.store.dispatch(setToolbarButton('microphone', {
  620. toggled: muted
  621. }));
  622. }
  623. };
  624. /**
  625. * Sets muted video state for participant
  626. */
  627. UI.setVideoMuted = function (id, muted) {
  628. VideoLayout.onVideoMute(id, muted);
  629. if (APP.conference.isLocalId(id)) {
  630. APP.store.dispatch(setVideoMuted(muted));
  631. APP.store.dispatch(setToolbarButton('camera', {
  632. toggled: muted
  633. }));
  634. }
  635. };
  636. /**
  637. * Triggers an update of remote video and large video displays so they may pick
  638. * up any state changes that have occurred elsewhere.
  639. *
  640. * @returns {void}
  641. */
  642. UI.updateAllVideos = () => VideoLayout.updateAllVideos();
  643. /**
  644. * Adds a listener that would be notified on the given type of event.
  645. *
  646. * @param type the type of the event we're listening for
  647. * @param listener a function that would be called when notified
  648. */
  649. UI.addListener = function (type, listener) {
  650. eventEmitter.on(type, listener);
  651. };
  652. /**
  653. * Removes the given listener for the given type of event.
  654. *
  655. * @param type the type of the event we're listening for
  656. * @param listener the listener we want to remove
  657. */
  658. UI.removeListener = function (type, listener) {
  659. eventEmitter.removeListener(type, listener);
  660. };
  661. /**
  662. * Emits the event of given type by specifying the parameters in options.
  663. *
  664. * @param type the type of the event we're emitting
  665. * @param options the parameters for the event
  666. */
  667. UI.emitEvent = (type, ...options) => eventEmitter.emit(type, ...options);
  668. UI.clickOnVideo = function (videoNumber) {
  669. let videos = $("#remoteVideos .videocontainer:not(#mixedstream)");
  670. let videosLength = videos.length;
  671. if(videosLength <= videoNumber) {
  672. return;
  673. }
  674. let videoIndex = videoNumber === 0 ? 0 : videosLength - videoNumber;
  675. videos[videoIndex].click();
  676. };
  677. // Used by torture.
  678. UI.showToolbar = timeout => APP.store.dispatch(showToolbox(timeout));
  679. // Used by torture.
  680. UI.dockToolbar = dock => APP.store.dispatch(dockToolbox(dock));
  681. /**
  682. * Updates the avatar for participant.
  683. * @param {string} id user id
  684. * @param {string} avatarUrl the URL for the avatar
  685. */
  686. function changeAvatar(id, avatarUrl) {
  687. VideoLayout.changeUserAvatar(id, avatarUrl);
  688. if (UI.ContactList)
  689. UI.ContactList.changeUserAvatar(id, avatarUrl);
  690. if (APP.conference.isLocalId(id)) {
  691. Profile.changeAvatar(avatarUrl);
  692. }
  693. }
  694. /**
  695. * Update user email.
  696. * @param {string} id user id
  697. * @param {string} email user email
  698. */
  699. UI.setUserEmail = function (id, email) {
  700. // update avatar
  701. Avatar.setUserEmail(id, email);
  702. changeAvatar(id, Avatar.getAvatarUrl(id));
  703. if (APP.conference.isLocalId(id)) {
  704. Profile.changeEmail(email);
  705. }
  706. };
  707. /**
  708. * Update user avtar id.
  709. * @param {string} id user id
  710. * @param {string} avatarId user's avatar id
  711. */
  712. UI.setUserAvatarID = function (id, avatarId) {
  713. // update avatar
  714. Avatar.setUserAvatarID(id, avatarId);
  715. changeAvatar(id, Avatar.getAvatarUrl(id));
  716. };
  717. /**
  718. * Update user avatar URL.
  719. * @param {string} id user id
  720. * @param {string} url user avatar url
  721. */
  722. UI.setUserAvatarUrl = function (id, url) {
  723. // update avatar
  724. Avatar.setUserAvatarUrl(id, url);
  725. changeAvatar(id, Avatar.getAvatarUrl(id));
  726. };
  727. /**
  728. * Notify user that connection failed.
  729. * @param {string} stropheErrorMsg raw Strophe error message
  730. */
  731. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  732. var message;
  733. if (stropheErrorMsg) {
  734. message = APP.translation.generateTranslationHTML(
  735. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  736. } else {
  737. message = APP.translation.generateTranslationHTML(
  738. "dialog.connectError");
  739. }
  740. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  741. };
  742. /**
  743. * Notify user that maximum users limit has been reached.
  744. */
  745. UI.notifyMaxUsersLimitReached = function () {
  746. var message = APP.translation.generateTranslationHTML(
  747. "dialog.maxUsersLimitReached");
  748. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  749. };
  750. /**
  751. * Notify user that he was automatically muted when joned the conference.
  752. */
  753. UI.notifyInitiallyMuted = function () {
  754. messageHandler.notify(
  755. null,
  756. "notify.mutedTitle",
  757. "connected",
  758. "notify.muted",
  759. null,
  760. { timeOut: 120000 });
  761. };
  762. /**
  763. * Mark user as dominant speaker.
  764. * @param {string} id user id
  765. */
  766. UI.markDominantSpeaker = function (id) {
  767. VideoLayout.onDominantSpeakerChanged(id);
  768. };
  769. UI.handleLastNEndpoints = function (leavingIds, enteringIds) {
  770. VideoLayout.onLastNEndpointsChanged(leavingIds, enteringIds);
  771. };
  772. /**
  773. * Will handle notification about participant's connectivity status change.
  774. *
  775. * @param {string} id the id of remote participant(MUC jid)
  776. */
  777. UI.participantConnectionStatusChanged = function (id) {
  778. VideoLayout.onParticipantConnectionStatusChanged(id);
  779. };
  780. /**
  781. * Prompt user for nickname.
  782. */
  783. UI.promptDisplayName = () => {
  784. const labelKey = 'dialog.enterDisplayName';
  785. const message = (
  786. `<div class="form-control">
  787. <label data-i18n="${labelKey}" class="form-control__label"></label>
  788. <input name="displayName" type="text"
  789. data-i18n="[placeholder]defaultNickname"
  790. class="input-control" autofocus>
  791. </div>`
  792. );
  793. // Don't use a translation string, because we're too early in the call and
  794. // the translation may not be initialised.
  795. const buttons = { Ok: true };
  796. const dialog = messageHandler.openDialog(
  797. 'dialog.displayNameRequired',
  798. message,
  799. true,
  800. buttons,
  801. (e, v, m, f) => {
  802. e.preventDefault();
  803. if (v) {
  804. const displayName = f.displayName;
  805. if (displayName) {
  806. UI.inputDisplayNameHandler(displayName);
  807. dialog.close();
  808. return;
  809. }
  810. }
  811. },
  812. () => {
  813. const form = $.prompt.getPrompt();
  814. const input = form.find("input[name='displayName']");
  815. const button = form.find("button");
  816. input.focus();
  817. button.attr("disabled", "disabled");
  818. input.keyup(() => {
  819. if (input.val()) {
  820. button.removeAttr("disabled");
  821. } else {
  822. button.attr("disabled", "disabled");
  823. }
  824. });
  825. }
  826. );
  827. };
  828. /**
  829. * Update audio level visualization for specified user.
  830. * @param {string} id user id
  831. * @param {number} lvl audio level
  832. */
  833. UI.setAudioLevel = (id, lvl) => VideoLayout.setAudioLevel(id, lvl);
  834. /**
  835. * Update state of desktop sharing buttons.
  836. *
  837. * @returns {void}
  838. */
  839. UI.updateDesktopSharingButtons
  840. = () =>
  841. APP.store.dispatch(setToolbarButton('desktop', {
  842. toggled: APP.conference.isSharingScreen
  843. }));
  844. /**
  845. * Hide connection quality statistics from UI.
  846. */
  847. UI.hideStats = function () {
  848. VideoLayout.hideStats();
  849. };
  850. /**
  851. * Update local connection quality statistics.
  852. * @param {number} percent
  853. * @param {object} stats
  854. */
  855. UI.updateLocalStats = function (percent, stats) {
  856. VideoLayout.updateLocalConnectionStats(percent, stats);
  857. };
  858. /**
  859. * Update connection quality statistics for remote user.
  860. * @param {string} id user id
  861. * @param {number} percent
  862. * @param {object} stats
  863. */
  864. UI.updateRemoteStats = function (id, percent, stats) {
  865. VideoLayout.updateConnectionStats(id, percent, stats);
  866. };
  867. /**
  868. * Mark video as interrupted or not.
  869. * @param {boolean} interrupted if video is interrupted
  870. */
  871. UI.markVideoInterrupted = function (interrupted) {
  872. if (interrupted) {
  873. VideoLayout.onVideoInterrupted();
  874. } else {
  875. VideoLayout.onVideoRestored();
  876. }
  877. };
  878. /**
  879. * Add chat message.
  880. * @param {string} from user id
  881. * @param {string} displayName user nickname
  882. * @param {string} message message text
  883. * @param {number} stamp timestamp when message was created
  884. */
  885. UI.addMessage = function (from, displayName, message, stamp) {
  886. Chat.updateChatConversation(from, displayName, message, stamp);
  887. };
  888. UI.updateDTMFSupport
  889. = isDTMFSupported => APP.store.dispatch(showDialPadButton(isDTMFSupported));
  890. /**
  891. * Show user feedback dialog if its required and enabled after pressing the
  892. * hangup button.
  893. * @returns {Promise} Resolved with value - false if the dialog is enabled and
  894. * resolved with true if the dialog is disabled or the feedback was already
  895. * submitted. Rejected if another dialog is already displayed. This values are
  896. * used to display or not display the thank you dialog from
  897. * conference.maybeRedirectToWelcomePage method.
  898. */
  899. UI.requestFeedbackOnHangup = function () {
  900. if (Feedback.isVisible())
  901. return Promise.reject(UIErrors.FEEDBACK_REQUEST_IN_PROGRESS);
  902. // Feedback has been submitted already.
  903. else if (Feedback.isEnabled() && Feedback.isSubmitted()) {
  904. return Promise.resolve({
  905. thankYouDialogVisible : true,
  906. feedbackSubmitted: true
  907. });
  908. }
  909. else
  910. return new Promise(function (resolve) {
  911. if (Feedback.isEnabled()) {
  912. Feedback.openFeedbackWindow(
  913. (options) => {
  914. options.thankYouDialogVisible = false;
  915. resolve(options);
  916. });
  917. } else {
  918. // If the feedback functionality isn't enabled we show a thank
  919. // you dialog. Signaling it (true), so the caller
  920. // of requestFeedback can act on it
  921. resolve(
  922. {thankYouDialogVisible : true, feedbackSubmitted: false});
  923. }
  924. });
  925. };
  926. UI.updateRecordingState = function (state) {
  927. Recording.updateRecordingState(state);
  928. };
  929. UI.notifyTokenAuthFailed = function () {
  930. messageHandler.showError( "dialog.tokenAuthFailedTitle",
  931. "dialog.tokenAuthFailed");
  932. };
  933. UI.notifyInternalError = function () {
  934. messageHandler.showError( "dialog.internalErrorTitle",
  935. "dialog.internalError");
  936. };
  937. UI.notifyFocusDisconnected = function (focus, retrySec) {
  938. messageHandler.notify(
  939. null, "notify.focus",
  940. 'disconnected', "notify.focusFail",
  941. {component: focus, ms: retrySec}
  942. );
  943. };
  944. /**
  945. * Updates auth info on the UI.
  946. * @param {boolean} isAuthEnabled if authentication is enabled
  947. * @param {string} [login] current login
  948. */
  949. UI.updateAuthInfo = function (isAuthEnabled, login) {
  950. let showAuth = isAuthEnabled && UIUtil.isAuthenticationEnabled();
  951. let loggedIn = !!login;
  952. Profile.showAuthenticationButtons(showAuth);
  953. if (showAuth) {
  954. Profile.setAuthenticatedIdentity(login);
  955. Profile.showLoginButton(!loggedIn);
  956. Profile.showLogoutButton(loggedIn);
  957. }
  958. };
  959. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  960. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  961. };
  962. /**
  963. * Notifies interested listeners that the raise hand property has changed.
  964. *
  965. * @param {boolean} isRaisedHand indicates the current state of the
  966. * "raised hand"
  967. */
  968. UI.onLocalRaiseHandChanged = function (isRaisedHand) {
  969. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  970. };
  971. /**
  972. * Update list of available physical devices.
  973. * @param {object[]} devices new list of available devices
  974. */
  975. UI.onAvailableDevicesChanged = function (devices) {
  976. APP.store.dispatch(updateDeviceList(devices));
  977. };
  978. /**
  979. * Returns the id of the current video shown on large.
  980. * Currently used by tests (torture).
  981. */
  982. UI.getLargeVideoID = function () {
  983. return VideoLayout.getLargeVideoID();
  984. };
  985. /**
  986. * Returns the current video shown on large.
  987. * Currently used by tests (torture).
  988. */
  989. UI.getLargeVideo = function () {
  990. return VideoLayout.getLargeVideo();
  991. };
  992. /**
  993. * Returns whether or not the passed in user id is currently pinned to the large
  994. * video.
  995. *
  996. * @param {string} userId - The id of the user to check is pinned or not.
  997. * @returns {boolean} True if the user is currently pinned to the large video.
  998. */
  999. UI.isPinned = userId => VideoLayout.getPinnedId() === userId;
  1000. /**
  1001. * Shows dialog with a link to FF extension.
  1002. */
  1003. UI.showExtensionRequiredDialog = function (url) {
  1004. messageHandler.openMessageDialog(
  1005. "dialog.extensionRequired",
  1006. "[html]dialog.firefoxExtensionPrompt",
  1007. {url: url});
  1008. };
  1009. /**
  1010. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  1011. * 2 button dialog with buttons - cancel and go to web store.
  1012. * @param url {string} the url of the extension.
  1013. */
  1014. UI.showExtensionExternalInstallationDialog = function (url) {
  1015. let submitFunction = function(e,v){
  1016. if (v) {
  1017. e.preventDefault();
  1018. eventEmitter.emit(UIEvents.OPEN_EXTENSION_STORE, url);
  1019. }
  1020. };
  1021. let closeFunction = function () {
  1022. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  1023. };
  1024. messageHandler.openTwoButtonDialog({
  1025. titleKey: 'dialog.externalInstallationTitle',
  1026. msgKey: 'dialog.externalInstallationMsg',
  1027. leftButtonKey: 'dialog.goToStore',
  1028. submitFunction,
  1029. loadedFunction: $.noop,
  1030. closeFunction
  1031. });
  1032. };
  1033. /**
  1034. * Shows dialog with combined information about camera and microphone errors.
  1035. * @param {JitsiTrackError} micError
  1036. * @param {JitsiTrackError} cameraError
  1037. */
  1038. UI.showDeviceErrorDialog = function (micError, cameraError) {
  1039. let dontShowAgain = {
  1040. id: "doNotShowWarningAgain",
  1041. localStorageKey: "doNotShowErrorAgain",
  1042. textKey: "dialog.doNotShowWarningAgain"
  1043. };
  1044. let isMicJitsiTrackErrorAndHasName = micError && micError.name &&
  1045. micError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1046. let isCameraJitsiTrackErrorAndHasName = cameraError && cameraError.name &&
  1047. cameraError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1048. let showDoNotShowWarning = false;
  1049. if (micError && cameraError && isMicJitsiTrackErrorAndHasName &&
  1050. isCameraJitsiTrackErrorAndHasName) {
  1051. showDoNotShowWarning = true;
  1052. } else if (micError && isMicJitsiTrackErrorAndHasName && !cameraError) {
  1053. showDoNotShowWarning = true;
  1054. } else if (cameraError && isCameraJitsiTrackErrorAndHasName && !micError) {
  1055. showDoNotShowWarning = true;
  1056. }
  1057. if (micError) {
  1058. dontShowAgain.localStorageKey += "-mic-" + micError.name;
  1059. }
  1060. if (cameraError) {
  1061. dontShowAgain.localStorageKey += "-camera-" + cameraError.name;
  1062. }
  1063. let cameraJitsiTrackErrorMsg = cameraError
  1064. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[cameraError.name]
  1065. : undefined;
  1066. let micJitsiTrackErrorMsg = micError
  1067. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[micError.name]
  1068. : undefined;
  1069. let cameraErrorMsg = cameraError
  1070. ? cameraJitsiTrackErrorMsg ||
  1071. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  1072. : "";
  1073. let micErrorMsg = micError
  1074. ? micJitsiTrackErrorMsg ||
  1075. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  1076. : "";
  1077. let additionalCameraErrorMsg = !cameraJitsiTrackErrorMsg && cameraError &&
  1078. cameraError.message
  1079. ? `<div>${cameraError.message}</div>`
  1080. : ``;
  1081. let additionalMicErrorMsg = !micJitsiTrackErrorMsg && micError &&
  1082. micError.message
  1083. ? `<div>${micError.message}</div>`
  1084. : ``;
  1085. let message = '';
  1086. if (micError) {
  1087. message = `
  1088. ${message}
  1089. <h3 data-i18n='dialog.micErrorPresent'></h3>
  1090. <h4 data-i18n='${micErrorMsg}'></h4>
  1091. ${additionalMicErrorMsg}`;
  1092. }
  1093. if (cameraError) {
  1094. message = `
  1095. ${message}
  1096. <h3 data-i18n='dialog.cameraErrorPresent'></h3>
  1097. <h4 data-i18n='${cameraErrorMsg}'></h4>
  1098. ${additionalCameraErrorMsg}`;
  1099. }
  1100. // To make sure we don't have multiple error dialogs open at the same time,
  1101. // we will just close the previous one if we are going to show a new one.
  1102. deviceErrorDialog && deviceErrorDialog.close();
  1103. deviceErrorDialog = messageHandler.openDialog(
  1104. getTitleKey(),
  1105. message,
  1106. false,
  1107. {Ok: true},
  1108. function () {},
  1109. null,
  1110. function () {
  1111. // Reset dialog reference to null to avoid memory leaks when
  1112. // user closed the dialog manually.
  1113. deviceErrorDialog = null;
  1114. },
  1115. showDoNotShowWarning ? dontShowAgain : undefined
  1116. );
  1117. function getTitleKey() {
  1118. let title = "dialog.error";
  1119. if (micError && micError.name === TrackErrors.PERMISSION_DENIED) {
  1120. if (!cameraError
  1121. || cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1122. title = "dialog.permissionDenied";
  1123. }
  1124. } else if (cameraError
  1125. && cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1126. title = "dialog.permissionDenied";
  1127. }
  1128. return title;
  1129. }
  1130. };
  1131. /**
  1132. * Shows error dialog that informs the user that no data is received from the
  1133. * device.
  1134. */
  1135. UI.showTrackNotWorkingDialog = function (stream) {
  1136. messageHandler.openMessageDialog(
  1137. "dialog.error",
  1138. stream.isAudioTrack()? "dialog.micNotSendingData" :
  1139. "dialog.cameraNotSendingData");
  1140. };
  1141. UI.updateDevicesAvailability = function (id, devices) {
  1142. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1143. };
  1144. /**
  1145. * Show shared video.
  1146. * @param {string} id the id of the sender of the command
  1147. * @param {string} url video url
  1148. * @param {string} attributes
  1149. */
  1150. UI.onSharedVideoStart = function (id, url, attributes) {
  1151. if (sharedVideoManager)
  1152. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1153. };
  1154. /**
  1155. * Update shared video.
  1156. * @param {string} id the id of the sender of the command
  1157. * @param {string} url video url
  1158. * @param {string} attributes
  1159. */
  1160. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1161. if (sharedVideoManager)
  1162. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1163. };
  1164. /**
  1165. * Stop showing shared video.
  1166. * @param {string} id the id of the sender of the command
  1167. * @param {string} attributes
  1168. */
  1169. UI.onSharedVideoStop = function (id, attributes) {
  1170. if (sharedVideoManager)
  1171. sharedVideoManager.onSharedVideoStop(id, attributes);
  1172. };
  1173. /**
  1174. * Enables / disables camera toolbar button.
  1175. *
  1176. * @param {boolean} enabled indicates if the camera button should be enabled
  1177. * or disabled
  1178. */
  1179. UI.setCameraButtonEnabled
  1180. = enabled => APP.store.dispatch(setVideoIconEnabled(enabled));
  1181. /**
  1182. * Enables / disables microphone toolbar button.
  1183. *
  1184. * @param {boolean} enabled indicates if the microphone button should be
  1185. * enabled or disabled
  1186. */
  1187. UI.setMicrophoneButtonEnabled
  1188. = enabled => APP.store.dispatch(setAudioIconEnabled(enabled));
  1189. UI.showRingOverlay = function () {
  1190. const { callee } = APP.store.getState()['features/jwt'];
  1191. callee && RingOverlay.show(callee, interfaceConfig.DISABLE_RINGING);
  1192. Filmstrip.toggleFilmstrip(false, false);
  1193. };
  1194. UI.hideRingOverlay
  1195. = () => RingOverlay.hide() && Filmstrip.toggleFilmstrip(true, false);
  1196. /**
  1197. * Indicates if any the "top" overlays are currently visible. The check includes
  1198. * the call overlay, the suspended overlay, the GUM permissions overlay, and the
  1199. * page-reload overlay.
  1200. *
  1201. * @returns {*|boolean} {true} if an overlay is visible; {false}, otherwise
  1202. */
  1203. UI.isOverlayVisible = function () {
  1204. return this.isRingOverlayVisible() || this.overlayVisible;
  1205. };
  1206. /**
  1207. * Indicates if the ring overlay is currently visible.
  1208. *
  1209. * @returns {*|boolean} {true} if the ring overlay is visible, {false} otherwise
  1210. */
  1211. UI.isRingOverlayVisible = () => RingOverlay.isVisible();
  1212. /**
  1213. * Handles user's features changes.
  1214. */
  1215. UI.onUserFeaturesChanged = user => VideoLayout.onUserFeaturesChanged(user);
  1216. /**
  1217. * Returns the number of known remote videos.
  1218. *
  1219. * @returns {number} The number of remote videos.
  1220. */
  1221. UI.getRemoteVideosCount = () => VideoLayout.getRemoteVideosCount();
  1222. /**
  1223. * Makes remote thumbnail videos visible or not visible.
  1224. *
  1225. * @param {boolean} shouldHide - True if remote thumbnails should be hidden,
  1226. * false f they should be visible.
  1227. * @returns {void}
  1228. */
  1229. UI.setRemoteThumbnailsVisibility
  1230. = shouldHide => Filmstrip.setRemoteVideoVisibility(shouldHide);
  1231. const UIListeners = new Map([
  1232. [
  1233. UIEvents.ETHERPAD_CLICKED,
  1234. () => etherpadManager && etherpadManager.toggleEtherpad()
  1235. ], [
  1236. UIEvents.SHARED_VIDEO_CLICKED,
  1237. () => sharedVideoManager && sharedVideoManager.toggleSharedVideo()
  1238. ], [
  1239. UIEvents.TOGGLE_FULLSCREEN,
  1240. UI.toggleFullScreen
  1241. ], [
  1242. UIEvents.TOGGLE_CHAT,
  1243. UI.toggleChat
  1244. ], [
  1245. UIEvents.TOGGLE_SETTINGS,
  1246. () => {
  1247. // Opening of device selection is special-cased as it is a dialog
  1248. // opened through a button in settings and not directly displayed in
  1249. // settings itself. As it is not useful to only have a settings menu
  1250. // with a button to open a dialog, open the dialog directly instead.
  1251. if (interfaceConfig.SETTINGS_SECTIONS.length === 1
  1252. && UIUtil.isSettingEnabled('devices')) {
  1253. APP.store.dispatch(openDeviceSelectionDialog());
  1254. } else {
  1255. UI.toggleSidePanel("settings_container");
  1256. }
  1257. }
  1258. ], [
  1259. UIEvents.TOGGLE_CONTACT_LIST,
  1260. UI.toggleContactList
  1261. ], [
  1262. UIEvents.TOGGLE_PROFILE,
  1263. () => {
  1264. const {
  1265. isGuest
  1266. } = APP.store.getState()['features/jwt'];
  1267. isGuest && UI.toggleSidePanel('profile_container');
  1268. }
  1269. ], [
  1270. UIEvents.TOGGLE_FILMSTRIP,
  1271. UI.handleToggleFilmstrip
  1272. ], [
  1273. UIEvents.FOLLOW_ME_ENABLED,
  1274. enabled => (followMeHandler && followMeHandler.enableFollowMe(enabled))
  1275. ]
  1276. ]);
  1277. module.exports = UI;