You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. 'use strict';
  2. /* App Module */
  3. var luticate = angular.module('luticate', [
  4. 'ui.bootstrap',
  5. 'ui.router',
  6. 'luticateUtils',
  7. 'luticateAuth',
  8. 'LocalStorageModule',
  9. 'dialogs.main',
  10. 'ngSanitize',
  11. 'ui.validate'
  12. ]);
  13. luticate.config(['$stateProvider', '$urlRouterProvider', '$httpProvider',
  14. function($stateProvider, $urlRouterProvider, $httpProvider) {
  15. $stateProvider.state('root', {
  16. abstract: true,
  17. template: '<div ui-view=""></div>',
  18. resolve: {
  19. userData: ['luticateAuthUsers', function(luticateAuthUsers)
  20. {
  21. return luticateAuthUsers.loadUserData(null);
  22. }]
  23. }
  24. });
  25. $stateProvider.state('login',{
  26. url:'/',
  27. parent: 'root',
  28. templateUrl:'views/login.html',
  29. controller:'LoginController'
  30. });
  31. $stateProvider.state('home',{
  32. url:'/home',
  33. parent: 'root',
  34. templateUrl:'views/home.html',
  35. controller:'HomeController'
  36. });
  37. $stateProvider.state('users',{
  38. url:'/users',
  39. parent: 'root',
  40. templateUrl:'views/users.html',
  41. controller:'UsersController'
  42. });
  43. $stateProvider.state('groups',{
  44. url:'/groups',
  45. parent: 'root',
  46. templateUrl:'views/groups.html',
  47. controller:'GroupsController'
  48. });
  49. $stateProvider.state('permissions',{
  50. url:'/permissions',
  51. parent: 'root',
  52. templateUrl:'views/permissions.html',
  53. controller:'PermissionsController'
  54. });
  55. $stateProvider.state('settings',{
  56. url:'/settings',
  57. parent: 'root',
  58. templateUrl:'views/settings.html',
  59. controller:'SettingsController'
  60. });
  61. $stateProvider.state('test',{
  62. url:'/test',
  63. parent: 'root',
  64. templateUrl:'views/test.html',
  65. controller:'TestController'
  66. });
  67. $urlRouterProvider.otherwise('/');
  68. $httpProvider.interceptors.push(['luticateAuthCache', '$injector', '$q',
  69. function (luticateAuthCache, $injector, $q) {
  70. return {
  71. 'request': function (config) {
  72. var token = luticateAuthCache.getToken();
  73. if (token != null)
  74. config.headers['X-Authorization'] = token;
  75. return config;
  76. },
  77. 'responseError': function(rejection) {
  78. /*if (rejection.status == 401) {
  79. luticateAuthCache.removeUser();
  80. $injector.get('$state').transitionTo('login');
  81. }*/
  82. return $q.reject(rejection);
  83. }
  84. };
  85. }]);
  86. }])
  87. .run(['$rootScope', '$state',function ($rootScope, $state) {
  88. $rootScope.$on('$stateChangeError', function (e, curr, prev) {
  89. //$state.go('login');
  90. });
  91. }]);