import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import MaxBlocks from './MaxBlocks'; import Button from '@material-ui/core/Button'; import DialogTitle from '@material-ui/core/DialogTitle'; import DialogContent from '@material-ui/core/DialogContent'; import DialogActions from '@material-ui/core/DialogActions'; import Dialog from '@material-ui/core/Dialog'; class WorkspaceFunc extends Component { state = { title: '', content: '', open: false } getArduinoCode = () => { this.setState({ title: 'Adurino Code', content: this.props.arduino, open: true }); } getXMLCode = () => { this.setState({ title: 'XML Code', content: this.props.xml, open: true }); } toggleDialog = () => { this.setState({ open: !this.state }); } compile = () => { const data = { "board": process.env.REACT_APP_BOARD, "sketch": this.props.arduino }; fetch(`${process.env.REACT_APP_COMPILER_URL}/compile`, { method: "POST", headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log(data) this.download(data.data.id) }); } download = (id) => { const filename = 'sketch' window.open(`${process.env.REACT_APP_COMPILER_URL}/download?id=${id}&board=${process.env.REACT_APP_BOARD}&filename=${filename}`, '_self'); } render() { return (