You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UI.js 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  1. /* global APP, $, config, interfaceConfig */
  2. const logger = require('jitsi-meet-logger').getLogger(__filename);
  3. const UI = {};
  4. import messageHandler from './util/MessageHandler';
  5. import UIUtil from './util/UIUtil';
  6. import UIEvents from '../../service/UI/UIEvents';
  7. import EtherpadManager from './etherpad/Etherpad';
  8. import SharedVideoManager from './shared_video/SharedVideo';
  9. import VideoLayout from './videolayout/VideoLayout';
  10. import Filmstrip from './videolayout/Filmstrip';
  11. import { getLocalParticipant } from '../../react/features/base/participants';
  12. import { toggleChat } from '../../react/features/chat';
  13. import { openDisplayNamePrompt } from '../../react/features/display-name';
  14. import { setEtherpadHasInitialzied } from '../../react/features/etherpad';
  15. import { setFilmstripVisible } from '../../react/features/filmstrip';
  16. import { setNotificationsEnabled } from '../../react/features/notifications';
  17. import {
  18. dockToolbox,
  19. setToolboxEnabled,
  20. showToolbox
  21. } from '../../react/features/toolbox';
  22. const EventEmitter = require('events');
  23. UI.messageHandler = messageHandler;
  24. const eventEmitter = new EventEmitter();
  25. UI.eventEmitter = eventEmitter;
  26. let etherpadManager;
  27. let sharedVideoManager;
  28. const UIListeners = new Map([
  29. [
  30. UIEvents.ETHERPAD_CLICKED,
  31. () => etherpadManager && etherpadManager.toggleEtherpad()
  32. ], [
  33. UIEvents.SHARED_VIDEO_CLICKED,
  34. () => sharedVideoManager && sharedVideoManager.toggleSharedVideo()
  35. ], [
  36. UIEvents.TOGGLE_FILMSTRIP,
  37. () => UI.toggleFilmstrip()
  38. ]
  39. ]);
  40. /**
  41. * Indicates if we're currently in full screen mode.
  42. *
  43. * @return {boolean} {true} to indicate that we're currently in full screen
  44. * mode, {false} otherwise
  45. */
  46. UI.isFullScreen = function() {
  47. return UIUtil.isFullScreen();
  48. };
  49. /**
  50. * Returns true if the etherpad window is currently visible.
  51. * @returns {Boolean} - true if the etherpad window is currently visible.
  52. */
  53. UI.isEtherpadVisible = function() {
  54. return Boolean(etherpadManager && etherpadManager.isVisible());
  55. };
  56. /**
  57. * Returns true if there is a shared video which is being shown (?).
  58. * @returns {boolean} - true if there is a shared video which is being shown.
  59. */
  60. UI.isSharedVideoShown = function() {
  61. return Boolean(sharedVideoManager && sharedVideoManager.isSharedVideoShown);
  62. };
  63. /**
  64. * Notify user that server has shut down.
  65. */
  66. UI.notifyGracefulShutdown = function() {
  67. messageHandler.showError({
  68. descriptionKey: 'dialog.gracefulShutdown',
  69. titleKey: 'dialog.serviceUnavailable'
  70. });
  71. };
  72. /**
  73. * Notify user that reservation error happened.
  74. */
  75. UI.notifyReservationError = function(code, msg) {
  76. messageHandler.showError({
  77. descriptionArguments: {
  78. code,
  79. msg
  80. },
  81. descriptionKey: 'dialog.reservationErrorMsg',
  82. titleKey: 'dialog.reservationError'
  83. });
  84. };
  85. /**
  86. * Notify user that he has been kicked from the server.
  87. */
  88. UI.notifyKicked = function() {
  89. messageHandler.showError({
  90. hideErrorSupportLink: true,
  91. descriptionKey: 'dialog.kickMessage',
  92. titleKey: 'dialog.kickTitle'
  93. });
  94. };
  95. /**
  96. * Notify user that conference was destroyed.
  97. * @param reason {string} the reason text
  98. */
  99. UI.notifyConferenceDestroyed = function(reason) {
  100. // FIXME: use Session Terminated from translation, but
  101. // 'reason' text comes from XMPP packet and is not translated
  102. messageHandler.showError({
  103. description: reason,
  104. titleKey: 'dialog.sessTerminated'
  105. });
  106. };
  107. /**
  108. * Change nickname for the user.
  109. * @param {string} id user id
  110. * @param {string} displayName new nickname
  111. */
  112. UI.changeDisplayName = function(id, displayName) {
  113. VideoLayout.onDisplayNameChanged(id, displayName);
  114. };
  115. /**
  116. * Initialize conference UI.
  117. */
  118. UI.initConference = function() {
  119. const { getState } = APP.store;
  120. const { id, name } = getLocalParticipant(getState);
  121. // Update default button states before showing the toolbar
  122. // if local role changes buttons state will be again updated.
  123. UI.updateLocalRole(APP.conference.isModerator);
  124. UI.showToolbar();
  125. const displayName = config.displayJids ? id : name;
  126. if (displayName) {
  127. UI.changeDisplayName('localVideoContainer', displayName);
  128. }
  129. };
  130. /**
  131. * Returns the shared document manager object.
  132. * @return {EtherpadManager} the shared document manager object
  133. */
  134. UI.getSharedVideoManager = function() {
  135. return sharedVideoManager;
  136. };
  137. /**
  138. * Starts the UI module and initializes all related components.
  139. *
  140. * @returns {boolean} true if the UI is ready and the conference should be
  141. * established, false - otherwise (for example in the case of welcome page)
  142. */
  143. UI.start = function() {
  144. document.title = interfaceConfig.APP_NAME;
  145. // Set the defaults for prompt dialogs.
  146. $.prompt.setDefaults({ persistent: false });
  147. Filmstrip.init(eventEmitter);
  148. VideoLayout.init(eventEmitter);
  149. if (!interfaceConfig.filmStripOnly) {
  150. VideoLayout.initLargeVideo();
  151. }
  152. // Do not animate the video area on UI start (second argument passed into
  153. // resizeVideoArea) because the animation is not visible anyway. Plus with
  154. // the current dom layout, the quality label is part of the video layout and
  155. // will be seen animating in.
  156. VideoLayout.resizeVideoArea(true, false);
  157. sharedVideoManager = new SharedVideoManager(eventEmitter);
  158. if (interfaceConfig.filmStripOnly) {
  159. $('body').addClass('filmstrip-only');
  160. APP.store.dispatch(setNotificationsEnabled(false));
  161. } else if (config.iAmRecorder) {
  162. // in case of iAmSipGateway keep local video visible
  163. if (!config.iAmSipGateway) {
  164. VideoLayout.setLocalVideoVisible(false);
  165. }
  166. APP.store.dispatch(setToolboxEnabled(false));
  167. APP.store.dispatch(setNotificationsEnabled(false));
  168. UI.messageHandler.enablePopups(false);
  169. }
  170. document.title = interfaceConfig.APP_NAME;
  171. };
  172. /**
  173. * Setup some UI event listeners.
  174. */
  175. UI.registerListeners
  176. = () => UIListeners.forEach((value, key) => UI.addListener(key, value));
  177. /**
  178. * Setup some DOM event listeners.
  179. */
  180. UI.bindEvents = () => {
  181. /**
  182. *
  183. */
  184. function onResize() {
  185. VideoLayout.resizeVideoArea();
  186. }
  187. // Resize and reposition videos in full screen mode.
  188. $(document).on(
  189. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  190. onResize);
  191. $(window).resize(onResize);
  192. };
  193. /**
  194. * Unbind some DOM event listeners.
  195. */
  196. UI.unbindEvents = () => {
  197. $(document).off(
  198. 'webkitfullscreenchange mozfullscreenchange fullscreenchange');
  199. $(window).off('resize');
  200. };
  201. /**
  202. * Show local stream on UI.
  203. * @param {JitsiTrack} track stream to show
  204. */
  205. UI.addLocalStream = track => {
  206. switch (track.getType()) {
  207. case 'audio':
  208. // Local audio is not rendered so no further action is needed at this
  209. // point.
  210. break;
  211. case 'video':
  212. VideoLayout.changeLocalVideo(track);
  213. break;
  214. default:
  215. logger.error(`Unknown stream type: ${track.getType()}`);
  216. break;
  217. }
  218. };
  219. /**
  220. * Removed remote stream from UI.
  221. * @param {JitsiTrack} track stream to remove
  222. */
  223. UI.removeRemoteStream = track => VideoLayout.onRemoteStreamRemoved(track);
  224. /**
  225. * Setup and show Etherpad.
  226. * @param {string} name etherpad id
  227. */
  228. UI.initEtherpad = name => {
  229. if (etherpadManager || !config.etherpad_base || !name) {
  230. return;
  231. }
  232. logger.log('Etherpad is enabled');
  233. etherpadManager
  234. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  235. APP.store.dispatch(setEtherpadHasInitialzied());
  236. };
  237. /**
  238. * Returns the shared document manager object.
  239. * @return {EtherpadManager} the shared document manager object
  240. */
  241. UI.getSharedDocumentManager = () => etherpadManager;
  242. /**
  243. * Show user on UI.
  244. * @param {JitsiParticipant} user
  245. */
  246. UI.addUser = function(user) {
  247. const id = user.getId();
  248. const displayName = user.getDisplayName();
  249. const status = user.getStatus();
  250. if (status) {
  251. // FIXME: move updateUserStatus in participantPresenceChanged action
  252. UI.updateUserStatus(user, status);
  253. }
  254. // set initial display name
  255. if (displayName) {
  256. UI.changeDisplayName(id, displayName);
  257. }
  258. };
  259. /**
  260. * Update videotype for specified user.
  261. * @param {string} id user id
  262. * @param {string} newVideoType new videotype
  263. */
  264. UI.onPeerVideoTypeChanged
  265. = (id, newVideoType) => VideoLayout.onVideoTypeChanged(id, newVideoType);
  266. /**
  267. * Update local user role and show notification if user is moderator.
  268. * @param {boolean} isModerator if local user is moderator or not
  269. */
  270. UI.updateLocalRole = isModerator => {
  271. VideoLayout.showModeratorIndicator();
  272. if (isModerator && !interfaceConfig.DISABLE_FOCUS_INDICATOR) {
  273. messageHandler.participantNotification(
  274. null, 'notify.me', 'connected', 'notify.moderator');
  275. }
  276. };
  277. /**
  278. * Check the role for the user and reflect it in the UI, moderator ui indication
  279. * and notifies user who is the moderator
  280. * @param user to check for moderator
  281. */
  282. UI.updateUserRole = user => {
  283. VideoLayout.showModeratorIndicator();
  284. // We don't need to show moderator notifications when the focus (moderator)
  285. // indicator is disabled.
  286. if (!user.isModerator() || interfaceConfig.DISABLE_FOCUS_INDICATOR) {
  287. return;
  288. }
  289. const displayName = user.getDisplayName();
  290. messageHandler.participantNotification(
  291. displayName,
  292. 'notify.somebody',
  293. 'connected',
  294. 'notify.grantedTo',
  295. { to: displayName
  296. ? UIUtil.escapeHtml(displayName) : '$t(notify.somebody)' });
  297. };
  298. /**
  299. * Updates the user status.
  300. *
  301. * @param {JitsiParticipant} user - The user which status we need to update.
  302. * @param {string} status - The new status.
  303. */
  304. UI.updateUserStatus = (user, status) => {
  305. const reduxState = APP.store.getState() || {};
  306. const { calleeInfoVisible } = reduxState['features/invite'] || {};
  307. if (!status || calleeInfoVisible) {
  308. return;
  309. }
  310. const displayName = user.getDisplayName();
  311. messageHandler.participantNotification(
  312. displayName,
  313. '',
  314. 'connected',
  315. 'dialOut.statusMessage',
  316. { status: UIUtil.escapeHtml(status) });
  317. };
  318. /**
  319. * Toggles filmstrip.
  320. */
  321. UI.toggleFilmstrip = function() {
  322. const { visible } = APP.store.getState()['features/filmstrip'];
  323. APP.store.dispatch(setFilmstripVisible(!visible));
  324. };
  325. /**
  326. * Checks if the filmstrip is currently visible or not.
  327. * @returns {true} if the filmstrip is currently visible, and false otherwise.
  328. */
  329. UI.isFilmstripVisible = () => Filmstrip.isFilmstripVisible();
  330. /**
  331. * Toggles the visibility of the chat panel.
  332. */
  333. UI.toggleChat = () => APP.store.dispatch(toggleChat());
  334. /**
  335. * Handle new user display name.
  336. */
  337. UI.inputDisplayNameHandler = function(newDisplayName) {
  338. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
  339. };
  340. /**
  341. * Return the type of the remote video.
  342. * @param jid the jid for the remote video
  343. * @returns the video type video or screen.
  344. */
  345. UI.getRemoteVideoType = function(jid) {
  346. return VideoLayout.getRemoteVideoType(jid);
  347. };
  348. // FIXME check if someone user this
  349. UI.showLoginPopup = function(callback) {
  350. logger.log('password is required');
  351. const message
  352. = `<input name="username" type="text"
  353. placeholder="user@domain.net"
  354. class="input-control" autofocus>
  355. <input name="password" type="password"
  356. data-i18n="[placeholder]dialog.userPassword"
  357. class="input-control"
  358. placeholder="user password">`
  359. ;
  360. // eslint-disable-next-line max-params
  361. const submitFunction = (e, v, m, f) => {
  362. if (v && f.username && f.password) {
  363. callback(f.username, f.password);
  364. }
  365. };
  366. messageHandler.openTwoButtonDialog({
  367. titleKey: 'dialog.passwordRequired',
  368. msgString: message,
  369. leftButtonKey: 'dialog.Ok',
  370. submitFunction,
  371. focus: ':input:first'
  372. });
  373. };
  374. UI.askForNickname = function() {
  375. // eslint-disable-next-line no-alert
  376. return window.prompt('Your nickname (optional)');
  377. };
  378. /**
  379. * Sets muted audio state for participant
  380. */
  381. UI.setAudioMuted = function(id, muted) {
  382. VideoLayout.onAudioMute(id, muted);
  383. if (APP.conference.isLocalId(id)) {
  384. APP.conference.updateAudioIconEnabled();
  385. }
  386. };
  387. /**
  388. * Sets muted video state for participant
  389. */
  390. UI.setVideoMuted = function(id, muted) {
  391. VideoLayout.onVideoMute(id, muted);
  392. if (APP.conference.isLocalId(id)) {
  393. APP.conference.updateVideoIconEnabled();
  394. }
  395. };
  396. /**
  397. * Triggers an update of remote video and large video displays so they may pick
  398. * up any state changes that have occurred elsewhere.
  399. *
  400. * @returns {void}
  401. */
  402. UI.updateAllVideos = () => VideoLayout.updateAllVideos();
  403. /**
  404. * Adds a listener that would be notified on the given type of event.
  405. *
  406. * @param type the type of the event we're listening for
  407. * @param listener a function that would be called when notified
  408. */
  409. UI.addListener = function(type, listener) {
  410. eventEmitter.on(type, listener);
  411. };
  412. /**
  413. * Removes the all listeners for all events.
  414. *
  415. * @returns {void}
  416. */
  417. UI.removeAllListeners = function() {
  418. eventEmitter.removeAllListeners();
  419. };
  420. /**
  421. * Removes the given listener for the given type of event.
  422. *
  423. * @param type the type of the event we're listening for
  424. * @param listener the listener we want to remove
  425. */
  426. UI.removeListener = function(type, listener) {
  427. eventEmitter.removeListener(type, listener);
  428. };
  429. /**
  430. * Emits the event of given type by specifying the parameters in options.
  431. *
  432. * @param type the type of the event we're emitting
  433. * @param options the parameters for the event
  434. */
  435. UI.emitEvent = (type, ...options) => eventEmitter.emit(type, ...options);
  436. UI.clickOnVideo = videoNumber => VideoLayout.togglePin(videoNumber);
  437. // Used by torture.
  438. UI.showToolbar = timeout => APP.store.dispatch(showToolbox(timeout));
  439. // Used by torture.
  440. UI.dockToolbar = dock => APP.store.dispatch(dockToolbox(dock));
  441. /**
  442. * Updates the displayed avatar for participant.
  443. *
  444. * @param {string} id - User id whose avatar should be updated.
  445. * @param {string} avatarURL - The URL to avatar image to display.
  446. * @returns {void}
  447. */
  448. UI.refreshAvatarDisplay = function(id, avatarURL) {
  449. VideoLayout.changeUserAvatar(id, avatarURL);
  450. };
  451. /**
  452. * Notify user that connection failed.
  453. * @param {string} stropheErrorMsg raw Strophe error message
  454. */
  455. UI.notifyConnectionFailed = function(stropheErrorMsg) {
  456. let descriptionKey;
  457. let descriptionArguments;
  458. if (stropheErrorMsg) {
  459. descriptionKey = 'dialog.connectErrorWithMsg';
  460. descriptionArguments = { msg: stropheErrorMsg };
  461. } else {
  462. descriptionKey = 'dialog.connectError';
  463. }
  464. messageHandler.showError({
  465. descriptionArguments,
  466. descriptionKey,
  467. titleKey: 'connection.CONNFAIL'
  468. });
  469. };
  470. /**
  471. * Notify user that maximum users limit has been reached.
  472. */
  473. UI.notifyMaxUsersLimitReached = function() {
  474. messageHandler.showError({
  475. hideErrorSupportLink: true,
  476. descriptionKey: 'dialog.maxUsersLimitReached',
  477. titleKey: 'dialog.maxUsersLimitReachedTitle'
  478. });
  479. };
  480. /**
  481. * Notify user that he was automatically muted when joned the conference.
  482. */
  483. UI.notifyInitiallyMuted = function() {
  484. messageHandler.participantNotification(
  485. null,
  486. 'notify.mutedTitle',
  487. 'connected',
  488. 'notify.muted',
  489. null);
  490. };
  491. UI.handleLastNEndpoints = function(leavingIds, enteringIds) {
  492. VideoLayout.onLastNEndpointsChanged(leavingIds, enteringIds);
  493. };
  494. /**
  495. * Prompt user for nickname.
  496. */
  497. UI.promptDisplayName = () => {
  498. APP.store.dispatch(openDisplayNamePrompt(undefined));
  499. };
  500. /**
  501. * Update audio level visualization for specified user.
  502. * @param {string} id user id
  503. * @param {number} lvl audio level
  504. */
  505. UI.setAudioLevel = (id, lvl) => VideoLayout.setAudioLevel(id, lvl);
  506. /**
  507. * Hide connection quality statistics from UI.
  508. */
  509. UI.hideStats = function() {
  510. VideoLayout.hideStats();
  511. };
  512. UI.notifyTokenAuthFailed = function() {
  513. messageHandler.showError({
  514. descriptionKey: 'dialog.tokenAuthFailed',
  515. titleKey: 'dialog.tokenAuthFailedTitle'
  516. });
  517. };
  518. UI.notifyInternalError = function(error) {
  519. messageHandler.showError({
  520. descriptionArguments: { error },
  521. descriptionKey: 'dialog.internalError',
  522. titleKey: 'dialog.internalErrorTitle'
  523. });
  524. };
  525. UI.notifyFocusDisconnected = function(focus, retrySec) {
  526. messageHandler.participantNotification(
  527. null, 'notify.focus',
  528. 'disconnected', 'notify.focusFail',
  529. { component: focus,
  530. ms: retrySec }
  531. );
  532. };
  533. /**
  534. * Notifies interested listeners that the raise hand property has changed.
  535. *
  536. * @param {boolean} isRaisedHand indicates the current state of the
  537. * "raised hand"
  538. */
  539. UI.onLocalRaiseHandChanged = function(isRaisedHand) {
  540. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  541. };
  542. /**
  543. * Update list of available physical devices.
  544. */
  545. UI.onAvailableDevicesChanged = function() {
  546. APP.conference.updateAudioIconEnabled();
  547. APP.conference.updateVideoIconEnabled();
  548. };
  549. /**
  550. * Returns the id of the current video shown on large.
  551. * Currently used by tests (torture).
  552. */
  553. UI.getLargeVideoID = function() {
  554. return VideoLayout.getLargeVideoID();
  555. };
  556. /**
  557. * Returns the current video shown on large.
  558. * Currently used by tests (torture).
  559. */
  560. UI.getLargeVideo = function() {
  561. return VideoLayout.getLargeVideo();
  562. };
  563. /**
  564. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  565. * 2 button dialog with buttons - cancel and go to web store.
  566. * @param url {string} the url of the extension.
  567. */
  568. UI.showExtensionExternalInstallationDialog = function(url) {
  569. let openedWindow = null;
  570. const submitFunction = function(e, v) {
  571. if (v) {
  572. e.preventDefault();
  573. if (openedWindow === null || openedWindow.closed) {
  574. openedWindow
  575. = window.open(
  576. url,
  577. 'extension_store_window',
  578. 'resizable,scrollbars=yes,status=1');
  579. } else {
  580. openedWindow.focus();
  581. }
  582. }
  583. };
  584. const closeFunction = function(e, v) {
  585. if (openedWindow) {
  586. // Ideally we would close the popup, but this does not seem to work
  587. // on Chrome. Leaving it uncommented in case it could work
  588. // in some version.
  589. openedWindow.close();
  590. openedWindow = null;
  591. }
  592. if (!v) {
  593. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  594. }
  595. };
  596. messageHandler.openTwoButtonDialog({
  597. titleKey: 'dialog.externalInstallationTitle',
  598. msgKey: 'dialog.externalInstallationMsg',
  599. leftButtonKey: 'dialog.goToStore',
  600. submitFunction,
  601. loadedFunction: $.noop,
  602. closeFunction
  603. });
  604. };
  605. /**
  606. * Shows a dialog which asks user to install the extension. This one is
  607. * displayed after installation is triggered from the script, but fails because
  608. * it must be initiated by user gesture.
  609. * @param callback {function} function to be executed after user clicks
  610. * the install button - it should make another attempt to install the extension.
  611. */
  612. UI.showExtensionInlineInstallationDialog = function(callback) {
  613. const submitFunction = function(e, v) {
  614. if (v) {
  615. callback();
  616. }
  617. };
  618. const closeFunction = function(e, v) {
  619. if (!v) {
  620. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  621. }
  622. };
  623. messageHandler.openTwoButtonDialog({
  624. titleKey: 'dialog.externalInstallationTitle',
  625. msgKey: 'dialog.inlineInstallationMsg',
  626. leftButtonKey: 'dialog.inlineInstallExtension',
  627. submitFunction,
  628. loadedFunction: $.noop,
  629. closeFunction
  630. });
  631. };
  632. /**
  633. * Shows error dialog that informs the user that no data is received from the
  634. * device.
  635. *
  636. * @param {boolean} isAudioTrack - Whether or not the dialog is for an audio
  637. * track error.
  638. * @returns {void}
  639. */
  640. UI.showTrackNotWorkingDialog = function(isAudioTrack) {
  641. messageHandler.showError({
  642. descriptionKey: isAudioTrack
  643. ? 'dialog.micNotSendingData' : 'dialog.cameraNotSendingData',
  644. titleKey: isAudioTrack
  645. ? 'dialog.micNotSendingDataTitle'
  646. : 'dialog.cameraNotSendingDataTitle'
  647. });
  648. };
  649. UI.updateDevicesAvailability = function(id, devices) {
  650. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  651. };
  652. /**
  653. * Show shared video.
  654. * @param {string} id the id of the sender of the command
  655. * @param {string} url video url
  656. * @param {string} attributes
  657. */
  658. UI.onSharedVideoStart = function(id, url, attributes) {
  659. if (sharedVideoManager) {
  660. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  661. }
  662. };
  663. /**
  664. * Update shared video.
  665. * @param {string} id the id of the sender of the command
  666. * @param {string} url video url
  667. * @param {string} attributes
  668. */
  669. UI.onSharedVideoUpdate = function(id, url, attributes) {
  670. if (sharedVideoManager) {
  671. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  672. }
  673. };
  674. /**
  675. * Stop showing shared video.
  676. * @param {string} id the id of the sender of the command
  677. * @param {string} attributes
  678. */
  679. UI.onSharedVideoStop = function(id, attributes) {
  680. if (sharedVideoManager) {
  681. sharedVideoManager.onSharedVideoStop(id, attributes);
  682. }
  683. };
  684. /**
  685. * Handles user's features changes.
  686. */
  687. UI.onUserFeaturesChanged = user => VideoLayout.onUserFeaturesChanged(user);
  688. /**
  689. * Returns the number of known remote videos.
  690. *
  691. * @returns {number} The number of remote videos.
  692. */
  693. UI.getRemoteVideosCount = () => VideoLayout.getRemoteVideosCount();
  694. /**
  695. * Sets the remote control active status for a remote participant.
  696. *
  697. * @param {string} participantID - The id of the remote participant.
  698. * @param {boolean} isActive - The new remote control active status.
  699. * @returns {void}
  700. */
  701. UI.setRemoteControlActiveStatus = function(participantID, isActive) {
  702. VideoLayout.setRemoteControlActiveStatus(participantID, isActive);
  703. };
  704. /**
  705. * Sets the remote control active status for the local participant.
  706. *
  707. * @returns {void}
  708. */
  709. UI.setLocalRemoteControlActiveChanged = function() {
  710. VideoLayout.setLocalRemoteControlActiveChanged();
  711. };
  712. // TODO: Export every function separately. For now there is no point of doing
  713. // this because we are importing everything.
  714. export default UI;