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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. templateUrl:'views/login.html',
  28. controller:'LoginController',
  29. resolve:{}
  30. });
  31. $stateProvider.state('home',{
  32. url:'/home',
  33. parent: 'root',
  34. templateUrl:'views/home.html',
  35. controller:'HomeController',
  36. revolve:{}
  37. });
  38. $urlRouterProvider.otherwise('/');
  39. $httpProvider.interceptors.push(['luticateAuthCache', '$injector', '$q',
  40. function (luticateAuthCache, $injector, $q) {
  41. return {
  42. 'request': function (config) {
  43. var token = luticateAuthCache.getToken();
  44. if (token != null)
  45. config.headers['X-Authorization'] = token;
  46. return config;
  47. },
  48. 'responseError': function(rejection) {
  49. return $q.reject(rejection);
  50. }
  51. };
  52. }]);
  53. }])
  54. .directive('dateNow', ['$filter', function($filter) {
  55. return {
  56. link: function( $scope, $element, $attrs) {
  57. $element.text($filter('date')(new Date(), $attrs.dateNow));
  58. }
  59. };
  60. }])
  61. .run(['$rootScope', '$state',function ($rootScope, $state) {
  62. $rootScope.$on('$stateChangeError', function (e, curr, prev) {
  63. //$state.go('login');
  64. });
  65. }]);