forked from pavol-brunclik-m2ms/fragalysis-frontend
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#14 add not completed manual snapshot
- Loading branch information
1 parent
fa30e1f
commit a710bbd
Showing
24 changed files
with
331 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
import React, { memo, useState } from 'react'; | ||
import { | ||
FormControl, | ||
FormControlLabel, | ||
FormHelperText, | ||
Grid, | ||
InputLabel, | ||
makeStyles, | ||
MenuItem, | ||
Radio, | ||
Typography | ||
} from '@material-ui/core'; | ||
import Modal from '../../common/Modal'; | ||
import { DJANGO_CONTEXT } from '../../../utils/djangoContext'; | ||
import { setCurrentProjectProperty, setProjectModalIsLoading, setProjectModalOpen } from '../redux/actions'; | ||
import { api, METHOD } from '../../../utils/api'; | ||
import { base_url, URLS } from '../../routes/constants'; | ||
import { Form, Formik } from 'formik'; | ||
import { RadioGroup, Select, TextField } from 'formik-material-ui'; | ||
import { ProjectCreationType } from '../redux/constants'; | ||
import { InputFieldAvatar } from '../projectModal/inputFieldAvatar'; | ||
import { Description, Label, Link, Title } from '@material-ui/icons'; | ||
import { Autocomplete } from '@material-ui/lab'; | ||
import { Button } from '../../common/Inputs/Button'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { setDialogCurrentStep } from '../../snapshot/redux/actions'; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
body: { | ||
width: '100%', | ||
marginTop: theme.spacing(1), | ||
marginBottom: theme.spacing(1) | ||
}, | ||
input: { | ||
width: 400 | ||
}, | ||
margin: { | ||
margin: theme.spacing(1) | ||
}, | ||
formControl: { | ||
margin: theme.spacing(1), | ||
width: 400 | ||
} | ||
})); | ||
|
||
export const AddProjectDetail = memo(() => { | ||
const classes = useStyles(); | ||
const [state, setState] = useState(); | ||
|
||
const dispatch = useDispatch(); | ||
const targetId = useSelector(state => state.apiReducers.target_on); | ||
|
||
const [tags, setTags] = React.useState([]); | ||
|
||
return ( | ||
<> | ||
<Typography variant="h3">Add Project Detail</Typography> | ||
<Formik | ||
initialValues={{ | ||
title: '', | ||
description: '', | ||
tags: '' | ||
}} | ||
validate={values => { | ||
const errors = {}; | ||
if (!values.title) { | ||
errors.title = 'Required!'; | ||
} | ||
if (!values.description) { | ||
errors.description = 'Required!'; | ||
} | ||
return errors; | ||
}} | ||
onSubmit={values => { | ||
const data = { | ||
...values, | ||
author: { | ||
username: DJANGO_CONTEXT['username'], | ||
email: DJANGO_CONTEXT['email'] | ||
}, | ||
tags | ||
}; | ||
dispatch(setProjectModalIsLoading(true)); | ||
api({ url: `${base_url}/api/project`, method: METHOD.POST, data }) | ||
.then(response => { | ||
const projectID = response.data.id; | ||
dispatch(setCurrentProjectProperty('projectID', projectID)); | ||
}) | ||
.catch(error => { | ||
setState(() => { | ||
throw error; | ||
}); | ||
}) | ||
.finally(() => { | ||
dispatch(setDialogCurrentStep(1)); | ||
}); | ||
}} | ||
> | ||
{({ submitForm, errors }) => ( | ||
<Form> | ||
<Grid container direction="column" className={classes.body}> | ||
<Grid item> | ||
<InputFieldAvatar | ||
icon={<Title />} | ||
field={ | ||
<TextField | ||
className={classes.input} | ||
name="title" | ||
label="Title" | ||
required | ||
// disabled={isProjectModalLoading} | ||
/> | ||
} | ||
/> | ||
</Grid> | ||
<Grid item> | ||
<InputFieldAvatar | ||
icon={<Description />} | ||
field={ | ||
<TextField | ||
className={classes.input} | ||
name="description" | ||
label="Description" | ||
required | ||
// disabled={isProjectModalLoading} | ||
/> | ||
} | ||
/> | ||
</Grid> | ||
<Grid item> | ||
<InputFieldAvatar | ||
icon={<Label />} | ||
field={ | ||
<Autocomplete | ||
multiple | ||
freeSolo | ||
id="tags-standard" | ||
options={tags} | ||
getOptionLabel={option => option} | ||
onChange={(e, data) => { | ||
setTags(data); | ||
}} | ||
// disabled={isProjectModalLoading} | ||
renderInput={params => ( | ||
<TextField | ||
{...params} | ||
className={classes.input} | ||
label="Tags" | ||
name="tags" | ||
fullWidth | ||
onKeyPress={e => { | ||
if (e.key === 'Enter') { | ||
setTags([...tags, e.target.value]); | ||
} | ||
}} | ||
/> | ||
)} | ||
/> | ||
} | ||
/> | ||
</Grid> | ||
</Grid> | ||
<Grid container justify="flex-end" direction="row"> | ||
<Grid item> | ||
<Button | ||
color="secondary" //disabled={isProjectModalLoading} onClick={handleCloseModal} | ||
> | ||
Cancel | ||
</Button> | ||
</Grid> | ||
<Grid item> | ||
<Button | ||
color="primary" | ||
onClick={submitForm} //loading={isProjectModalLoading} | ||
> | ||
Create | ||
</Button> | ||
</Grid> | ||
</Grid> | ||
</Form> | ||
)} | ||
</Formik> | ||
</> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React, { memo, useState } from 'react'; | ||
|
||
export const NewSnapshotForm = memo(() => { | ||
return; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { memo } from 'react'; | ||
import Modal from '../../common/Modal'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { setOpenSnapshotSavingDialog } from '../redux/actions'; | ||
import { Typography } from '@material-ui/core'; | ||
import { AddProjectDetail } from '../../projects/addProjectDetail'; | ||
|
||
export const NewSnapshotModal = memo(({ match }) => { | ||
const dispatch = useDispatch(); | ||
const openSavingDialog = useSelector(state => state.snapshotReducers.openSavingDialog); | ||
const dialogCurrentStep = useSelector(state => state.snapshotReducers.dialogCurrentStep); | ||
const currectProject = useSelector(state => state.projectReducers.currentProject); | ||
|
||
const projectId = (match && match.params && match.params.projectId) || (currectProject && currectProject.projectID); | ||
|
||
const handleCloseModal = () => { | ||
dispatch(setOpenSnapshotSavingDialog(false)); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Modal open={openSavingDialog} onClose={handleCloseModal}> | ||
{projectId && <Typography variant="h3">Save Session</Typography>} | ||
{!projectId && dialogCurrentStep === 0 && <AddProjectDetail />} | ||
{!projectId && dialogCurrentStep === 1 && <AddProjectDetail />} | ||
</Modal> | ||
</> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.