Skip to content

Commit

Permalink
fix pagination bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
laxman committed Nov 2, 2015
1 parent 9fce696 commit 76d4ab7
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 41 deletions.
14 changes: 14 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
<!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/vsr/boot/Application.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.vsr.boot;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.orm.jpa.EntityScan;
Expand All @@ -17,8 +19,10 @@
@EnableAutoConfiguration
@PropertySource("application.properties")
public class Application {

public static void main(String[] args) {
private static Logger log = LoggerFactory.getLogger(Application.class);
public static void main(String[] args) throws Exception {
log.info("++++++++++++++++++++++++++++START++++++++++++++++++++++++++++");
// Log4jConfigurer.initLogging("classpath:log4j.properties");
SpringApplication.run(Application.class, args);
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/vsr/boot/RepositoryConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration
config.exposeIdsFor(Station.class, Department.class, Faremap.class, Invoice.class);
config.projectionConfiguration().addProjection(FareDetails.class);
config.projectionConfiguration().addProjection(InvoiceDetails.class);
config.setMaxPageSize(Integer.MAX_VALUE);
super.configureRepositoryRestConfiguration(config);
}
}
3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spring.datasource.driverClassName=com.mysql.jdbc.Driver

# Show or not log for each sql query
spring.jpa.show-sql = true
spring.jpa.format-sql = true

spring.jpa.hibernate.default_schema=vsr

Expand All @@ -41,4 +42,4 @@ spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.EJB3NamingStrategy
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

#server.servlet-path = /spring
#server.servlet-path = /spring
16 changes: 16 additions & 0 deletions src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Root logger option
log4j.rootLogger=DEBUG, file, stdout

# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=/host/working/codebase/vsr/target/logs/vsr.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
36 changes: 15 additions & 21 deletions src/main/resources/static/pages/invoice-print.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
<td style="width:25%; border: hidden">
From:&nbsp;<span id="LblFrom">{{fromAddress}}</span>
</td>
<td colspan="3" style="align-content: center; text-align: right; width: 72%; border: hidden">
To:&nbsp;<span id="LblTo">{{toAddress}}</span> </td>
<td colspan="3" style="align-content: center; text-align: center; width: 72%; border: hidden">
&nbsp;</td>
<td style="width: 35%; border: hidden">
<td colspan="3" style="align-content: center; text-align: center; border: hidden">To:&nbsp;<span id="LblTo">{{toAddress}}</span></td>
<td colspan="2" style="border: hidden">&nbsp;</td>
<td colspan="2" style="align-content: center; text-align: right; border: hidden">
WayBill#: <span id="LblWayBno" style="font-size: medium">{{waybillNumber}}</span>
</td>
</tr>
Expand All @@ -31,12 +29,11 @@
<td style="width:20%; border: hidden">
DC#:&nbsp;<span id="LbldcNumber">{{dcNumber}}</span>
</td>
<td colspan="3" style="align-content: center; text-align: right; width: 72%; border: hidden">
<td colspan="3" style="align-content: center; text-align: center; border: hidden">
Department:&nbsp;<span id="LblDept">{{deptName}}</span></td>
<td colspan="3" style="align-content: center; text-align: center; width: 72%; border: hidden">
&nbsp;</td>
<td style="width: 13%; border: hidden">
Date:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span id="LblDate">{{date |date:"dd-MM-yyyy"}}</span></td>
<td colspan="2" style="border: hidden">&nbsp;</td>
<td colspan="2" style="text-align: right; border: hidden">
Date:&nbsp;<span id="LblDate">{{date |date:"dd-MM-yyyy"}}</span></td>
</tr>

<tr>
Expand Down Expand Up @@ -132,7 +129,7 @@
<td colspan="6" style="align-content: center; text-align: center; width: 70%;border-left:hidden;border-right:hidden;border-top:hidden">
<img alt="" src="images/vsrbanner.png" width="400px" style="text-align: center">
<br>
<b>ACCOUNTS COPY</b>
<b>CONSIGNEE COPY</b>
</td>
<td style="width: 15%;border-left:hidden;border-right:hidden;border-top:hidden">&nbsp;</td>
</tr>
Expand All @@ -141,11 +138,9 @@
<td style="width:25%; border: hidden">
From:&nbsp;<span id="LblFrom">{{fromAddress}}</span>
</td>
<td colspan="3" style="align-content: center; text-align: right; width: 72%; border: hidden">
To:&nbsp;<span id="LblTo">{{toAddress}}</span> </td>
<td colspan="3" style="align-content: center; text-align: center; width: 72%; border: hidden">
&nbsp;</td>
<td style="width: 35%; border: hidden">
<td colspan="3" style="align-content: center; text-align: center; border: hidden">To:&nbsp;<span id="LblTo">{{toAddress}}</span></td>
<td colspan="2" style="border: hidden">&nbsp;</td>
<td colspan="2" style="align-content: center; text-align: right; border: hidden">
WayBill#: <span id="LblWayBno" style="font-size: medium">{{waybillNumber}}</span>
</td>
</tr>
Expand All @@ -154,12 +149,11 @@
<td style="width:20%; border: hidden">
DC#:&nbsp;<span id="LbldcNumber">{{dcNumber}}</span>
</td>
<td colspan="3" style="align-content: center; text-align: right; width: 72%; border: hidden">
<td colspan="3" style="align-content: center; text-align: center; border: hidden">
Department:&nbsp;<span id="LblDept">{{deptName}}</span></td>
<td colspan="3" style="align-content: center; text-align: center; width: 72%; border: hidden">
&nbsp;</td>
<td style="width: 13%; border: hidden">
Date:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span id="LblDate">{{date |date:"dd-MM-yyyy"}}</span></td>
<td colspan="2" style="border: hidden">&nbsp;</td>
<td colspan="2" style="text-align: right; border: hidden">
Date:&nbsp;<span id="LblDate">{{date |date:"dd-MM-yyyy"}}</span></td>
</tr>

<tr>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/static/pages/stations.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
<td>{{station.district}}</td>
<td>{{station.state}}</td>
<td>
<a href="javascript:void(0)" ng-click="addEdit('edit', station.id)">Edit<a>
<a href="javascript:void(0)" ng-click="addEdit('edit', station.id)">Edit</a>
|
<a href="javascript:void(0)" ng-click="deleteItem(station._links.self.href)">Delete<a>
<a href="javascript:void(0)" ng-click="deleteItem(station._links.self.href)">Delete</a>
</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ app.controller('department-ctrl', function ($scope, $http, $filter, $modal, ngTa
$scope.getList = function (callback) {
$http({
method: 'GET',
url: '/departments'
url: '/departments',
params: {
page: 0,
size: 2000,
sort: 'name'
}
}).then(function (response) {
if (typeof response.data._embedded != 'undefined') {
$scope.departments = response.data._embedded.departments;
Expand Down Expand Up @@ -39,7 +44,7 @@ app.controller('department-ctrl', function ($scope, $http, $filter, $modal, ngTa
$scope.initTable = function () {
$scope.tableParams = new ngTableParams({
page: 1,
count: 10,
count: 25,
sorting: {
"name": "asc"
}
Expand Down
11 changes: 8 additions & 3 deletions src/main/resources/static/scripts/controllers/fares-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ app.controller('fares-ctrl', function ($scope, $http, $filter, $modal, ngTablePa

$http({
method: 'GET',
url: '/fares'
url: '/fares',
params: {
page: 0,
size: 2000,
sort: 'fromStation.stationName'
}
}).then(function (response) {
if (typeof response.data._embedded != 'undefined') {

Expand Down Expand Up @@ -122,8 +127,8 @@ app.controller('fares-ctrl', function ($scope, $http, $filter, $modal, ngTablePa
$http({
method: 'GET',
url: '/stations',
data: {
page: 1,
params: {
page: 0,
size: 2000,
sort: 'stationName'
}
Expand Down
25 changes: 18 additions & 7 deletions src/main/resources/static/scripts/controllers/invoice-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ app.controller('invoice-ctrl', function ($scope, $http, $filter, $modal, ngTable

$http({
method: 'GET',
url: '/invoices?projection=invoice_details'
url: '/invoices',
params: {
page: 0,
size: 9999999,
sort: 'date,desc',
projection: 'invoice_details'
}
}).then(function (response) {
if (typeof response.data._embedded != 'undefined') {
$scope.invoices = response.data._embedded.invoices;
Expand Down Expand Up @@ -40,9 +46,9 @@ app.controller('invoice-ctrl', function ($scope, $http, $filter, $modal, ngTable
$scope.initTable = function () {
$scope.tableParams = new ngTableParams({
page: 1,
count: 2000,
count: 25,
sorting: {
"waybillNumber": "asc"
"date": "desc"
}
}, {
counts: [],
Expand Down Expand Up @@ -121,11 +127,12 @@ app.controller('invoice-ctrl', function ($scope, $http, $filter, $modal, ngTable
$scope.getAllFares = function () {
$http({
method: 'GET',
url: '/fares?projection=fare_details',
url: '/fares',
data: {
page: 1,
page: 0,
size: 2000,
sort: 'fromStation.stationName,toStation.stationName'
sort: 'fromStation.stationName,toStation.stationName',
projection: 'fare_details'
}
}).then(function (response) {
if (typeof response.data._embedded != 'undefined') {
Expand All @@ -145,7 +152,7 @@ app.controller('invoice-ctrl', function ($scope, $http, $filter, $modal, ngTable
method: 'GET',
url: '/departments',
data: {
page: 1,
page: 0,
size: 2000,
sort: 'name'
}
Expand Down Expand Up @@ -242,6 +249,10 @@ app.controller('invoiceModalCtrl', function ($scope, $http, $modalInstance, data
}, function (response) {

});
} else {
$scope.submitData = {};
$scope.submitData.doordelCharges = 200;
$scope.submitData.statCharges = 10;
}
};

Expand Down
9 changes: 6 additions & 3 deletions src/main/resources/static/scripts/controllers/station-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ app.controller('station-ctrl', function ($scope, $http, $filter, $modal, ngTable
$scope.getList = function (callback) {
$http({
method: 'GET',
url: '/stations'
url: '/stations',
params: {
page: 0,
size: 2000,
sort: 'stationName'
}
}).then(function (response) {
if (typeof response.data._embedded != 'undefined') {
$scope.stations = response.data._embedded.stations;
Expand Down Expand Up @@ -111,10 +116,8 @@ app.controller('station-ctrl', function ($scope, $http, $filter, $modal, ngTable
};

$scope.init();

});


app.controller('stationModalCtrl', function ($scope, $http, $modalInstance, dataToModal) {
$scope.action = dataToModal.action;

Expand Down

0 comments on commit 76d4ab7

Please sign in to comment.