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.

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