Skip to content

Commit 99cb69d

Browse files
committed
some tweaks for react going
1 parent a0738fc commit 99cb69d

28 files changed

+505
-215
lines changed

.babelrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": ["es2015", "react"],
3+
"plugins": [
4+
"react-require"
5+
]
6+
}

.eslintrc

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"node": true
5+
},
6+
"rules": {
7+
"array-bracket-spacing": [2, "never"],
8+
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
9+
"camelcase": [2, { "properties": "never" }],
10+
"comma-dangle": [2, "never"],
11+
"comma-spacing": [2, { "before": false, "after": true }],
12+
"consistent-return": 0,
13+
"curly": [2, "multi-line"],
14+
"dot-notation": [2, { "allowKeywords": true, "allowPattern": "^[a-z]+(_[a-z]+)+$" }],
15+
"eol-last": 0,
16+
"eqeqeq": [2, "allow-null"],
17+
"handle-callback-err": 2,
18+
"indent": [2, 4, { "SwitchCase": 1 }],
19+
"key-spacing": [1, { "beforeColon": false, "afterColon": true }],
20+
"linebreak-style": [2, "unix"],
21+
"max-len": [1, 140, 4],
22+
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
23+
"new-parens": 0,
24+
"no-alert": 0,
25+
"no-array-constructor": 2,
26+
"no-caller": 2,
27+
"no-case-declarations": 2,
28+
"no-catch-shadow": 0,
29+
"no-cond-assign": [2, "except-parens"],
30+
"no-console": 0,
31+
"no-constant-condition": 2,
32+
"no-control-regex": 2,
33+
"no-debugger": 2,
34+
"no-delete-var": 2,
35+
"no-dupe-args": 2,
36+
"no-dupe-keys": 2,
37+
"no-duplicate-case": 2,
38+
"no-empty": 2,
39+
"no-empty-character-class": 2,
40+
"no-empty-label": 2,
41+
"no-empty-pattern": 2,
42+
"no-eval": 2,
43+
"no-ex-assign": 2,
44+
"no-extend-native": 2,
45+
"no-extra-bind": 2,
46+
"no-extra-boolean-cast": 2,
47+
"no-extra-parens": 0,
48+
"no-fallthrough": 2,
49+
"no-floating-decimal": 2,
50+
"no-func-assign": 2,
51+
"no-implied-eval": 2,
52+
"no-inner-declarations": 2,
53+
"no-invalid-regexp": 2,
54+
"no-iterator": 2,
55+
"no-label-var": 2,
56+
"no-labels": 0,
57+
"no-lone-blocks": 0,
58+
"no-loop-func": 0,
59+
"no-mixed-spaces-and-tabs": [2, false],
60+
"no-multi-spaces": 2,
61+
"no-multi-str": 0,
62+
"no-multiple-empty-lines": [2, { "max": 2 }],
63+
"no-native-reassign": 2,
64+
"no-negated-in-lhs": 2,
65+
"no-new": 0,
66+
"no-new-func": 2,
67+
"no-new-object": 2,
68+
"no-new-wrappers": 2,
69+
"no-obj-calls": 2,
70+
"no-octal": 2,
71+
"no-octal-escape": 2,
72+
"no-process-exit": 0,
73+
"no-proto": 2,
74+
"no-redeclare": 2,
75+
"no-regex-spaces": 2,
76+
"no-restricted-syntax": [2, "WithStatement"],
77+
"no-return-assign": [2, "always"],
78+
"no-script-url": 2,
79+
"no-sequences": 2,
80+
"no-shadow": 0,
81+
"no-shadow-restricted-names": 2,
82+
"no-spaced-func": 2,
83+
"no-sparse-arrays": 2,
84+
"no-trailing-spaces": [2, { "skipBlankLines": false }],
85+
"no-undef": 2,
86+
"no-undef-init": 2,
87+
"no-underscore-dangle": 0,
88+
"no-unused-expressions": 0,
89+
"no-unused-vars": 2,
90+
"no-use-before-define": [1, "nofunc"],
91+
"no-with": 2,
92+
"object-curly-spacing": [2, "always"],
93+
"one-var": [2, "never"],
94+
"quote-props": 0,
95+
"quotes": [2, "single", "avoid-escape"],
96+
"semi": 2,
97+
"semi-spacing": 0,
98+
"space-before-blocks": [2, "always"],
99+
"space-before-function-paren": [2, { "anonymous": "always", "named": "never" }],
100+
"space-infix-ops": 2,
101+
"space-return-throw-case": 2,
102+
"space-unary-ops": 0,
103+
"spaced-comment": [1, "always"],
104+
"strict": 0,
105+
"use-isnan": 2,
106+
"valid-typeof": 2,
107+
"yoda": [2, "never"]
108+
}
109+
}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ nohup.out
1010
/.settings
1111
/RUNNING_PID
1212
/bin/
13+
logs
14+
app/assets/javascripts/build
15+
node_modules

.jshintrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"-W099": true, // allowed mixed tabs and spaces
3+
"-W030": true, // allowed mixed tabs and spaces
4+
"asi": true // allowed mixed tabs and spaces
5+
}

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## Validation Framework
22

3+
#### To prepare javascript
4+
```
5+
npm install
6+
```
7+
Note: I'm transitioning from Angular to React, so it may be messy for a while, until everything is converted to React.
8+
9+
310
#### To compile
411

512
```
@@ -23,4 +30,4 @@ sbt "run -Dconfig.file=/opt/conf/prod.conf"
2330
sbt -jvm-debug 9999 "run -Dconfig.file=/opt/conf/prod.conf"
2431
```
2532

26-
Then setup a new Debug Configuration, as a Remote Java Application on this project on localhost:9999
33+
Then setup a new Debug Configuration, as a Remote Java Application on this project on localhost:9999

app/assets/javascripts/app.jsx

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react';
2+
import { render } from 'react-dom';
3+
4+
render((
5+
<div>
6+
<h1>app2</h1>
7+
</div>), document.getElementById("app2"));

app/assets/javascripts/cohorts.jsx

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import ReactDOM from 'react-dom';
2+
import React from 'react';
3+
import axios from 'axios';
4+
5+
import CohortList from './components/CohortList.jsx';
6+
7+
class App extends React.Component {
8+
constructor(props) {
9+
super(props);
10+
this.state = {
11+
cohorts : []
12+
};
13+
}
14+
15+
componentDidMount() {
16+
axios.get("/cohorts")
17+
.then((response) => {
18+
this.setState(prevState => ({
19+
cohorts : reponse.data
20+
}));
21+
})
22+
.catch((error) => {
23+
console.log(error);
24+
});
25+
};
26+
27+
28+
render () {
29+
return (
30+
<div className="container-fluid">
31+
<CohortList cohorts={this.state.cohorts}/>
32+
</div>
33+
34+
);}
35+
}
36+
37+
ReactDOM.render(<App/>, document.getElementById('app'));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from 'react';
2+
3+
class CohortList extends React.Component {
4+
5+
render() {
6+
return (
7+
<div className="row">
8+
9+
<table className="table table-striped table-hover">
10+
<thead>
11+
<tr>
12+
<th>#</th>
13+
<th>Name</th>
14+
<th>Description</th>
15+
<th>Date</th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
{
20+
this.props.cohorts.map((cohort) => {
21+
return (
22+
<tr style={{cursor:pointer}}>
23+
<td>{cohort.id}</td>
24+
<td>{cohort.name}</td>
25+
<td>{cohort.description}</td>
26+
<td>{cohort.createdDate}</td>
27+
</tr>
28+
)
29+
})
30+
}
31+
</tbody>
32+
</table>
33+
</div>
34+
);
35+
};
36+
}
37+
38+
export default CohortList;

app/controllers/AsyncController.scala

-41
This file was deleted.

app/controllers/CohortController.scala

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@ import services.JsonMapper
55
import javax.inject.Inject
66
import play.api.mvc.Controller
77
import play.api.mvc.Action
8+
import org.webjars.play.RequireJS
89

9-
class CohortController @Inject() (solrDAO: dao.SolrDAO, wepAPIsvc:WebAPIService) extends Controller with JsonMapper {
10+
class CohortController @Inject() (webJarAssets: WebJarAssets, requireJS: RequireJS, solrDAO: dao.SolrDAO, wepAPIsvc:WebAPIService) extends Controller with JsonMapper {
1011
def index = Action {
11-
Ok(views.html.cohorts.render("Cohorts", "Begin exploring clinical cohorts."))
12+
Ok(views.html.cohorts.render(webJarAssets, requireJS, "Cohorts"))
1213
}
13-
14+
1415
def getCohorts = Action {
1516
val cohorts = wepAPIsvc.getCohortDefinitions()
1617
Ok(cohorts)
1718
}
18-
19+
1920
def getCohortEntities(cohortId:String) = Action {
2021
val cohortEntities = wepAPIsvc.getCohortEntities(cohortId)
2122
Ok(cohortEntities)
2223
}
23-
}
24+
}

app/controllers/CountController.scala

-25
This file was deleted.

app/controllers/IndexController.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package controllers
33
import javax.inject.Inject
44
import play.api.mvc.Controller
55
import play.api.mvc.Action
6+
import org.webjars.play.RequireJS
67

78
class IndexController @Inject() extends Controller {
89

910
def welcome = Action {
1011
Ok("Welcome!")
1112
}
1213

13-
}
14+
}

app/controllers/SearchController.scala

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ import play.api.mvc._
77
import play.api.mvc.Controller
88
import services.JsonMapper
99
import services.WebAPIService
10-
10+
import org.webjars.play.RequireJS
11+
12+
13+
class SearchController @Inject() (webJarAssets: WebJarAssets, requireJS: RequireJS, solrDAO: dao.SolrDAO, wepAPIsvc:WebAPIService) extends Controller with JsonMapper {
1114

12-
class SearchController @Inject() (solrDAO: dao.SolrDAO, wepAPIsvc:WebAPIService) extends Controller with JsonMapper {
13-
1415
def index = Action {
15-
Ok(views.html.index.render("Search", "Begin exploring patient and document level clinical data."))
16+
Ok(views.html.index.render(webJarAssets, requireJS, "Search"))
1617
}
17-
18+
1819
def queryText(query:String, start:Int, rows:Int) = Action {
1920
val res = solrDAO.simpleQuery(query, rows, start, null)
2021
Ok(Json.toJson(res))
2122
}
22-
23-
24-
}
23+
24+
25+
}

0 commit comments

Comments
 (0)