app.config.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // bootstrap theme
  2. app.run(['editableOptions', '$rootScope', '$location', function(editableOptions, $rootScope, $location) {
  3. editableOptions.theme = 'bs3'; // bootstrap3 theme. Can be also 'bs2', 'default'
  4. $rootScope.$on('$routeChangeSuccess', function() {
  5. $rootScope.currentMenuItem = $location.path() || '/home';
  6. });
  7. }]);
  8. // translations settings
  9. app.config(['$translateProvider', function($translateProvider) {
  10. $translateProvider.useStaticFilesLoader({
  11. prefix: 'i18n/',
  12. suffix: '.json'
  13. });
  14. $translateProvider.preferredLanguage(localStorage.getItem('preferredLanguage') || 'en');
  15. }]);
  16. // check authorization
  17. app.config(['$httpProvider', function($httpProvider) {
  18. $httpProvider.interceptors.push(['$q', '$location', function($q, $location) {
  19. return {
  20. request: function(config) {
  21. config.headers = config.headers || {};
  22. if (localStorage.getItem('authToken')) {
  23. config.headers.Authorization = 'Bearer ' + localStorage.getItem('authToken');
  24. }
  25. return config;
  26. },
  27. responseError: function(response) {
  28. if (response.status === 401) {
  29. $location.path('/');
  30. }
  31. return $q.reject(response);
  32. }
  33. };
  34. }]);
  35. }]);