forked from angular-app/angular-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
69 lines (58 loc) · 2.57 KB
/
Copy pathapp.js
File metadata and controls
69 lines (58 loc) · 2.57 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
angular.module('app', [
'login',
'projectsinfo',
'dashboard',
'projects',
'admin',
'services.breadcrumbs',
'services.i18nNotifications',
'services.httpRequestTracker',
'directives.crud',
'templates']);
angular.module('app').constant('MONGOLAB_CONFIG', {
baseUrl: '/databases/',
dbName: 'ascrum'
});
//TODO: move those messages to a separate module
angular.module('app').constant('I18N.MESSAGES', {
'errors.route.changeError':'Route change error',
'crud.user.save.success':"A user with id '{{id}}' was saved successfully.",
'crud.user.remove.success':"A user with id '{{id}}' was removed successfully.",
'crud.user.save.error':"Something went wrong when saving a user...",
'crud.project.save.success':"A project with id '{{id}}' was saved successfully.",
'crud.project.remove.success':"A project with id '{{id}}' was removed successfully.",
'crud.project.save.error':"Something went wrong when saving a project...",
'login.error.notAuthorized':"You do not have the necessary access permissions. Do you want to login as someone else?",
'login.error.notAuthenticated':"You must be logged in to access this part of the application."
});
angular.module('app').config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider.otherwise({redirectTo:'/projectsinfo'});
}]);
angular.module('app').controller('AppCtrl', ['$scope', 'i18nNotifications', 'localizedMessages', function($scope, i18nNotifications) {
$scope.notifications = i18nNotifications;
$scope.removeNotification = function (notification) {
i18nNotifications.remove(notification);
};
$scope.$on('$routeChangeError', function(event, current, previous, rejection){
i18nNotifications.pushForCurrentRoute('errors.route.changeError', 'error', {}, {rejection: rejection});
});
}]);
angular.module('app').controller('HeaderCtrl', ['$scope', '$location', '$route', 'currentUser', 'breadcrumbs', 'notifications', 'httpRequestTracker', function ($scope, $location, $route, currentUser, breadcrumbs, notifications, httpRequestTracker) {
$scope.location = $location;
$scope.currentUser = currentUser;
$scope.breadcrumbs = breadcrumbs;
$scope.home = function () {
if ($scope.currentUser.isAuthenticated()) {
$location.path('/dashboard');
} else {
$location.path('/projectsinfo');
}
};
$scope.isNavbarActive = function (navBarPath) {
return navBarPath === breadcrumbs.getFirst().name;
};
$scope.hasPendingRequests = function () {
return httpRequestTracker.hasPendingRequests();
};
}]);