forked from xchem/fragalysis-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update: Session Management (#34) - browser bomb to warn of unsupported nature - add report error button to modal in case of no target available - add logos to header - set creation date as default title - rename session saving buttons and change saving modal text * Funders page (#35) * New feature: Sessions page (#36) * Fix testing for sessions (#37) - Modify sessionList to remove scene information - Update tests for new variables - Reformat session summary on landing and session pages - Add throbber during session loading * bundle of fixes (#38) * Mock up of proposal management (#39) * Session debugging (#40) * New feature: session renaming and deleting. closes xchem#109, closes #42 (#41) * Bug fix: Select all compounds to the buy list. Closes xchem#106 (#42) * Bug fix: stop multi-session generation, correctly update state and vector presentation. Closes xchem#112 & closes xchem#108 (#43) - Compound classes transferred into fragglebox. - Session generation refactored to stop generation of multiple sessions. - Correct update of session title in header/modal/sessionList page. - Redeploy vectors in NGL viewer. - Compound list correctly displayed in fragglebox. * Finalise sessions (#48) - Add copy link button - Check target access for fragglebox - Deploy unrecognised target modal if necessary - Fix associated bugs! * Download pdb files (#49) - enable users to download all pdbs for a target - fix browser bomb for chrome 71
- Loading branch information
1 parent
81595e1
commit e840897
Showing
35 changed files
with
1,190 additions
and
440 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
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,61 @@ | ||
/** | ||
* Created by ricGillams on 7/12/2018. | ||
*/ | ||
import React from "react"; | ||
import JSZip from "jszip"; | ||
import {connect} from "react-redux"; | ||
import {Button, ButtonToolbar} from "react-bootstrap"; | ||
import fetch from "cross-fetch"; | ||
import FileSaver from "file-saver"; | ||
|
||
class DownloadPdb extends React.Component{ | ||
constructor(props) { | ||
super(props); | ||
this.handlePdbDownload = this.handlePdbDownload.bind(this); | ||
} | ||
|
||
async handlePdbDownload() { | ||
var protPdbUrl = window.location.protocol + "//" + window.location.host + "/api/protpdb/?target_id=" + this.props.targetOn.toString(); | ||
var proteinsUrl = window.location.protocol + "//" + window.location.host + "/api/proteins/?target_id=" + this.props.targetOn.toString(); | ||
const protResponse = await fetch(proteinsUrl); | ||
const protJson = await protResponse.json(); | ||
const protInfo = protJson.results; | ||
const pdbResponse = await fetch(protPdbUrl); | ||
const pdbJson = await pdbResponse.json(); | ||
const pdbInfo = pdbJson.results; | ||
var zip = new JSZip(); | ||
const timeOptions = {year:'numeric', month:'short', day:'2-digit'} | ||
var fName = this.props.targetOnName + "_allPdb_" + new Intl.DateTimeFormat('en-GB', timeOptions).format(Date.now()).replace(/\s/g, '-'); | ||
var totFolder = zip.folder(fName); | ||
for(var structure in protInfo) { | ||
var pdbData = pdbInfo[structure].pdb_data; | ||
var pdbCode = protInfo[structure].code; | ||
var molGroupUrl = window.location.protocol + "//" + window.location.host + "/api/molecules/?prot_id=" + pdbInfo[0].id; | ||
const molResponse = await fetch(molGroupUrl); | ||
const molJson = await molResponse.json(); | ||
const sdfData = molJson.results[0].sdf_info | ||
totFolder.file(pdbCode+".pdb",pdbData); | ||
totFolder.file(pdbCode+".sdf",sdfData); | ||
} | ||
const content = await zip.generateAsync({type: "blob"}); | ||
FileSaver.saveAs(content, fName + ".zip"); | ||
} | ||
|
||
render() { | ||
return <ButtonToolbar> | ||
<Button bsSize="sm" bsStyle="success" onClick={this.handlePdbDownload}>Download all PBDs for target</Button> | ||
</ButtonToolbar> | ||
} | ||
} | ||
|
||
function mapStateToProps(state) { | ||
return { | ||
targetOn: state.apiReducers.present.target_on, | ||
targetOnName: state.apiReducers.present.target_on_name, | ||
} | ||
} | ||
|
||
const mapDispatchToProps = { | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(DownloadPdb); |
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.