Skip to content

Commit 68596b4

Browse files
authored
Merge branch 'main' into support_action_cost
2 parents 7eac36c + c8fb79f commit 68596b4

File tree

3 files changed

+144
-92
lines changed

3 files changed

+144
-92
lines changed

src/pages/PageFour/screenComponents.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export default function Screen({ canvasWidth, canvasHeight, sprites, vfg }) {
6161
const spriteHeight = (sprite.maxY - sprite.minY) * canvasHeight;
6262
const centerY = y + spriteHeight / 2;
6363

64-
6564
// Draw the sprite with a text
6665
return (
6766
<React.Fragment key={i}>
@@ -275,6 +274,7 @@ export function GoalScreen({
275274
visualStage
276275
}) {
277276

277+
278278
return (
279279
<React.Fragment>
280280
<div className={styles.sub_title} style={{position: "relative"}}>

src/pages/PageOne/dropAndFetch.jsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,32 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
3838

3939
const uploadPDDL = async (files) => {
4040
const formData = new FormData();
41+
4142
for (const name in files) {
4243
formData.append(name, files[name]);
4344
}
4445

46+
4547
try {
4648
setLoading(true);
4749
const resp = await fetch(
4850
"https://planimation.planning.domains/upload/pddl",
51+
//"http://127.0.0.1:8000/upload/pddl",
4952
{
50-
//"http://127.0.0.1:8000/upload/pddl" On local server
53+
// "http://127.0.0.1:8000/upload/pddl" On local server
5154
method: "POST", //DO NOT use headers
5255
body: formData, // Dataformat
5356
}
5457
);
5558
const data = await resp.json();
59+
if(data.status==='error'){
60+
throw new Error(data.message)
61+
}
62+
5663
const txt = JSON.stringify(data);
5764
onStore(txt);
5865
} catch (error) {
59-
60-
setAlert(error);
66+
setAlert(error.message);
6167
} finally {
6268
setLoading(false);
6369
}
@@ -69,17 +75,18 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
6975

7076
const handleSubmit = () => {
7177
//Control check for files
72-
if (newURL.lenght > 1) {
78+
if (newURL.length > 1) {
7379
handleFileLoad("url", newURL);
7480
}
81+
7582
if (
7683
"domain" in dataFiles &&
7784
"problem" in dataFiles &&
78-
"animation" in dataFiles
85+
"animation" in dataFiles &&
86+
"url" in dataFiles
7987
) {
8088
uploadPDDL(dataFiles);
8189
} else {
82-
8390
setAlert("Some files are missing");
8491
}
8592
};
@@ -131,7 +138,7 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
131138
<Alert
132139
open={showAlert.length > 1 ? true : false}
133140
reset={handleResetAlert}
134-
severity="warning"
141+
severity="error"
135142
>
136143
{showAlert}
137144
</Alert>

src/pages/PageOne/index.js

Lines changed: 129 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -5,100 +5,145 @@ import TextField from '@material-ui/core/TextField';
55
import Button from '@material-ui/core/Button';
66
import Alert from '../../components/alertInFormat';
77
import css from '../../Styles/index.module.less';
8+
import {InputLabel} from "@material-ui/core";
9+
import Select from "@mui/material/Select";
10+
import MenuItem from "@mui/material/MenuItem";
811

9-
12+
const options = [
13+
{
14+
value: 'https://solver.planning.domains:5001/package/dual-bfws-ffparser/solve',
15+
label: 'BFWS--FF-parser version'
16+
},
17+
// {
18+
// value: 'https://solver.planning.domains:5001/package/delfi/solve',
19+
// label: 'Delfi:online planner selection for cost-optimal planning'
20+
// },
21+
// {
22+
// value: 'https://solver.planning.domains:5001/package/enhsp-2020/solve',
23+
// label: 'ENHSP -- 2020 version'
24+
// },
25+
{
26+
value: 'https://solver.planning.domains:5001/package/lama-first/solve',
27+
label: 'LAMA-first: satisficing planner without solution improvement'
28+
},
29+
// {
30+
// value: 'https://solver.planning.domains:5001/package/optic/solve',
31+
// label: 'OPTIC: Optimising Preferences and Time-Dependent Cost'
32+
// },
33+
// {
34+
// value: 'https://solver.planning.domains:5001/package/tfd/solve',
35+
// label: 'Temporal Fast Downward planning system'
36+
// }
37+
]
1038
class PageOne extends React.Component {
11-
constructor(props) {
12-
super(props);
13-
this.state = {url:'',fineUrl:'',alertURL:false, alertMessage: ''};
14-
this.handleOnClick = this.handleOnClick.bind(this);
15-
this.handleSendURL = this.handleSendURL.bind(this);
16-
}
39+
constructor(props) {
40+
super(props);
41+
this.state = {url:'https://solver.planning.domains:5001/package/dual-bfws-ffparser/solve',
42+
fineUrl:'',
43+
alertURL:false,
44+
alertMessage: ''};
45+
this.handleOnClick = this.handleOnClick.bind(this);
46+
this.handleSendURL = this.handleSendURL.bind(this);
47+
}
1748

18-
handleOnClick = () => {
19-
this.props.history.push('/')
20-
}
49+
handleOnClick = () => {
50+
this.props.history.push('/')
51+
}
2152

22-
handleStore = (content)=> {
23-
localStorage.setItem('fileContent', content);
24-
window.location.href = '/demo';
25-
}
53+
handleStore = (content)=> {
54+
localStorage.setItem('fileContent', content);
55+
window.location.href = '/demo';
56+
}
2657

27-
handleNewURL = (urlString) => {
28-
const url = {...this.state};
29-
url['url'] = urlString;
30-
this.setState(url);
31-
}
58+
handleNewURL = (urlString) => {
59+
const url = {...this.state};
60+
url['url'] = urlString;
61+
this.setState(url);
62+
}
3263

33-
handleSendURL = () => {
34-
const state = {...this.state};
35-
const url = state.url;
36-
const pattern = /^((http|https):\/\/)?(([A-Za-z0-9]+-[A-Za-z0-9]+|[A-Za-z0-9]+)\.)+([A-Za-z]+)[/\?\:]?.*$/;
64+
handleSendURL = () => {
65+
const state = {...this.state};
66+
const url = state.url;
67+
const pattern = /^((http|https):\/\/)?(([A-Za-z0-9]+-[A-Za-z0-9]+|[A-Za-z0-9]+)\.)+([A-Za-z]+)[/\?\:]?.*$/;
3768

38-
if (!!pattern.test(url)){
39-
state['fineUrl'] = url;
40-
this.setState(state);
41-
} else {
42-
this.handleAlert('The URL is not valid');
43-
}
69+
if (!!pattern.test(url)){
70+
state['fineUrl'] = url;
71+
this.setState(state);
72+
} else {
73+
this.handleAlert('The URL is not valid');
4474
}
75+
}
4576

46-
handleAlert = (message) => {
47-
const state = {...this.state};
48-
state.alertURL = true;
49-
state.alertMessage = message;
50-
this.setState(state);
51-
}
77+
handleAlert = (message) => {
78+
const state = {...this.state};
79+
state.alertURL = true;
80+
state.alertMessage = message;
81+
this.setState(state);
82+
}
5283

53-
handleResetAlert = () => {
54-
const state = {...this.state};
55-
state.alertURL = false;
56-
this.setState(state)
57-
}
84+
handleResetAlert = () => {
85+
const state = {...this.state};
86+
state.alertURL = false;
87+
this.setState(state)
88+
}
5889

59-
render() {
60-
const useStyles = makeStyles((theme) => ({
61-
root: {
62-
'& > *': {
63-
margin: theme.spacing(1),
64-
width: '25ch',
65-
},
66-
},
67-
}));
90+
render() {
91+
const useStyles = makeStyles((theme) => ({
92+
root: {
93+
'& > *': {
94+
margin: theme.spacing(1),
95+
width: '25ch',
96+
},
97+
},
98+
}));
6899

69-
return (
70-
<div className={css.container}>
71-
<div className={css.header}>
72-
<h3 className={css.subtitle}>Build Visualisation From Problem</h3>
73-
</div>
74-
<div>
75-
<h3 className={css.text}>
76-
Step 1 - Change planner URL (Optional)
77-
</h3>
78-
</div>
79-
<form className={useStyles.root} noValidate autoComplete="off">
80-
<div className={css.text}>
81-
<TextField onChange={ e => this.handleNewURL(e.target.value)} id="outlined-basic" label="URL" size='small' variant="outlined" style={{float: 'left', width: '90%', marginLeft: '10%'}}/>
82-
</div>
83-
<div style={{float: 'left', marginLeft: '1%', alignItems: 'center'}}>
84-
<Button onClick={this.handleSendURL} variant="contained" color="primary" size="medium">
85-
Paste
86-
</Button>
87-
</div>
88-
</form>
89-
<div>
90-
<h3 className={css.text}>
91-
Step 2 - Upload Problem, Domain and Animation Profile Files
92-
</h3>
93-
</div>
94-
<DropAndFetch onClick={this.handleOnClick} onStore={this.handleStore} newURL={this.state.fineUrl}/>
95-
<Alert open={this.state.alertURL} reset={this.handleResetAlert} severity="warning">
96-
{this.state.alertMessage}
97-
</Alert>
98-
</div>
99-
);
100-
}
101-
100+
return (
101+
<div className={css.container}>
102+
<div className={css.header}>
103+
<h3 className={css.subtitle}>Build Visualisation From Problem</h3>
104+
</div>
105+
<div>
106+
<h3 className={css.text}>
107+
Step 1 - Select planner URL
108+
</h3>
109+
</div>
110+
<form className={useStyles.root} noValidate autoComplete="off">
111+
<div className={css.text}>
112+
<Select
113+
value={this.state.url}
114+
id="outlined-basic"
115+
labelId="outlined-basic"
116+
size='small'
117+
label="Solver"
118+
onChange={ e => this.handleNewURL(e.target.value)}
119+
style={{float: 'left', width: '90%', marginLeft: '10%'}}
120+
>
121+
122+
{options.map(
123+
(item,index)=>
124+
<MenuItem value={item.value} key={index}>{item.label}</MenuItem>)
125+
}
126+
</Select>
127+
</div>
128+
<div style={{float: 'left', marginLeft: '1%', alignItems: 'center'}}>
129+
<Button onClick={this.handleSendURL} variant="contained" color="primary" size="medium">
130+
Paste
131+
</Button>
132+
</div>
133+
</form>
134+
<div>
135+
<h3 className={css.text}>
136+
Step 2 - Upload Problem, Domain and Animation Profile Files
137+
</h3>
138+
</div>
139+
<DropAndFetch onClick={this.handleOnClick} onStore={this.handleStore} newURL={this.state.url}/>
140+
<Alert open={this.state.alertURL} reset={this.handleResetAlert} severity="warning">
141+
{this.state.alertMessage}
142+
</Alert>
143+
</div>
144+
);
102145
}
103-
104-
export default PageOne;
146+
147+
}
148+
149+
export default PageOne;

0 commit comments

Comments
 (0)