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.

137 lines
3.3 KiB

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