-
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.
allow user to check progress and submit another crawler request
- Loading branch information
Showing
11 changed files
with
334 additions
and
176 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React, { Component } from 'react' | ||
// components | ||
import { | ||
withStyles, | ||
CardHeader, | ||
Grid, | ||
Card, | ||
CardActions, | ||
Button | ||
} from '@material-ui/core' | ||
// icons | ||
import ImportIcon from '@material-ui/icons/CloudUpload' | ||
// redux | ||
import { connect } from 'react-redux' | ||
import { compose } from 'recompose' | ||
import { pollCrawlerStatus } from 'store/modules/data/crawler' | ||
import { push } from 'react-router-redux' | ||
|
||
const styles = { | ||
root: { | ||
padding: '20px' | ||
}, | ||
} | ||
|
||
class CrawlerStatus extends Component { | ||
|
||
componentDidMount() { | ||
this.props.pollCrawlerStatus() | ||
} | ||
|
||
goToImportPage = () => this.props.push('/import') | ||
|
||
render() { | ||
const { classes, loading, starting, running } = this.props | ||
const subtitle = | ||
loading ? 'Checking Status...' | ||
: starting ? 'Starting import process...' | ||
: running ? 'An import operation is in progress' | ||
: 'No import process running for your DID' | ||
return (<Grid container spacing={16} className={classes.root}> | ||
<Grid item xs={12}> | ||
<Card> | ||
<CardHeader | ||
avatar={<ImportIcon />} | ||
title='Import Reviews' | ||
subheader={subtitle} | ||
/> | ||
<CardActions> | ||
<Button disabled={loading || starting || running} onClick={this.goToImportPage}> | ||
Import Now | ||
</Button> | ||
</CardActions> | ||
</Card> | ||
</Grid> | ||
</Grid>) | ||
} | ||
} | ||
|
||
const mapStateToProps = state => ({ | ||
loading: state.data.crawler.loading, | ||
starting: state.data.crawler.starting, | ||
running: state.data.crawler.running, | ||
}) | ||
|
||
const mapDispatchToProps = { | ||
pollCrawlerStatus, | ||
push | ||
} | ||
|
||
export default compose( | ||
withStyles(styles), | ||
connect(mapStateToProps, mapDispatchToProps) | ||
)(CrawlerStatus) |
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,96 @@ | ||
import React, { Component } from 'react' | ||
// Components | ||
import { Grid, CircularProgress } from '@material-ui/core' | ||
import RegularCard from 'components/MaterialDashboardPro/RegularCard' | ||
import NavPills from 'components/MaterialDashboardPro/NavPills' | ||
import InfoArea from 'components/MaterialDashboardPro/InfoArea' | ||
// Icons | ||
import Person from '@material-ui/icons/Person'; | ||
import Business from '@material-ui/icons/Business'; | ||
// Form | ||
import ImportReviewsForm from './form' | ||
// Redux | ||
import { connect } from 'react-redux' | ||
import { pollCrawlerStatus } from 'store/modules/data/crawler' | ||
|
||
class ImportReviews extends Component { | ||
|
||
componentDidMount() { | ||
this.props.pollCrawlerStatus() | ||
} | ||
|
||
render () { | ||
const { running, starting, loading } = this.props | ||
|
||
if (loading || starting) { | ||
return ( | ||
<InfoArea | ||
icon={CircularProgress} | ||
title='Checking Status' | ||
description='Please Wait' | ||
/> | ||
) | ||
} else if (running) { | ||
return ( | ||
<InfoArea | ||
icon={CircularProgress} | ||
title='In Progress' | ||
description='An import operation is already in progress' | ||
/> | ||
) | ||
} else { | ||
return (<Grid container justify='center'> | ||
<NavPills | ||
color='info' | ||
alignCenter | ||
tabs={[ | ||
{ | ||
tabButton: 'Individuals', | ||
tabIcon: Person, | ||
tabContent: ( | ||
<RegularCard | ||
cardTitle={[ | ||
<p key={0} style={{ textAlign:'center' }}>To begin, simply enter your email & password for any of the sites below on which you have an active profile.</p>, | ||
<p key={1} style={{ textAlign:'center' }}>We extract, merge and decentrally store your reputation in a portable format so you own and control it.</p> | ||
]} | ||
content={<ImportReviewsForm userType='individual' />} | ||
/> | ||
) | ||
}, | ||
{ | ||
tabButton: 'Businesses', | ||
tabIcon: Business, | ||
tabContent: ( | ||
<RegularCard | ||
cardTitle={[ | ||
<p key={0} style={{ textAlign: 'center' }}>To begin, simply enter your email & password for any of the sites below on which you have an active profile.</p>, | ||
<p key={1} style={{ textAlign: 'center' }}>We extract, merge and decentrally store your reputation in a portable format so you own and control it.</p> | ||
]} | ||
content={<ImportReviewsForm userType='business' />} | ||
/> | ||
) | ||
} | ||
]} | ||
/> | ||
<Grid item xs={12} sm={12} md={12}> | ||
<p>Chlu guarantees that no information submitted from this form is ever stored on our system</p> | ||
<p>By submitting this form you acknowledge you are entitled to invoke your <a href='https://gdpr-info.eu/recitals/no-63/'>data access rights</a> and | ||
<a href='https://www.i-scoop.eu/gdprarticle/gdpr-article-20-right-data-portability/'> data portability rights</a> under European <a href='https://www.eugdpr.org/'>GDPR</a> legislation. | ||
</p> | ||
</Grid> | ||
</Grid>) | ||
} | ||
} | ||
} | ||
|
||
const mapStateToProps = state => ({ | ||
loading: state.data.crawler.loading, | ||
starting: state.data.crawler.starting, | ||
running: state.data.crawler.running, | ||
}) | ||
|
||
const mapDispatchToProps = { | ||
pollCrawlerStatus | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(ImportReviews) |
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,34 @@ | ||
import React, { Component } from 'react' | ||
// components | ||
import { withStyles, Button } from '@material-ui/core' | ||
// Forms | ||
import BusinessCrawlerForm from './businessCrawlerForm'; | ||
import IndividualsCrawlerForm from './individualsCrawlerForm'; | ||
// redux | ||
import { reduxForm } from 'redux-form' | ||
import { compose } from 'recompose' | ||
|
||
const styles = { | ||
button: { | ||
marginLeft: 'auto' | ||
} | ||
} | ||
|
||
class ImportReviewsForm extends Component { | ||
render () { | ||
const { classes, handleSubmit, userType, ...otherProps } = this.props | ||
const isBusiness = userType === 'business' | ||
const Form = isBusiness ? BusinessCrawlerForm : IndividualsCrawlerForm | ||
|
||
return <form onSubmit={handleSubmit}> | ||
<Form {...otherProps} /> | ||
</form> | ||
} | ||
} | ||
|
||
export default compose( | ||
withStyles(styles), | ||
reduxForm({ | ||
form: 'import-reviews' | ||
}) | ||
)(ImportReviewsForm) |
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 |
---|---|---|
@@ -1,34 +1,58 @@ | ||
import React, { Component } from 'react' | ||
// Components | ||
import { LinearProgress, Grid } from '@material-ui/core' | ||
// Forms | ||
import BusinessCrawlerForm from './businessCrawlerForm'; | ||
import IndividualsCrawlerForm from './individualsCrawlerForm'; | ||
// redux | ||
import { reduxForm } from 'redux-form' | ||
import { Button, Grid, Card, CardContent, withStyles, CardActions } from '@material-ui/core' | ||
import ImportReviews from './ImportReviews' | ||
// Redux | ||
import { connect } from 'react-redux' | ||
import { compose } from 'recompose' | ||
import { importReviews } from 'store/modules/data/crawler' | ||
|
||
class ImportReviews extends Component { | ||
render () { | ||
const { handleSubmit, crawlerRunning, userType, ...otherProps } = this.props | ||
const isBusiness = userType === 'business' | ||
const Form = isBusiness ? BusinessCrawlerForm : IndividualsCrawlerForm | ||
const styles = { | ||
root: { | ||
padding: '20px' | ||
}, | ||
button: { | ||
marginLeft: 'auto' | ||
} | ||
} | ||
|
||
if (crawlerRunning) { | ||
return ( | ||
<Grid container justify='center'> | ||
<Grid item xs={12} md={12} > | ||
<LinearProgress size={100} /> | ||
</Grid> | ||
</Grid> | ||
) | ||
} else { | ||
return <form onSubmit={handleSubmit}> | ||
<Form {...otherProps} /> | ||
</form> | ||
} | ||
class ImportReviewsPage extends Component { | ||
render() { | ||
const { classes, importReviews, running, starting, loading } = this.props | ||
return (<Grid container spacing={16} justify='center' className={classes.root}> | ||
<Grid item xs={12}> | ||
<Card> | ||
<CardContent> | ||
<ImportReviews showSubmitButton={true} /> | ||
</CardContent> | ||
<CardActions> | ||
{ !loading && !running && <Button | ||
onClick={importReviews} | ||
disabled={running || starting || loading} | ||
variant='contained' | ||
color='primary' | ||
type='submit' | ||
className={classes.button} | ||
> | ||
Start | ||
</Button> } | ||
</CardActions> | ||
</Card> | ||
</Grid> | ||
</Grid>) | ||
} | ||
} | ||
|
||
export default reduxForm({ | ||
form: 'import-reviews' | ||
})(ImportReviews) | ||
const mapStateToProps = state => ({ | ||
running: state.data.crawler.running, | ||
starting: state.data.crawler.starting, | ||
loading: state.data.crawler.loading | ||
}) | ||
|
||
const mapDispatchToProps = { | ||
importReviews | ||
} | ||
|
||
export default compose( | ||
withStyles(styles), | ||
connect(mapStateToProps, mapDispatchToProps) | ||
)(ImportReviewsPage) |
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.