<commit_before>/** ={this.state.in}
 *
 * GeometryCanvasWithOptions
 *
 */

import { compose } from 'recompose';
import React from 'react';
import PropTypes, { instanceOf } from 'prop-types';
import { withCookies, Cookies } from 'react-cookie';
import FileDownload from 'react-file-download';
import _ from 'lodash';

import { withStyles } from 'material-ui/styles';
import Modal from 'material-ui/Modal';
import Grid from 'material-ui/Grid';
import Button from 'material-ui/Button';
import IconButton from 'material-ui/IconButton';
import Dialog, { DialogTitle } from 'material-ui/Dialog';
import List, { ListItem, ListItemText } from 'material-ui/List';
import { MdFullscreen, MdFileDownload, MdBookmarkOutline } from 'react-icons/lib/md';

import axios from 'axios';
import { flaskRoot } from 'utils/constants';
import GeometryCanvasCifdata from 'components/GeometryCanvasCifdata';


const outputFormats = ['abinit', 'castep-cell', 'cfg', 'cif', 'dlp4', 'eon', 'espresso-in', 'extxyz', 'findsym',
  'gen', 'gromos', 'json', 'jsv', 'nwchem', 'proteindatabank', 'py', 'turbomole', 'v-sim', 'vasp', 'xsf', 'xyz'];


const styles = (theme) => ({
  avatar: {
    fontColor: '#000000',
    fontSize: 18,
    backgroundColor: '#ffffff',
    marginLeft: -14,
    marginRight: -14,
    marginTop: -5,
    textTranformation: 'none',
    [theme.breakpoints.down('sm')]: {
      fontSize: 12,
    },
  },
  button: {
    margin: theme.spacing.unit,
  },
  iconButton: {
    fontColor: '#000000',
    backgroundColor: '#ffffff',
    [theme.breakpoints.down('sm')]: {
      fontSize: 12,
      height: 15,
      width: 15,
    },
    [theme.breakpoints.down('xs')]: {
      fontSize: 12,
      height: 10,
      width: 10,
    },
  },
  iconButtonIcon: {
    fontColor: '#000000',
    backgroundColor: '#ffffff',
    marginTop: 7,
  },
});

const initialState = {
  open: false,
  height: Math.max(Math.min(window.innerWidth * 0.5, 600), 300),
  width: Math.max(Math.min(window.innerWidth * 0.5, 600), 300),
  color: '#fff',
  x: 2,
  y: 2,
  z: 1,
  borderWidth: 0,
  altLabels: {},
  perspective: true,
  tiltToRotate: true,
  in: false,
  downloadOpen: false,
};

class GeometryCanvasWithOptions extends React.Component { // eslint-disable-line react/prefer-stateless-function
  constructor(props) {
    super(props);
    this.state = initialState;
    this.handleDownloadOpen = this.handleDownloadOpen.bind(this);
    this.handleDownload = this.handleDownload.bind(this);
    this.handleDownloadClose = this.handleDownloadClose.bind(this);
  }
  componentWillReceiveProps() {
    this.setState({ in: false });
    setTimeout(() => {
      this.setState({ in: true });
    }, 10);
  }

  handleOpen() {
    this.setState({ open: true });
  }

  handleClose() {
    this.setState({ open: false });
  }

  handleDownloadOpen() {
    this.setState({
      downloadOpen: true,
    });
  }

  handleDownloadClose() {
    this.setState({
      downloadOpen: false,
    });
  }

  handleDownload(format) {
    this.setState({
      downloadOpen: false,
    });
    const url = `${flaskRoot}/apps/catKitDemo/convert_atoms/`;
    const params = { params: {
      format,
      cif: this.props.cifdata,
    } };
    axios.get(url, params).then((response) => {
      FileDownload(response.data.image, !_.isEmpty(this.props.extraSlug) ? `${this.props.extraSlug}_${response.data.filename}` : response.data.filename);
    });
    this.props.cookies.set('preferredFormat', format);
  }

  handleChange(axis, diff) {
    return () => {
      this.setState({
        [axis]: Math.max(1, this.state[axis] + diff),
      });
    };
  }

  render() {
    return (
      <div>
        <Modal
          aria-labelledby="simple-modal-title"
          aria-describedby="simple-modal-description"<commit_msg>Send cif string as post before downloading<commit_after>/** ={this.state.in}
 *
 * GeometryCanvasWithOptions
 *
 */

import { compose } from 'recompose';
import React from 'react';
import PropTypes, { instanceOf } from 'prop-types';
import { withCookies, Cookies } from 'react-cookie';
import FileDownload from 'react-file-download';
import _ from 'lodash';

import { withStyles } from 'material-ui/styles';
import Modal from 'material-ui/Modal';
import Grid from 'material-ui/Grid';
import Button from 'material-ui/Button';
import IconButton from 'material-ui/IconButton';
import Dialog, { DialogTitle } from 'material-ui/Dialog';
import List, { ListItem, ListItemText } from 'material-ui/List';
import { MdFullscreen, MdFileDownload, MdBookmarkOutline } from 'react-icons/lib/md';

import axios from 'axios';
import { flaskRoot } from 'utils/constants';
import GeometryCanvasCifdata from 'components/GeometryCanvasCifdata';


const outputFormats = ['abinit', 'castep-cell', 'cfg', 'cif', 'dlp4', 'eon', 'espresso-in', 'extxyz', 'findsym',
  'gen', 'gromos', 'json', 'jsv', 'nwchem', 'proteindatabank', 'py', 'turbomole', 'v-sim', 'vasp', 'xsf', 'xyz'];


const styles = (theme) => ({
  avatar: {
    fontColor: '#000000',
    fontSize: 18,
    backgroundColor: '#ffffff',
    marginLeft: -14,
    marginRight: -14,
    marginTop: -5,
    textTranformation: 'none',
    [theme.breakpoints.down('sm')]: {
      fontSize: 12,
    },
  },
  button: {
    margin: theme.spacing.unit,
  },
  iconButton: {
    fontColor: '#000000',
    backgroundColor: '#ffffff',
    [theme.breakpoints.down('sm')]: {
      fontSize: 12,
      height: 15,
      width: 15,
    },
    [theme.breakpoints.down('xs')]: {
      fontSize: 12,
      height: 10,
      width: 10,
    },
  },
  iconButtonIcon: {
    fontColor: '#000000',
    backgroundColor: '#ffffff',
    marginTop: 7,
  },
});

const initialState = {
  open: false,
  height: Math.max(Math.min(window.innerWidth * 0.5, 600), 300),
  width: Math.max(Math.min(window.innerWidth * 0.5, 600), 300),
  color: '#fff',
  x: 2,
  y: 2,
  z: 1,
  borderWidth: 0,
  altLabels: {},
  perspective: true,
  tiltToRotate: true,
  in: false,
  downloadOpen: false,
};

class GeometryCanvasWithOptions extends React.Component { // eslint-disable-line react/prefer-stateless-function
  constructor(props) {
    super(props);
    this.state = initialState;
    this.handleDownloadOpen = this.handleDownloadOpen.bind(this);
    this.handleDownload = this.handleDownload.bind(this);
    this.handleDownloadClose = this.handleDownloadClose.bind(this);
  }
  componentWillReceiveProps() {
    this.setState({ in: false });
    setTimeout(() => {
      this.setState({ in: true });
    }, 10);
  }

  handleOpen() {
    this.setState({ open: true });
  }

  handleClose() {
    this.setState({ open: false });
  }

  handleDownloadOpen() {
    this.setState({
      downloadOpen: true,
    });
  }

  handleDownloadClose() {
    this.setState({
      downloadOpen: false,
    });
  }

  handleDownload(format) {
    this.setState({
      downloadOpen: false,
    });
    const url = `${flaskRoot}/apps/catKitDemo/convert_atoms/`;
    const params = { params: {
      format,
      cif: this.props.cifdata,
    } };
    axios.post(url, params, { headers: {
      'Content-Type': 'application/json',
      'Access-Control-Allow-Origin': '*' },
    }).then((response) => {
      FileDownload(response.data.image, !_.isEmpty(this.props.extraSlug) ? `${this.props.extraSlug}_${response.data.filename}` : response.data.filename);
    });
    this.props.cookies.set('preferredFormat', format);
  }

  handleChange(axis, diff) {
    return () => {
      this.setState({
        [axis]: Math.max(1, this.state[axis] + diff),
      });
    };
  }

  render() {
    return (
      <div>
        <Modal
          aria-labelledby="simple-modal-title"
          aria-describedby="simple-modal-description"
{'fraction_non_alphanumeric': 0.16315378610460576, 'fraction_numerical': 0.016653655997918293, 'mean_word_length': 3.3161145423919147, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 35, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1555637', 'n_tokens_mistral': 2693, 'n_tokens_neox': 2546, 'n_words': 528}