Skip to content

Commit

Permalink
Merge branch 'JacobPlaster-cancel-order-in-table'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Plaster committed Aug 2, 2019
2 parents b943ee6 + b6ad1af commit da741a3
Show file tree
Hide file tree
Showing 57 changed files with 672 additions and 341 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"import/no-named-as-default-member": 0,
"no-underscore-dangle": 0,
"no-console": 0,
"no-empty-function": 0
"no-empty-function": 0,
"arrow-body-style": 0
},
"settings": {
"import/resolver": {
Expand Down
26 changes: 19 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"lint": "eslint src/**/*.js",
"electron": "electron .",
"electron-dev": "electron .",
"electron-prod": "nohup electron . > logs.log",
"dist": "build --mac --win --linux -c.extraMetadata.main=build/electron.js --publish never"
},
"author": "Bitfinex",
Expand Down Expand Up @@ -73,9 +74,8 @@
"@blueprintjs/core": "3.1.0",
"@blueprintjs/datetime": "3.1.0",
"@blueprintjs/select": "3.1.0",
"dotenv": "8.0.0",
"axios": "^0.18.0",
"socks-proxy-agent": "^4.0.2",
"bfx-hf-algo": "git+https://github.com/bitfinexcom/bfx-hf-algo.git",
"bfx-hf-ext-plugin-bitfinex": "git+https://github.com/bitfinexcom/bfx-hf-ext-plugin-bitfinex.git",
"bfx-hf-indicators": "bitfinexcom/bfx-hf-indicators",
"bfx-hf-models": "git+https://github.com/bitfinexcom/bfx-hf-models.git",
Expand All @@ -96,6 +96,7 @@
"express-request-proxy": "^2.2.2",
"lodash": "^4.17.11",
"node-sass-chokidar": "^1.3.0",
"nohup": "^0.1.0",
"prop-types": "^15.7.2",
"react": "^16.4.0",
"react-codemirror2": "^5.1.0",
Expand All @@ -114,6 +115,7 @@
"react-virtualized": "^9.19.1",
"redux": "^4.0.0",
"redux-saga": "^0.16.0",
"redux-thunk": "^2.3.0",
"socks-proxy-agent": "^4.0.2",
"url": "^0.11.0",
"wait-on": "^3.2.0"
Expand Down
34 changes: 30 additions & 4 deletions scripts/start-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const run = async () => {
if (hfServer) {
hfServer.close()
}
debug(SOCKS_PROXY_URL)
const creds = await Credential.get(CRED_KEY)
if (creds) {
restAPI = new RESTv2({
Expand All @@ -66,6 +65,7 @@ const run = async () => {
proxy: true,
asPort: 9999,
dsPort: 8899,
hfPort: 7799,
port: 10000,
agent: SOCKS_PROXY_URL ? new SocksProxyAgent(SOCKS_PROXY_URL) : null,
restURL: REST_URL,
Expand All @@ -84,7 +84,7 @@ const run = async () => {
secret: creds.secret,
})
})

app.post('/api-key', async (req, res) => {
const { key, secret } = req.body

Expand All @@ -103,15 +103,41 @@ const run = async () => {
secret,
})
} catch (error) {
console.log(error)
console.error(error)
return res.status(500).json({ error: error.message })
}
startHFServer()
return res.json({ key, secret })
})

app.post('/api-key-update', async (req, res) => {
const { key, secret } = req.body
debug(key, secret)

if (!_isString(key)) {
return res.status(400).json({ error: 'No API key provided' })
}

if (!_isString(secret)) {
return res.status(400).json({ error: 'No API secret provided' })
}

try {
debug(await Credential.update(CRED_KEY, {
cid: CRED_KEY,
key,
secret,
}))
} catch (error) {
debug('===============', error)
return res.status(500).json({ error: error.message })
}
startHFServer()
return res.json({ key, secret })
})

app.post('/reconnect-bfx', async (req, res) => {
// await startHFServer()
await startHFServer()
res.status(200)
})

Expand Down
117 changes: 117 additions & 0 deletions src/components/ADAOForm/AlgoOrderForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import React, { PureComponent } from 'react'
import Modal from 'react-modal'
import { Icon } from '@blueprintjs/core'
import { NotificationManager } from 'react-notifications'

import { store } from '../../StoreWrapper'

const customStyles = {
content: {
top: '40%',
left: '50%',
bottom: 'auto',
width: '50%',
marginRight: '-50%',
transform: 'translate(-50%, -50%)',
background: '#161E24',
border: 'none',
position: 'relative',
},
overlay: {
background: 'rgba(0,0,0,0.5)',
},
}

export default class ModalForm extends PureComponent {
state = {
modalIsOpen: false,
fileName: '',
}

toggleModal() {
const { modalIsOpen } = this.state
this.setState({
modalIsOpen: !modalIsOpen,
fileName: '',
})
}

handleFile(e) {
if (e.target.files[0]) {
const { name } = e.target.files[0]
this.setState({ fileName: name })
}
}

handleSubmit(e) {
e.preventDefault()
const { algoName, algoDesc } = e.target

/* POST data to HF server (this is pseudo-code)
const options = {
name: algoName.value,
description: algoDesc.value,
file: this.state.file,
}
axios.('POST','some-back-url', options)
*/

store.dispatch({
type: 'ADD_ALGO_ORDER',
payload: {
algoOrder: [42, 'bfx-ping_pong', false, null, 1561361614648],
},
})
NotificationManager.success('Algo order Succesfuly added!', 'Success!')
this.toggleModal()
}

render() {
const { modalIsOpen, fileName } = this.state || {}
return (
<div>
<button
type='button'
className='hfui__add-order-btn'
onClick={() => this.toggleModal()
}
>
Create Algo Order
</button>
<Modal
isOpen={modalIsOpen}
onAfterOpen={this.afterOpenModal}
onRequestClose={this.closeModal}
style={customStyles}
contentLabel='Example Modal'
>
<Icon
className='hfui__close-modal-button'
icon='cross'
key='cross'
onClick={() => this.toggleModal()}
/>
<div>Create Algo Order</div>
<form className='hfui_modal-algo-form' onSubmit={e => this.handleSubmit(e)}>
{/* <input name='algoName' type='text' placeholder='Name of algo order' />
<input name='algoDesc' type='text' placeholder='Short description' />
<label>
<div className='button'>Upload File</div>
<div className='filesContainer'>{fileName}</div>
<input type='file' accept='.js' size='60' onChange={e => this.handleFile(e)} />
</label> */}
<input type='text' placeholder='amount btc'></input>
<input type='text' placeholder='slice amount'></input>
<input type='text' placeholder='AMOUNT DISTORTION %'></input>
<input type='text' placeholder='SLICE INTERVAL (SEC)'></input>
<input type='text' placeholder='SLICE DISTORTION %'></input>

<input name='algo_order_submit' type='submit' value='Submit' className='hfui__add-order-btn' />
</form>
</Modal>
</div>
)
}
}
82 changes: 82 additions & 0 deletions src/components/ADAOForm/_AlgoOrderForm.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
.hfui__close-modal-button {
float: right;
}

.hfui_modal-algo-form input, label{
display: block;
width: 100%;
margin-top: 10px ;
float: left;
margin-top: 20px;
}

.hfui_modal-algo-form label {
display: block;
height: 30px;
margin-right: 0px;
padding-right: 0px;
}

label {
background: #2c3940;
color: white;
}


input[type="file"] {
display: none;
}

.button {
width: 30%;
height: 100%;
display: block;
float: left;
margin: auto;
text-align: center;
justify-content: center;
margin-top: 1%;
}
.filesContainer{
float: right;
width:70%;
height: 100%;
display: block;
background: white;
color: #c1c2c3;
text-align: center;
padding-top: 1%;
}
input[type='text'], input[type='submit'] {
padding: 5px 10px 5px 10px;
}
input[type='text'] {
background: #2c3940;
border-style: none;
border-color: #5b91b2;
}
input[type='submit'] {
max-width: 30%;
margin-left: 33%;
margin-top: 30px;
text-transform:uppercase;
}


.hfui__add-order-btn {
border: none;
background: #5b91b2;
color: #dbdfe3;
padding: 5px 10px 5px 10px;
margin-top: '15px';
text-transform: 'uppercase';
outline: none;
}

.hfui__add-order-btn:active {
outline: none;
}

button:focus {
outline: 0;
}
3 changes: 3 additions & 0 deletions src/components/ADAOForm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import AlgoOrderFormView from './AlgoOrderForm'

export default AlgoOrderFormView
2 changes: 1 addition & 1 deletion src/components/APIComboDialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class APIComboDialog extends React.Component {
const { key, secret } = this.state

return (
<div className='hfui-api-combo-dialog'>
<div className='hfui-api-combo-dialog-menu'>
<Card elevation={Elevation.TWO}>
<p>No Bitfinex API key/secret configured. Enter your key combination below to connect to the Bitfinex API.</p>

Expand Down
Loading

0 comments on commit da741a3

Please sign in to comment.