Permalink
Browse files

a lot of tiny improvements

* search and pagination of users and applications
* node upgrade
* async/await usage
* cleanup
  • Loading branch information...
peh committed Oct 9, 2018
1 parent 5284cea commit f87f9e5f7ab0f833daea8c2edb31bf53ffc131f6
@@ -17,7 +17,7 @@ before_script:
- rm -rf build/
- rm -rf .asscache
install: bash gradlew npmInstall
script: bash gradlew -Dgrails.babel.node.path=.nodejs/node-v7.4.0-linux-x64/bin/node -Dgrails.env=prod :clean :npmInstall :assetCompile :bootRepackage
script: bash gradlew -Dgrails.babel.node.path=.nodejs/node-v10.10.0-linux-x64/bin/node -Dgrails.env=prod :clean :npmInstall :assetCompile :bootRepackage
env:
global:
- GIT_NAME="Philipp Eschenbach"
@@ -72,7 +72,7 @@ See Option 2 for general Database setup needed
* Clone the repo `git clone https://github.com/peh/errbuddy.git`
* in build.gradle change `compile "org.springframework.boot:spring-boot-starter-tomcat"` to `provided "org.springframework.boot:spring-boot-starter-tomcat"`
* if you have build the project before: `rm -f .asscache && rm -f build/`
* run `./gradlew -Dgrails.babel.node.path=.nodejs/node-v7.4.0-linux-x64/bin/node -Dgrails.env=prod :clean :npmInstall :assetCompile :package`
* run `./gradlew -Dgrails.babel.node.path=.nodejs/node-v10.10.0-linux-x64/bin/node -Dgrails.env=prod :clean :npmInstall :assetCompile :package`
* you might have to adjust the node path depending on your system. If you are on macOS it would be `.nodejs/node-v7.4.0-linux-x64/bin/node`. You can find out what to use here by first just running `./gradlew npmSetup` and then check what's in `./.nodejs/`
* you will find the created warfile in `./builds/libs`
* Follow the instructions in configuration step of Option 2
@@ -85,14 +85,14 @@ dependencies {
compile 'org.jodd:jodd-http:3.6.6'
compile 'org.grails.plugins:joda-time:2.0.0'
compile "org.grails.plugins:errbuddy:2.2.0"
compile "org.grails.plugins:errbuddy:2.2.1"
compile "com.uberall.plugins:uber-doc:2.0.4"
compile 'org.grails.plugins:elasticsearch:1.0.0.2'
compile 'org.grails.plugins:jesque-admin:0.6.5'
compile 'org.grails.plugins:redis:2.0.4'
compile 'org.grails.plugins:jesque:1.2.1-UBERALL'
assets 'net.errbuddy.plugins:babel-asset-pipeline:2.1.0'
compile 'net.errbuddy.plugins:babel-asset-pipeline:2.1.0'
compile 'org.jadira.usertype:usertype.jodatime:2.0.1'
@@ -126,7 +126,7 @@ assets {
processor : 'webpack',
processJsFiles : false,
externalWebpackConfig: "webpack.prod.config.js",
nodeExec : System.getProperty('grails.babel.node.path') ?: ".nodejs/node-v7.4.0-linux-x64/bin/node"
nodeExec : System.getProperty('grails.babel.node.path') ?: ".nodejs/node-v10.10.0-linux-x64/bin/node"
]
]
}
@@ -149,15 +149,11 @@ bootRun {
}
node {
version = '7.4.0'
version = '10.10.0'
download = true
workDir = file("${project.projectDir}/.nodejs")
npmWorkDir = file("${project.projectDir}/.npm")
nodeModulesDir = file("${project.projectDir}")
}
tasks.withType(JavaExec).each { task ->
task.systemProperties System.properties
}
war.archiveName "errbuddy.war"
@@ -45,7 +45,7 @@ export default class App {
setTimeout(() => {
this.emitter.emit(AppEvents.PAUSE_STATE_CHANGED, App.paused)
}, 500);
})
});
window.onerror = function (message, url, lineNumber) {
console.log(arguments)
@@ -62,7 +62,7 @@ export default class App {
start() {
this.userService.validate().then((user) => {
this.setCurrentUser(user)
this.setCurrentUser(user);
this._doStart(user)
}).catch(() => {
this._doStart(null)
@@ -1,63 +1,80 @@
import React from "react";
import BaseComponent from "../tools/base-component";
import * as _ from "lodash";
import LoadingHero from "../tools/loading-hero";
import ReactPaginate from "react-paginate";
import {observer} from "mobx-react"
import {observable} from "mobx";
import Highlighter from "react-highlight-words";
@observer
export default class ApplicationList extends BaseComponent {
constructor(props) {
super(props)
this.state = {
applications: [],
total: 0,
max: 20,
offset: 0
};
}
@observable total = 0;
@observable max = 20;
@observable offset = 0;
@observable applications = [];
@observable loading = false;
@observable query = "";
componentDidMount() {
this.getApplicationList();
}
getApplicationList() {
let {max, offset} = this.state;
this.getApplicationService().list(offset, max)
.then((json) => {
this.setState(_.assign(this.state, {applications: json.applications, total: json.total}))
})
.catch((err) => {
this.showError('Failed to fetch Applications from Server');
throw err;
});
async getApplicationList() {
this.loading = true;
try {
let response = await this.getApplicationService().list(this.max, this.offset, this.query);
this.total = response.total;
this.applications = response.applications;
this.loading = false;
} catch (e) {
this.showError('Failed to fetch Applications from Server');
this.loading = false;
throw e;
}
}
changePage(pageObj) {
let offset = pageObj.selected * this.state.max;
this.setState({...this.state, offset: offset}, () => {
this.getApplicationList()
});
this.offset = pageObj.selected * this.max;
this.getApplicationList();
}
getTableRows() {
return this.applications.map(app => {
return (<tr key={app.id}>
<td>
<Highlighter
highlightClassName="query-match"
searchWords={[this.query]}
autoEscape={true}
textToHighlight={app.name}
/>
</td>
<td>{app.latest}</td>
<td><a href="javascript: void(0)" className="btn btn-sm btn-default" onClick={() => {
this.navigate(`/applications/${app.id}`)
}}><i className="fa fa-cog"></i></a></td>
</tr>)
})
}
async onQueryChange(e) {
this.query = e.target.value;
this.offset = 0;
await this.getApplicationList();
}
render() {
const {applications, total, max, offset} = this.state;
if (applications.length === 0) {
return <LoadingHero />
if (this.applications.length === 0) {
return <LoadingHero/>
}
let rows = _.map(this.state.applications, (app) => {
return (
<tr key={app.id}>
<td>{app.name}</td>
<td>{app.latest}</td>
<td><a href="javascript: void(0)" className="btn btn-sm btn-default" onClick={() => {
this.navigate(`/applications/${app.id}`)
}}><i className="fa fa-cog"></i></a></td>
</tr>
)
})
return (
<section className="application-list">
<input type="search" className="form-control" placeholder="Search" onChange={::this.onQueryChange} value={this.query}/>
<table className="table table-hover">
<thead>
<tr>
@@ -71,14 +88,14 @@ export default class ApplicationList extends BaseComponent {
</tr>
</thead>
<tbody>
{rows}
{this.getTableRows()}
</tbody>
</table>
<ReactPaginate
pageCount={Math.ceil(total / max)}
pageCount={Math.ceil(this.total / this.max)}
pageRangeDisplayed={4}
marginPagesDisplayed={1}
forceSelected={Math.floor(offset / max)}
forceSelected={Math.floor(this.offset / this.max)}
onPageChange={::this.changePage}
previousLabel="&laquo;"
nextLabel="&raquo;"
Oops, something went wrong.

0 comments on commit f87f9e5

Please sign in to comment.