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.

197 lines
4.6 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.alerts',
  12. 'app.savedEvents',
  13. 'app.byCategories',
  14. 'app.users',
  15. 'app.user',
  16. 'app.login',
  17. 'app.userZone',
  18. 'app.newEvent'
  19. ])
  20. .run(function($ionicPlatform) {
  21. $ionicPlatform.ready(function() {
  22. // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
  23. // for form inputs)
  24. if (window.cordova && window.cordova.plugins.Keyboard) {
  25. cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
  26. cordova.plugins.Keyboard.disableScroll(true);
  27. }
  28. if (window.StatusBar) {
  29. // org.apache.cordova.statusbar required
  30. StatusBar.styleDefault();
  31. }
  32. });
  33. })
  34. .config(function($stateProvider, $urlRouterProvider) {
  35. $stateProvider
  36. // setup an abstract state for the tabs directive
  37. .state('app', {
  38. url: '/app',
  39. abstract: true,
  40. templateUrl: 'templates/menu.html',
  41. controller: 'MenuCtrl'
  42. })
  43. .state('app.main', {
  44. url: '/main',
  45. views: {
  46. 'menuContent': {
  47. templateUrl: 'templates/main.html',
  48. controller: 'MainCtrl'
  49. }
  50. }
  51. })
  52. .state('app.events', {
  53. url: '/events',
  54. views: {
  55. 'menuContent': {
  56. templateUrl: 'templates/events.html',
  57. controller: 'EventsCtrl'
  58. }
  59. }
  60. })
  61. .state('app.event', {
  62. url: '/events/:eventid',
  63. views: {
  64. 'menuContent': {
  65. templateUrl: 'templates/event.html',
  66. controller: 'EventCtrl'
  67. }
  68. }
  69. })
  70. .state('app.alerts', {
  71. url: '/alerts',
  72. views: {
  73. 'menuContent': {
  74. templateUrl: 'templates/alerts.html',
  75. controller: 'AlertsCtrl'
  76. }
  77. }
  78. })
  79. .state('app.savedEvents', {
  80. url: '/savedEvents',
  81. views: {
  82. 'menuContent': {
  83. templateUrl: 'templates/savedEvents.html',
  84. controller: 'SavedEventsCtrl'
  85. }
  86. }
  87. })
  88. .state('app.byCategories', {
  89. url: '/byCategories',
  90. views: {
  91. 'menuContent': {
  92. templateUrl: 'templates/byCategories.html',
  93. controller: 'ByCategoriesCtrl'
  94. }
  95. }
  96. })
  97. .state('app.users', {
  98. url: '/users',
  99. views: {
  100. 'menuContent': {
  101. templateUrl: 'templates/users.html',
  102. controller: 'UsersCtrl'
  103. }
  104. }
  105. })
  106. .state('app.user', {
  107. url: '/users/:userid',
  108. views: {
  109. 'menuContent': {
  110. templateUrl: 'templates/user.html',
  111. controller: 'UserCtrl'
  112. }
  113. }
  114. })
  115. .state('app.login', {
  116. url: '/login',
  117. views: {
  118. 'menuContent': {
  119. templateUrl: 'templates/login.html',
  120. controller: 'LoginCtrl'
  121. }
  122. }
  123. })
  124. .state('app.userZone', {
  125. url: '/userZone',
  126. views: {
  127. 'menuContent': {
  128. templateUrl: 'templates/userZone.html',
  129. controller: 'UserZoneCtrl'
  130. }
  131. }
  132. })
  133. .state('app.newEvent', {
  134. url: '/newEvent',
  135. views: {
  136. 'menuContent': {
  137. templateUrl: 'templates/newEvent.html',
  138. controller: 'NewEventCtrl'
  139. }
  140. }
  141. });
  142. // if none of the above states are matched, use this as the fallback
  143. $urlRouterProvider.otherwise('/app/main');
  144. })
  145. /* translator */
  146. .config(['$translateProvider', function($translateProvider) {
  147. /* get lang from the file translations.js */
  148. for (lang in translations) {
  149. $translateProvider.translations(lang, translations[lang]);
  150. }
  151. if (window.localStorage.getItem('lang')) {
  152. $translateProvider.preferredLanguage(window.localStorage.getItem('lang'));
  153. } else {
  154. $translateProvider.preferredLanguage('english');
  155. };
  156. $translateProvider.useSanitizeValueStrategy('escape');
  157. }])
  158. .factory('httpInterceptor', function httpInterceptor($q, $window, $location) {
  159. return {
  160. request: function(config) {
  161. return config;
  162. },
  163. requestError: function(config) {
  164. return config;
  165. },
  166. response: function(res) {
  167. return res;
  168. },
  169. responseError: function(res) {
  170. return res;
  171. }
  172. }
  173. })
  174. .factory('api', function($http) {
  175. return {
  176. init: function() {
  177. $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem("events_app_token");
  178. $http.defaults.headers.post['X-Access-Token'] = localStorage.getItem("events_app_token");
  179. }
  180. };
  181. })
  182. .run(function(api) {
  183. api.init();
  184. });