Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

app.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. 'camotionSdk'
  13. ]);
  14. camotion.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider',
  15. function($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) {
  16. $stateProvider.state('login',{
  17. url:'/',
  18. templateUrl:'views/login.html',
  19. controller:'LoginController'
  20. });
  21. $stateProvider.state('home',{
  22. url:'/home',
  23. templateUrl:'views/home.html',
  24. controller:'HomeController'
  25. });
  26. $stateProvider.state('hosts',{
  27. url:'/hosts',
  28. templateUrl:'views/hosts.html',
  29. controller:'HostsController'
  30. });
  31. $stateProvider.state('cameras',{
  32. url:'/cameras',
  33. templateUrl:'views/cameras.html',
  34. controller:'CamerasController'
  35. });
  36. $stateProvider.state('sensors',{
  37. url:'/sensors',
  38. templateUrl:'views/sensors.html',
  39. controller:'SensorsController'
  40. });
  41. $stateProvider.state('commands',{
  42. url:'/commands',
  43. templateUrl:'views/commands.html',
  44. controller:'CommandsController'
  45. });
  46. $urlRouterProvider.otherwise('/');
  47. $httpProvider.interceptors.push(['luticateAuthCache', '$injector', '$q',
  48. function (luticateAuthCache, $injector, $q) {
  49. return {
  50. 'request': function (config) {
  51. var token = luticateAuthCache.getToken();
  52. if (token != null)
  53. config.headers['X-Authorization'] = token;
  54. return config;
  55. },
  56. 'responseError': function(rejection) {
  57. return $q.reject(rejection);
  58. }
  59. };
  60. }]);
  61. }])
  62. .run(['$rootScope', '$state', 'luticateAuthUsers', function ($rootScope, $state, luticateAuthUsers) {
  63. luticateAuthUsers.loadPermissions(null);
  64. $rootScope.$on('$stateChangeError', function (e, curr, prev) {
  65. $state.go('login');
  66. });
  67. }]);