Skip to content

Commit

Permalink
prepare app for release
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Feb 17, 2018
1 parent 97a9e3c commit 57e3d98
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 22 deletions.
2 changes: 1 addition & 1 deletion UI/src/js/app.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default class App extends React.Component {
}

$(function() {
const dataService = new EBookDataService();
const dataService = new EBookDataService('http://localhost:8121');

ReactDOM.render(
<App dataService={dataService} />,
Expand Down
18 changes: 9 additions & 9 deletions UI/src/js/ebook-data.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function processAjaxError(jqXHR) {
export default class EBookDataService {
constructor(serverUrl) {
this.activeLibraryName = null;
this.serverUrl = serverUrl; // TODO
this.serverUrl = serverUrl;
}

setActiveLibraryName(libraryName) {
Expand All @@ -25,7 +25,7 @@ export default class EBookDataService {
listLibraries() {
return new Promise((resolve, reject) => {
$.ajax({
url: 'http://localhost:8080/libraries',
url: this.serverUrl + '/libraries',
type: 'GET',
timeout: 1500
}).done((response) => {
Expand All @@ -39,7 +39,7 @@ export default class EBookDataService {
createLibrary(libraryName) {
return new Promise((resolve, reject) => {
$.ajax({
url: 'http://localhost:8080/libraries',
url: this.serverUrl + '/libraries',
type: 'POST',
data: {
name: libraryName
Expand All @@ -57,7 +57,7 @@ export default class EBookDataService {
const that = this;
return new Promise((resolve, reject) => {
$.ajax({
url: 'http://localhost:8080/libraries/commit',
url: this.serverUrl + '/libraries/commit',
type: 'POST',
contentType: 'application/json',
dataType: 'json',
Expand All @@ -82,7 +82,7 @@ export default class EBookDataService {
const that = this;
return new Promise((resolve, reject) => {
$.ajax({
url: 'http://localhost:8080/books',
url: this.serverUrl + '/books',
type: 'POST',
contentType: 'application/json',
dataType: 'json',
Expand Down Expand Up @@ -112,7 +112,7 @@ export default class EBookDataService {

return new Promise((resolve, reject) => {
$.ajax({
url: 'http://localhost:8080/libraries/upload',
url: this.serverUrl + '/libraries/upload',
type: 'POST',
data: formData,
processData: false,
Expand Down Expand Up @@ -163,7 +163,7 @@ export default class EBookDataService {
const that = this;
return new Promise((resolve, reject) => {
$.ajax({
url: 'http://localhost:8080/books/' + book.id,
url: this.serverUrl + '/books/' + book.id,
type: 'PATCH',
contentType: 'application/json', // TODO wrong content type for patch
dataType: 'json',
Expand All @@ -188,7 +188,7 @@ export default class EBookDataService {
});
return new Promise((resolve, reject) => {
$.ajax({
url: 'http://localhost:8080/books/' + id + '?' + params,
url: this.serverUrl + '/books/' + id + '?' + params,
type: 'DELETE',
contentType: 'application/json',
dataType: 'json',
Expand All @@ -205,7 +205,7 @@ export default class EBookDataService {
const that = this;
return new Promise((resolve, reject) => {
$.ajax({
url: 'http://localhost:8080/books',
url: this.serverUrl + '/books',
type: 'GET',
data: {
name: that.activeLibraryName
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ dependencies {
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.3'

providedRuntime group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: '1.5.10.RELEASE'

testCompile 'junit:junit:4.12'
}

Expand Down
1 change: 1 addition & 0 deletions setup-client.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cd UI && npm install && .\\node_modules\\.bin\\gulp default && cd ..
23 changes: 23 additions & 0 deletions src/main/java/org/thetasinner/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.thetasinner;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.thetasinner.data.storage.ILibraryStorage;
import org.thetasinner.data.storage.file.FileLibraryStorage;

@Configuration
public class Config {
@Bean
public CommonsMultipartResolver multipartResolver() {
CommonsMultipartResolver resolver = new CommonsMultipartResolver();
resolver.setMaxUploadSize(-1);

return resolver;
}

@Bean
public ILibraryStorage libraryStorage() {
return new FileLibraryStorage();
}
}
18 changes: 6 additions & 12 deletions src/main/java/org/thetasinner/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,21 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.thetasinner.data.storage.file.FileLibraryStorage;
import org.thetasinner.data.storage.ILibraryStorage;

@SpringBootApplication
public class Main {
public class Main extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}

@Bean
public CommonsMultipartResolver multipartResolver() {
CommonsMultipartResolver resolver = new CommonsMultipartResolver();
resolver.setMaxUploadSize(-1);

return resolver;
}

@Bean
public ILibraryStorage libraryStorage() {
return new FileLibraryStorage();
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder applicationBuilder) {
return applicationBuilder.sources(Main.class);
}
}
2 changes: 2 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
server.port = 8121

# Disable the spring multipart resolver.
spring.servlet.multipart.enabled=false

Expand Down
2 changes: 2 additions & 0 deletions start-client.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd UI
npm run serve
1 change: 1 addition & 0 deletions start-server.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gradlew.bat bootRun

0 comments on commit 57e3d98

Please sign in to comment.