Import feature and cache tuning

This commit is contained in:
2016-07-28 16:21:59 +02:00
parent db7f651157
commit 6bc9dca2c3
7 changed files with 55 additions and 26 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ https://letsencrypt.org/getting-started/
# TODO # TODO
- Server: SSL und logs konfigurieren - Server: logs konfigurieren
- Transaktionen mit Passwort-Management ausstatten, Usermanagement korrekt aufsetzen und Rollen durchreichen (derzeit noch inMemoryAuthentication) - Transaktionen mit Passwort-Management ausstatten, Usermanagement korrekt aufsetzen und Rollen durchreichen (derzeit noch inMemoryAuthentication)
- http://kielczewski.eu/2014/12/spring-boot-security-application/ - http://kielczewski.eu/2014/12/spring-boot-security-application/
- http://spr.com/part-5-integrating-spring-security-with-spring-boot-web/ - http://spr.com/part-5-integrating-spring-security-with-spring-boot-web/
+1 -1
View File
@@ -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.2.1</version> <version>1.3.0</version>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@@ -1,7 +1,10 @@
package de.tilman.transactions; package de.tilman.transactions;
import org.h2.server.web.WebServlet;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
@SpringBootApplication @SpringBootApplication
public class Application { public class Application {
@@ -11,7 +11,6 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.header.HeaderWriter; import org.springframework.security.web.header.HeaderWriter;
import org.springframework.security.web.header.writers.CacheControlHeadersWriter;
@Configuration @Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true) @EnableGlobalMethodSecurity(prePostEnabled = true)
@@ -28,29 +27,32 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
// Basis-Schutz: Nur autorisierte Zugriffe (feingranulare Steuerung über Assertions) // Basis-Schutz: Nur autorisierte Zugriffe (feingranulare Steuerung über Assertions)
http.authorizeRequests().antMatchers(HttpMethod.GET, "/public/**").permitAll() http.authorizeRequests().antMatchers(HttpMethod.GET, "/public/**").permitAll()
// .antMatchers("/console/**").permitAll() // H2 console for the dev database // .antMatchers("/console/**").permitAll() // H2 console for the dev database
.anyRequest().authenticated(); .anyRequest().authenticated();
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 H2 console
// configure caching // configure caching
http.headers().cacheControl().disable(); http.headers().cacheControl().disable();
http.headers().addHeaderWriter(new HeaderWriter() { http.headers().addHeaderWriter(new HeaderWriter() {
CacheControlHeadersWriter originalWriter = new CacheControlHeadersWriter(); // for dev
// CacheControlHeadersWriter originalWriter = new CacheControlHeadersWriter();
@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")) {
originalWriter.writeHeaders(request, response);
} else {
response.setHeader("Cache-Control", "public, max-age=10000000"); response.setHeader("Cache-Control", "public, max-age=10000000");
} }
else {
response.setHeader("Cache-Control", "public, max-age=600000");
// originalWriter.writeHeaders(request, response);
}
} }
}); });
} }
+23 -6
View File
@@ -402,14 +402,14 @@ transactionControllers.controller('ImportCtrl', [ '$scope', '$resource', '$locat
}); });
// XXX // XXX
$scope.csvInput = "\"08.07.2016\";\"08.07.2016\";\"Übertrag/Überweisung\";\"Empfänger: Tilman Liero Kto/IBAN: DE44200411330649163305 BLZ/BIC: COBADEHD001 Buchungstext: none End-to-End-Ref.: nicht angegeben Ref. JK21619010302362/2\";\"-40,00\";\n\"27.06.2016\";\"27.06.2016\";\"Lastschrift/Belast.\";\"Auftraggeber: DANKE, IHR LIDL Kto/IBAN: DE61300500000008000119 Buchungstext: Kartenzahlung DANKE, IHR LIDL//Berlin/DE 2016-06-25T09:47:08 KFN 2 VJ 1912 Ref. 6GL16179A2640086/6763\";\"-70,17\";\n\"24.06.2016\";\"24.06.2016\";\"Übertrag/Überweisung\";\"Auftraggeber: Tilman Liero Buchungstext: Uebertrag comdirect bank End-to-End-Ref.: nicht angegeben Ref. IX216176F0205292/1\";\"200,00\";\n\"24.06.2016\";\"24.06.2016\";\"Übertrag/Überweisung\";\"Auftraggeber: Wohnungsbau-Verein Neukölln eG Buchungstext: Mg.-Nr. 35823, Walther, Tilman - 4, Dividende 2015 End-to-End-Ref.: nicht angegeben Ref. H221617674648332/35629\";\"4,42\";"; $scope.csvInput = "\"30.07.2016\";\"30.07.2016\";\"Übertrag/Überweisung\";\"Empfänger: Tilman Liero Kto/IBAN: DE44200411330649163305 BLZ/BIC: COBADEHD001 Buchungstext: none End-to-End-Ref.: nicht angegeben Ref. JK21619010302362/2\";\"-40,00\";\n\"29.07.2016\";\"29.07.2016\";\"Lastschrift/Belast.\";\"Auftraggeber: DANKE, IHR LIDL Kto/IBAN: DE61300500000008000119 Buchungstext: Kartenzahlung DANKE, IHR LIDL//Berlin/DE 2016-06-25T09:47:08 KFN 2 VJ 1912 Ref. 6GL16179A2640086/6763\";\"-70,17\";\n\"28.07.2016\";\"28.07.2016\";\"Übertrag/Überweisung\";\"Auftraggeber: Tilman Liero Buchungstext: Uebertrag comdirect bank End-to-End-Ref.: nicht angegeben Ref. IX216176F0205292/1\";\"200,00\";\n\"28.07.2016\";\"28.07.2016\";\"Übertrag/Überweisung\";\"Auftraggeber: Wohnungsbau-Verein Neukölln eG Buchungstext: Mg.-Nr. 35823, Walther, Tilman - 4, Dividende 2015 End-to-End-Ref.: nicht angegeben Ref. H221617674648332/35629\";\"4,42\";";
} }
$scope.initPage(); $scope.initPage();
} ]); } ]);
transactionControllers.controller('ImportListCtrl', [ '$scope', '$resource', '$location', 'ImportService', function($scope, $resource, $location, ImportService) { transactionControllers.controller('ImportListCtrl', [ '$scope', '$resource', '$location', 'ImportService', 'Transaction', function($scope, $resource, $location, ImportService, Transaction) {
$scope.processCSV = function () { $scope.processCSV = function () {
$scope.account = ImportService.getAccount(); $scope.account = ImportService.getAccount();
@@ -452,10 +452,6 @@ transactionControllers.controller('ImportListCtrl', [ '$scope', '$resource', '$l
} }
// XXX
console.log(matcherData);
console.log($scope.matchers);
for (i = 0; i < $scope.csv.length; i++) { for (i = 0; i < $scope.csv.length; i++) {
var matched = false; var matched = false;
var j = 0; var j = 0;
@@ -487,5 +483,26 @@ transactionControllers.controller('ImportListCtrl', [ '$scope', '$resource', '$l
}); });
} }
$scope.importTransaction = function(line) {
if (line.targetCategory) {
var newTransaction = new Transaction({
"account" : $scope.account._links.self.href,
"amount" : line[4].replace(',', '.'),
"date" : new Date(line[1].substr(6,4), line[1].substr(3,2), line[1].substr(0,2)),
"description" : line.targetDescription,
"category" : line.targetCategory._links.self.href,
"creditor" : ""
});
newTransaction.$save(function(transaction) {
line.submitted = true;
console.log(transaction);
line.submittedTransactionLink = transaction._links.self.href;
line.submittedTransactionId = transaction.id;
});
}
}
} ]); } ]);
@@ -1,20 +1,22 @@
<div class="container" ng-init="processCSV()"> <div class="container" ng-init="processCSV()">
<div class="row"> <div class="row">
<div>Import to <h2 style="margin-top: 1ex; margin-bottom: 2ex;">{{account.name}}</h2></div>
<table class="importTable"> <table class="importTable">
<tr> <tr>
<th style="width: 5%;" class="spacer"></th> <th style="width: 5%;">Wertstellung</th>
<th style="width: 8%;">Wertstellung</th>
<th style="width: 8%;">Typ</th> <th style="width: 8%;">Typ</th>
<th style="width: 35%;">Text</th> <th style="width: 41%;">Text</th>
<th style="width: 9%;">Betrag</th> <th style="width: 5%;">Betrag</th>
<th class="spacer"></th> <th class="spacer"></th>
<th style="width: 14%;">Kategorie</th> <th style="width: 14%;">Kategorie</th>
<th style="width: 14%;">Notiz</th> <th style="width: 14%;">Notiz</th>
<th class="spacer"></th> <th class="spacer"></th>
<th style="width: 5%;">Matcher</th> <th style="width: 5%;">Matcher</th>
<th class="spacer"></th>
<th style="width: 5%; border: none; background: transparent;"></th>
</tr> </tr>
<tr ng-repeat="line in csv"> <tr ng-repeat="line in csv">
<td class="spacer"></td>
<td>{{line[1]}}</td> <td>{{line[1]}}</td>
<td>{{line[2]}}</td> <td>{{line[2]}}</td>
<td>{{line[3]}}</td> <td>{{line[3]}}</td>
@@ -25,11 +27,17 @@
id="categorySelect" id="categorySelect"
ng-model='line.targetCategory' ng-model='line.targetCategory'
size='1' size='1'
ng-options="category.name for category in categories track by category._links.self.href"></select> ng-options="category.name for category in categories track by category._links.self.href">
</select>
</td> </td>
<td>{{line.targetDescription}}</td> <td><input value="{{line.targetDescription}}"></input></td>
<td class="spacer"></td> <td class="spacer"></td>
<td align="center">{{line.matcherPosition}}</td> <td align="center">{{line.matcherPosition}}</td>
<td class="spacer"></td>
<td style="border: none; background: transparent; text-align: center;">
<button class="btn btn-primary" ng-disabled="!line.targetCategory" ng-click="importTransaction(line)" ng-show="!line.submitted">OK</button>
<a href="{{line.submittedTransactionLink}}" ng-show="line.submittedTransactionId">{{line.submittedTransactionId}}</a>
</td>
</tr> </tr>
</table> </table>
</div> </div>
@@ -46,7 +54,7 @@
<th style="width: 14%;">Target Description</th> <th style="width: 14%;">Target Description</th>
<th style="width: 6%;" class="spacer"></th> <th style="width: 6%;" class="spacer"></th>
</tr> </tr>
<tr ng-repeat="matcher in matchers"> <tr ng-repeat="matcher in matchers" ng-click="openDetails(matcher)">
<td align="center">{{matcher.position}}</td> <td align="center">{{matcher.position}}</td>
<td>{{matcher.dateMatcherCode}}</td> <td>{{matcher.dateMatcherCode}}</td>
<td>{{matcher.typeMatcherCode}}</td> <td>{{matcher.typeMatcherCode}}</td>
@@ -3,14 +3,13 @@
<div ng-show="accounts.length > 1" style="margin: 2ex; text-align: center; font-size: 120%;"> <div ng-show="accounts.length > 1" style="margin: 2ex; text-align: center; font-size: 120%;">
<select <select
ng-model='account' ng-model='account'
ng-change='initPage()'
ng-options="account.name for account in accounts track by account.id"></select> ng-options="account.name for account in accounts track by account.id"></select>
</div> </div>
<form name="importForm" ng-submit="importCSV()" style="text-align: center;"> <form name="importForm" ng-submit="importCSV()" style="text-align: center;">
<textarea ng-model='csvInput' name="csvText" cols="140" rows="20"></textarea> <textarea ng-model='csvInput' name="csvText" cols="140" rows="20"></textarea>
<div> <div style="margin: 2ex;">
<button id="transactionSubmit" type="submit" class="btn btn-primary"> <button id="transactionSubmit" type="submit" class="btn btn-primary">
<span ng-show="waitingForImport"><i class="glyphicon glyphicon-refresh spinning"></i>&nbsp;</span> <span ng-show="waitingForImport"><i class="glyphicon glyphicon-refresh spinning"></i>&nbsp;</span>
Analyze Analyze