Skip to content

Commit 38ddbdd

Browse files
authored
Merge branch 'develop' into feat_visualization
2 parents 5d0961c + 053b2fa commit 38ddbdd

File tree

13 files changed

+124
-439
lines changed

13 files changed

+124
-439
lines changed

src/components/navigationBar/navigationBar.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function NavigationBar() {
5050
}
5151

5252
return(
53-
<AppBar position="static" backgroundColor="#224878" elevation={0} className={classes.appBar}>
53+
<AppBar position="static" elevation={0} className={classes.appBar}>
5454
<Toolbar className={classes.toolbar}>
5555
<Typography variant="h6" color="inherit" align="left" noWrap className={classes.toolbarTitle}>
5656
Planimation
@@ -65,9 +65,9 @@ function NavigationBar() {
6565
<Link variant="button" color="inherit" onClick={()=>handleClick('manual')} className={classes.link}>
6666
User Manual
6767
</Link>
68-
{/*<Link variant="button" color="inherit" onClick={()=>handleClick('demo')} className={classes.link}>*/}
69-
{/* Demo*/}
70-
{/*</Link>*/}
68+
<Link variant="button" color="inherit" onClick={()=>handleClick('demo')} className={classes.link}>
69+
Demo
70+
</Link>
7171
</nav>
7272
<Button color="inherit" variant="outlined"onClick={()=>handleClick('home')} className={classes.link} >
7373
HomePage

src/pages/HomePage/home.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ const tiers = [
104104
buttonText: 'Contact us',
105105
buttonVariant: 'outlined',
106106
},
107-
// {
108-
// title: 'Demo',
109-
// pageNo: 4,
110-
// description: ['Demo File for visualisation',""],
111-
// buttonText: 'Sign up for free',
112-
// buttonVariant: 'outlined',
113-
// },
107+
{
108+
title: 'Demo',
109+
pageNo: 4,
110+
description: ['Demo File for visualisation',""],
111+
buttonText: 'Sign up for free',
112+
buttonVariant: 'outlined',
113+
},
114114
];
115115
// const footers = [
116116
// {
@@ -157,10 +157,10 @@ export default function Home() {
157157
</Container>
158158
{/* End hero unit */}
159159
<Container maxWidth="md" component="main">
160-
<Grid container spacing={4} alignItems="stretch" direction="row">
160+
<Grid container spacing={3} alignItems="stretch" direction="row">
161161
{tiers.map((tier) => (
162162
// Enterprise card is full width at sm breakpoint
163-
<Grid item key={tier.title} xs={4} sm={tier.title === 'Enterprise' ? 12 : 4} md={4}>
163+
<Grid item key={tier.title} xs={3} sm={tier.title === 'Enterprise' ? 12 : 3} md={3}>
164164
<Card>
165165
<CardHeader
166166
title={tier.title}

src/pages/PageFour/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ class PageFour extends React.Component {
375375
<div className={styles.sub_title}> Steps </div>
376376
<div className={styles.left_upper}>
377377
{
378-
steps.map((step, i) => {
378+
steps && steps.map((step, i) => {
379379
return <div className={styles.stage_item}
380380
style={{backgroundColor: i === this.state.stepInfoIndex ? '#eef': 'white'}}
381381
onClick={()=>{this.handleSwitchStage(i);}}

src/pages/PageOne/dragAndDrop.jsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/pages/PageOne/dropAndFetch.jsx

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,52 @@ import Container from "@material-ui/core/Container";
55
import CloudUploadIcon from "@material-ui/icons/CloudUpload";
66
import css from "./index.module.less";
77

8+
const dragsAndDrops = [
9+
{ name: "Domain", fileType: ".pddl", desc: "or predictes and actions." },
10+
{
11+
name: "Problem",
12+
fileType: ".pddl",
13+
desc: "for objects, initial state and goal.",
14+
},
15+
{
16+
name: "Animation",
17+
fileType: ".pddl",
18+
desc: "object is representation.",
19+
},
20+
];
821
class DropAndFetch extends React.Component {
922
constructor(props) {
1023
super(props);
1124
this.datas = {};
1225
}
1326

14-
state = {
15-
dragsAndDrops: [
16-
{ name: "Domain", fileType: ".pddl", desc: "or predictes and actions." },
17-
{
18-
name: "Problem",
19-
fileType: ".pddl",
20-
desc: "for objects, initial state and goal.",
21-
},
22-
{
23-
name: "Animation",
24-
fileType: ".pddl",
25-
desc: "object is representation.",
26-
},
27-
],
27+
componentWillUnmount = () => {
28+
this.setState = (state, callback) => {
29+
return;
30+
};
2831
};
2932

30-
uploadPDDL = (files) => {
33+
uploadPDDL = async (files) => {
3134
const formData = new FormData();
3235
for (const name in files) {
3336
formData.append(name, files[name]);
3437
}
35-
let resp;
38+
try {
39+
const resp = await fetch(
40+
"https://planimation.planning.domains/upload/pddl",
41+
{
42+
//"http://127.0.0.1:8000/upload/pddl" On local server
43+
method: "POST", //DO NOT use headers
44+
body: formData, // Dataformat
45+
}
46+
);
3647

37-
fetch("https://planimation.planning.domains/upload/pddl", {
38-
//"http://127.0.0.1:8000/upload/pddl", {
39-
method: "POST", //DO NOT use headers
40-
body: formData, // Dataformat
41-
})
42-
.then(
43-
(response) => console.log(response) //read response code and replicate
44-
)
45-
.then(
46-
(success) => (resp = success) //success contains the VFG
47-
)
48-
.catch((error) => console.log(error));
49-
return resp;
48+
const data = await resp.json();
49+
const txt = JSON.stringify(data);
50+
this.props.onStore(txt);
51+
} catch (error) {
52+
alert(error);
53+
}
5054
};
5155

5256
handleSubmit = () => {
@@ -56,24 +60,24 @@ class DropAndFetch extends React.Component {
5660
"problem" in this.datas &&
5761
"animation" in this.datas
5862
) {
59-
let resp = this.uploadPDDL(this.datas);
60-
console.log(resp);
63+
this.uploadPDDL(this.datas);
6164
} else {
6265
console.log("Some files are missing");
6366
alert("Some files are missing");
6467
}
6568
};
6669

6770
handleFileLoad = (name, file) => {
68-
this.datas[name] = file;
71+
this.datas[name.toLowerCase()] = file;
72+
console.log(this.datas);
6973
};
7074

7175
render() {
7276
return (
7377
<React.Fragment>
7478
<div>
7579
<Container component="main" className={css.dropareaBox}>
76-
{this.state.dragsAndDrops.map((drag) => (
80+
{dragsAndDrops.map((drag) => (
7781
<DropZone
7882
key={drag.name}
7983
name={drag.name}
@@ -83,11 +87,11 @@ class DropAndFetch extends React.Component {
8387
/>
8488
))}
8589
</Container>
86-
<Container maxWidth="sm" component="main" marginTop="50">
90+
<Container maxWidth="sm" component="main">
8791
<div className={css.buttonBox}>
8892
<Button
8993
variant="contained"
90-
color="#224878"
94+
color="default"
9195
onClick={() => this.props.onClick()}
9296
>
9397
Cancel

src/pages/PageOne/dropZone.jsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ class DropZone extends React.Component {
1515
console.log(file);
1616

1717
if (file[0].name.endsWith(this.props.fileType)) {
18-
console.log(this.state.files);
18+
//console.log(this.state.files);
1919
this.setState({ files: file });
20-
console.log(this.state.files);
21-
this.props.onFileLoad(this.props.name, file[0]);
20+
//console.log(this.state.files);
21+
file[0].text().then((result) => {
22+
this.props.onFileLoad(this.props.name, result);
23+
});
2224
} else {
2325
console.log("Wrong file type");
2426
alert("Wrong file type");
@@ -30,8 +32,8 @@ class DropZone extends React.Component {
3032
this.state.files.length > 0
3133
? this.state.files[0].name
3234
: "Drag and drop " +
33-
this.props.name.toLowerCase() +
34-
this.props.fileType +
35+
this.props?.name?.toLowerCase() +
36+
this.props?.fileType?? '--' +
3537
" here or click";
3638

3739
return (
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import DragAndDrop from './dragAndDrop';
3+
import DropZone from './dropZone';
44

55

66
it("Renders Correctly ", () => {
77
const div = document.createElement("div");
8-
ReactDOM.render(<DragAndDrop
8+
ReactDOM.render(<DropZone
99
/>, div);
1010
ReactDOM.unmountComponentAtNode(div);
1111
});

src/pages/PageOne/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ class PageOne extends React.Component {
5353
handleOnClick() {
5454
this.props.history.push('/')
5555
}
56+
handleStore = (content)=> {
57+
localStorage.setItem('fileContent', content);
58+
window.location.href = '/page4';
59+
}
5660

5761
render() {
5862

@@ -91,7 +95,7 @@ class PageOne extends React.Component {
9195
Option 2 - Upload Problem Domain and Animation Profile Files
9296
</h3>
9397
</div>
94-
<DropAndFetch onClick={this.handleOnClick}/>
98+
<DropAndFetch onClick={this.handleOnClick} onStore={this.handleStore}/>
9599
</div>
96100

97101
);
Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,23 @@
1-
.buttonBox {
1+
.dropzoneBox {
22
/*
33
background: #fff;
44
*/
5-
display: flex;
5+
display: inline-block;
66
justify-content: space-around;
7+
width: 30%;
78
padding: 20px;
89
}
910

10-
.textBox {
11-
/*
12-
background: #fff;
13-
*/
14-
display: flex;
15-
justify-content: space-around;
11+
.buttonBox {
1612
padding: 20px;
17-
}
18-
19-
.dropzoneBox {
20-
/*
21-
background: #fff;
22-
*/
23-
display: inline-block;
13+
display: flex;
2414
justify-content: space-around;
25-
width: 30%;
26-
padding: 20px;
2715
}
2816

2917
.dropareaBox {
3018
/*
31-
background: #fff;
32-
*/
19+
background: #fff;
20+
*/
3321
display: flex;
3422
justify-content: space-around;
35-
width: 80%;
36-
}
23+
}

0 commit comments

Comments
 (0)