Commit d9681acbe17f17dcddaeaff643e365bc4c9c88cc
1 parent
2e188a0c
Exists in
master
and in
38 other branches
Move navbar controller to the main state
Showing
5 changed files
with
31 additions
and
8 deletions
Show diff stats
src/app/components/navbar/navbar.directive.js
@@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
21 | return directive; | 21 | return directive; |
22 | 22 | ||
23 | /** @ngInject */ | 23 | /** @ngInject */ |
24 | - function NavbarController(moment, $modal, AuthService, Session, $scope, AUTH_EVENTS) { | 24 | + function NavbarController(moment, $modal, AuthService, Session, $scope, $state, AUTH_EVENTS) { |
25 | var vm = this; | 25 | var vm = this; |
26 | 26 | ||
27 | // "vm.creation" is avaible by directive option "bindToController: true" | 27 | // "vm.creation" is avaible by directive option "bindToController: true" |
@@ -39,17 +39,20 @@ | @@ -39,17 +39,20 @@ | ||
39 | }; | 39 | }; |
40 | vm.logout = function() { | 40 | vm.logout = function() { |
41 | AuthService.logout(); | 41 | AuthService.logout(); |
42 | + $state.go($state.current, {}, {reload: true}); //TODO move to auth | ||
42 | }; | 43 | }; |
43 | $scope.$on(AUTH_EVENTS.loginSuccess, function() { | 44 | $scope.$on(AUTH_EVENTS.loginSuccess, function() { |
44 | if(vm.modalInstance) { | 45 | if(vm.modalInstance) { |
45 | vm.modalInstance.close(); | 46 | vm.modalInstance.close(); |
46 | vm.modalInstance = null; | 47 | vm.modalInstance = null; |
47 | } | 48 | } |
48 | - vm.currentUser = Session.getCurrentUser(); | 49 | + $state.go($state.current, {}, {reload: true}); //TODO move to auth |
49 | }); | 50 | }); |
50 | $scope.$on(AUTH_EVENTS.logoutSuccess, function() { | 51 | $scope.$on(AUTH_EVENTS.logoutSuccess, function() { |
51 | vm.currentUser = Session.getCurrentUser(); | 52 | vm.currentUser = Session.getCurrentUser(); |
52 | }); | 53 | }); |
54 | + | ||
55 | + if(!vm.currentUser) vm.openLogin(); | ||
53 | } | 56 | } |
54 | } | 57 | } |
55 | 58 |
src/app/index.route.js
@@ -9,10 +9,10 @@ | @@ -9,10 +9,10 @@ | ||
9 | $urlRouterProvider.when('/profile/:profile', '/:profile'); | 9 | $urlRouterProvider.when('/profile/:profile', '/:profile'); |
10 | 10 | ||
11 | $stateProvider | 11 | $stateProvider |
12 | - .state('profile', { | ||
13 | - url: '/:profile', | ||
14 | - templateUrl: 'app/profile/profile.html', | ||
15 | - controller: 'ProfileController', | 12 | + .state('main', { |
13 | + url: '/', | ||
14 | + templateUrl: 'app/main/main.html', | ||
15 | + controller: 'MainController', | ||
16 | controllerAs: 'vm', | 16 | controllerAs: 'vm', |
17 | resolve: { | 17 | resolve: { |
18 | currentUser: function(AuthService) { | 18 | currentUser: function(AuthService) { |
@@ -20,7 +20,13 @@ | @@ -20,7 +20,13 @@ | ||
20 | } | 20 | } |
21 | } | 21 | } |
22 | }) | 22 | }) |
23 | - .state('profile.page', { | 23 | + .state('main.profile', { |
24 | + url: ':profile', | ||
25 | + templateUrl: 'app/profile/profile.html', | ||
26 | + controller: 'ProfileController', | ||
27 | + controllerAs: 'vm' | ||
28 | + }) | ||
29 | + .state('main.profile.page', { | ||
24 | url: '/{page:.*}', | 30 | url: '/{page:.*}', |
25 | templateUrl: 'app/content-viewer/page.html', | 31 | templateUrl: 'app/content-viewer/page.html', |
26 | controller: 'ContentViewerController', | 32 | controller: 'ContentViewerController', |
src/index.html
@@ -25,7 +25,6 @@ | @@ -25,7 +25,6 @@ | ||
25 | <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p> | 25 | <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p> |
26 | <![endif]--> | 26 | <![endif]--> |
27 | 27 | ||
28 | - <acme-navbar></acme-navbar> | ||
29 | <div ui-view></div> | 28 | <div ui-view></div> |
30 | 29 | ||
31 | <!-- build:js(src) scripts/vendor.js --> | 30 | <!-- build:js(src) scripts/vendor.js --> |