create web application
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.lucares.pdbui")
|
||||
// @PropertySource("classpath:/config.system.properties")
|
||||
// @PropertySource("classpath:/config.user.properties")
|
||||
public class MySpringConfiguration {
|
||||
|
||||
}
|
||||
14
pdb-ui/src/main/java/org/lucares/pdbui/MyWebapp.java
Normal file
14
pdb-ui/src/main/java/org/lucares/pdbui/MyWebapp.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
||||
public class MyWebapp {
|
||||
|
||||
public static final String IMAGE_DIR = Paths.get("/tmp/images").toFile().getAbsolutePath() + "/";
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
SpringApplication.run(MySpringConfiguration.class, args);
|
||||
}
|
||||
}
|
||||
34
pdb-ui/src/main/java/org/lucares/pdbui/PdbController.java
Normal file
34
pdb-ui/src/main/java/org/lucares/pdbui/PdbController.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import org.lucares.pdbui.domain.PlotRequest;
|
||||
import org.lucares.pdbui.domain.PlotResponse;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
@EnableAutoConfiguration
|
||||
public class PdbController {
|
||||
|
||||
private final PdbRepository pdbRepository;
|
||||
|
||||
public PdbController(final PdbRepository pdbRepository) {
|
||||
this.pdbRepository = pdbRepository;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/plots", //
|
||||
method = RequestMethod.POST, //
|
||||
consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, //
|
||||
produces = MediaType.APPLICATION_JSON_UTF8_VALUE //
|
||||
)
|
||||
@ResponseBody
|
||||
PlotResponse createPlot(@RequestBody final PlotRequest request) {
|
||||
System.out.println(request.getQuery());
|
||||
return new PlotResponse("img/abc.png");
|
||||
}
|
||||
|
||||
}
|
||||
19
pdb-ui/src/main/java/org/lucares/pdbui/PdbRepository.java
Normal file
19
pdb-ui/src/main/java/org/lucares/pdbui/PdbRepository.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import org.lucares.performance.db.PerformanceDb;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class PdbRepository implements DisposableBean {
|
||||
private final PerformanceDb db;
|
||||
|
||||
public PdbRepository(final PerformanceDb db) {
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
14
pdb-ui/src/main/java/org/lucares/pdbui/WebConfiguration.java
Normal file
14
pdb-ui/src/main/java/org/lucares/pdbui/WebConfiguration.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
@Configuration
|
||||
public class WebConfiguration extends WebMvcConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/img/**").addResourceLocations("file:" + MyWebapp.IMAGE_DIR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
public class PlotRequest {
|
||||
private String query;
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(final String query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return query;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class PlotResponse {
|
||||
private List<String> imageUrls = new ArrayList<>();
|
||||
|
||||
public PlotResponse() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PlotResponse(final String... imageUrls) {
|
||||
this.imageUrls.addAll(Arrays.asList(imageUrls));
|
||||
}
|
||||
|
||||
public List<String> getImageUrls() {
|
||||
return imageUrls;
|
||||
}
|
||||
|
||||
public void setImageUrls(final List<String> imageUrls) {
|
||||
this.imageUrls = imageUrls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(imageUrls);
|
||||
}
|
||||
|
||||
}
|
||||
1
pdb-ui/src/main/resources/config.system.properties
Normal file
1
pdb-ui/src/main/resources/config.system.properties
Normal file
@@ -0,0 +1 @@
|
||||
db.base=/tmp/db
|
||||
1
pdb-ui/src/main/resources/config.user.properties
Normal file
1
pdb-ui/src/main/resources/config.user.properties
Normal file
@@ -0,0 +1 @@
|
||||
db.base=/home/andi/ws/performanceDb/db
|
||||
55
pdb-ui/src/main/resources/resources/css/design.css
Normal file
55
pdb-ui/src/main/resources/resources/css/design.css
Normal file
@@ -0,0 +1,55 @@
|
||||
body {
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'FontAwesome';
|
||||
src: url('../fonts/fontawesome-webfont.eot?v=4.7.0');
|
||||
src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('../fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
|
||||
#top-menu-bar {
|
||||
background-color: black;
|
||||
color: white;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
#logo {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#search-bar {
|
||||
background-color: #aaa;
|
||||
text-align: right;
|
||||
padding-bottom:3px;
|
||||
}
|
||||
|
||||
#search-bar #search-query {
|
||||
width:100%;
|
||||
padding:2;
|
||||
border:0;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#search-bar #search-submit {
|
||||
margin-right:3px;
|
||||
}
|
||||
|
||||
#result-view {
|
||||
background: red;
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
#result-view i {
|
||||
background: white;
|
||||
display:inline;
|
||||
font-style:normal;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
34
pdb-ui/src/main/resources/resources/css/icons.css
Normal file
34
pdb-ui/src/main/resources/resources/css/icons.css
Normal file
@@ -0,0 +1,34 @@
|
||||
.fa {
|
||||
display: inline-block;
|
||||
font: normal normal normal 14px/1 FontAwesome;
|
||||
font-size: inherit;
|
||||
text-rendering: auto;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
/* makes the font 33% larger relative to the icon container */
|
||||
.fa-lg {
|
||||
font-size: 1.33333333em;
|
||||
line-height: 0.75em;
|
||||
vertical-align: -15%;
|
||||
}
|
||||
.fa-2x {
|
||||
font-size: 2em;
|
||||
}
|
||||
.fa-3x {
|
||||
font-size: 3em;
|
||||
}
|
||||
.fa-4x {
|
||||
font-size: 4em;
|
||||
}
|
||||
.fa-5x {
|
||||
font-size: 5em;
|
||||
}
|
||||
|
||||
.fa-search:before {
|
||||
content: "\f002";
|
||||
}
|
||||
|
||||
.fa-icons:before {
|
||||
content: "\f002";
|
||||
}
|
||||
8
pdb-ui/src/main/resources/resources/css/typography.css
Normal file
8
pdb-ui/src/main/resources/resources/css/typography.css
Normal file
@@ -0,0 +1,8 @@
|
||||
body, p, td, th, textarea
|
||||
{
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
textarea {
|
||||
font-size:1.2em;
|
||||
}
|
||||
2
pdb-ui/src/main/resources/resources/fonts/.gitignore
vendored
Normal file
2
pdb-ui/src/main/resources/resources/fonts/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/font-awesome-4.7.0/
|
||||
/font-awesome-4.7.0.zip
|
||||
Binary file not shown.
21
pdb-ui/src/main/resources/resources/index.html
Normal file
21
pdb-ui/src/main/resources/resources/index.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
|
||||
<script type="text/javascript" src="js/search.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="css/typography.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/design.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/icons.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="top-menu-bar">
|
||||
<div id="logo">LOGO</div>
|
||||
</div>
|
||||
<div id="search-bar">
|
||||
<textarea id="search-query"></textarea>
|
||||
<button id="search-submit"><i class="fa fa-search"> Search</i></button>
|
||||
</div>
|
||||
<div id="result-view">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
4
pdb-ui/src/main/resources/resources/js/jquery-3.1.1.min.js
vendored
Normal file
4
pdb-ui/src/main/resources/resources/js/jquery-3.1.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
39
pdb-ui/src/main/resources/resources/js/search.js
Normal file
39
pdb-ui/src/main/resources/resources/js/search.js
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$('#search-submit').click(function(event){
|
||||
event.preventDefault(); // prevent submit of form which would reload the page
|
||||
|
||||
var request = {};
|
||||
request['query'] = $('#search-query').val();
|
||||
|
||||
var success = function(response){
|
||||
|
||||
$('#result-view').text("SUCCESS: "+response.imageUrls);
|
||||
};
|
||||
var error = function(e) {
|
||||
//var response = JSON.parse(e.responseText);
|
||||
$('#result-view').text("FAILED: " + JSON.stringify(e));
|
||||
};
|
||||
|
||||
|
||||
postJson("plots", request, success, error);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function postJson(url, requestData, successCallback, errorCallback) {
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: JSON.stringify(requestData),
|
||||
contentType: 'application/json'
|
||||
})
|
||||
.done(successCallback)
|
||||
.fail(errorCallback);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user