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 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. 'use strict';
  2. /* App Module */
  3. var camotion = angular.module('camotionAdmin', [
  4. 'ui.bootstrap',
  5. 'ui.router',
  6. 'luticateUtils',
  7. 'luticateAuth',
  8. 'LocalStorageModule',
  9. 'dialogs.main',
  10. 'ngSanitize',
  11. 'JSONedit'
  12. ]);
  13. camotion.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider',
  14. function($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) {
  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('hosts',{
  26. url:'/hosts',
  27. templateUrl:'views/hosts.html',
  28. controller:'HostsController'
  29. });
  30. $stateProvider.state('cameras',{
  31. url:'/cameras',
  32. templateUrl:'views/cameras.html',
  33. controller:'CamerasController'
  34. });
  35. $urlRouterProvider.otherwise('/');
  36. $httpProvider.interceptors.push(['luticateAuthCache', '$injector', '$q',
  37. function (luticateAuthCache, $injector, $q) {
  38. return {
  39. 'request': function (config) {
  40. var token = luticateAuthCache.getToken();
  41. if (token != null)
  42. config.headers['X-Authorization'] = token;
  43. return config;
  44. },
  45. 'responseError': function(rejection) {
  46. return $q.reject(rejection);
  47. }
  48. };
  49. }]);
  50. }])
  51. .run(['$rootScope', '$state', 'luticateAuthUsers', function ($rootScope, $state, luticateAuthUsers) {
  52. luticateAuthUsers.loadPermissions(null);
  53. $rootScope.$on('$stateChangeError', function (e, curr, prev) {
  54. $state.go('login');
  55. });
  56. }]);