diff options
Diffstat (limited to 'cmd/web/js/poloniex.jsx')
-rw-r--r-- | cmd/web/js/poloniex.jsx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/cmd/web/js/poloniex.jsx b/cmd/web/js/poloniex.jsx new file mode 100644 index 0000000..877198d --- /dev/null +++ b/cmd/web/js/poloniex.jsx | |||
@@ -0,0 +1,49 @@ | |||
1 | var Api = require('./api.js').Api; | ||
2 | var App = require('./app.js'); | ||
3 | var classNames = require('classnames'); | ||
4 | |||
5 | module.exports.PoloniexForm = React.createClass({ | ||
6 | getInitialState: function() { | ||
7 | return {'hideMsg': true, 'msg': '', 'msgOk': false, 'apiSecret': this.props.apiSecret, 'apiKey': this.props.apiKey}; | ||
8 | }, | ||
9 | handleSubmit: function(e) { | ||
10 | Api.Call('UPDATE_MARKET', {'key': this.state.apiKey, 'secret': this.state.apiSecret, 'name': 'poloniex'}, function(err, status, data) { | ||
11 | if (err) { | ||
12 | console.error(err, data); | ||
13 | this.displayMessage(App.errorCodeToMessage(err.code), false); | ||
14 | return; | ||
15 | } | ||
16 | |||
17 | this.displayMessage('OK', true); | ||
18 | |||
19 | }.bind(this)); | ||
20 | e.preventDefault(); | ||
21 | }, | ||
22 | handleApiKeyChange: function(event) { | ||
23 | this.setState({'apiKey': event.target.value}); | ||
24 | }, | ||
25 | handleApiSecretChange: function(event) { | ||
26 | this.setState({'apiSecret': event.target.value}); | ||
27 | }, | ||
28 | hideMessage: function() { | ||
29 | this.setState({'hideMsg': true}); | ||
30 | }, | ||
31 | displayMessage: function(msg, ok) { | ||
32 | this.setState({'msg': msg, 'msgOk': ok, 'hideMsg': false}); | ||
33 | }, | ||
34 | render: function() { | ||
35 | var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk}); | ||
36 | return ( | ||
37 | <div className='row justify-content-center api-credentials-form'> | ||
38 | <div className='col-lg-offset-4 col-lg-4 col-md-offset-4 col-md-4 col-sm-offset-4 col-sm-4 col-xs-offset-1 col-xs-10'> | ||
39 | <form role='form' onSubmit={this.handleSubmit}> | ||
40 | <input className='form-control' type='text' placeholder='apiKey' value={this.state.apiKey} onChange={this.handleApiKeyChange} /> | ||
41 | <input className='form-control' type='text' placeholder='apiSecret' value={this.state.apiSecret} onChange={this.handleApiSecretChange} /> | ||
42 | <input className='form-control submit' type='submit' value='Save' /> | ||
43 | <div className={cName} ref='message'>{this.state.msg}</div> | ||
44 | </form> | ||
45 | </div> | ||
46 | </div> | ||
47 | ); | ||
48 | } | ||
49 | }); | ||