Skip to content

Commit

Permalink
Merge pull request #1 from xchem/dev
Browse files Browse the repository at this point in the history
Merge a load of development
  • Loading branch information
abradle authored Mar 21, 2018
2 parents 102166c + 627bf58 commit 14b6f90
Show file tree
Hide file tree
Showing 32 changed files with 1,463 additions and 345 deletions.
12 changes: 12 additions & 0 deletions css/index.css

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions js/actions/actonTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ export const GET_FROM_API = 'GET_FROM_API';
export const GET_FROM_API_SUCCESS = 'GET_FROM_API_SUCCESS';
export const GET_FROM_API_FAILURE = 'GET_FROM_API_FAILURE';
export const RECEIVE_DATA_FROM_API = 'RECEIVE_DATA_FROM_API';
export const SET_TARGET_ID_LIST = 'SET_TARGET_ID_LIST';
export const SET_TARGET_ON = 'SET_TARGET_ON';
export const SET_MOL_GROUP_LIST = 'SET_MOL_GROUP_LIST';
export const SET_MOLECULE_LIST = 'SET_MOLECULE_LIST';
export const SET_MOL_GROUP_ON = 'SET_MOL_GROUP_ON';
export const OBJECT_LOADING = 'OBJECT_LOADING';
export const DELETE_OBJECT_TYPE = 'DELETE_OBJECT_TYPE';
export const SET_TO_BUY_LIST = 'SET_TO_BUY_LIST:';
export const APPEND_TO_BUY_LIST = 'APPEND_TO_BUY_LIST';
export const REMOVE_FROM_TO_BUY_LIST = 'REMOVE_FROM_TO_BUY_LIST';
export const POST_TO_API = 'POST_TO_API';
export const POST_TO_API_SUCCESS = 'POST_TO_API_SUCESS';
export const POST_TO_API_FAILURE = 'POST_TO_API_FAILURE';

// Data related to network
export const GET_FULL_GRAPH = 'GET_FULL_GRAPH';
export const GOT_FULL_GRAPH = 'GOT_FULL_GRAPH';
export const SELECT_VECTOR = 'SELECT_VECTOR';

69 changes: 57 additions & 12 deletions js/actions/apiActions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/**
* Created by abradley on 03/03/2018.
*/
import {LOAD_TARGETS, LOAD_MOLECULES, LOAD_MOL_GROUPS, GET_FROM_API, GET_FROM_API_FAILURE, GET_FROM_API_SUCCESS, RECEIVE_DATA_FROM_API} from './actonTypes'

import {LOAD_TARGETS, SET_TARGET_ON, SET_TARGET_ID_LIST, SET_MOLECULE_LIST,
SET_MOL_GROUP_LIST, SET_MOL_GROUP_ON, LOAD_MOLECULES,
LOAD_MOL_GROUPS, GET_FROM_API, GET_FROM_API_FAILURE,
GET_FROM_API_SUCCESS, RECEIVE_DATA_FROM_API} from './actonTypes'

export const loadTargets = function (project_id=undefined) {
console.log("ACTIONS: " + project_id);
Expand All @@ -21,6 +23,46 @@ export const loadMolGroups = function (target_id,group_type="MC") {
};
}

export const setTargetIdList = function (input_json) {
console.log("ACTIONS: " + input_json);
return {
type: SET_TARGET_ID_LIST,
target_id_list: input_json
};
}

export const setTargetOn = function (target_id){
console.log("ACTIONS: "+ target_id)
return {
type: SET_TARGET_ON,
target_on: target_id
}
}

export const setMolGroupOn = function (mol_group_id){
console.log("ACTIONS: "+ mol_group_id)
return {
type: SET_MOL_GROUP_ON,
mol_group_on: mol_group_id
}
}

export const setMolGroupList = function (mol_group_list){
console.log("ACTIONS: "+ mol_group_list)
return {
type: SET_MOL_GROUP_LIST,
mol_group_list: mol_group_list
}
}

export const setMoleculeList = function (molecule_list){
console.log("ACTIONS: "+ molecule_list)
return {
type: SET_MOLECULE_LIST,
molecule_list: molecule_list
}
}

export const loadMolecules = function (target_id=undefined,group_id=undefined) {
console.log("ACTIONS: " + target_id + " " + group_id);
return {
Expand All @@ -31,14 +73,12 @@ export const loadMolecules = function (target_id=undefined,group_id=undefined) {
}


export const getFromApi = function (request_url, get_params, element_type){
console.log("ACTIONS: " + request_url);
export const getFromApi = function (element_type){
console.log("ACTIONS: " + element_type);
return {
type: GET_FROM_API,
isFetching: true,
get_params: get_params,
element_type: element_type,
url: request_url
element_type: element_type
}
}

Expand Down Expand Up @@ -71,12 +111,17 @@ export const receiveDataFromApi = function (json, element_type) {
}
}

export function fetchDataFillDiv(input_type, element_type=null) {
export function renderData(element_type, div_id) {

}

export function fetchDataFillDiv(url) {
return dispatch => {
// Set the URL and the get params
const url = getFromApi
return fetch(url)
.then(response => response.json())
.then(json => dispatch(receiveDataFromApi(json, element_type)))
return fetch(url)
.then(response => response.json(),
error => console.log('An error occurred.', error)
)
.then(json => dispatch(receiveDataFromApi(json, element_type)))
}
}
22 changes: 20 additions & 2 deletions js/actions/nglLoadActions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Created by abradley on 03/03/2018.
*/
import {LOAD_OBJECT, LOAD_OBJECT_SUCCESS, LOAD_OBJECT_FAILURE,
DELETE_OBJECT, DELETE_OBJECT_FAILURE, DELETE_OBJECT_SUCCESS} from './actonTypes'
import {LOAD_OBJECT, LOAD_OBJECT_SUCCESS, LOAD_OBJECT_FAILURE, OBJECT_LOADING,
DELETE_OBJECT, DELETE_OBJECT_FAILURE, DELETE_OBJECT_SUCCESS,DELETE_OBJECT_TYPE} from './actonTypes'


export const loadObject = function (group) {
Expand All @@ -13,6 +13,15 @@ export const loadObject = function (group) {
};
}

export const objectLoading = function (group){
console.log("ACTIONS: " + group);
return {
type: OBJECT_LOADING,
group: group
};

}

export const loadObjectSuccess = function (group) {
console.log("ACTIONS: " + group);
return {
Expand All @@ -22,6 +31,15 @@ export const loadObjectSuccess = function (group) {
};
}

export const deleteObjectType = function (object_type) {
console.log("ACTIONS: " + object_type);
return {
type: DELETE_OBJECT_TYPE,
object_type: object_type
}

}

export const loadObjectFailure = function (group) {
console.log("ACTIONS: " + group);
return {
Expand Down
56 changes: 56 additions & 0 deletions js/actions/selectionActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* 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'

export const setToBuyList = function (to_buy_list){
console.log("ACTIONS: "+ to_buy_list)
return {
type: SET_TO_BUY_LIST,
to_buy_list: to_buy_list
}
}

export const appendToBuyList = function (item){
console.log("ACTIONS: "+ item)
return {
type: APPEND_TO_BUY_LIST,
item: item
}
}

export const removeFromToBuyList = function (item){
console.log("ACTIONS: "+ item)
return {
type: REMOVE_FROM_TO_BUY_LIST,
item: item
}
}

export const getFullGraph = function (item) {
console.log("ACTIONS: " + item)
return {
type: GET_FULL_GRAPH,
item: item
}
}



export const gotFullGraph = function (result){
console.log("ACTIONS: "+ result)
return {
type: GOT_FULL_GRAPH,
input_mol_dict: result
}
}


export const selectVector = function (vector){
console.log("ACTIONS: "+ vector)
return {
type: SELECT_VECTOR,
vector: vector
}
}
132 changes: 0 additions & 132 deletions js/components/apiComponents.js

This file was deleted.

41 changes: 41 additions & 0 deletions js/components/compoundList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Created by abradley on 15/03/2018.
*/
import { ListGroupItem, ListGroup, Col, Row} from 'react-bootstrap';
import React from 'react';
import { connect } from 'react-redux'
import CompoundView from './compoundView';

class CompoundList extends React.Component {

constructor(props) {
super(props);
}

render() {
var totArray = new Array()
for(var key in this.props.moleculeList){
var retArray = new Array();
for (var ele in this.props.moleculeList[key]){
var input_data = {}
input_data["smiles"]=this.props.moleculeList[key][ele]
input_data["vector"]=key.split("_")[0]
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>)
}
return totArray;
}
}
function mapStateToProps(state) {
return {
moleculeList: state.selectionReducers.this_vector_list,
thisMol: state.selectionReducers.to_query
}
}
const mapDispatchToProps = {

}

export default connect(mapStateToProps, mapDispatchToProps)(CompoundList);
Loading

0 comments on commit 14b6f90

Please sign in to comment.