Skip to content

Commit c1d6bf2

Browse files
committed
Organise styles, create alert MIU style, add E2E testing, fix conflicts
2 parents b35a01a + 6574056 commit c1d6bf2

File tree

10 files changed

+120
-22
lines changed

10 files changed

+120
-22
lines changed

src/App.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@ const theme = createTheme({
2323

2424
function App() {
2525
return (
26+
<div className={styles.root}>
2627
<div className={styles.App}>
2728
<ThemeProvider theme={theme}>
2829
<NavigationBar />
2930
<Switch>
3031
<Route path="/" component={HomePage} exact />
31-
<Route path="/page1" component={PageOne} />
32-
<Route path="/page2" component={PageTwo} />
32+
<Route path="/problem" component={PageOne} />
33+
<Route path="/vfg" component={PageTwo} />
3334
<Route path="/page3" component={PageThree} />
34-
<Route path="/page4" component={PageFour} />
35+
<Route path="/demo" component={PageFour} />
3536
</Switch>
3637
</ThemeProvider>
3738
{/* <div>this is app</div> */}
3839
</div>
40+
</div>
3941
);
4042
}
4143

src/App.module.less

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
.root{
2+
position: absolute;
3+
top: 0;
4+
left: 0;
5+
right: 0;
6+
bottom: 0;
7+
background-color: #ffffff;
8+
9+
}
110
.App {
211
text-align: center;
312
display: flex;
413
flex-direction: column;
514
align-items: center;
615
justify-content: center;
16+
717
}
818

src/Styles/index.module.less

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,22 @@ background: #fff;
5151
margin-top: 2%;
5252
margin-left: 25%;
5353
margin-right: 25%;
54+
}
55+
56+
.wrapper {
57+
position: relative;
58+
59+
}
60+
.loading {
61+
position: absolute;
62+
top: 5px;
63+
left: 71px;
64+
}
65+
.loadingBox {
66+
position: absolute;
67+
top: 0;
68+
left: 0;
69+
right: 0;
70+
bottom: 0;
71+
z-index: 999;
5472
}

src/components/navigationBar/navigationBar.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@ const useStyles = makeStyles((theme) => ({
2828
link: {
2929
margin: theme.spacing(1, 1.5),
3030
cursor: 'pointer'
31+
},
32+
alink: {
33+
color: '#ffffff',
34+
textDecoration: 'none'
3135
}
3236
}));
3337

3438
const nav = {
35-
problem: '/page1',
36-
vfg: '/page2',
37-
manual: '/page3',
38-
demo: '/page4',
39+
problem: '/problem',
40+
vfg: '/vfg',
41+
manual: 'https://planimation.github.io/documentation/ ',
42+
demo: '/demo',
3943
home: '/'
4044
};
4145

@@ -46,7 +50,12 @@ function NavigationBar() {
4650

4751
const handleClick = (url) => {
4852
setUrl(url);
49-
history.push(nav[url]);
53+
if(url==='manual'){
54+
window.location.href(nav[url])
55+
}else{
56+
history.push(nav[url]);
57+
58+
}
5059
}
5160

5261
return(
@@ -62,8 +71,8 @@ function NavigationBar() {
6271
<Link variant="button" color="inherit" onClick={()=>handleClick('vfg')} className={classes.link}>
6372
VFG
6473
</Link>
65-
<Link variant="button" color="inherit" onClick={()=>handleClick('manual')} className={classes.link}>
66-
User Manual
74+
<Link variant="button" color="inherit" className={classes.link}>
75+
<a href={'https://planimation.github.io/documentation/'} target='_blank' rel="noreferrer" className={classes.alink}>User Manual</a>
6776
</Link>
6877
<Link variant="button" color="inherit" onClick={()=>handleClick('demo')} className={classes.link}>
6978
Demo

src/pages/HomePage/home.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,23 @@ export default function Home() {
139139

140140
const handleOnClick = (num) => {
141141
setNum( num + 1 );
142-
history.push('/page'+num);
142+
switch(num){
143+
case 1:
144+
history.push('/problem');
145+
break;
146+
case 2:
147+
history.push('/vfg');
148+
break;
149+
case 3:
150+
window.open('https://planimation.github.io/documentation/')
151+
break;
152+
case 4:
153+
history.push('/demo');
154+
break;
155+
default: return;
156+
}
157+
158+
143159
}
144160

145161
return (

src/pages/PageFour/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,12 @@ class PageFour extends React.Component {
376376
playSpeed: value
377377
})
378378
}
379-
379+
380+
componentWillUnmount(){
381+
if(this.handlerPlay) {
382+
clearInterval(this.handlerPlay);
383+
}
384+
}
380385

381386
render() {
382387
// Get all sprites

src/pages/PageOne/dropAndFetch.jsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Container from "@material-ui/core/Container";
55
import CloudUploadIcon from "@material-ui/icons/CloudUpload";
66
import css from "../../Styles/index.module.less";
77
import Alert from "../../components/alertInFormat";
8+
import CircularProgress from "@material-ui/core/CircularProgress";
89

910
/**
1011
* Three DropZones and Upload button to fetch pddl to server
@@ -16,6 +17,7 @@ import Alert from "../../components/alertInFormat";
1617
export default function DropAndFetch({ onStore, onClick, newURL }) {
1718
const [dataFiles, setDataFiles] = useState({});
1819
const [showAlert, setAlert] = useState(false);
20+
const [loading, setLoading] = useState(false);
1921

2022
const dragsAndDrops = [
2123
{
@@ -47,6 +49,7 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
4749
formData.append(name, files[name]);
4850
}
4951
try {
52+
setLoading(true);
5053
const resp = await fetch(
5154
"https://planimation.planning.domains/upload/pddl",
5255
{
@@ -61,6 +64,8 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
6164
onStore(txt);
6265
} catch (error) {
6366
alert(error);
67+
} finally {
68+
setLoading(false);
6469
}
6570
};
6671

@@ -102,6 +107,7 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
102107
onFileLoad={handleFileLoad}
103108
/>
104109
))}
110+
{loading && <div className={css.loadingBox} />}
105111
</Container>
106112
<Container maxWidth="sm" component="main">
107113
<div className={css.buttonBox}>
@@ -112,14 +118,20 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
112118
>
113119
Cancel
114120
</Button>
115-
<Button
116-
variant="contained"
117-
color="primary"
118-
startIcon={<CloudUploadIcon />}
119-
onClick={handleSubmit}
120-
>
121-
Upload Files
122-
</Button>
121+
<div className={css.wrapper}>
122+
<Button
123+
variant="contained"
124+
color="primary"
125+
startIcon={<CloudUploadIcon />}
126+
onClick={handleSubmit}
127+
disabled={loading}
128+
>
129+
Upload Files
130+
</Button>
131+
{loading && (
132+
<CircularProgress size={24} className={css.loading} />
133+
)}
134+
</div>
123135
</div>
124136
</Container>
125137
<Alert open={showAlert} reset={handleResetAlert} severity="warning">

src/pages/PageOne/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class PageOne extends React.Component {
2020

2121
handleStore = (content)=> {
2222
localStorage.setItem('fileContent', content);
23-
window.location.href = '/page4';
23+
window.location.href = '/demo';
2424
}
2525

2626
handleNewURL = (urlString) => {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.dropzoneBox {
2+
/*
3+
background: #fff;
4+
*/
5+
display: inline-block;
6+
justify-content: space-around;
7+
width: 30%;
8+
padding: 20px;
9+
}
10+
11+
.buttonBox {
12+
padding: 20px;
13+
display: flex;
14+
justify-content: space-around;
15+
}
16+
17+
.dropareaBox {
18+
/*
19+
background: #fff;
20+
*/
21+
display: flex;
22+
justify-content: space-around;
23+
position: relative;
24+
25+
}
26+

src/pages/PageTwo/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ render() {
129129
<Button variant="contained" color="default" onClick={this.handleOnClick} text-align="left">Cancel</Button>
130130
<Button variant="contained" color="primary" startIcon={<CloudUploadIcon />} onClick={()=>{
131131
// eslint-disable-next-line no-restricted-globals
132-
location.href = '/page4';
132+
location.href = '/demo';
133133
}} text-align="right">Continue</Button>
134134
</div>
135135
</Container>

0 commit comments

Comments
 (0)