forked from umdhelpdesk/whenWeWorkClient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
52 lines (48 loc) · 1.49 KB
/
app.js
File metadata and controls
52 lines (48 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var app = angular.module('hdsp', ['ui.router','ui.bootstrap']);
app.config( function($stateProvider, $urlRouterProvider, $locationProvider){
//$locationProvider.html5Mode(true);
$stateProvider
.state('signin', {
url: '/signin',
templateUrl: 'views/signin.html',
controller: 'LoginCtrl'
})
.state('signup',{
url:'/signup',
templateUrl: 'views/signup.html',
controller: 'SignupCtrl'
})
.state('dashboard', {
url:'/dashboard',
templateUrl: 'views/dashboard.html',
controller: 'DashboardCtrl'
})
.state('dashboard.addAvailability',{
url:'/availability',
templateUrl: 'views/availability.html',
controller: 'AvailabilityCtrl'
})
.state('dashboard.admin',{
url:'/admin',
templateUrl: 'views/adminmain.html',
controller: 'AdminCtrl'
})
.state('dashboard.calendar',{
url:'/calendar',
templateUrl: 'views/calendar.html',
controller: 'CalendarCtrl'
});
$urlRouterProvider.otherwise('/signin');
});
//.run is like a main function
app.run(function ($rootScope, $state, AuthService, AUTH_EVENTS){
$rootScope.$on('stateChangeStart', function(event, next, nextParams, fromState){
if(!AuthService.isAuthenticated()){
console.log(next.name);
if(next.name !== 'signin' && next.name !== 'signup'){
event.preventDefault();
$state.go('signin');
}
}
});
});