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 | 21 | return directive; |
| 22 | 22 | |
| 23 | 23 | /** @ngInject */ |
| 24 | - function NavbarController(moment, $modal, AuthService, Session, $scope, AUTH_EVENTS) { | |
| 24 | + function NavbarController(moment, $modal, AuthService, Session, $scope, $state, AUTH_EVENTS) { | |
| 25 | 25 | var vm = this; |
| 26 | 26 | |
| 27 | 27 | // "vm.creation" is avaible by directive option "bindToController: true" |
| ... | ... | @@ -39,17 +39,20 @@ |
| 39 | 39 | }; |
| 40 | 40 | vm.logout = function() { |
| 41 | 41 | AuthService.logout(); |
| 42 | + $state.go($state.current, {}, {reload: true}); //TODO move to auth | |
| 42 | 43 | }; |
| 43 | 44 | $scope.$on(AUTH_EVENTS.loginSuccess, function() { |
| 44 | 45 | if(vm.modalInstance) { |
| 45 | 46 | vm.modalInstance.close(); |
| 46 | 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 | 51 | $scope.$on(AUTH_EVENTS.logoutSuccess, function() { |
| 51 | 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 | 9 | $urlRouterProvider.when('/profile/:profile', '/:profile'); |
| 10 | 10 | |
| 11 | 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 | 16 | controllerAs: 'vm', |
| 17 | 17 | resolve: { |
| 18 | 18 | currentUser: function(AuthService) { |
| ... | ... | @@ -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 | 30 | url: '/{page:.*}', |
| 25 | 31 | templateUrl: 'app/content-viewer/page.html', |
| 26 | 32 | controller: 'ContentViewerController', | ... | ... |
src/index.html
| ... | ... | @@ -25,7 +25,6 @@ |
| 25 | 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 | 26 | <![endif]--> |
| 27 | 27 | |
| 28 | - <acme-navbar></acme-navbar> | |
| 29 | 28 | <div ui-view></div> |
| 30 | 29 | |
| 31 | 30 | <!-- build:js(src) scripts/vendor.js --> | ... | ... |