123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- 'use strict';
-
- /* App Module */
-
- var camotion = angular.module('camotionAdmin', [
- 'ui.bootstrap',
- 'ui.router',
- 'luticateUtils',
- 'luticateAuth',
- 'LocalStorageModule',
- 'dialogs.main',
- 'ngSanitize',
- 'JSONedit',
- 'camotionSdk'
- ]);
-
- camotion.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider',
- function($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) {
-
- $stateProvider.state('login',{
- url:'/',
- templateUrl:'views/login.html',
- controller:'LoginController'
- });
-
- $stateProvider.state('home',{
- url:'/home',
- templateUrl:'views/home.html',
- controller:'HomeController'
- });
-
- $stateProvider.state('hosts',{
- url:'/hosts',
- templateUrl:'views/hosts.html',
- controller:'HostsController'
- });
-
- $stateProvider.state('cameras',{
- url:'/cameras',
- templateUrl:'views/cameras.html',
- controller:'CamerasController'
- });
-
- $stateProvider.state('sensors',{
- url:'/sensors',
- templateUrl:'views/sensors.html',
- controller:'SensorsController'
- });
-
- $stateProvider.state('commands',{
- url:'/commands',
- templateUrl:'views/commands.html',
- controller:'CommandsController'
- });
-
- $urlRouterProvider.otherwise('/');
-
- $httpProvider.interceptors.push(['luticateAuthCache', '$injector', '$q',
- function (luticateAuthCache, $injector, $q) {
- return {
- 'request': function (config) {
- var token = luticateAuthCache.getToken();
-
- if (token != null)
- config.headers['X-Authorization'] = token;
-
- return config;
- },
- 'responseError': function(rejection) {
- return $q.reject(rejection);
- }
- };
- }]);
-
- }])
- .run(['$rootScope', '$state', 'luticateAuthUsers', function ($rootScope, $state, luticateAuthUsers) {
- luticateAuthUsers.loadPermissions(null);
- $rootScope.$on('$stateChangeError', function (e, curr, prev) {
- $state.go('login');
- });
- }]);
|