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.

147 lines
3.5 KiB

7 years ago
7 years ago
7 years ago
  1. //var urlapi = "http://localhost:3000/api/";
  2. var urlapi = "http://192.168.1.34:3000/api/";
  3. angular.module('app', [
  4. 'ionic',
  5. 'pascalprecht.translate',
  6. 'ngCordova',
  7. 'app.menu',
  8. 'app.main',
  9. 'app.events',
  10. 'app.event',
  11. 'app.savedEvents',
  12. 'app.users',
  13. 'app.user'
  14. ])
  15. .run(function($ionicPlatform) {
  16. $ionicPlatform.ready(function() {
  17. // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
  18. // for form inputs)
  19. if (window.cordova && window.cordova.plugins.Keyboard) {
  20. cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
  21. cordova.plugins.Keyboard.disableScroll(true);
  22. }
  23. if (window.StatusBar) {
  24. // org.apache.cordova.statusbar required
  25. StatusBar.styleDefault();
  26. }
  27. });
  28. })
  29. .config(function($stateProvider, $urlRouterProvider) {
  30. $stateProvider
  31. // setup an abstract state for the tabs directive
  32. .state('app', {
  33. url: '/app',
  34. abstract: true,
  35. templateUrl: 'templates/menu.html',
  36. controller: 'MenuCtrl'
  37. })
  38. .state('app.main', {
  39. url: '/main',
  40. views: {
  41. 'menuContent': {
  42. templateUrl: 'templates/main.html',
  43. controller: 'MainCtrl'
  44. }
  45. }
  46. })
  47. .state('app.events', {
  48. url: '/events',
  49. views: {
  50. 'menuContent': {
  51. templateUrl: 'templates/events.html',
  52. controller: 'EventsCtrl'
  53. }
  54. }
  55. })
  56. .state('app.event', {
  57. url: '/events/:eventid',
  58. views: {
  59. 'menuContent': {
  60. templateUrl: 'templates/event.html',
  61. controller: 'EventCtrl'
  62. }
  63. }
  64. })
  65. .state('app.savedEvents', {
  66. url: '/savedEvents',
  67. views: {
  68. 'menuContent': {
  69. templateUrl: 'templates/savedEvents.html',
  70. controller: 'SavedEventsCtrl'
  71. }
  72. }
  73. })
  74. .state('app.users', {
  75. url: '/users',
  76. views: {
  77. 'menuContent': {
  78. templateUrl: 'templates/users.html',
  79. controller: 'UsersCtrl'
  80. }
  81. }
  82. })
  83. .state('app.user', {
  84. url: '/users/:userid',
  85. views: {
  86. 'menuContent': {
  87. templateUrl: 'templates/user.html',
  88. controller: 'UserCtrl'
  89. }
  90. }
  91. });
  92. // if none of the above states are matched, use this as the fallback
  93. $urlRouterProvider.otherwise('/app/main');
  94. })
  95. /* translator */
  96. .config(['$translateProvider', function($translateProvider) {
  97. /* get lang from the file translations.js */
  98. for (lang in translations) {
  99. $translateProvider.translations(lang, translations[lang]);
  100. }
  101. if (window.localStorage.getItem('lang')) {
  102. $translateProvider.preferredLanguage(window.localStorage.getItem('lang'));
  103. } else {
  104. $translateProvider.preferredLanguage('english');
  105. };
  106. $translateProvider.useSanitizeValueStrategy('escape');
  107. }])
  108. .factory('httpInterceptor', function httpInterceptor($q, $window, $location) {
  109. return {
  110. request: function(config) {
  111. return config;
  112. },
  113. requestError: function(config) {
  114. return config;
  115. },
  116. response: function(res) {
  117. return res;
  118. },
  119. responseError: function(res) {
  120. return res;
  121. }
  122. }
  123. })
  124. .factory('api', function($http) {
  125. return {
  126. init: function() {
  127. $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem("cim_app_token");
  128. $http.defaults.headers.post['X-Access-Token'] = localStorage.getItem("cim_app_token");
  129. }
  130. };
  131. })
  132. .run(function(api) {
  133. api.init();
  134. });