Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

app.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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('login',{
  16. url:'/',
  17. templateUrl:'views/login.html',
  18. controller:'LoginController'
  19. });
  20. $stateProvider.state('home',{
  21. url:'/home',
  22. templateUrl:'views/home.html',
  23. controller:'HomeController'
  24. });
  25. $stateProvider.state('users',{
  26. url:'/users',
  27. templateUrl:'views/users.html',
  28. controller:'UsersController'
  29. });
  30. $stateProvider.state('groups',{
  31. url:'/groups',
  32. templateUrl:'views/groups.html',
  33. controller:'GroupsController'
  34. });
  35. $stateProvider.state('permissions',{
  36. url:'/permissions',
  37. templateUrl:'views/permissions.html',
  38. controller:'PermissionsController'
  39. });
  40. $stateProvider.state('settings',{
  41. url:'/settings',
  42. templateUrl:'views/settings.html',
  43. controller:'SettingsController'
  44. });
  45. $stateProvider.state('test',{
  46. url:'/test',
  47. templateUrl:'views/test.html',
  48. controller:'TestController'
  49. });
  50. $urlRouterProvider.otherwise('/');
  51. $httpProvider.interceptors.push(['luticateAuthCache', '$injector', '$q',
  52. function (luticateAuthCache, $injector, $q) {
  53. return {
  54. 'request': function (config) {
  55. var token = luticateAuthCache.getToken();
  56. if (token != null)
  57. config.headers['X-Authorization'] = token;
  58. return config;
  59. },
  60. 'responseError': function(rejection) {
  61. /*if (rejection.status == 401) {
  62. luticateAuthCache.removeUser();
  63. $injector.get('$state').transitionTo('login');
  64. }*/
  65. return $q.reject(rejection);
  66. }
  67. };
  68. }]);
  69. }])
  70. .run(['$rootScope', '$state', 'luticateAuthUsers',function ($rootScope, $state, luticateAuthUsers) {
  71. luticateAuthUsers.loadPermissions(null);
  72. $rootScope.$on('$stateChangeError', function (e, curr, prev) {
  73. $state.go('login');
  74. });
  75. }]);