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 41KB

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