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.

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