123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // bootstrap theme
- app.run(['editableOptions', '$rootScope', '$location', function(editableOptions, $rootScope, $location) {
- editableOptions.theme = 'bs3'; // bootstrap3 theme. Can be also 'bs2', 'default'
- $rootScope.$on('$routeChangeSuccess', function() {
- $rootScope.currentMenuItem = $location.path() || '/home';
- });
- }]);
- // translations settings
- app.config(['$translateProvider', function($translateProvider) {
-
- $translateProvider.useStaticFilesLoader({
- prefix: 'i18n/',
- suffix: '.json'
- });
- $translateProvider.preferredLanguage(localStorage.getItem('preferredLanguage') || 'en');
- }]);
- // check authorization
- app.config(['$httpProvider', function($httpProvider) {
- $httpProvider.interceptors.push(['$q', '$location', function($q, $location) {
- return {
- request: function(config) {
- config.headers = config.headers || {};
-
- if (localStorage.getItem('authToken')) {
- config.headers.Authorization = 'Bearer ' + localStorage.getItem('authToken');
- }
- return config;
- },
- responseError: function(response) {
- if (response.status === 401) {
- $location.path('/');
- }
- return $q.reject(response);
- }
- };
- }]);
- }]);
|