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.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. $stateProvider.state('sensors',{
  36. url:'/sensors',
  37. templateUrl:'views/sensors.html',
  38. controller:'SensorsController'
  39. });
  40. $urlRouterProvider.otherwise('/');
  41. $httpProvider.interceptors.push(['luticateAuthCache', '$injector', '$q',
  42. function (luticateAuthCache, $injector, $q) {
  43. return {
  44. 'request': function (config) {
  45. var token = luticateAuthCache.getToken();
  46. if (token != null)
  47. config.headers['X-Authorization'] = token;
  48. return config;
  49. },
  50. 'responseError': function(rejection) {
  51. return $q.reject(rejection);
  52. }
  53. };
  54. }]);
  55. }])
  56. .run(['$rootScope', '$state', 'luticateAuthUsers', function ($rootScope, $state, luticateAuthUsers) {
  57. luticateAuthUsers.loadPermissions(null);
  58. $rootScope.$on('$stateChangeError', function (e, curr, prev) {
  59. $state.go('login');
  60. });
  61. }]);