@@ -5,100 +5,145 @@ import TextField from '@material-ui/core/TextField';
55import Button from '@material-ui/core/Button' ;
66import Alert from '../../components/alertInFormat' ;
77import 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+ ]
1038class 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 = / ^ ( ( h t t p | h t t p s ) : \/ \/ ) ? ( ( [ A - Z a - z 0 - 9 ] + - [ A - Z a - z 0 - 9 ] + | [ A - Z a - z 0 - 9 ] + ) \. ) + ( [ A - Z a - z ] + ) [ / \? \: ] ? .* $ / ;
64+ handleSendURL = ( ) => {
65+ const state = { ...this . state } ;
66+ const url = state . url ;
67+ const pattern = / ^ ( ( h t t p | h t t p s ) : \/ \/ ) ? ( ( [ A - Z a - z 0 - 9 ] + - [ A - Z a - z 0 - 9 ] + | [ A - Z a - z 0 - 9 ] + ) \. ) + ( [ A - Z a - 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