Skip to content

Commit f7d3e11

Browse files
committed
Improved look of reporting context UI
1 parent 8d0a554 commit f7d3e11

File tree

5 files changed

+150
-45
lines changed

5 files changed

+150
-45
lines changed

dddsample/external/reporting/src/test/resources/context-test-setup.xml renamed to dddsample/external/reporting/src/main/resources/context-test-setup.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99
<constructor-arg value="classpath:sample_data.sql"/>
1010
</bean>
1111

12-
1312
</beans>

dddsample/external/reporting/src/main/webapp/WEB-INF/web.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<param-value>
3030
classpath:context.xml
3131
classpath:context-cxf.xml
32+
classpath:context-test-setup.xml
3233
</param-value>
3334
</context-param>
3435

dddsample/external/reporting/src/main/webapp/index.jsp

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,30 @@
44
<head>
55
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
66
<script type="text/javascript" src="jquery-1.3.2.js"></script>
7-
<title>Reporting</title>
7+
<script type="text/javascript" src="reporting.js"></script>
8+
<link rel="stylesheet" type="text/css" href="main.css"/>
9+
<title>DDDSample Reporting</title>
810
</head>
911
<body>
10-
<h1 id="apa">Reporting</h1>
11-
<div>
12-
<form action="" method="get" onsubmit="search(); return false;">
13-
Search:
14-
<input id="query" name="query" type="text"/>
15-
<input id="submit" name="submit" type="submit" value="Search"/>
16-
</form>
12+
<img id="background" src="background.png" alt=""/>
13+
<div id="content">
14+
<div id="header">
15+
<img src="dddsample.png" alt="dddsample"/>
16+
</div>
17+
<div id="form">
18+
<form action="" method="get" onsubmit="search(); return false;">
19+
Track cargo or voyage:
20+
<input id="query" name="query" type="text" size="30" value="ABC"/>
21+
<input id="submit" name="submit" type="submit" value="Track"/>
22+
</form>
23+
</div>
24+
<div id="result"></div>
25+
<div id="footer">
26+
Created by <a href="http://www.citerus.se">Citerus</a> and <a href="http://www.domainlanguage.com">Domain Language</a>
27+
</div>
1728
</div>
18-
<div id="result"></div>
1929
<script type="text/javascript">
2030
$('#query').focus();
21-
22-
function search() {
23-
$.ajax({
24-
url: "http://localhost:8080/reporting/rest/cargo/" + $("#query").val() + ".json",
25-
type: 'GET',
26-
contentType: 'application/json',
27-
success: function(response) {
28-
var json = eval('(' + response + ')');
29-
var cargo = json.cargoReport.cargo;
30-
$('#result').empty();
31-
var pdfUrl = "http://localhost:8080/reporting/rest/cargo/" + $("#query").val() + ".pdf"
32-
$('#result').
33-
append('<p><a href="' + pdfUrl + '">Download PDF</a></p>').
34-
append('<h2>Cargo ' + cargo.trackingId + '</h2>').
35-
append('<p>Destination: ' + cargo.finalDestination + ' (at ' + cargo.arrivalDeadline + ')</p>')
36-
37-
if (cargo.currentLocation) {
38-
$('#result').append('<p>Status: ' + cargo.currentStatus + ' ' + cargo.currentLocation + '</p>');
39-
} else if (cargo.currentVoyage) {
40-
$('#result').append('<p>Status: ' + cargo.currentStatus + ' ' + cargo.currentVoyage + '</p>');
41-
}
42-
43-
$('#result').append('<p>Updated on: ' + cargo.lastUpdatedOn + '</p>');
44-
45-
for (var handling in json.cargoReport.handlings) {
46-
$('#result').append('<p>' + handling['location'] + '</p>');
47-
}
48-
},
49-
error: function(response) {
50-
if (response.status == 404) {
51-
$('#result').text('No cargo with tracking id ' + $("#query").val());
52-
}
53-
}
54-
});
55-
}
5631
</script>
5732
</body>
5833
</html>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
html {
2+
overflow-y: scroll;
3+
}
4+
5+
a {
6+
text-decoration: none;
7+
color: #234;
8+
}
9+
10+
a:hover {
11+
color: #123;
12+
}
13+
14+
body {
15+
font-family: Helvetica, Arial, sans-serif;
16+
font-size: large;
17+
background: rgb(11,19,36);
18+
margin: 0;
19+
padding: 20px;
20+
}
21+
22+
img#background {
23+
width: 98%;
24+
z-index: -1;
25+
position: absolute;
26+
bottom: 0;
27+
}
28+
29+
h1, h2 {
30+
margin: 15px 0;
31+
padding: 0;
32+
font-size: x-large;
33+
}
34+
35+
div#header {
36+
margin: 30px 0;
37+
}
38+
39+
div#content {
40+
-moz-border-radius: 10px;
41+
-webkit-border-radius: 10px;
42+
background-color: rgb(255, 157, 84);
43+
width: 600px;
44+
padding: 10px 20px;
45+
margin: auto;
46+
border: 2px solid;
47+
}
48+
49+
div#footer {
50+
text-align: center;
51+
font-size: x-small;
52+
padding-top: 10px;
53+
width: 100%;
54+
margin-top: 20px;
55+
}
56+
57+
input#query {
58+
padding: 5px;
59+
font-size: large;
60+
}
61+
62+
input#submit {
63+
padding: 5px 10px;
64+
font-size: large;
65+
border: 2px solid;
66+
background-color: rgb(255, 203, 134);
67+
}
68+
69+
table {
70+
}
71+
72+
td {
73+
padding: 8px;
74+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
function search() {
2+
$('#result').empty();
3+
if (!$("#query").val()) {
4+
return;
5+
}
6+
7+
$.ajax({
8+
url: 'http://localhost:8080/reporting/rest/cargo/' + $("#query").val() + '.json',
9+
type: 'GET',
10+
contentType: 'application/json',
11+
success: function(response) {
12+
var json = eval('(' + response + ')');
13+
var cargo = json.cargoReport.cargo;
14+
var pdfUrl = 'http://localhost:8080/reporting/rest/cargo/' + $("#query").val() + '.pdf';
15+
$('#result').append('<h2>Cargo: ' + cargo.trackingId + '</h2>').append('<table>');
16+
17+
if (cargo.currentLocation) {
18+
$('#result').append('<tr><td>Status</td><td>' + cargo.currentStatus + ' ' + cargo.currentLocation + '</td></tr>');
19+
} else if (cargo.currentVoyage) {
20+
$('#result').append('<tr><td>Status</td><td>' + cargo.currentStatus + ' ' + cargo.currentVoyage + '</td></tr>');
21+
}
22+
23+
$('#result').
24+
append('<tr><td>Destination</td><td>' + cargo.finalDestination + ' by ' + cargo.arrivalDeadline + '</td></tr>').
25+
append('<tr><td>ETA</td><td>' + cargo.eta + '</td></tr>');
26+
27+
28+
$('#result').
29+
append('<tr><td>Updated on</td><td>' + cargo.lastUpdatedOn + '</td></tr>').
30+
append('</table>');
31+
32+
$('#result').append(json.cargoReport.misdirected);
33+
34+
$('#result').
35+
append('<h2>Handling history</h2>');
36+
for (i in json.cargoReport.handlings) {
37+
var handling = json.cargoReport.handlings[i];
38+
$('#result').
39+
append('<tr>').
40+
append('<td>' + handling.completedOn + '</td>').
41+
append('<td>' + handling.type + '</td>').
42+
append('<td>' + handling.voyage + '</td>').
43+
append('<td>' + handling.location + '</td>').
44+
append('</tr>');
45+
}
46+
$('#result').
47+
append('</table>').
48+
append('<p><a href="' + pdfUrl + '">Download as PDF</a></p>');
49+
},
50+
error: function(response) {
51+
if (response.status == 404) {
52+
$('#result').append('<p>No cargo found with tracking ID ' + $("#query").val() + '</p>');
53+
}
54+
}
55+
});
56+
}

0 commit comments

Comments
 (0)