keep workspace code and prepare dialog
This commit is contained in:
parent
9ed49f2972
commit
53b4f5dfeb
@ -20,6 +20,7 @@ class BlocklyWindow extends Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const workspace = Blockly.getMainWorkspace();
|
const workspace = Blockly.getMainWorkspace();
|
||||||
|
if (!this.props.readOnly) {
|
||||||
this.props.onChangeWorkspace({});
|
this.props.onChangeWorkspace({});
|
||||||
this.props.clearStats();
|
this.props.clearStats();
|
||||||
workspace.addChangeListener((event) => {
|
workspace.addChangeListener((event) => {
|
||||||
@ -30,6 +31,7 @@ class BlocklyWindow extends Component {
|
|||||||
Blockly.Events.disableOrphans(event);
|
Blockly.Events.disableOrphans(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
Blockly.svgResize(workspace);
|
Blockly.svgResize(workspace);
|
||||||
const zoomToFit = new ZoomToFitControl(workspace);
|
const zoomToFit = new ZoomToFitControl(workspace);
|
||||||
zoomToFit.init();
|
zoomToFit.init();
|
||||||
@ -37,6 +39,7 @@ class BlocklyWindow extends Component {
|
|||||||
|
|
||||||
componentDidUpdate(props) {
|
componentDidUpdate(props) {
|
||||||
const workspace = Blockly.getMainWorkspace();
|
const workspace = Blockly.getMainWorkspace();
|
||||||
|
if (!this.props.readOnly) {
|
||||||
var xml = this.props.initialXml;
|
var xml = this.props.initialXml;
|
||||||
// if svg is true, then the update process is done in the BlocklySvg component
|
// if svg is true, then the update process is done in the BlocklySvg component
|
||||||
if (props.initialXml !== xml && !this.props.svg) {
|
if (props.initialXml !== xml && !this.props.svg) {
|
||||||
@ -53,6 +56,7 @@ class BlocklyWindow extends Component {
|
|||||||
// var toolbox = workspace.getToolbox();
|
// var toolbox = workspace.getToolbox();
|
||||||
// workspace.updateToolbox(toolbox.toolboxDef_);
|
// workspace.updateToolbox(toolbox.toolboxDef_);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Blockly.svgResize(workspace);
|
Blockly.svgResize(workspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class Home extends Component {
|
|||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.props.clearStats();
|
this.props.clearStats();
|
||||||
this.props.workspaceName(null);
|
// this.props.workspaceName(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange = () => {
|
onChange = () => {
|
||||||
@ -112,10 +112,17 @@ class Home extends Component {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
<TrashcanButtons />
|
<TrashcanButtons />
|
||||||
<div className='blocklyWindow'>
|
<div className='blocklyWindow'>
|
||||||
{this.props.project ?
|
{this.props.project ? (
|
||||||
< BlocklyWindow blocklyCSS={{ height: '80vH' }} initialXml={this.props.project.xml} />
|
<BlocklyWindow
|
||||||
: < BlocklyWindow blocklyCSS={{ height: '80vH' }} />
|
blocklyCSS={{ height: "80vH" }}
|
||||||
}
|
initialXml={this.props.project.xml}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<BlocklyWindow
|
||||||
|
blocklyCSS={{ height: "80vH" }}
|
||||||
|
initialXml={this.props.workspaceCode?.xml}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Grid>
|
</Grid>
|
||||||
{this.state.codeOn ?
|
{this.state.codeOn ?
|
||||||
@ -146,7 +153,8 @@ Home.propTypes = {
|
|||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
message: state.message,
|
message: state.message,
|
||||||
statistics: state.general.statistics
|
statistics: state.general.statistics,
|
||||||
|
workspaceCode: state.workspace.code
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ import Divider from "@material-ui/core/Divider";
|
|||||||
import Typography from "@material-ui/core/Typography";
|
import Typography from "@material-ui/core/Typography";
|
||||||
import Backdrop from "@material-ui/core/Backdrop";
|
import Backdrop from "@material-ui/core/Backdrop";
|
||||||
import CircularProgress from "@material-ui/core/CircularProgress";
|
import CircularProgress from "@material-ui/core/CircularProgress";
|
||||||
|
import Dialog from "../Dialog";
|
||||||
|
import Button from "@material-ui/core/Button";
|
||||||
|
|
||||||
const styles = (theme) => ({
|
const styles = (theme) => ({
|
||||||
link: {
|
link: {
|
||||||
@ -36,6 +38,7 @@ class ProjectHome extends Component {
|
|||||||
type: "",
|
type: "",
|
||||||
key: "",
|
key: "",
|
||||||
message: "",
|
message: "",
|
||||||
|
dialog: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -126,10 +129,24 @@ class ProjectHome extends Component {
|
|||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Link
|
<div
|
||||||
to={`/${
|
onClick={() => {
|
||||||
|
console.log(this.props.workspaceCode.arduino);
|
||||||
|
const showDialog =
|
||||||
|
this.props.workspaceCode.arduino !==
|
||||||
|
"void setup() { } void loop() { } ";
|
||||||
|
if (showDialog)
|
||||||
|
this.setState({
|
||||||
|
dialog: true,
|
||||||
|
});
|
||||||
|
else {
|
||||||
|
this.props.history.push(
|
||||||
|
`/${
|
||||||
data === "Projekte" ? "project" : "gallery"
|
data === "Projekte" ? "project" : "gallery"
|
||||||
}/${project._id}`}
|
}/${project._id}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}}
|
||||||
style={{ textDecoration: "none", color: "inherit" }}
|
style={{ textDecoration: "none", color: "inherit" }}
|
||||||
>
|
>
|
||||||
<h3 style={{ marginTop: 0 }}>{project.title}</h3>
|
<h3 style={{ marginTop: 0 }}>{project.title}</h3>
|
||||||
@ -139,6 +156,7 @@ class ProjectHome extends Component {
|
|||||||
<BlocklyWindow
|
<BlocklyWindow
|
||||||
svg
|
svg
|
||||||
blockDisabled
|
blockDisabled
|
||||||
|
readOnly
|
||||||
initialXml={project.xml}
|
initialXml={project.xml}
|
||||||
/>
|
/>
|
||||||
<Typography
|
<Typography
|
||||||
@ -151,7 +169,7 @@ class ProjectHome extends Component {
|
|||||||
>
|
>
|
||||||
{project.description}
|
{project.description}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Link>
|
</div>
|
||||||
{this.props.user &&
|
{this.props.user &&
|
||||||
this.props.user.email === project.creator ? (
|
this.props.user.email === project.creator ? (
|
||||||
<div>
|
<div>
|
||||||
@ -206,6 +224,27 @@ class ProjectHome extends Component {
|
|||||||
type={this.state.type}
|
type={this.state.type}
|
||||||
key={this.state.key}
|
key={this.state.key}
|
||||||
/>
|
/>
|
||||||
|
<Dialog
|
||||||
|
open={this.state.dialog}
|
||||||
|
title="Achtung"
|
||||||
|
actions={
|
||||||
|
<React.Fragment>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
this.setState({ dialog: false });
|
||||||
|
}}
|
||||||
|
color="secondary"
|
||||||
|
>
|
||||||
|
Schließen
|
||||||
|
</Button>
|
||||||
|
<Button onClick={() => {}} color="primary">
|
||||||
|
Speichern
|
||||||
|
</Button>
|
||||||
|
</React.Fragment>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Hello World
|
||||||
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -226,6 +265,7 @@ const mapStateToProps = (state) => ({
|
|||||||
progress: state.project.progress,
|
progress: state.project.progress,
|
||||||
user: state.auth.user,
|
user: state.auth.user,
|
||||||
message: state.message,
|
message: state.message,
|
||||||
|
workspaceCode: state.workspace.code,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps, {
|
export default connect(mapStateToProps, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user