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.

237 lines
5.5 KiB

7 years ago
7 years ago
7 years ago
7 years ago
  1. var urlapi = "http://localhost:3000/api/";
  2. //var urlapi = "http://192.168.1.33:3000/api/";
  3. angular.module('app', [
  4. 'ionic',
  5. 'pascalprecht.translate',
  6. 'ngCordova',
  7. 'app.menu',
  8. 'app.main',
  9. 'app.events',
  10. 'app.mapEvents',
  11. 'app.event',
  12. 'app.alerts',
  13. 'app.savedEvents',
  14. 'app.categories',
  15. 'app.byCategory',
  16. 'app.place',
  17. 'app.byPlace',
  18. 'app.users',
  19. 'app.user',
  20. 'app.login',
  21. 'app.userZone',
  22. 'app.newEvent'
  23. ])
  24. .run(function($ionicPlatform) {
  25. $ionicPlatform.ready(function() {
  26. // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
  27. // for form inputs)
  28. if (window.cordova && window.cordova.plugins.Keyboard) {
  29. cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
  30. cordova.plugins.Keyboard.disableScroll(true);
  31. }
  32. if (window.StatusBar) {
  33. // org.apache.cordova.statusbar required
  34. StatusBar.styleDefault();
  35. }
  36. });
  37. })
  38. .config(function($stateProvider, $urlRouterProvider) {
  39. $stateProvider
  40. // setup an abstract state for the tabs directive
  41. .state('app', {
  42. url: '/app',
  43. abstract: true,
  44. templateUrl: 'templates/menu.html',
  45. controller: 'MenuCtrl'
  46. })
  47. .state('app.main', {
  48. url: '/main',
  49. views: {
  50. 'menuContent': {
  51. templateUrl: 'templates/main.html',
  52. controller: 'MainCtrl'
  53. }
  54. }
  55. })
  56. .state('app.events', {
  57. url: '/events',
  58. views: {
  59. 'menuContent': {
  60. templateUrl: 'templates/events.html',
  61. controller: 'EventsCtrl'
  62. }
  63. }
  64. })
  65. .state('app.mapEvents', {
  66. url: '/mapEvents',
  67. views: {
  68. 'menuContent': {
  69. templateUrl: 'templates/mapEvents.html',
  70. controller: 'MapEventsCtrl'
  71. }
  72. }
  73. })
  74. .state('app.event', {
  75. url: '/events/:eventid',
  76. views: {
  77. 'menuContent': {
  78. templateUrl: 'templates/event.html',
  79. controller: 'EventCtrl'
  80. }
  81. }
  82. })
  83. .state('app.alerts', {
  84. url: '/alerts',
  85. views: {
  86. 'menuContent': {
  87. templateUrl: 'templates/alerts.html',
  88. controller: 'AlertsCtrl'
  89. }
  90. }
  91. })
  92. .state('app.savedEvents', {
  93. url: '/savedEvents',
  94. views: {
  95. 'menuContent': {
  96. templateUrl: 'templates/savedEvents.html',
  97. controller: 'SavedEventsCtrl'
  98. }
  99. }
  100. })
  101. .state('app.categories', {
  102. url: '/categories',
  103. views: {
  104. 'menuContent': {
  105. templateUrl: 'templates/categories.html',
  106. controller: 'CategoriesCtrl'
  107. }
  108. }
  109. })
  110. .state('app.byCategory', {
  111. url: '/byCategory/:categoryname',
  112. views: {
  113. 'menuContent': {
  114. templateUrl: 'templates/byCategory.html',
  115. controller: 'ByCategoryCtrl'
  116. }
  117. }
  118. })
  119. .state('app.place', {
  120. url: '/place',
  121. views: {
  122. 'menuContent': {
  123. templateUrl: 'templates/place.html',
  124. controller: 'PlaceCtrl'
  125. }
  126. }
  127. })
  128. .state('app.byPlace', {
  129. url: '/byPlace/:place',
  130. views: {
  131. 'menuContent': {
  132. templateUrl: 'templates/byPlace.html',
  133. controller: 'ByPlaceCtrl'
  134. }
  135. }
  136. })
  137. .state('app.users', {
  138. url: '/users',
  139. views: {
  140. 'menuContent': {
  141. templateUrl: 'templates/users.html',
  142. controller: 'UsersCtrl'
  143. }
  144. }
  145. })
  146. .state('app.user', {
  147. url: '/users/:userid',
  148. views: {
  149. 'menuContent': {
  150. templateUrl: 'templates/user.html',
  151. controller: 'UserCtrl'
  152. }
  153. }
  154. })
  155. .state('app.login', {
  156. url: '/login',
  157. views: {
  158. 'menuContent': {
  159. templateUrl: 'templates/login.html',
  160. controller: 'LoginCtrl'
  161. }
  162. }
  163. })
  164. .state('app.userZone', {
  165. url: '/userZone',
  166. views: {
  167. 'menuContent': {
  168. templateUrl: 'templates/userZone.html',
  169. controller: 'UserZoneCtrl'
  170. }
  171. }
  172. })
  173. .state('app.newEvent', {
  174. url: '/newEvent',
  175. views: {
  176. 'menuContent': {
  177. templateUrl: 'templates/newEvent.html',
  178. controller: 'NewEventCtrl'
  179. }
  180. }
  181. });
  182. // if none of the above states are matched, use this as the fallback
  183. $urlRouterProvider.otherwise('/app/main');
  184. })
  185. /* translator */
  186. .config(['$translateProvider', function($translateProvider) {
  187. /* get lang from the file translations.js */
  188. for (lang in translations) {
  189. $translateProvider.translations(lang, translations[lang]);
  190. }
  191. if (window.localStorage.getItem('lang')) {
  192. $translateProvider.preferredLanguage(window.localStorage.getItem('lang'));
  193. } else {
  194. $translateProvider.preferredLanguage('english');
  195. };
  196. $translateProvider.useSanitizeValueStrategy('escape');
  197. }])
  198. .factory('httpInterceptor', function httpInterceptor($q, $window, $location) {
  199. return {
  200. request: function(config) {
  201. return config;
  202. },
  203. requestError: function(config) {
  204. return config;
  205. },
  206. response: function(res) {
  207. return res;
  208. },
  209. responseError: function(res) {
  210. return res;
  211. }
  212. }
  213. })
  214. .factory('api', function($http) {
  215. return {
  216. init: function() {
  217. $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem("events_app_token");
  218. $http.defaults.headers.post['X-Access-Token'] = localStorage.getItem("events_app_token");
  219. }
  220. };
  221. })
  222. .run(function(api) {
  223. api.init();
  224. });