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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. 'use strict';
  2. /* App Module */
  3. var app = angular.module('app', [
  4. 'ui.bootstrap',
  5. 'ui.router',
  6. 'LocalStorageModule',
  7. 'dialogs.main',
  8. 'ngSanitize',
  9. 'luticateUtils',
  10. 'luticateAuth',
  11. 'appSdk'
  12. ]);
  13. app.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider',
  14. function($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) {
  15. $stateProvider.state('root', {
  16. abstract: true,
  17. template: '<div ui-view=""></div>',
  18. resolve: ['luticateAuthUsers', function(luticateAuthUsers)
  19. {
  20. return luticateAuthUsers.loadUserData(null);
  21. }]
  22. });
  23. //$locationProvider.html5Mode(true);
  24. $stateProvider.state('login',{
  25. url:'/',
  26. parent: 'root',
  27. title: "Login",
  28. templateUrl:'views/login.html',
  29. controller:'LoginController'
  30. });
  31. $stateProvider.state('home',{
  32. url:'/home',
  33. parent: 'root',
  34. title: "Home",
  35. templateUrl:'views/home.html',
  36. controller:'HomeController'
  37. });
  38. $stateProvider.state('dns',{
  39. url:'/dns',
  40. parent: 'root',
  41. title: "DNS",
  42. templateUrl:'views/dns.html',
  43. controller:'DnsController'
  44. });
  45. $urlRouterProvider.otherwise('/');
  46. $httpProvider.interceptors.push(['luticateAuthCache', '$injector', '$q',
  47. function (luticateAuthCache, $injector, $q) {
  48. return {
  49. 'request': function (config) {
  50. var token = luticateAuthCache.getToken();
  51. if (token != null)
  52. config.headers['X-Authorization'] = token;
  53. return config;
  54. },
  55. 'responseError': function(rejection) {
  56. return $q.reject(rejection);
  57. }
  58. };
  59. }]);
  60. }])
  61. .directive('dateNow', ['$filter', function($filter) {
  62. return {
  63. link: function( $scope, $element, $attrs) {
  64. $element.text($filter('date')(new Date(), $attrs.dateNow));
  65. }
  66. };
  67. }])
  68. .run(['$rootScope', '$state',function ($rootScope, $state) {
  69. $rootScope.$on('$stateChangeSuccess', function (event, current, previous) {
  70. $rootScope.title = current.title + " - App";
  71. });
  72. $rootScope.$on('$stateChangeError', function (e, curr, prev) {
  73. //$state.go('login');
  74. });
  75. }]);