import React, { Component } from 'react'; import { Button } from '../ui/button'; import Mousetrap from 'mousetrap'; import ViewerComponent from '../ViewerComponent'; import SignalQualityIndicatorComponent from '../SignalQualityIndicatorComponent'; import PreviewExperimentComponent from '../PreviewExperimentComponent'; import PreviewButton from '../PreviewButtonComponent'; import { HelpSidebar, HelpButton } from './HelpSidebar'; import { getExperimentFromType } from '../../utils/labjs/functions'; import { ExperimentActions, DeviceActions } from '../../actions'; import { DEVICES, DEVICE_AVAILABILITY, EXPERIMENTS, PLOTTING_INTERVAL, CONNECTION_STATUS, } from '../../constants/constants'; import { ExperimentParameters, Device, SignalQualityData, } from '../../constants/interfaces'; import { Observable } from 'rxjs'; interface Props { ExperimentActions: typeof ExperimentActions; connectedDevice: Record; signalQualityObservable: Observable | null | undefined; deviceType: DEVICES; deviceAvailability: DEVICE_AVAILABILITY; connectionStatus: CONNECTION_STATUS; DeviceActions: typeof DeviceActions; availableDevices: Array; type: EXPERIMENTS; isRunning: boolean; params: ExperimentParameters; subject: string; group: string; session: number; title: string; openRunComponent: () => void; } interface State { isPreviewing: boolean; isSidebarVisible: boolean; } export default class PreTestComponent extends Component { constructor(props: Props) { super(props); this.state = { isPreviewing: false, isSidebarVisible: true, }; this.handlePreview = this.handlePreview.bind(this); this.handleSidebarToggle = this.handleSidebarToggle.bind(this); this.endPreview = this.endPreview.bind(this); } componentDidMount() { Mousetrap.bind('esc', this.props.ExperimentActions.Stop); } componentWillUnmount() { Mousetrap.unbind('esc'); } endPreview() { this.setState({ isPreviewing: false }); } handlePreview(e) { e.target.blur(); this.setState((prevState) => ({ ...prevState, isSidebarVisible: false, isPreviewing: !prevState.isPreviewing, })); } handleSidebarToggle() { this.setState((prevState) => ({ ...prevState, isSidebarVisible: !prevState.isSidebarVisible, })); } renderSignalQualityOrPreview() { if (this.state.isPreviewing) { return ( ); } return (
  • Strong Signal
  • Mediocre signal
  • Weak Signal
  • No Signal
); } renderHelpButton() { if (!this.state.isSidebarVisible) { return ; } } render() { return (
{this.state.isSidebarVisible && (
)}

Collect

this.handlePreview(e)} />
{this.renderSignalQualityOrPreview()}
{this.renderHelpButton()}
); } }