diff --git a/js/components/browserBombModal.js b/js/components/browserBombModal.js new file mode 100644 index 000000000..49f90551f --- /dev/null +++ b/js/components/browserBombModal.js @@ -0,0 +1,86 @@ +/** + * Created by ricgillams on 14/06/2018. + */ + +import React from "react"; +import {connect} from "react-redux"; +import ReactModal from "react-modal"; +import {Button} from 'react-bootstrap'; + +const customStyles = { + overlay : { + zIndex: 50, + backgroundColor: 'rgba(0, 0, 0, 0.85)' + }, + content : { + top: '50%', + left: '50%', + right: 'auto', + bottom: 'auto', + marginRight: '-20%', + transform: 'translate(-50%, -50%)', + border: '10px solid #7a7a7a' + } +}; + +export class BrowserBomb extends React.Component { + constructor(props) { + super(props); + this.closeModal = this.closeModal.bind(this); + this.checkBrowser = this.checkBrowser.bind(this); + this.state = { + currentBrowser: undefined, + notSupported: undefined + }; + } + + checkBrowser(){ + if (typeof InstallTrigger !== 'undefined'){ + this.setState(prevState => ({currentBrowser: "Firefox should be supported"})); + this.setState(prevState => ({notSupported: false})); + } else if (!!window.chrome && !!window.chrome.webstore){ + this.setState(prevState => ({currentBrowser: "Chrome should be supported"})) + this.setState(prevState => ({notSupported: false})); + } else { + this.setState(prevState => ({currentBrowser: "This browser may not perform properly. Please consider using Firefox or Chrome."})) + this.setState(prevState => ({notSupported: true})); + } + } + + closeModal(){ + this.setState(prevState => ({notSupported:undefined})); + } + + componentWillMount() { + ReactModal.setAppElement('body') + this.checkBrowser() + } + + componentWillReceiveProps(nextProps) { + if (nextProps.errorMessage != undefined){ + this.setState(prevState => ({errorMessage: nextProps.errorMessage})) + } + } + + render() { + return ( + +
+

This browser is not supported by Fragalysis, please consider moving to + Google Chrome or Mozilla Firefox.

+ +
+
+ ); + } +} + +function mapStateToProps(state) { + return { + } +} + +const mapDispatchToProps = { +} + +export default connect(mapStateToProps, mapDispatchToProps)(BrowserBomb); diff --git a/js/components/header.js b/js/components/header.js index 25a85f1a5..f17a0865f 100644 --- a/js/components/header.js +++ b/js/components/header.js @@ -11,14 +11,15 @@ import TargetList from "./targetList"; import SessionManagement from "./sessionManagement"; import {ErrorReport} from "./errorReport"; - class Header extends React.Component { - constructor(props) { super(props) this.getTargetList = this.getTargetList.bind(this); this.selectTarget = this.selectTarget.bind(this); this.generateTargetObject = this.generateTargetObject.bind(this); + this.openXchem = this.openXchem.bind(this); + this.openDiamond = this.openDiamond.bind(this); + this.openSgc = this.openSgc.bind(this); } getViewUrl(pk, get_view) { @@ -30,7 +31,7 @@ class Header extends React.Component { generateTargetObject(targetData) { // Now deal with this target var prot_to_load = targetData.protein_set[0] - if(prot_to_load!=undefined) { + if (prot_to_load != undefined) { var out_object = { "name": "PROTEIN_" + prot_to_load.toString(), "prot_url": this.getViewUrl(prot_to_load, "prot_from_pk"), @@ -43,62 +44,76 @@ class Header extends React.Component { getTargetList() { var newArray = [] - for(var key in this.props.target_id_list){ - newArray.push(this.props.target_id_list[key].title) + for (var key in this.props.target_id_list) { + newArray.push(this.props.target_id_list[key].title) } return newArray; } - selectTarget(option) { this.props.history.push("/viewer/react/preview/target/" + option) } - render() { - var landing = "/viewer/react/landing"; - var login = "/accounts/login" - var logout = "/accounts/logout" - var new_ele; - var username = DJANGO_CONTEXT["username"]; - if (username=="NOT_LOGGED_IN"){ - new_ele = -
Login
-
- } - else{ - new_ele = -
Hello {username}! Logout.
-
- } + openXchem() { + window.location.href = 'https://www.diamond.ac.uk/Instruments/Mx/Fragment-Screening.html' + } - return - - -

- FragalysisHome -

-
-
- - - -
- } + } + + return + + +

+ FragalysisHome +

+
+
+ + + +
+ } } function mapStateToProps(state) { - return { - target_id_list: state.apiReducers.present.target_id_list, - } + return { + target_id_list: state.apiReducers.present.target_id_list, + } } const mapDispatchToProps = { } diff --git a/js/components/landing.js b/js/components/landing.js index fe223298f..46ed1b931 100644 --- a/js/components/landing.js +++ b/js/components/landing.js @@ -5,6 +5,7 @@ import {Col, Row} from "react-bootstrap"; import React from "react"; import {connect} from "react-redux"; import TargetList from "./targetList"; +import {BrowserBomb} from "./browserBombModal"; export class Welcome extends React.Component { constructor(props) { @@ -34,6 +35,7 @@ export class Welcome extends React.Component { + ) } diff --git a/js/components/modalErrorDisplay.js b/js/components/modalErrorDisplay.js index 00d758c1f..3c0c5755c 100644 --- a/js/components/modalErrorDisplay.js +++ b/js/components/modalErrorDisplay.js @@ -53,7 +53,7 @@ export class ModalErrorMessage extends React.Component {

Error occurred during state saving. Please contact Fragalysis support!

- +
); diff --git a/js/components/modalStateSave.js b/js/components/modalStateSave.js index 2331fc35e..9998783a3 100644 --- a/js/components/modalStateSave.js +++ b/js/components/modalStateSave.js @@ -5,7 +5,7 @@ import React, {Component} from "react"; import {connect} from "react-redux"; import ReactModal from "react-modal"; -import {Tooltip, OverlayTrigger, ButtonToolbar} from 'react-bootstrap'; +import {Tooltip, OverlayTrigger, ButtonToolbar, Row} from 'react-bootstrap'; import * as apiActions from "../actions/apiActions"; import Clipboard from 'react-clipboard.js'; @@ -70,34 +70,34 @@ export class ModalStateSave extends Component { ); var urlToCopy = ""; var information = ""; - var text = ""; if (this.state.fraggleBoxLoc != undefined) { if (this.props.savingState == "savingSnapshot") { urlToCopy = window.location.protocol + "//" + window.location.hostname + "/viewer/react/snapshot/" + this.props.latestSnapshot.slice(1, -1); - information = "A snapshot of the current point in time has been saved and can "; - text = ". This snapshot cannot be overwritten."; + information = "A permanent, fixed snapshot of the current state has been saved "; } else if (this.props.savingState == "savingSession") { urlToCopy = window.location.protocol + "//" + window.location.hostname + "/viewer/react/fragglebox/" + this.props.latestSession.slice(1, -1); - information = "A new session has been generated and can "; - text = ". The session can be overwritten."; + information = "A new session has been generated "; } else if (this.props.savingState == "overwritingSession") { urlToCopy = window.location.protocol + "//" + window.location.hostname + "/viewer/react/fragglebox/" + this.props.latestSession.slice(1, -1); - information = "Your session has been updated and can still "; - text = ". This has overwritten the session record."; + information = "Your session has been overwritten and remains "; } return ( - - {information} be viewed here {text} - - - - Copy link - - - - + + + {information} be viewed here. + + + + + + Copy link + + + + + ); } else { diff --git a/js/components/modalTargetUnrecognised.js b/js/components/modalTargetUnrecognised.js index bca1b6f06..1f86f2e66 100644 --- a/js/components/modalTargetUnrecognised.js +++ b/js/components/modalTargetUnrecognised.js @@ -8,6 +8,7 @@ import ReactModal from "react-modal"; import {Button} from 'react-bootstrap'; import * as apiActions from "../actions/apiActions"; import TargetList from "./targetList"; +import {ErrorReport} from "./errorReport"; const customStyles = { overlay : { @@ -49,29 +50,27 @@ export class ModalTargetUnrecognised extends React.Component { } render() { - if (this.state.targetUnrecognised == true) { - if(this.state.targetListLength == 0) { - return ( - -
-

No targets available.
Please contact Fragalysis Support!

- -
-
- ); - } else { - return ( - -
-

Target was not recognised.
Please select a target:

- - -
-
- ); - } + if (this.state.targetListLength == 0) { + return ( + +
+

The target was not recognised and there are no other available targets.

+ + +
+
+ ); } else { - return null; + return ( + +
+

Target was not recognised.
Please select a target:

+ + + +
+
+ ); } } } diff --git a/js/components/refinementOutcome.js b/js/components/refinementOutcome.js index d064e9b34..99dfde6a6 100644 --- a/js/components/refinementOutcome.js +++ b/js/components/refinementOutcome.js @@ -59,7 +59,7 @@ class RefinementOutcome extends React.Component{ return ; } else if (this.state.refinementOutcome==5){ - return ; + return ; } else if (this.state.refinementOutcome==4){ return ; diff --git a/js/components/sessionManagement.js b/js/components/sessionManagement.js index d43182f54..b4bea7d13 100644 --- a/js/components/sessionManagement.js +++ b/js/components/sessionManagement.js @@ -13,7 +13,6 @@ import {getStore} from "../containers/globalStore"; import * as selectionActions from "../actions/selectionActions"; import {withRouter} from "react-router-dom"; - const override = css` display: block; margin: 0 auto; @@ -31,8 +30,10 @@ export class SessionManagement extends React.Component { this.newSession = this.newSession.bind(this); this.saveSession = this.saveSession.bind(this); this.newSnapshot = this.newSnapshot.bind(this); + this.handleSessionNaming = this.handleSessionNaming.bind(this); this.state = { - saveType: "" + saveType: "", + sessionName: "", }; } @@ -62,6 +63,14 @@ export class SessionManagement extends React.Component { this.postToServer(); } + handleSessionNaming(e){ + if (e.keyCode === 13) { + var newSessionName = e.target.value; + console.log('submit new session name ' + newSessionName); + // this.props.setSessionName(newSessionName); + } + } + newSnapshot(){ this.setState(prevState => ({saveType: "snapshotNew"})); this.postToServer(); @@ -132,7 +141,9 @@ export class SessionManagement extends React.Component { var store = JSON.stringify(getStore().getState()); const csrfToken = this.getCookie("csrftoken"); var fullState = {"state": store}; - var TITLE = 'need to define title'; + const timeOptions = {year:'numeric', month:'numeric', day:'numeric', hour: 'numeric', minute: 'numeric', + second: 'numeric', hour12: false,} + var TITLE = 'Created on ' + new Intl.DateTimeFormat('en-GB', timeOptions).format(Date.now()); var userId = DJANGO_CONTEXT["pk"]; if (this.state.saveType == "sessionNew") { const uuidv4 = require('uuid/v4'); @@ -209,28 +220,33 @@ export class SessionManagement extends React.Component { render() { const {pathname} = this.props.location; - var button = "" + var urlToCopy = "testing"; + if (this.props.latestSession != undefined) { + urlToCopy = window.location.protocol + "//" + window.location.hostname + "/viewer/react/fragglebox/" + this.props.latestSession.slice(1, -1); + } + var buttons = ""; if (pathname != "/viewer/react/landing") { if (this.props.latestSession == undefined) { - button =
- - - - - + buttons =
+ + + + + -

Currently no active session.

+

Currently no active session.

} else { - button =
+ buttons =
- - - + + + -

Session: {this.props.latestSession}, author: tbd

+ {/**/} +

Session: {this.props.latestSession}, author: tbd

} @@ -239,7 +255,7 @@ export class SessionManagement extends React.Component { return } else { return - {button} + {buttons} } } diff --git a/js/containers/fraggleBoxHolder.js b/js/containers/fraggleBoxHolder.js index 696cfb052..29efacc32 100644 --- a/js/containers/fraggleBoxHolder.js +++ b/js/containers/fraggleBoxHolder.js @@ -18,6 +18,7 @@ import ModalLoadingScreen from "../components/modalLoadingScreen"; import ModalStateSave from "../components/modalStateSave"; import ModalErrorMessage from "../components/modalErrorDisplay"; import HotspotList from "../components/hotspotList"; +import {BrowserBomb} from "../components/browserBombModal"; class FraggleBox extends Component { @@ -60,6 +61,7 @@ class FraggleBox extends Component { + ) } diff --git a/js/containers/previewHolder.js b/js/containers/previewHolder.js index 7e28077c8..dac71356c 100644 --- a/js/containers/previewHolder.js +++ b/js/containers/previewHolder.js @@ -20,6 +20,7 @@ import * as apiActions from "../actions/apiActions"; import * as selectionActions from "../actions/selectionActions"; import fetch from "cross-fetch"; import {withRouter} from "react-router-dom"; +import {BrowserBomb} from "../components/browserBombModal"; class Preview extends Component { @@ -86,6 +87,7 @@ class Preview extends Component { + ) } diff --git a/js/img/dlsLogo.png b/js/img/dlsLogo.png new file mode 100644 index 000000000..db92cd8c3 Binary files /dev/null and b/js/img/dlsLogo.png differ diff --git a/js/img/sgcLogo.png b/js/img/sgcLogo.png new file mode 100644 index 000000000..b3fdc3e27 Binary files /dev/null and b/js/img/sgcLogo.png differ diff --git a/js/img/xchemLogo.png b/js/img/xchemLogo.png new file mode 100644 index 000000000..3b21b32d4 Binary files /dev/null and b/js/img/xchemLogo.png differ