Skip to content

Commit f4171f7

Browse files
committed
betted
1 parent 9350f67 commit f4171f7

9 files changed

Lines changed: 33 additions & 26 deletions

File tree

server/compute.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ module.exports = function compute({ user, segments }, ship, sourceCode) {
3434

3535
sandbox.console = { log, warn: log, error: logError };
3636

37-
3837
const code = sourceCode || ship.private_settings.code || '';
3938

4039
try {

server/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const notifHandler = NotifHandler({
3333
function fetchUser(req, res, next) {
3434
req.hull = req.hull || {};
3535
const { client, ship } = req.hull;
36-
let { userId, userEmail, user } = req.body || {};
36+
let { userId, userSearch, user } = req.body || {};
3737

3838
console.warn("Starting fetchUser with ", req.body);
3939

@@ -43,21 +43,25 @@ function fetchUser(req, res, next) {
4343
if (userId) {
4444
console.warn("Getting user with ID", userId)
4545
userPromise = client.get(userId + '/user_report')
46-
} else if (userEmail) {
46+
} else {
4747

4848
const params = {
4949
query: {
50-
multi_match: {
51-
query: userEmail,
52-
fields: ["name", "name.exact", "email", "email.exact", "contact_email", "contact_email.exact"]
53-
}
50+
match_all: {}
5451
},
5552
raw: true,
5653
page: 1,
5754
per_page: 1
5855
};
5956

60-
console.warn("Searching user with email", {userEmail, params: JSON.stringify(params)})
57+
if (userSearch) {
58+
params.query = { multi_match: {
59+
query: userSearch,
60+
fields: ["name", "name.exact", "email", "email.exact", "contact_email", "contact_email.exact"]
61+
} };
62+
}
63+
64+
console.warn("Searching user with email", {userSearch, params: JSON.stringify(params)})
6165

6266
userPromise = client.post('search/user_reports', params).then(res => {
6367
return res.data[0];

src/app.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ export default class App extends Component {
1818

1919
buildState(props) {
2020

21-
const userEmail = props.user && props.user.user && props.user.user.email;
21+
const userSearch = props.user && props.user.user && props.user.user.email;
2222
const state = {
2323
input: { value: JSON.stringify(props.user || {}, ' ', 2), dirty: false },
2424
code: { value: this.getCode(props), dirty: false },
2525
result: props.result,
2626
loading: false,
27-
userEmail
27+
userSearch
2828
};
2929
return state;
3030
}
@@ -61,7 +61,7 @@ export default class App extends Component {
6161
const { result, input, code, loading } = this.state;
6262

6363
return <Grid fluid={true}>
64-
<Controls loading={this.state.loading} onRun={this.handleCompute.bind(this)} />
64+
<Controls loading={this.state.loading} userSearch={this.state.userSearch} onRun={this.handleCompute.bind(this)} />
6565
<Row>
6666
<Col md={4}>
6767
<UserPane loading={this.state.loading} onChange={this.handleChange.bind(this, 'input')} {...input} />

src/code/index.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export default class Code extends Component {
2222
const options = {
2323
mode: 'javascript',
2424
lineNumbers: true,
25-
readOnly: !!this.props.loading,
2625
gutters: ["CodeMirror-lint-markers"],
2726
lint: true
2827
};

src/controls/index.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { Button, Grid, Row, Col } from 'react-bootstrap';
44

55
export default class Controls extends Component {
66

7-
handleSearch(userEmail) {
8-
if (userEmail && !this.props.loading) {
9-
this.props.onRun({ userEmail });
7+
handleSearch(userSearch) {
8+
if (userSearch && !this.props.loading) {
9+
this.props.onRun({ userSearch });
1010
}
1111
}
1212

@@ -17,11 +17,14 @@ export default class Controls extends Component {
1717

1818
render() {
1919

20-
const { loading, onRun, userEmail } = this.props;
20+
const { loading, onRun, userSearch } = this.props;
2121

2222
return (
2323
<Row>
24-
<Col md={4}><SearchForm loading={loading} userEmail={userEmail} onSubmit={this.handleSearch.bind(this)} /></Col>
24+
<Col md={4}>
25+
<SearchForm loading={loading}
26+
userSearch={userSearch}
27+
onSubmit={this.handleSearch.bind(this)} /></Col>
2528
<Col md={4}></Col>
2629
<Col md={4}>
2730
<Button bsStyle="primary" className="pull-right" onClick={this.handleRun.bind(this)}>

src/controls/search-form.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,31 @@ export default class SearchForm extends Component {
44

55
constructor(props) {
66
super(props);
7-
this.state = { userEmail: props.userEmail };
7+
this.state = { userSearch: props.userSearch };
88
}
99

1010
handleEmailChange(e) {
1111
if (e && e.target) {
12-
this.setState({ userEmail: e.target.value });
12+
this.setState({ userSearch: e.target.value });
1313
}
1414
}
1515

1616
handleSubmit(e) {
1717
if (e && e.preventDefault) e.preventDefault();
18-
this.props.onSubmit(this.state.userEmail);
18+
this.props.onSubmit(this.state.userSearch);
1919
}
2020

2121
componentWillReceiveProps(nextProps) {
22-
if (nextProps.userEmail && nextProps.userEmail != this.props.userEmail) {
23-
this.setState({ userEmail });
22+
const { userSearch } = nextProps;
23+
if (userSearch && userSearch != this.props.userSearch) {
24+
this.setState({ userSearch });
2425
}
2526
}
2627

2728
render() {
2829
return <form className="form" onSubmit={this.handleSubmit.bind(this)}>
2930
<div className="input-group">
30-
<input type="text" placeholder="Name or Email" value={this.props.userEmail} onChange={this.handleEmailChange.bind(this)} className="form-control form-control" />
31+
<input type="text" placeholder="Name or Email" value={this.state.userSearch} onChange={this.handleEmailChange.bind(this)} className="form-control form-control" />
3132
<div className="input-group-btn">
3233
<a className="btn btn-primary" onClick={this.handleSubmit.bind(this)}>
3334
Search user

src/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import Promise from 'bluebird';
2929

3030
Hull.ready((hull, user, app, org) => {
3131
const root = document.getElementById('app');
32-
compute({ userId: user.id }).then((props) => {
32+
const userId = user && user.id;
33+
compute({ userId }).then((props) => {
3334
ReactDOM.render(<App {...props} onCompute={compute} />, root);
3435
}, (err) => {
3536
console.warn("Oops terrible error", err);

src/user/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default class UserPane extends Component {
77
return <div>
88
<Codemirror value={this.props.value}
99
onChange={this.props.onChange}
10-
options={{ mode: 'javascript', readOnly: !!this.props.loading }} />
10+
options={{ mode: 'javascript' }} />
1111
</div>;
1212
}
1313
}

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var path = require('path');
22
var webpack = require('webpack');
33

44
module.exports = {
5-
devtool : '#cheap-eval-source-map',
5+
devtool : '#source-map',
66
entry: {
77
admin: path.join(__dirname, 'src/index.jsx'),
88
},

0 commit comments

Comments
 (0)