restructured resources for caching
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.tilman</groupId>
|
<groupId>de.tilman</groupId>
|
||||||
<artifactId>next-transactions</artifactId>
|
<artifactId>next-transactions</artifactId>
|
||||||
<version>1.3.4</version>
|
<version>1.4.0</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
http.formLogin();
|
http.formLogin();
|
||||||
|
|
||||||
http.csrf().disable(); // XXX später wieder aktivieren
|
http.csrf().disable(); // XXX später wieder aktivieren
|
||||||
// http.headers().frameOptions().disable(); // for H2 console
|
// http.headers().frameOptions().disable(); // for dev H2 console
|
||||||
|
|
||||||
// configure caching
|
// configure caching
|
||||||
http.headers().cacheControl().disable();
|
http.headers().cacheControl().disable();
|
||||||
@@ -48,14 +48,12 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public void writeHeaders(HttpServletRequest request, HttpServletResponse response) {
|
public void writeHeaders(HttpServletRequest request, HttpServletResponse response) {
|
||||||
String requestUri = request.getRequestURI();
|
String requestUri = request.getRequestURI();
|
||||||
if (requestUri.startsWith("/public")) {
|
if (requestUri.startsWith("/public/")) {
|
||||||
response.setHeader("Cache-Control", "public, max-age=10000000");
|
response.setHeader("Cache-Control", "public, max-age=31536000"); // 1 year
|
||||||
// } else if (requestUri.startsWith("/api")) {
|
} else if (requestUri.startsWith("/api/") || requestUri.startsWith("/app/") || requestUri.startsWith("/user")) {
|
||||||
// // TODO handle API resources under common path (see application.properties)
|
|
||||||
// originalWriter.writeHeaders(request, response);
|
|
||||||
} else {
|
|
||||||
// response.setHeader("Cache-Control", "public, max-age=600000");
|
|
||||||
originalWriter.writeHeaders(request, response);
|
originalWriter.writeHeaders(request, response);
|
||||||
|
} else {
|
||||||
|
response.setHeader("Cache-Control", "public, max-age=6048000"); // 10 weeks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ server.port=8084
|
|||||||
server.session.cookie.max-age=1200000
|
server.session.cookie.max-age=1200000
|
||||||
server.session.timeout=1200000
|
server.session.timeout=1200000
|
||||||
|
|
||||||
#spring.data.rest.base-path=api
|
spring.data.rest.base-path=api
|
||||||
|
|
||||||
## PRODUCTION SETTINGS
|
## PRODUCTION SETTINGS
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ var transactionsApp = angular.module('transactionsApp', ['ui.bootstrap', 'ngRout
|
|||||||
|
|
||||||
transactionsApp.config([ '$routeProvider', function($routeProvider) {
|
transactionsApp.config([ '$routeProvider', function($routeProvider) {
|
||||||
$routeProvider.when('/list', {
|
$routeProvider.when('/list', {
|
||||||
templateUrl : 'partials/transaction-list.html',
|
templateUrl : 'app/transaction-list.html',
|
||||||
controller : 'TransactionListCtrl'
|
controller : 'TransactionListCtrl'
|
||||||
}).when('/import', {
|
}).when('/import', {
|
||||||
templateUrl : 'partials/import.html',
|
templateUrl : 'app/import.html',
|
||||||
controller : 'ImportCtrl'
|
controller : 'ImportCtrl'
|
||||||
}).when('/importList', {
|
}).when('/importList', {
|
||||||
templateUrl : 'partials/import-list.html',
|
templateUrl : 'app/import-list.html',
|
||||||
controller : 'ImportListCtrl'
|
controller : 'ImportListCtrl'
|
||||||
}).otherwise({
|
}).otherwise({
|
||||||
redirectTo : '/list'
|
redirectTo : '/list'
|
||||||
+14
-11
@@ -26,7 +26,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara
|
|||||||
// get outstandings (expenses and withdrawals) for all users of the account
|
// get outstandings (expenses and withdrawals) for all users of the account
|
||||||
var promises = new Array($scope.accountUsers.length);
|
var promises = new Array($scope.accountUsers.length);
|
||||||
for (i = 0; i < $scope.accountUsers.length; i++) {
|
for (i = 0; i < $scope.accountUsers.length; i++) {
|
||||||
var resource = $resource('/transactions/search/outstandings', { accountId: $scope.account.id, userId: $scope.accountUsers[i].id }).get();
|
var resource = $resource('/api/transactions/search/outstandings', { accountId: $scope.account.id, userId: $scope.accountUsers[i].id }).get();
|
||||||
promises[i] = resource.$promise;
|
promises[i] = resource.$promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get recent transactions
|
// get recent transactions
|
||||||
var transactions = $resource('/transactions/search/forAccount', { accountId: $scope.account.id, size: $scope.pageSize, sort: 'date,desc' }).get();
|
var transactions = $resource('/api/transactions/search/forAccount', { accountId: $scope.account.id, size: $scope.pageSize, sort: 'date,desc' }).get();
|
||||||
transactions.$promise.then(function(data) {
|
transactions.$promise.then(function(data) {
|
||||||
$scope.transactions = transactions._embedded.transactions;
|
$scope.transactions = transactions._embedded.transactions;
|
||||||
$scope.nextPageAvailable = (transactions.page.totalPages !== transactions.page.number + 1);
|
$scope.nextPageAvailable = (transactions.page.totalPages !== transactions.page.number + 1);
|
||||||
@@ -112,12 +112,12 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara
|
|||||||
userinfo.$promise.then(function(data) {
|
userinfo.$promise.then(function(data) {
|
||||||
$scope.userid = userinfo.name;
|
$scope.userid = userinfo.name;
|
||||||
|
|
||||||
userinfo = $resource('/users/search/findByUsername', { username: $scope.userid }).get();
|
userinfo = $resource('/api/users/search/findByUsername', { username: $scope.userid }).get();
|
||||||
userinfo.$promise.then(function(data) {
|
userinfo.$promise.then(function(data) {
|
||||||
$scope.userinfo = userinfo;
|
$scope.userinfo = userinfo;
|
||||||
});
|
});
|
||||||
|
|
||||||
var accountInfo = $resource('/accounts/search/findByUserName', { username: $scope.userid }).get();
|
var accountInfo = $resource('/api/accounts/search/findByUserName', { username: $scope.userid }).get();
|
||||||
accountInfo.$promise.then(function(data) {
|
accountInfo.$promise.then(function(data) {
|
||||||
$scope.accounts = accountInfo._embedded.accounts;
|
$scope.accounts = accountInfo._embedded.accounts;
|
||||||
if ($scope.account == undefined) {
|
if ($scope.account == undefined) {
|
||||||
@@ -130,7 +130,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var categories = $resource('/categories/search/listForAccount', { accountId: $scope.account.id }).get();
|
var categories = $resource('/api/categories/search/listForAccount', { accountId: $scope.account.id }).get();
|
||||||
categories.$promise.then(function(data) {
|
categories.$promise.then(function(data) {
|
||||||
$scope.categories = categories._embedded.categories;
|
$scope.categories = categories._embedded.categories;
|
||||||
$scope.refreshList();
|
$scope.refreshList();
|
||||||
@@ -173,7 +173,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara
|
|||||||
$scope.moreTransactions = function() {
|
$scope.moreTransactions = function() {
|
||||||
if ($scope.nextPageAvailable) {
|
if ($scope.nextPageAvailable) {
|
||||||
$scope.pageNumber++;
|
$scope.pageNumber++;
|
||||||
var transactions = $resource('/transactions/search/forAccount', { accountId: $scope.account.id, size: $scope.pageSize, sort: 'date,desc', page: $scope.pageNumber }).get();
|
var transactions = $resource('/api/transactions/search/forAccount', { accountId: $scope.account.id, size: $scope.pageSize, sort: 'date,desc', page: $scope.pageNumber }).get();
|
||||||
transactions.$promise.then(function(data) {
|
transactions.$promise.then(function(data) {
|
||||||
for (i = 0; i < transactions._embedded.transactions.length; i++) {
|
for (i = 0; i < transactions._embedded.transactions.length; i++) {
|
||||||
transactions._embedded.transactions[i].amount = numberToAmount(transactions._embedded.transactions[i].amount);
|
transactions._embedded.transactions[i].amount = numberToAmount(transactions._embedded.transactions[i].amount);
|
||||||
@@ -188,7 +188,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.updateSuggestions = function(val) {
|
$scope.updateSuggestions = function(val) {
|
||||||
var suggestions = $resource('/transactions/search/descriptions', { accountId: $scope.account.id, prefix: val.toLowerCase() }).get();
|
var suggestions = $resource('/api/transactions/search/descriptions', { accountId: $scope.account.id, prefix: val.toLowerCase() }).get();
|
||||||
return suggestions.$promise.then(function(data) {
|
return suggestions.$promise.then(function(data) {
|
||||||
var newSuggestions = new Array(suggestions._embedded.transactions.length);
|
var newSuggestions = new Array(suggestions._embedded.transactions.length);
|
||||||
for (i = 0; i < suggestions._embedded.transactions.length; i++) {
|
for (i = 0; i < suggestions._embedded.transactions.length; i++) {
|
||||||
@@ -360,17 +360,17 @@ transactionControllers.controller('ImportCtrl', [ '$scope', '$resource', '$locat
|
|||||||
userinfo.$promise.then(function(data) {
|
userinfo.$promise.then(function(data) {
|
||||||
$scope.userid = userinfo.name;
|
$scope.userid = userinfo.name;
|
||||||
|
|
||||||
userinfo = $resource('/users/search/findByUsername', { username: $scope.userid }).get();
|
userinfo = $resource('/api/users/search/findByUsername', { username: $scope.userid }).get();
|
||||||
userinfo.$promise.then(function(data) {
|
userinfo.$promise.then(function(data) {
|
||||||
$scope.userinfo = userinfo;
|
$scope.userinfo = userinfo;
|
||||||
});
|
});
|
||||||
|
|
||||||
var accountInfo = $resource('/accounts/search/findByUserName', { username: $scope.userid }).get();
|
var accountInfo = $resource('/api/accounts/search/findByUserName', { username: $scope.userid }).get();
|
||||||
accountInfo.$promise.then(function(data) {
|
accountInfo.$promise.then(function(data) {
|
||||||
$scope.accounts = accountInfo._embedded.accounts;
|
$scope.accounts = accountInfo._embedded.accounts;
|
||||||
$scope.account = $scope.accounts[0];
|
$scope.account = $scope.accounts[0];
|
||||||
|
|
||||||
var categories = $resource('/categories/search/listForAccount', { accountId: $scope.account.id }).get();
|
var categories = $resource('/api/categories/search/listForAccount', { accountId: $scope.account.id }).get();
|
||||||
categories.$promise.then(function(data) {
|
categories.$promise.then(function(data) {
|
||||||
$scope.categories = categories._embedded.categories;
|
$scope.categories = categories._embedded.categories;
|
||||||
|
|
||||||
@@ -394,7 +394,7 @@ transactionControllers.controller('ImportListCtrl', [ '$scope', '$resource', '$l
|
|||||||
$scope.categories = ImportService.getCategories();
|
$scope.categories = ImportService.getCategories();
|
||||||
$scope.csv = Papa.parse(ImportService.getCSV()).data;
|
$scope.csv = Papa.parse(ImportService.getCSV()).data;
|
||||||
|
|
||||||
var matcherData = $resource('/matchers/search/listForAccount', { projection: 'full', accountId: $scope.account.id }).get();
|
var matcherData = $resource('/api/matchers/search/listForAccount', { projection: 'full', accountId: $scope.account.id }).get();
|
||||||
matcherData.$promise.then(function(data) {
|
matcherData.$promise.then(function(data) {
|
||||||
matcherData = matcherData._embedded.matchers;
|
matcherData = matcherData._embedded.matchers;
|
||||||
$scope.matchers = new Array(matcherData.length);
|
$scope.matchers = new Array(matcherData.length);
|
||||||
@@ -464,6 +464,9 @@ transactionControllers.controller('ImportListCtrl', [ '$scope', '$resource', '$l
|
|||||||
$scope.importTransaction = function(line) {
|
$scope.importTransaction = function(line) {
|
||||||
if (line.targetCategory) {
|
if (line.targetCategory) {
|
||||||
|
|
||||||
|
console.log(line[1]);
|
||||||
|
console.log(line[1].substr(6,4) + "-" + line[1].substr(3,2) + "-" + line[1].substr(0,2));
|
||||||
|
|
||||||
var newTransaction = new Transaction({
|
var newTransaction = new Transaction({
|
||||||
"account" : $scope.account._links.self.href,
|
"account" : $scope.account._links.self.href,
|
||||||
"amount" : line[4].replace(',', '.'),
|
"amount" : line[4].replace(',', '.'),
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
var transactionServices = angular.module('transactionServices', [ 'ngResource' ]);
|
var transactionServices = angular.module('transactionServices', [ 'ngResource' ]);
|
||||||
|
|
||||||
transactionServices.factory('Transaction', [ '$resource', function($resource) {
|
transactionServices.factory('Transaction', [ '$resource', function($resource) {
|
||||||
return $resource('/transactions/:id', { id: '@id' }, {
|
return $resource('/api/transactions/:id', { id: '@id' }, {
|
||||||
update : {
|
update : {
|
||||||
method : 'PUT'
|
method : 'PUT'
|
||||||
},
|
},
|
||||||
@@ -24,9 +24,9 @@
|
|||||||
<script src="js/papaparse.min.js"></script>
|
<script src="js/papaparse.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script src="js/app.js"></script>
|
<script src="app/app.js"></script>
|
||||||
<script src="js/controllers.js"></script>
|
<script src="app/controllers.js"></script>
|
||||||
<script src="js/services.js"></script>
|
<script src="app/services.js"></script>
|
||||||
|
|
||||||
<!-- Google fonts -->
|
<!-- Google fonts -->
|
||||||
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
|
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
|
||||||
|
|||||||
Reference in New Issue
Block a user