From 8d30eb2d4f412fbfcc2f7f2f0f0435c986c38600 Mon Sep 17 00:00:00 2001 From: Lim Han Date: Wed, 4 Feb 2015 22:32:07 +0800 Subject: [PATCH] LH :: Activated Dashboard screen --- src/main/webapp/WEB-INF/jsp/index.jsp | 1 + .../components/dashboard/DashboardController.js | 3 +++ .../webapp/components/dashboard/dashboard.html | 8 ++++---- .../webapp/components/main/MainController.js | 11 +++++++++++ .../components/veterinarians/veterinarians.html | 2 +- src/main/webapp/js/app.js | 17 ++++++++++++++--- 6 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 src/main/webapp/components/dashboard/DashboardController.js diff --git a/src/main/webapp/WEB-INF/jsp/index.jsp b/src/main/webapp/WEB-INF/jsp/index.jsp index 233334665..b47e43178 100644 --- a/src/main/webapp/WEB-INF/jsp/index.jsp +++ b/src/main/webapp/WEB-INF/jsp/index.jsp @@ -39,6 +39,7 @@ + diff --git a/src/main/webapp/components/dashboard/DashboardController.js b/src/main/webapp/components/dashboard/DashboardController.js new file mode 100644 index 000000000..f3c31c31a --- /dev/null +++ b/src/main/webapp/components/dashboard/DashboardController.js @@ -0,0 +1,3 @@ +var DashboardController = ['$scope',function($scope) { + +}]; \ No newline at end of file diff --git a/src/main/webapp/components/dashboard/dashboard.html b/src/main/webapp/components/dashboard/dashboard.html index 2395c2987..0d380aed2 100644 --- a/src/main/webapp/components/dashboard/dashboard.html +++ b/src/main/webapp/components/dashboard/dashboard.html @@ -1,11 +1,11 @@ - + - + - + - + diff --git a/src/main/webapp/components/main/MainController.js b/src/main/webapp/components/main/MainController.js index e491d77f3..5652ed19c 100644 --- a/src/main/webapp/components/main/MainController.js +++ b/src/main/webapp/components/main/MainController.js @@ -6,10 +6,12 @@ var MainController = ['$scope','$rootScope','$state',function($scope, $rootScop $scope.login = function() { $scope.session = { 'username' : 'test' }; + $state.go('dashboard'); }; $scope.logout = function() { $scope.session = null; + $state.go('landing'); }; $scope.menuTabs = [ { @@ -37,5 +39,14 @@ var MainController = ['$scope','$rootScope','$state',function($scope, $rootScop $scope.footerText = '© ' + new Date().getFullYear() + ' Pet Clinic, A Spring Framework Demonstration'; $rootScope.$state = $state; + + $rootScope.$on('$stateChangeStart', function (event, toState, toParams) { + var requireLogin = toState.data.requireLogin; + + if (requireLogin && $scope.session == null) { + event.preventDefault(); + $state.go('landing'); + } + }); }]; diff --git a/src/main/webapp/components/veterinarians/veterinarians.html b/src/main/webapp/components/veterinarians/veterinarians.html index e6f0a6103..496e2c3d8 100644 --- a/src/main/webapp/components/veterinarians/veterinarians.html +++ b/src/main/webapp/components/veterinarians/veterinarians.html @@ -12,7 +12,7 @@
- Generic placeholder image + Generic placeholder image

Veterinarian Name

Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum.

diff --git a/src/main/webapp/js/app.js b/src/main/webapp/js/app.js index 2b70533cc..3564b4a49 100644 --- a/src/main/webapp/js/app.js +++ b/src/main/webapp/js/app.js @@ -11,27 +11,38 @@ app.config(['stateHelperProvider','$urlRouterProvider','$urlMatcherFactoryProvid url: "/", templateUrl: "components/landing/landing.html", controller: "MainController", + data: { requireLogin : false } + }).state({ + name: "dashboard", + url: "/dashboard", + templateUrl: "components/dashboard/dashboard.html", + controller: "DashboardController", + data: { requireLogin : true } }).state({ name: "vets", url: "/vets", templateUrl: "components/veterinarians/veterinarians.html", controller: "VeterinarianController", + data: { requireLogin : true } }).state({ name: "pets", url: "/pets", templateUrl: "components/pets/pets.html", - controller: "PetController" + controller: "PetController", + data: { requireLogin : true } }).state({ name: "owners", url: "/owners", templateUrl: "components/owners/owners.html", - controller: "OwnerController" + controller: "OwnerController", + data: { requireLogin : true } }); } ]); /** Controllers **/ app.controller('MainController', MainController); +app.controller('DashboardController', DashboardController); app.controller('VeterinarianController', VeterinarianController); app.controller('PetController', PetController); app.controller('OwnerController', OwnerController); @@ -50,7 +61,7 @@ app.directive('scrollToTarget', function() { element.bind('click', function() { angular.element('html, body').stop().animate({ scrollTop: angular.element(angular.element(element).attr('href')).offset().top - 20 - }, 1500); + }, 1500); return false; }); };