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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. resolve:{}
  31. });
  32. $stateProvider.state('home',{
  33. url:'/home',
  34. parent: 'root',
  35. title: "Home",
  36. templateUrl:'views/home.html',
  37. controller:'HomeController',
  38. revolve:{}
  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. .directive('dateNow', ['$filter', function($filter) {
  57. return {
  58. link: function($scope, $element, $attrs) {
  59. $element.text($filter('date')(new Date(), $attrs.dateNow));
  60. }
  61. };
  62. }])
  63. .run(['$rootScope', '$state',function ($rootScope, $state) {
  64. $rootScope.$on('$stateChangeSuccess', function (event, current, previous) {
  65. $rootScope.title = current.title + " - App";
  66. });
  67. $rootScope.$on('$stateChangeError', function (e, curr, prev) {
  68. //$state.go('login');
  69. });
  70. }]);