diff --git a/src/main/java/de/tilman/transactions/SecurityConfiguration.java b/src/main/java/de/tilman/transactions/SecurityConfiguration.java index 504aefe..2dc0092 100644 --- a/src/main/java/de/tilman/transactions/SecurityConfiguration.java +++ b/src/main/java/de/tilman/transactions/SecurityConfiguration.java @@ -28,7 +28,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { // .antMatchers("/console/**").permitAll() // H2 console for the dev database .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.csrf().disable(); // XXX später wieder aktivieren diff --git a/src/main/resources/data-h2.sql b/src/main/resources/data-h2.sql index b898e1c..216b491 100644 --- a/src/main/resources/data-h2.sql +++ b/src/main/resources/data-h2.sql @@ -1,4 +1,4 @@ -INSERT INTO User (id, name, username) VALUES (1, 'Adam', 'adam@mail.com'), (2, 'Betty', 'betty@mail.com'), (3, 'Curt', 'curt@mail.com'); +INSERT INTO User (id, name, username) VALUES (1, 'Adam', 'adam'), (2, 'Betty', 'betty'), (3, 'Curt', 'curt'); INSERT INTO Account (id, name, owner_id) VALUES (1, 'Gemeinschaftskonto', 1), (2, 'Konto Adam', 1); INSERT INTO Category (id, name, account_id, position) VALUES diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html index 0963d7c..aa97f9d 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/static/index.html @@ -34,7 +34,7 @@ - + diff --git a/src/main/resources/static/js/controllers.js b/src/main/resources/static/js/controllers.js index 83f44ab..ab19dc2 100644 --- a/src/main/resources/static/js/controllers.js +++ b/src/main/resources/static/js/controllers.js @@ -359,7 +359,7 @@ transactionControllers.controller('OutstandingsModalCtrl', [ '$scope', '$uibModa } } ]); -transactionControllers.controller('ImportCtrl', [ '$scope', '$location', 'ImportService', function($scope, $location, ImportService) { +transactionControllers.controller('ImportCtrl', [ '$scope', '$resource', '$location', 'ImportService', function($scope, $resource, $location, ImportService) { $scope.importCSV = function () { ImportService.saveData($scope.csvInput); @@ -373,4 +373,45 @@ transactionControllers.controller('ImportCtrl', [ '$scope', '$location', 'Import console.log($scope.csv); } + // COPIED CODE from TransactionListCtrl.initList, needs to be moved into a Service + $scope.initPage = function () { + console.log('aloha'); + var userinfo = $resource('/user').get(); + userinfo.$promise.then(function(data) { + $scope.userid = userinfo.name; + + userinfo = $resource('/users/search/findByUsername', { username: $scope.userid }).get(); + userinfo.$promise.then(function(data) { + $scope.userinfo = userinfo; + }); + + var accountInfo = $resource('/accounts/search/findByUserName', { username: $scope.userid }).get(); + accountInfo.$promise.then(function(data) { + console.log(accountInfo._embedded.accounts); + $scope.accounts = accountInfo._embedded.accounts; + if ($scope.account == undefined) { + $scope.account = $scope.accounts[0]; + if ($routeParams.account != undefined) { + for (i = 0; i < $scope.accounts.length; i++) { + if ($scope.accounts[i].name == $routeParams.account) + $scope.account = $scope.accounts[i]; + } + } + } + + var categories = $resource('/categories/search/listForAccount', { accountId: $scope.account.id }).get(); + categories.$promise.then(function(data) { + $scope.categories = categories._embedded.categories; + + if ($scope.importForm) { + $scope.importForm.$setPristine(); + $scope.importForm.$setUntouched(); + } + }); + }); + }); + } + + $scope.initPage(); + } ]); diff --git a/src/main/resources/static/partials/import.html b/src/main/resources/static/partials/import.html index c5267cf..3f3fd75 100644 --- a/src/main/resources/static/partials/import.html +++ b/src/main/resources/static/partials/import.html @@ -1,5 +1,12 @@
+
+ +
+