C of CRUD

This commit is contained in:
2016-03-08 22:31:37 +01:00
parent 4113246222
commit 70d6b42539
4 changed files with 24 additions and 14 deletions
+3 -1
View File
@@ -1 +1,3 @@
Aloha, funky time! Aloha, funky time!
curl -i -X POST -H "Content-Type:application/json" -d '{"account":"http://localhost:8080/accounts/1","amount":12.3,"date":"2016-05-31T22:00:00.000+0000","description":"test","category":"http://localhost:8080/categories/1"}' http://localhost:8080/transactions
@@ -23,9 +23,9 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override @Override
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() // http.authorizeRequests()
.antMatchers(HttpMethod.GET, "/public/**").permitAll() // .antMatchers(HttpMethod.GET, "/public/**").permitAll()
.anyRequest().authenticated(); // .anyRequest().authenticated();
// http.httpBasic(); // XXX mit HTTP Basic Auth funktioniert der Logout nicht richtig // http.httpBasic(); // XXX mit HTTP Basic Auth funktioniert der Logout nicht richtig
http.formLogin(); http.formLogin();
+12 -8
View File
@@ -14,19 +14,16 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
for (var i = 0; i < $scope.transactions.length; i++) { for (var i = 0; i < $scope.transactions.length; i++) {
$scope.transactions[i].category = $resource($scope.transactions[i]._links.category.href).get(); $scope.transactions[i].category = $resource($scope.transactions[i]._links.category.href).get();
$scope.transactions[i].creditor = $resource($scope.transactions[i]._links.creditor.href).get(); $scope.transactions[i].creditor = $resource($scope.transactions[i]._links.creditor.href).get();
// $scope.transactions[i].account = $resource($scope.transactions[i]._links.account.href).get();
} }
// XXX get selected account from frontend
$scope.account = $scope.transactions[0]._links.account;
}); });
} }
$scope.initList = function() { $scope.initList = function() {
// TODO pass accountId // TODO get account from frontend
$scope.accountId = 1; $scope.accountId = 1;
$scope.account = 'http://localhost:8080/accounts/1';
console.log('initList()'); console.log('initList()');
@@ -63,15 +60,22 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
"amount" : $scope.amount, "amount" : $scope.amount,
"date" : $scope.date, "date" : $scope.date,
"description" : $scope.description, "description" : $scope.description,
"category" : $scope.category, "category" : $scope.category._links.self.href,
"creditor" : $scope.creditor "creditor" : $scope.creditor
}); });
console.log(newTransaction); console.log(newTransaction);
newTransaction.$save(); // create copy of transaction object
var newTransactionCopy = (JSON.parse(JSON.stringify(newTransaction)));
$scope.newTransaction = newTransaction;
$scope.newTransactionCopy = newTransactionCopy;
newTransaction.$save(function(transaction, putResponseHeaders) {
$scope.refreshList();
});
$scope.refreshList();
}; };
$scope.showTransaction = function(transaction) { $scope.showTransaction = function(transaction) {
@@ -37,11 +37,15 @@
</table> </table>
<div> <div>
<pre style="font-size: 75%">{{account | json}}</pre> <pre style="font-size: 75%; color: darkred;">{{newTransaction | json}}</pre>
</div> </div>
<div> <div>
<pre style="font-size: 75%">{{transactions | json}}</pre> <pre style="font-size: 75%; color: darkgreen;">{{newTransactionCopy | json}}</pre>
</div>
<div>
<pre style="font-size: 75%">{{account | json}}</pre>
</div> </div>
</div> </div>