2017-01-27 23:41:11 +08:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
2016-09-01 21:56:41 +08:00
|
|
|
import Modal from '/imports/ui/components/modal/component';
|
2017-01-27 23:41:11 +08:00
|
|
|
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
|
|
|
|
|
2017-02-16 02:49:40 +08:00
|
|
|
import ClosedCaptions from '/imports/ui/components/settings/submenus/closed-captions/component';
|
|
|
|
import Audio from '/imports/ui/components/settings/submenus/audio/component';
|
2017-02-25 04:19:53 +08:00
|
|
|
import Application from '/imports/ui/components/settings/submenus/application/container';
|
2017-02-16 02:49:40 +08:00
|
|
|
import Participants from '/imports/ui/components/settings/submenus/participants/component';
|
|
|
|
import Video from '/imports/ui/components/settings/submenus/video/component';
|
2017-01-27 23:41:11 +08:00
|
|
|
|
|
|
|
import Button from '../button/component';
|
|
|
|
import Icon from '../icon/component';
|
|
|
|
import styles from './styles';
|
|
|
|
import cx from 'classnames';
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
};
|
2016-05-06 05:14:39 +08:00
|
|
|
|
2017-02-16 02:49:40 +08:00
|
|
|
export default class Settings extends Component {
|
2016-05-06 05:14:39 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2017-02-22 04:29:36 +08:00
|
|
|
|
2017-03-09 22:34:33 +08:00
|
|
|
const audio = props.audio;
|
|
|
|
const video = props.video;
|
|
|
|
const application = props.application;
|
|
|
|
const cc = props.cc;
|
|
|
|
const participants = props.participants;
|
|
|
|
|
2017-01-27 23:41:11 +08:00
|
|
|
this.state = {
|
|
|
|
current: {
|
2017-03-09 22:34:33 +08:00
|
|
|
audio,
|
|
|
|
video,
|
|
|
|
application,
|
|
|
|
cc,
|
|
|
|
participants,
|
2017-01-27 23:41:11 +08:00
|
|
|
},
|
2017-02-25 04:19:53 +08:00
|
|
|
saved: {
|
2017-03-09 22:34:33 +08:00
|
|
|
audio: _.clone(audio),
|
|
|
|
video: _.clone(video),
|
|
|
|
application: _.clone(application),
|
|
|
|
cc: _.clone(cc),
|
|
|
|
participants: _.clone(participants),
|
2017-02-25 04:19:53 +08:00
|
|
|
},
|
|
|
|
selectedTab: 2,
|
2016-05-06 05:14:39 +08:00
|
|
|
};
|
|
|
|
|
2017-02-16 02:49:40 +08:00
|
|
|
this.handleSettingsApply = props.updateSettings;
|
2017-01-27 23:41:11 +08:00
|
|
|
this.handleUpdateSettings = this.handleUpdateSettings.bind(this);
|
2017-02-25 04:19:53 +08:00
|
|
|
this.handleSelectTab = this.handleSelectTab.bind(this);
|
2016-07-12 01:43:42 +08:00
|
|
|
}
|
|
|
|
|
2017-02-25 04:19:53 +08:00
|
|
|
setHtmlFontSize(size) {
|
|
|
|
document.getElementsByTagName('html')[0].style.fontSize = size;
|
|
|
|
};
|
|
|
|
|
2016-09-01 21:56:41 +08:00
|
|
|
render() {
|
2016-05-06 05:14:39 +08:00
|
|
|
return (
|
2016-09-01 21:56:41 +08:00
|
|
|
<Modal
|
|
|
|
title="Settings"
|
|
|
|
confirm={{
|
|
|
|
callback: (() => {
|
2017-02-16 02:49:40 +08:00
|
|
|
this.handleSettingsApply(this.state.current);
|
2016-09-01 21:56:41 +08:00
|
|
|
}),
|
2016-12-14 23:40:13 +08:00
|
|
|
label: 'Save',
|
2016-09-01 21:56:41 +08:00
|
|
|
description: 'Saves the changes and close the settings menu',
|
|
|
|
}}
|
|
|
|
dismiss={{
|
|
|
|
callback: (() => {
|
2017-03-09 22:34:33 +08:00
|
|
|
|
2017-02-25 04:38:16 +08:00
|
|
|
this.setHtmlFontSize(this.state.saved.application.fontSize);
|
2016-09-01 21:56:41 +08:00
|
|
|
}),
|
|
|
|
label: 'Cancel',
|
|
|
|
description: 'Discart the changes and close the settings menu',
|
|
|
|
}}>
|
2017-01-27 23:41:11 +08:00
|
|
|
{this.renderModalContent()}
|
2016-09-01 21:56:41 +08:00
|
|
|
</Modal>
|
2016-05-06 05:14:39 +08:00
|
|
|
);
|
|
|
|
}
|
2016-05-07 01:46:14 +08:00
|
|
|
|
2017-01-27 23:41:11 +08:00
|
|
|
handleUpdateSettings(key, newSettings) {
|
2017-03-09 22:34:33 +08:00
|
|
|
let settings = this.state;
|
2017-01-27 23:41:11 +08:00
|
|
|
settings.current[key] = newSettings;
|
2017-02-25 04:19:53 +08:00
|
|
|
this.setState(settings);
|
2017-01-27 23:41:11 +08:00
|
|
|
}
|
|
|
|
|
2017-02-25 04:19:53 +08:00
|
|
|
handleSelectTab(tab) {
|
2017-01-27 23:41:11 +08:00
|
|
|
this.setState({
|
|
|
|
selectedTab: tab,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
renderModalContent() {
|
2017-02-25 04:19:53 +08:00
|
|
|
const {
|
|
|
|
isModerator,
|
|
|
|
} = this.props;
|
|
|
|
|
2017-01-27 23:41:11 +08:00
|
|
|
return (
|
|
|
|
<Tabs
|
|
|
|
className={styles.tabs}
|
2017-02-25 04:19:53 +08:00
|
|
|
onSelect={this.handleSelectTab}
|
2017-01-27 23:41:11 +08:00
|
|
|
selectedIndex={this.state.selectedTab}
|
|
|
|
>
|
|
|
|
<TabList className={styles.tabList}>
|
2017-03-09 22:34:33 +08:00
|
|
|
<Tab className={styles.tabSelector}>
|
|
|
|
<Icon iconName='application' className={styles.icon}/>
|
|
|
|
Application
|
|
|
|
</Tab>
|
2017-01-27 23:41:11 +08:00
|
|
|
<Tab className={styles.tabSelector}>
|
2017-03-10 00:49:28 +08:00
|
|
|
<Icon iconName='unmute' className={styles.icon}/>
|
2017-01-27 23:41:11 +08:00
|
|
|
<span>Audio</span>
|
|
|
|
</Tab>
|
|
|
|
<Tab className={styles.tabSelector}>
|
|
|
|
<Icon iconName='video' className={styles.icon}/>
|
|
|
|
Video
|
|
|
|
</Tab>
|
|
|
|
<Tab className={styles.tabSelector}>
|
|
|
|
<Icon iconName='user' className={styles.icon}/>
|
|
|
|
Closed Captions
|
|
|
|
</Tab>
|
2017-02-25 04:19:53 +08:00
|
|
|
{ isModerator ?
|
|
|
|
<Tab className={styles.tabSelector}>
|
|
|
|
<Icon iconName='user' className={styles.icon}/>
|
|
|
|
Participants
|
|
|
|
</Tab>
|
|
|
|
: null }
|
2017-01-27 23:41:11 +08:00
|
|
|
</TabList>
|
2017-03-09 22:34:33 +08:00
|
|
|
<TabPanel className={styles.tabPanel}>
|
|
|
|
<Application
|
|
|
|
handleUpdateSettings={this.handleUpdateSettings}
|
|
|
|
settings={this.state.current.application}
|
|
|
|
/>
|
|
|
|
</TabPanel>
|
2017-01-27 23:41:11 +08:00
|
|
|
<TabPanel className={styles.tabPanel}>
|
2017-02-16 02:49:40 +08:00
|
|
|
<Audio
|
|
|
|
settings={this.state.current.audio}
|
|
|
|
handleUpdateSettings={this.handleUpdateSettings}/>
|
2017-01-27 23:41:11 +08:00
|
|
|
</TabPanel>
|
|
|
|
<TabPanel className={styles.tabPanel}>
|
2017-02-16 02:49:40 +08:00
|
|
|
<Video
|
2017-02-22 04:29:36 +08:00
|
|
|
handleUpdateSettings={this.handleUpdateSettings}
|
2017-02-16 02:49:40 +08:00
|
|
|
settings={this.state.current.video}
|
|
|
|
/>
|
2017-01-27 23:41:11 +08:00
|
|
|
</TabPanel>
|
|
|
|
<TabPanel className={styles.tabPanel}>
|
2017-02-16 02:49:40 +08:00
|
|
|
<ClosedCaptions
|
|
|
|
settings={this.state.current.cc}
|
2017-02-22 04:29:36 +08:00
|
|
|
handleUpdateSettings={this.handleUpdateSettings}
|
|
|
|
locales={this.props.locales}/>
|
2017-01-27 23:41:11 +08:00
|
|
|
</TabPanel>
|
2017-02-25 04:19:53 +08:00
|
|
|
{ isModerator ?
|
|
|
|
<TabPanel className={styles.tabPanel}>
|
|
|
|
<Participants
|
|
|
|
settings={this.state.current.participants}
|
|
|
|
handleUpdateSettings={this.handleUpdateSettings}/>
|
|
|
|
</TabPanel>
|
|
|
|
: null }
|
2017-01-27 23:41:11 +08:00
|
|
|
</Tabs>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-16 02:49:40 +08:00
|
|
|
Settings.propTypes = propTypes;
|