Projekt

Obecné

Profil

Stáhnout (1.26 KB) Statistiky
| Větev: | Revize:
1
angular.module('pvpk')
2
  .constant('config', {
3
    APP_NAME: 'PVPK',
4
    APP_VERSION: __VERSION__,
5
    API_URL: __API_URL__,
6
    API_TOKEN: __API_TOKEN__,
7
    DEFAULT_POSITION: { lat: 49.53, lng: 13.3 },
8
    DEFAULT_ZOOM: 10,
9
    DEFAULT_ZOOM_MIN: 7,
10
    DEFAULT_RANGE_DATE_DAY: { from: -30, to: -1 },
11
    DEFAULT_RANGE_TIME_HOUR: { from: 7, to: 16 }
12
  })
13

    
14
angular.module('pvpk')
15
  .config(['$httpProvider', function ($httpProvider) {
16
    $httpProvider.interceptors.push('HttpInterceptor')
17
  }])
18

    
19
angular.module('pvpk').factory('HttpInterceptor', ['$q', '$rootScope', '$injector',
20
  function ($q, $rootScope, $injector) {
21
    return {
22
      'request': function (config) {
23
        $rootScope.loadingCount++
24

    
25
        return config
26
      },
27
      'requestError': function (rejection) {
28
        if (canRecover(rejection)) {
29
          return responseOrNewPromise
30
        }
31
        return $q.reject(rejection)
32
      },
33
      'response': function (response) {
34
        $rootScope.loadingCount--
35

    
36
        return response
37
      },
38
      'responseError': function (rejection) {
39
        $rootScope.loadingCount--
40
        $rootScope.handleErrorResponse(rejection)
41

    
42
        if (canRecover(rejection)) {
43
          return responseOrNewPromise
44
        }
45
        return $q.reject(rejection)
46
      }
47
    }
48
  }
49
])
(1-1/2)