This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
executable file
·111 lines (98 loc) · 3.37 KB
/
app.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//angular.module('ossdbWeb', ['ui.bootstrap', 'ui.utils', 'ui.router', 'ngAnimate', 'ngSanitize', 'ui.select']);
angular.module('ossdbWeb', ['ui.bootstrap', 'ui.utils', 'ui.router', 'ngSanitize', 'ui.select']);
angular.module('ossdbWeb').config(function ($stateProvider, $urlRouterProvider, $logProvider, $httpProvider) {
$httpProvider.defaults.withCredentials = true;
$stateProvider.state('project', {
url: '/project/:page',
templateUrl: 'partial/project/project.html'
});
$stateProvider.state('ossp', {
url: '/ossp/:page',
templateUrl: 'partial/ossp/ossp.html'
});
$stateProvider.state('license', {
url: '/license/:page',
templateUrl: 'partial/license/license.html'
});
$stateProvider.state('package', {
url: '/package/:page',
templateUrl: 'partial/package/package.html'
});
$stateProvider.state('home', {
url: '/home',
templateUrl: 'partial/home/home.html'
});
$stateProvider.state('ossp-detail', {
url: '/ossp-detail/:id?fromPage',
templateUrl: 'partial/ossp-detail/ossp-detail.html'
});
$stateProvider.state('license-detail', {
url: '/license-detail/:id?fromPage',
templateUrl: 'partial/license-detail/license-detail.html'
});
$stateProvider.state('package-detail', {
url: '/package-detail/:id?fromPage',
// url: '/package-detail/{id}/{fromPage:(?:/[^/]+)?}',
templateUrl: 'partial/package-detail/package-detail.html'
});
$stateProvider.state('project-detail', {
url: '/project-detail/:id?fromPage',
templateUrl: 'partial/project-detail/project-detail.html'
});
/**
* Anonymous routes
*/
$stateProvider.state('anonymous', {
abstract: true,
template: '<ui-view/>',
data: {
access: 'anonymous'
}
}).state('login', {
url: '/login',
templateUrl: 'partial/login/login.html'
}).state('register', {
url: '/register',
templateUrl: 'partial/register/register.html'
}).state('profile', {
url: '/profile',
templateUrl: 'partial/profile/profile.html'
});
/* Add New States Above */
$urlRouterProvider.otherwise('/home');
/**
* enable log
*/
$logProvider.debugEnabled(true);
});
angular.module('ossdbWeb').run(function ($rootScope) {
$rootScope.safeApply = function (fn) {
var phase = $rootScope.$$phase;
if (phase === '$apply' || phase === '$digest') {
if (fn && (typeof(fn) === 'function')) {
fn();
}
} else {
this.$apply(fn);
}
};
});
angular.module('ossdbWeb').controller('NavCtrl',function($rootScope, $scope, $ossdb, $state){
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
console.log('$stateChangeStart: ' + fromState.name + '->' + toState.name);
if (toState.name === 'login' || toState.name === 'register') {
return;
}
$ossdb.profile(function(err, user) {
if (err) {
//if (err.status === 401 || err.status === 403) {
if (err.status === 401) {
$state.go('login');
}
console.log(err);
return;
}
$scope.user = user;
});
});
});