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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. 'use strict';
  2. /* App Module */
  3. angular.module('app', [
  4. 'ui.bootstrap',
  5. 'ui.router',
  6. 'LocalStorageModule',
  7. 'ngMaterial',
  8. 'dialogs.main',
  9. 'luticateAuth',
  10. 'luticateUtils',
  11. 'appSdk'
  12. ])
  13. .config(['$stateProvider', '$urlRouterProvider', '$compileProvider', '$httpProvider',
  14. function($stateProvider, $urlRouterProvider, $compileProvider, $httpProvider) {
  15. $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|mailto|data):/);
  16. $stateProvider.state('root', {
  17. abstract: true,
  18. template: '<div ui-view=""></div>',
  19. resolve: ['luticateAuthUsers', function(luticateAuthUsers)
  20. {
  21. return luticateAuthUsers.loadUserData(null);
  22. }]
  23. });
  24. $stateProvider.state('home', {
  25. url:'/',
  26. parent: 'root',
  27. title: "Home",
  28. reloadOnSearch: false,
  29. templateUrl:'views/home.html',
  30. controller:'HomeController'
  31. });
  32. $stateProvider.state('login', {
  33. url:'/login',
  34. parent: 'root',
  35. title: "Login",
  36. reloadOnSearch: false,
  37. templateUrl:'views/login.html',
  38. controller:'LoginController'
  39. });
  40. $stateProvider.state('signUp', {
  41. url:'/signUp',
  42. parent: 'root',
  43. title: "Sign Up",
  44. reloadOnSearch: false,
  45. templateUrl:'views/signup.html',
  46. controller:'SignUpController'
  47. });
  48. $stateProvider.state('upload', {
  49. url:'/upload',
  50. parent: 'root',
  51. title: "Upload",
  52. reloadOnSearch: false,
  53. templateUrl:'views/upload.html',
  54. controller:'UploadController'
  55. });
  56. $urlRouterProvider.otherwise('/');
  57. $httpProvider.interceptors.push(['luticateAuthCache', '$injector', '$q',
  58. function (luticateAuthCache, $injector, $q) {
  59. return {
  60. 'request': function (config) {
  61. var token = luticateAuthCache.getToken();
  62. if (token != null)
  63. config.headers['X-Authorization'] = token;
  64. return config;
  65. },
  66. 'responseError': function(rejection) {
  67. return $q.reject(rejection);
  68. }
  69. };
  70. }]);
  71. }])
  72. .directive('dateNow', ['$filter', function($filter) {
  73. return {
  74. link: function( $scope, $element, $attrs) {
  75. $element.text($filter('date')(new Date(), $attrs.dateNow));
  76. }
  77. };
  78. }])
  79. .run(['$rootScope', '$state',
  80. function ($rootScope, $state) {
  81. $rootScope.$on('$stateChangeSuccess', function (event, current, previous) {
  82. $rootScope.title = current.title + " - 420px";
  83. });
  84. }]).filter("toDataUrl", function() {
  85. return function (data) {
  86. return "data:image/*;base64," + btoa(data);
  87. }
  88. });