From 57e3d98cf787b08342d415f5d51eababf072f803 Mon Sep 17 00:00:00 2001 From: ThetaSinner Date: Sat, 17 Feb 2018 22:16:43 +0000 Subject: [PATCH] prepare app for release --- UI/src/js/app.component.js | 2 +- UI/src/js/ebook-data.service.js | 18 +++++++++--------- build.gradle | 2 ++ setup-client.bat | 1 + src/main/java/org/thetasinner/Config.java | 23 +++++++++++++++++++++++ src/main/java/org/thetasinner/Main.java | 18 ++++++------------ src/main/resources/application.properties | 2 ++ start-client.bat | 2 ++ start-server.bat | 1 + 9 files changed, 47 insertions(+), 22 deletions(-) create mode 100644 setup-client.bat create mode 100644 src/main/java/org/thetasinner/Config.java create mode 100644 start-client.bat create mode 100644 start-server.bat diff --git a/UI/src/js/app.component.js b/UI/src/js/app.component.js index 22dcc03..c51d401 100644 --- a/UI/src/js/app.component.js +++ b/UI/src/js/app.component.js @@ -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( , diff --git a/UI/src/js/ebook-data.service.js b/UI/src/js/ebook-data.service.js index fdd0e05..3047f0c 100644 --- a/UI/src/js/ebook-data.service.js +++ b/UI/src/js/ebook-data.service.js @@ -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) { @@ -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) => { @@ -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 @@ -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', @@ -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', @@ -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, @@ -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', @@ -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', @@ -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 diff --git a/build.gradle b/build.gradle index 2ae86b2..16cbc9c 100644 --- a/build.gradle +++ b/build.gradle @@ -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' } diff --git a/setup-client.bat b/setup-client.bat new file mode 100644 index 0000000..341c9f0 --- /dev/null +++ b/setup-client.bat @@ -0,0 +1 @@ +cd UI && npm install && .\\node_modules\\.bin\\gulp default && cd .. diff --git a/src/main/java/org/thetasinner/Config.java b/src/main/java/org/thetasinner/Config.java new file mode 100644 index 0000000..2474fa2 --- /dev/null +++ b/src/main/java/org/thetasinner/Config.java @@ -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(); + } +} diff --git a/src/main/java/org/thetasinner/Main.java b/src/main/java/org/thetasinner/Main.java index 5794bc2..42f1ef9 100644 --- a/src/main/java/org/thetasinner/Main.java +++ b/src/main/java/org/thetasinner/Main.java @@ -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); } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b59a54b..a45e411 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,5 @@ +server.port = 8121 + # Disable the spring multipart resolver. spring.servlet.multipart.enabled=false diff --git a/start-client.bat b/start-client.bat new file mode 100644 index 0000000..d2fd74a --- /dev/null +++ b/start-client.bat @@ -0,0 +1,2 @@ +cd UI +npm run serve diff --git a/start-server.bat b/start-server.bat new file mode 100644 index 0000000..75f350b --- /dev/null +++ b/start-server.bat @@ -0,0 +1 @@ +gradlew.bat bootRun \ No newline at end of file