Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge a semi-stable frontend #2

Merged
merged 147 commits into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
0ce8632
DEV
Mar 21, 2018
919f35f
DEV
Mar 21, 2018
5081474
DEV
Mar 21, 2018
feebb23
DEV
Mar 21, 2018
5d75fcb
DEV
Mar 21, 2018
93fa777
DEV
Mar 21, 2018
69fae49
DEV
Mar 21, 2018
d4c1124
DEV
Mar 21, 2018
45016d7
DEV
Mar 21, 2018
8131cfe
DEV
Mar 21, 2018
2df290e
DEV
Mar 21, 2018
56e3f0b
DEV
Mar 21, 2018
acf8d5e
DEV
Mar 21, 2018
5a37e1c
DEV
Mar 21, 2018
1e5be46
DEV
Mar 21, 2018
2dfb0c9
DEV
Mar 21, 2018
7b3f634
DEV
Mar 21, 2018
cbe88e1
DEV
Mar 21, 2018
77b0cf6
DEV
Mar 21, 2018
31b7b9c
DEV
Mar 21, 2018
2902d78
DEV
Mar 21, 2018
2e4e050
DEV
Mar 21, 2018
c82312e
DEV
Mar 22, 2018
d210e98
DEV
Mar 22, 2018
8ada029
DEV
Mar 22, 2018
1d73ab1
DEV
Mar 22, 2018
21d580e
DEV
Mar 22, 2018
e32d1e5
DEV
Mar 22, 2018
b9600fb
DEV
Mar 22, 2018
5a0f6cd
DEV
Mar 22, 2018
fb0f96f
DEV
Mar 22, 2018
c3b4aae
DEV
Mar 22, 2018
a4d0adc
DEV
Mar 22, 2018
d6053cb
DEV
Mar 22, 2018
be5c6f5
DEV
Mar 22, 2018
d1990f3
DEV
Mar 22, 2018
391b860
DEV
Mar 22, 2018
1c75232
DEV
Mar 22, 2018
3f7c56a
DEV
Mar 22, 2018
6435e56
DEV
Mar 22, 2018
6236d2b
DEV
Mar 22, 2018
a5e576d
DEV
Mar 22, 2018
1a21865
DEV
Mar 22, 2018
f174a17
DEV
Mar 22, 2018
54f7ad2
DEV
Mar 22, 2018
a8bc9c9
DEV
Mar 22, 2018
9207543
DEV
Mar 22, 2018
47a6502
DEV
Mar 22, 2018
1705de3
DEV
Mar 22, 2018
37803eb
DEV
Mar 22, 2018
53ecd13
DEV
Mar 22, 2018
2823d0d
DEV
Mar 22, 2018
afedc22
DEV
Mar 22, 2018
dbae558
DEV
Mar 22, 2018
dea57ab
DEV
Mar 22, 2018
c391524
DEV
Mar 22, 2018
429f92a
DEV
Mar 22, 2018
0f2befb
DEV
Mar 22, 2018
c031e33
DEV
Mar 22, 2018
3fa7ec4
DEV
Mar 22, 2018
cc53095
DEV
Mar 22, 2018
140a4a7
DEV
Mar 22, 2018
0be07c4
DEV
Mar 22, 2018
beef21b
DEV
Mar 22, 2018
7c07577
DEV
Mar 22, 2018
e463ac0
DEV
Mar 22, 2018
9437268
DEV
Mar 22, 2018
e8c29cc
DEV
Mar 22, 2018
1b0d729
DEV
Mar 22, 2018
ba98dcf
DEV
Mar 22, 2018
b5b08f8
DEV
Mar 22, 2018
b31059c
DEV
Mar 22, 2018
9ee3470
DEV
Mar 22, 2018
ed15176
DEV
Mar 22, 2018
4a2bf46
DEV
Mar 22, 2018
9320b42
DEV
Mar 22, 2018
7a8405a
DEV
Mar 22, 2018
b94d15e
DEV
Mar 22, 2018
4756e90
DEV
Mar 22, 2018
749dd9f
DEV
Mar 22, 2018
27312c4
DEV
Mar 22, 2018
369d61a
DEV
Mar 22, 2018
7ce6bb2
DEV
Mar 22, 2018
bbd07c8
DEV
Mar 22, 2018
1ae2ece
DEV
Mar 22, 2018
41d41b8
DEV
Mar 22, 2018
1310a95
DEV
Mar 22, 2018
c2ca7d0
DEV
Mar 22, 2018
4e63853
DEV
Mar 22, 2018
af7684c
Added toggle switch
Mar 22, 2018
f79cded
DEV
Mar 22, 2018
77b7038
DEV
Mar 22, 2018
b9b7228
DEV
Mar 22, 2018
a997a60
DEV
Mar 22, 2018
7b5796b
DEV
Mar 22, 2018
8e141da
DEV
Mar 22, 2018
c41c0b8
DEV
Mar 22, 2018
a8d807f
DEV
Mar 22, 2018
ab69813
DEV
Mar 22, 2018
6aa72cf
DEV
Mar 22, 2018
fb9a4f3
DEV
Mar 22, 2018
3b75cc0
DEV
Mar 22, 2018
ce688c4
DEV
Mar 22, 2018
8dd28ca
DEV
Mar 22, 2018
cc9c50f
DEV
Mar 22, 2018
95c5910
DEV
Mar 22, 2018
462ed9f
DEV
Mar 22, 2018
c766a08
DEV
Mar 23, 2018
a63e856
DEV
Mar 23, 2018
74f0296
DEV
Mar 23, 2018
192f307
DEV
Mar 23, 2018
2ef47d4
DEV
Mar 23, 2018
bd5993f
DEV
Mar 23, 2018
177b360
DEV
Mar 23, 2018
517d1d3
DEV
Mar 23, 2018
81f111d
DEV
Mar 23, 2018
1023c08
DEV
Mar 23, 2018
e26e5d2
DEV
Mar 23, 2018
e0cf9e9
DEV
Mar 23, 2018
bd5b67c
DEV
Mar 23, 2018
7d67c4d
DEV
Mar 24, 2018
df147f0
DEV
Mar 26, 2018
7628587
DEV
Mar 26, 2018
d78fff9
DEV
Mar 26, 2018
aaa6ef8
DEV
Mar 26, 2018
e46d527
DEV
Mar 26, 2018
6121109
DEV
Mar 26, 2018
3e25dbd
DEV
Mar 26, 2018
7a57843
DEV
Mar 26, 2018
e40fb2c
DEV
Mar 26, 2018
ec1f07c
DEV
Mar 26, 2018
617c1d7
DEV
Mar 26, 2018
9f06989
DEV
Mar 26, 2018
61e7766
DEV
Mar 26, 2018
c1e7044
DEV
Mar 26, 2018
41b00a6
DEV
Mar 26, 2018
f50ce52
DEV
Mar 26, 2018
471402d
DEV
Mar 26, 2018
116d283
DEV
Mar 26, 2018
353ab47
DEV
Mar 26, 2018
84af816
DEV
Mar 26, 2018
8405e82
DEV
Mar 26, 2018
f416e1d
DEV
Mar 26, 2018
5c48ccc
DEV
Mar 26, 2018
2146318
DEV
Mar 26, 2018
726eb89
DEV
Mar 26, 2018
8ea376d
DEV
Mar 27, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions css/toggle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*! ========================================================================
* Bootstrap Toggle: bootstrap2-toggle.css v2.2.0
* http://www.bootstraptoggle.com
* ========================================================================
* Copyright 2014 Min Hur, The New York Times Company
* Licensed under MIT
* ======================================================================== */


label.checkbox .toggle,
label.checkbox.inline .toggle {
margin-left: -20px;
margin-right: 5px;
}

.toggle {
min-width: 20px;
height: 1px;
position: relative;
overflow: hidden;
}

.toggle-group {
position: absolute;
width: 200%;
top: 0;
bottom: 0;
left: 0;
transition: left 0.35s;
-webkit-transition: left 0.35s;
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
}

.toggle.off .toggle-group {
left: -100%;
}

.toggle-on {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 50%;
margin: 0;
border: 0;
border-radius: 0;
}

.toggle-off {
position: absolute;
top: 0;
bottom: 0;
left: 50%;
right: 0;
margin: 0;
border: 0;
border-radius: 0;
}

.toggle-handle {
position: relative;
margin: 0 auto;
padding-top: 0px;
padding-bottom: 0px;
height: 100%;
width: 0px;
border-width: 0 1px;
}

.toggle-handle.btn-mini {
top: -2px;
}

.toggle-handle.btn-xs {
top: -2px;
}

.toggle.btn { min-width: 15px; }
.toggle-on.btn { padding-right: 24px; display: flex; align-items: center; }
.toggle-off.btn { padding-left: 24px; display: flex; align-items: center; }

.toggle.btn-large { min-width: 40px; }
.toggle-on.btn-large { padding-right: 35px; }
.toggle-off.btn-large { padding-left: 35px; }

.toggle.btn-lg { min-width: 40px; }
.toggle-on.btn-lg { padding-right: 35px; }
.toggle-off.btn-lg { padding-left: 35px; }


.toggle.btn-small { min-width: 25px; }
.toggle-on.btn-small { padding-right: 20px; }
.toggle-off.btn-small { padding-left: 20px; }

.toggle.btn-sm { min-width: 25px; }
.toggle-on.btn-sm { padding-right: 20px; }
.toggle-off.btn-sm { padding-left: 20px; }

.toggle.btn-mini { min-width: 20px; }
.toggle-on.btn-mini { padding-right: 12px; }
.toggle-off.btn-mini { padding-left: 12px; }

.toggle.btn-xs { min-width: 10px; }
.toggle-on.btn-xs { padding-right: 7px; }
.toggle-off.btn-xs { padding-left: 7px; }

.slow .toggle-group { transition: left 0.7s; -webkit-transition: left 0.7s; }
.fast .toggle-group { transition: left 0.1s; -webkit-transition: left 0.1s; }
.quick .toggle-group { transition: none; -webkit-transition: none; }
2 changes: 1 addition & 1 deletion js/actions/actonTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ export const POST_TO_API_FAILURE = 'POST_TO_API_FAILURE';
export const GET_FULL_GRAPH = 'GET_FULL_GRAPH';
export const GOT_FULL_GRAPH = 'GOT_FULL_GRAPH';
export const SELECT_VECTOR = 'SELECT_VECTOR';

export const SET_VECTOR_LIST = 'SET_VECTOR_LIST';
11 changes: 10 additions & 1 deletion js/actions/selectionActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Created by abradley on 15/03/2018.
*/

import {SET_TO_BUY_LIST, APPEND_TO_BUY_LIST, REMOVE_FROM_TO_BUY_LIST, GET_FULL_GRAPH, GOT_FULL_GRAPH, SELECT_VECTOR} from './actonTypes'
import {SET_TO_BUY_LIST, APPEND_TO_BUY_LIST, REMOVE_FROM_TO_BUY_LIST, GET_FULL_GRAPH, GOT_FULL_GRAPH, SET_VECTOR_LIST, SELECT_VECTOR} from './actonTypes'

export const setToBuyList = function (to_buy_list){
console.log("ACTIONS: "+ to_buy_list)
Expand Down Expand Up @@ -46,6 +46,15 @@ export const gotFullGraph = function (result){
}
}

export const setVectorList = function (vectList){
console.log("ACTIONS: "+ vectList)
return {
type: SET_VECTOR_LIST,
vector_list: vectList
}

}


export const selectVector = function (vector){
console.log("ACTIONS: "+ vector)
Expand Down
28 changes: 28 additions & 0 deletions js/components/MoleculeSlider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Created by abradley on 22/03/2018.
*/

import React from 'react';
import { connect } from 'react-redux'
import * as apiActions from '../actions/apiActions'
import {Slider} from './generalComponents'


class MoleculeSlider extends Slider{

constructor(props) {
super(props);
this.slider_name = "MOLECULE"
}
}

function mapStateToProps(state) {
return {
object_list: state.apiReducers.molecule_list,
object_on: state.apiReducers.molecule_on
}
}
const mapDispatchToProps = {
setObjectOn: apiActions.setMoleculeOn
}
export default connect(mapStateToProps, mapDispatchToProps)(MoleculeSlider);
5 changes: 4 additions & 1 deletion js/components/compoundList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import React from 'react';
import { connect } from 'react-redux'
import CompoundView from './compoundView';

const molStyle = {height: "400px",
overflow:"scroll"}

class CompoundList extends React.Component {

constructor(props) {
Expand All @@ -23,7 +26,7 @@ class CompoundList extends React.Component {
input_data["mol"]=this.props.thisMol
retArray.push(<CompoundView height={100} width={100} key={ele+"__"+key} data={input_data}/>)
}
totArray.push(<Row key={key}>{retArray}</Row>)
totArray.push(<Row style={molStyle} key={key}>{retArray}</Row>)
}
return totArray;
}
Expand Down
71 changes: 68 additions & 3 deletions js/components/generalComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
*/
import SVGInline from "react-svg-inline"
import React from 'react';
import { ListGroup, Col } from 'react-bootstrap';
import { ListGroup, Col, Pager, ProgressBar, Well } from 'react-bootstrap';
import fetch from 'cross-fetch'
import * as listTypes from './listTypes';

export function FillMe(props) {
return <h1>FILL ME UP PLEASE</h1>;
}
Expand Down Expand Up @@ -132,7 +131,6 @@ export class GenericView extends React.Component{
super(props);
this.loadFromServer = this.loadFromServer.bind(this);
this.handleClick = this.handleClick.bind(this);
this.selected_style = {width: props.width.toString+'px', height: props.height.toString()+'px', backgroundColor: "#faebcc"}
this.not_selected_style = {width: props.width.toString+'px', height: props.height.toString()+'px'}
this.old_url = ''
this.state = {isToggleOn: false, img_data: '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="50px" height="50px"><g>' +
Expand All @@ -150,6 +148,7 @@ export class GenericView extends React.Component{
'<circle cx="25" cy="6.6987298" r="5" transform="translate(5 5)"/> ' +
'<animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 55 55" to="360 55 55" dur="3s" repeatCount="indefinite" /> </g> ' +
'</svg>'}
this.selected_style = {width: props.width.toString+'px', height: props.height.toString()+'px', backgroundColor: "#B7C185"}
}

loadFromServer(width,height) {
Expand Down Expand Up @@ -195,4 +194,70 @@ export class GenericView extends React.Component{
this.current_style = this.state.isToggleOn ? this.selected_style : this.not_selected_style;
return <div onClick={this.handleClick} style={this.current_style}>{svg_image}</div>
}
}

export class Slider extends React.Component{

constructor(props) {
super(props);
this.handleForward = this.handleForward.bind(this);
this.handleBackward = this.handleBackward.bind(this);
this.handleChange = this.handleChange.bind(this);
this.checkForUpdate = this.checkForUpdate.bind(this);
this.state = {currentlySelected: -1, progress: 0}
this.slider_name = "DEFAULT"
}

render() {
this.progress = this.state.progress;
return <Well bsSize="small">
<h3>{this.slider_name} Selector</h3>
<Pager>
<Pager.Item onClick={this.handleBackward}>Previous</Pager.Item>{' '}
<Pager.Item onClick={this.handleForward}>Next</Pager.Item>
</Pager>
<ProgressBar active now={this.state.progress}/>
</Well>;
}

handleForward(){
var selected = this.state.currentlySelected;
if (selected<this.props.object_list.length-1){
selected+=1
this.handleChange(selected);
}
}
handleBackward(){
var selected = this.state.currentlySelected;
if (selected>0){
selected-=1
this.handleChange(selected);
}
}
handleChange(selected){
var progress = 100*selected/(this.props.object_list.length-1)
this.setState(prevState => ({currentlySelected: selected, progress: progress}))
this.props.setObjectOn(this.props.object_list[selected].id)
}

checkForUpdate(){
if (this.props.object_list != []) {
var selected;
var counter =0
for (var index in this.props.object_list) {
if (this.props.object_list[index].id == this.props.object_on) {
selected = counter;
}
counter+=1
}
if(selected!=undefined && selected !=this.state.currentlySelected) {
this.handleChange(selected);
}
}
}

componentDidMount(){
setInterval(this.checkForUpdate,50);
}

}
90 changes: 86 additions & 4 deletions js/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,92 @@
*/
import React from 'react';
import { Navbar, Nav, NavItem, NavDropdown, MenuItem} from 'react-bootstrap'
import { Typeahead } from 'react-typeahead';
import * as apiActions from '../actions/apiActions'
import * as nglActions from '../actions/nglLoadActions'
import { connect } from 'react-redux'
import * as nglObjectTypes from '../components/nglObjectTypes'

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);
}

getViewUrl(pk,get_view){
var base_url = window.location.protocol + "//" + window.location.host
base_url += "/viewer/"+get_view+"/"+pk.toString()+"/"
return base_url
}

generateTargetObject(targetData){
// Now deal with this target
var prot_to_load = targetData.protein_set[0]
if(prot_to_load!=undefined) {
var out_object = {
"name": "PROTEIN_" + prot_to_load.toString(),
"prot_url": this.getViewUrl(prot_to_load, "prot_from_pk"),
"OBJECT_TYPE": nglObjectTypes.PROTEIN
}
return out_object
}
return undefined;
}


getTargetList(){
var newArray = new Array()
for(var key in this.props.target_id_list){
newArray.push(this.props.target_id_list[key].title)
}
return newArray;
}


selectTarget(option){
for(var key in this.props.target_id_list){
if(this.props.target_id_list[key].title==option){
this.props.setTargetOn(this.props.target_id_list[key].id);
var targObject = this.generateTargetObject(this.props.target_id_list[key]);
this.props.setMoleculeList([]);
for(var key in this.props.objectsInView){
this.props.deleteObject(this.props.objectsInView[key]);
}
if(targObject) {
this.props.loadObject(targObject);
}
break;
}
}
}



export default class Header extends React.Component {
render() {
return <div>
</div>
return <Navbar>
<Typeahead
labelKey="name"
onOptionSelected={this.selectTarget}
options={this.getTargetList()}
placeholder="Choose a target..."
/>
</Navbar>
}
}

function mapStateToProps(state) {
return {
target_id_list: state.apiReducers.target_id_list,
target_on: state.apiReducers.target_on
}
}
}
const mapDispatchToProps = {
setMoleculeList: apiActions.setMoleculeList,
deleteObject: nglActions.deleteObject,
loadObject: nglActions.loadObject,
setTargetOn: apiActions.setTargetOn,
}
export default connect(mapStateToProps, mapDispatchToProps)(Header)
2 changes: 1 addition & 1 deletion js/components/menu.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Created by abradley on 20/03/2018.
*/
import {slide as Menu} from 'react-burger-menu';
import {fallDown as Menu} from 'react-burger-menu';
import {decorator as reduxBurgerMenu} from 'redux-burger-menu';

export default reduxBurgerMenu(Menu);
Loading