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.

Conference.web.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /* global APP, $, interfaceConfig, config */
  2. import React, { Component } from 'react';
  3. import { connect as reactReduxConnect } from 'react-redux';
  4. import {
  5. connect,
  6. disconnect
  7. } from '../../base/connection';
  8. import ConferenceUrl from '../../../../modules/URL/ConferenceUrl';
  9. import HttpConfigFetch from '../../../../modules/config/HttpConfigFetch';
  10. import BoshAddressChoice from '../../../../modules/config/BoshAddressChoice';
  11. const logger = require('jitsi-meet-logger').getLogger(__filename);
  12. /**
  13. * For legacy reasons, inline style for display none.
  14. * @type {{display: string}}
  15. */
  16. const DISPLAY_NONE_STYLE = {
  17. display: 'none'
  18. };
  19. /**
  20. * Implements a React Component which renders initial conference layout
  21. */
  22. class Conference extends Component {
  23. /**
  24. * Until we don't rewrite UI using react components
  25. * we use UI.start from old app. Also method translates
  26. * component right after it has been mounted.
  27. *
  28. * @inheritdoc
  29. */
  30. componentDidMount() {
  31. /**
  32. * If JWT token data it will be used for local user settings.
  33. *
  34. * @returns {void}
  35. */
  36. function setTokenData() {
  37. const localUser = APP.tokenData.caller;
  38. if (localUser) {
  39. const email = localUser.getEmail();
  40. const avatarUrl = localUser.getAvatarUrl();
  41. const name = localUser.getName();
  42. APP.settings.setEmail((email || '').trim(), true);
  43. APP.settings.setAvatarUrl((avatarUrl || '').trim());
  44. APP.settings.setDisplayName((name || '').trim(), true);
  45. }
  46. }
  47. /**
  48. * Initialization of the app.
  49. *
  50. * @returns {void}
  51. */
  52. function init() {
  53. setTokenData();
  54. // Initialize the conference URL handler
  55. APP.ConferenceUrl = new ConferenceUrl(window.location);
  56. }
  57. /**
  58. * If we have an HTTP endpoint for getting config.json configured
  59. * we're going to read it and override properties from config.js and
  60. * interfaceConfig.js. If there is no endpoint we'll just
  61. * continue with initialization.
  62. * Keep in mind that if the endpoint has been configured and we fail
  63. * to obtain the config for any reason then the conference won't
  64. * start and error message will be displayed to the user.
  65. *
  66. * @returns {void}
  67. */
  68. function obtainConfigAndInit() {
  69. const room = APP.conference.roomName;
  70. if (config.configLocation) {
  71. const configFetch = HttpConfigFetch;
  72. const location = config.configLocation;
  73. configFetch.obtainConfig(location, room, obtainConfigHandler);
  74. } else {
  75. BoshAddressChoice.chooseAddress(config, room);
  76. init();
  77. }
  78. }
  79. /**
  80. * Obtain config handler.
  81. *
  82. * @param {boolean} success - Equals to true if
  83. * config has been obtained w/o errors.
  84. * @param {Object} error - Error object if there is error occured
  85. * while fetching config.
  86. * @returns {void}
  87. */
  88. function obtainConfigHandler(success, error) {
  89. if (success) {
  90. const now = window.performance.now();
  91. APP.connectionTimes['configuration.fetched'] = now;
  92. logger.log('(TIME) configuration fetched:\t', now);
  93. init();
  94. } else {
  95. // Show obtain config error,
  96. // pass the error object for report
  97. APP.UI.messageHandler.openReportDialog(
  98. null, 'dialog.connectError', error);
  99. }
  100. }
  101. obtainConfigAndInit();
  102. APP.UI.start();
  103. // XXX Temporary solution until we add React translation.
  104. APP.translation.translateElement($('#videoconference_page'));
  105. this.props.dispatch(connect());
  106. }
  107. /**
  108. * Disconnect from the conference when component will be
  109. * unmounted.
  110. *
  111. * @inheritdoc
  112. */
  113. componentWillUnmount() {
  114. this.props.dispatch(disconnect());
  115. }
  116. /**
  117. * Conference component's property types.
  118. *
  119. * @static
  120. */
  121. static propTypes = {
  122. dispatch: React.PropTypes.func
  123. };
  124. /**
  125. * Initializes Conference component instance.
  126. *
  127. * @param {Object} props - The read-only properties with which the new
  128. * instance is to be initialized.
  129. */
  130. constructor(props) {
  131. super(props);
  132. const showBrandWatermark = interfaceConfig.SHOW_BRAND_WATERMARK;
  133. const showJitsiWatermark = interfaceConfig.SHOW_JITSI_WATERMARK;
  134. this.state = {
  135. ...this.state,
  136. showBrandWatermark,
  137. showJitsiWatermark,
  138. brandWatermarkLink:
  139. showBrandWatermark ? interfaceConfig.BRAND_WATERMARK_LINK : '',
  140. jitsiWatermarkLink:
  141. showJitsiWatermark ? interfaceConfig.JITSI_WATERMARK_LINK : '',
  142. showPoweredBy: interfaceConfig.SHOW_POWERED_BY
  143. };
  144. }
  145. /**
  146. * Implements React's {@link Component#render()}.
  147. *
  148. * @inheritdoc
  149. * @returns {ReactElement}
  150. */
  151. render() {
  152. return (
  153. <div id = 'videoconference_page'>
  154. <div id = 'mainToolbarContainer'>
  155. <div
  156. className = 'notice'
  157. id = 'notice'
  158. style = { DISPLAY_NONE_STYLE }>
  159. <span
  160. className = 'noticeText'
  161. id = 'noticeText' />
  162. </div>
  163. <div
  164. className = 'toolbar'
  165. id = 'mainToolbar' />
  166. </div>
  167. <div
  168. className = 'hide'
  169. id = 'subject' />
  170. <div
  171. className = 'toolbar'
  172. id = 'extendedToolbar'>
  173. <div id = 'extendedToolbarButtons' />
  174. <a
  175. className = 'button icon-feedback'
  176. id = 'feedbackButton' />
  177. <div id = 'sideToolbarContainer' />
  178. </div>
  179. <div id = 'videospace'>
  180. <div
  181. className = 'videocontainer'
  182. id = 'largeVideoContainer'>
  183. <div id = 'sharedVideo'>
  184. <div id = 'sharedVideoIFrame' />
  185. </div>
  186. <div id = 'etherpad' />
  187. {
  188. this._renderJitsiWatermark()
  189. }
  190. {
  191. this._renderBrandWatermark()
  192. }
  193. {
  194. this._renderPoweredBy()
  195. }
  196. <div id = 'dominantSpeaker'>
  197. <div className = 'dynamic-shadow' />
  198. <img
  199. id = 'dominantSpeakerAvatar'
  200. src = '' />
  201. </div>
  202. <span id = 'remoteConnectionMessage' />
  203. <div id = 'largeVideoWrapper'>
  204. <video
  205. autoPlay = { true }
  206. id = 'largeVideo'
  207. muted = 'true' />
  208. </div>
  209. <span id = 'localConnectionMessage' />
  210. <span
  211. className = 'video-state-indicator moveToCorner'
  212. id = 'videoResolutionLabel'>HD</span>
  213. <span
  214. className
  215. = 'video-state-indicator centeredVideoLabel'
  216. id = 'recordingLabel'>
  217. <span id = 'recordingLabelText' />
  218. <img
  219. className = 'recordingSpinner'
  220. id = 'recordingSpinner'
  221. src = 'images/spin.svg' />
  222. </span>
  223. </div>
  224. <div className = 'filmstrip'>
  225. <div
  226. className = 'filmstrip__videos'
  227. id = 'remoteVideos'>
  228. <span
  229. className = 'videocontainer'
  230. id = 'localVideoContainer'>
  231. <div
  232. className = 'videocontainer__background' />
  233. <span id = 'localVideoWrapper' />
  234. <audio
  235. autoPlay = { true }
  236. id = 'localAudio'
  237. muted = { true } />
  238. <div className = 'videocontainer__toolbar' />
  239. <div
  240. className = 'videocontainer__toptoolbar' />
  241. <div
  242. className
  243. = 'videocontainer__hoverOverlay' />
  244. </span>
  245. <audio
  246. id = 'userJoined'
  247. preload = 'auto'
  248. src = 'sounds/joined.wav' />
  249. <audio
  250. id = 'userLeft'
  251. preload = 'auto'
  252. src = 'sounds/left.wav' />
  253. </div>
  254. </div>
  255. </div>
  256. </div>
  257. );
  258. }
  259. /**
  260. * Method that returns brand watermark element if it is enabled.
  261. *
  262. * @returns {ReactElement|null}
  263. * @private
  264. */
  265. _renderBrandWatermark() {
  266. if (this.state.showBrandWatermark) {
  267. return (
  268. <a
  269. href = { this.state.brandWatermarkLink }
  270. target = '_new'>
  271. <div className = 'watermark rightwatermark' />
  272. </a>
  273. );
  274. }
  275. return null;
  276. }
  277. /**
  278. * Method that returns jitsi watermark element if it is enabled.
  279. *
  280. * @returns {ReactElement|null}
  281. * @private
  282. */
  283. _renderJitsiWatermark() {
  284. if (this.state.showJitsiWatermark) {
  285. return (
  286. <a
  287. href = { this.state.jitsiWatermarkLink }
  288. target = '_new'>
  289. <div className = 'watermark leftwatermark' />
  290. </a>
  291. );
  292. }
  293. return null;
  294. }
  295. /**
  296. * Renders powered by block if it is enabled.
  297. *
  298. * @returns {ReactElement|null}
  299. * @private
  300. */
  301. _renderPoweredBy() {
  302. if (this.state.showPoweredBy) {
  303. return (
  304. <a
  305. className = 'poweredby hide'
  306. href = 'http://jitsi.org'
  307. target = '_new'>
  308. <span data-i18n = 'poweredby' /> jitsi.org
  309. </a>
  310. );
  311. }
  312. return null;
  313. }
  314. }
  315. export default reactReduxConnect()(Conference);