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.
Merge pull request #166 from m2ms/session-projects
Session projects
- Loading branch information
Showing
62 changed files
with
3,477 additions
and
1,225 deletions.
There are no files selected for viewing
Empty file.
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 |
---|---|---|
@@ -1,72 +1,74 @@ | ||
/** | ||
* Created by ricgillams on 21/06/2018. | ||
*/ | ||
import { Grid } from '@material-ui/core'; | ||
import React, { memo, useEffect } from 'react'; | ||
import { Grid, Link } from '@material-ui/core'; | ||
import React, { memo, useContext, useEffect, useState } from 'react'; | ||
import TargetList from '../target/targetList'; | ||
import SessionList from '../session/sessionList'; | ||
//import SessionList from '../session/sessionList'; | ||
import { connect } from 'react-redux'; | ||
import * as apiActions from '../../reducers/api/actions'; | ||
import * as selectionActions from '../../reducers/selection/actions'; | ||
import { DJANGO_CONTEXT } from '../../utils/djangoContext'; | ||
import { Projects } from '../projects'; | ||
import { HeaderContext } from '../header/headerContext'; | ||
import { resetCurrentCompoundsSettings } from '../preview/compounds/redux/actions'; | ||
import { resetProjectsReducer } from '../projects/redux/actions'; | ||
|
||
const Landing = memo(({ resetSelectionState, resetTargetState, resetCurrentCompoundsSettings }) => { | ||
let text_div; | ||
const Landing = memo( | ||
({ resetSelectionState, resetTargetState, resetCurrentCompoundsSettings, resetProjectsReducer }) => { | ||
const { setSnackBarTitle } = useContext(HeaderContext); | ||
const [loginText, setLoginText] = useState("You're logged in as " + DJANGO_CONTEXT['username']); | ||
|
||
if (DJANGO_CONTEXT['authenticated'] === true) { | ||
var entry_text = "You're logged in as " + DJANGO_CONTEXT['username']; | ||
text_div = <h3>{entry_text}</h3>; | ||
} else { | ||
text_div = ( | ||
<h3> | ||
To view own targets login here: | ||
<a className="inline" href="/accounts/login"> | ||
FedID Login | ||
</a> | ||
</h3> | ||
); | ||
} | ||
useEffect(() => { | ||
if (DJANGO_CONTEXT['authenticated'] !== true) { | ||
setLoginText( | ||
<> | ||
{'To view own targets login here: '} | ||
<Link href="/accounts/login" color="inherit" variant="subtitle2"> | ||
FedID Login | ||
</Link> | ||
</> | ||
); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
resetTargetState(); | ||
resetSelectionState(); | ||
resetCurrentCompoundsSettings(true); | ||
}, [resetTargetState, resetSelectionState, resetCurrentCompoundsSettings]); | ||
useEffect(() => { | ||
resetTargetState(); | ||
resetSelectionState(); | ||
setSnackBarTitle(loginText); | ||
resetCurrentCompoundsSettings(true); | ||
resetProjectsReducer(); | ||
}, [ | ||
resetTargetState, | ||
resetSelectionState, | ||
setSnackBarTitle, | ||
loginText, | ||
resetCurrentCompoundsSettings, | ||
resetProjectsReducer | ||
]); | ||
|
||
return ( | ||
<Grid container spacing={2}> | ||
<Grid container item xs={12} sm={6} md={4} direction="column" justify="flex-start"> | ||
<Grid item> | ||
<h1>Welcome to Fragalysis</h1> | ||
{text_div} | ||
return ( | ||
<Grid container spacing={2}> | ||
<Grid item xs={4}> | ||
<TargetList key="TARGLIST" /> | ||
</Grid> | ||
<Grid item> | ||
<p> | ||
<a className="inline" href="http://cs04r-sc-vserv-137.diamond.ac.uk:8089/overview/targets/"> | ||
Target status overview | ||
</a>{' '} | ||
(only accessible within Diamond) | ||
</p> | ||
<Grid item xs={8}> | ||
{/*<SessionList />*/} | ||
<Projects /> | ||
</Grid> | ||
</Grid> | ||
<Grid item xs={12} sm={6} md={4}> | ||
<TargetList key="TARGLIST" /> | ||
</Grid> | ||
<Grid item xs={12} sm={6} md={4}> | ||
<SessionList /> | ||
</Grid> | ||
</Grid> | ||
); | ||
}); | ||
); | ||
} | ||
); | ||
|
||
function mapStateToProps(state) { | ||
return {}; | ||
} | ||
const mapDispatchToProps = { | ||
resetSelectionState: selectionActions.resetSelectionState, | ||
resetTargetState: apiActions.resetTargetState, | ||
resetCurrentCompoundsSettings | ||
resetCurrentCompoundsSettings, | ||
resetProjectsReducer | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(Landing); |
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.