2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
22 var app = angular.module('ecompApp', [
40 .config(($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider, ngDialogProvider, $controllerProvider, hammerDefaultOptsProvider) => {
41 app.controllerProvider = $controllerProvider;
42 $urlRouterProvider.otherwise('/error404');
43 $locationProvider.html5Mode(true);
45 //initialize get if not there
46 if (!$httpProvider.defaults.headers.get) {
47 $httpProvider.defaults.headers.get = {};
50 myHostName = location.host;
53 //withCredentials flag on the XHR object - add cookie to XHR requests
54 if (!(myHostName.includes("localhost"))) { // Don't load this for Mock
55 $httpProvider.defaults.withCredentials = true;
58 $httpProvider.defaults.useXDomain = true;
59 $httpProvider.defaults.timeout = 30000;
61 //default configuration for ngDialog modal
62 ngDialogProvider.setDefaults({
63 className: 'ngdialog-theme-default',
65 closeByDocument: false,
69 //hammer defaults for gestures
70 hammerDefaultOptsProvider.set({
71 recognizers: [[Hammer.Pan, 'enabled']]
74 if (!(myHostName.includes("localhost"))) {
75 $httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
76 $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
77 $httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
82 var interceptor = function ($q, $injector, $log) {
84 'responseError': function (rejection) {
85 $log.error('Interceptor rejection: ' + JSON.stringify(rejection));
86 var $state = $injector.get('$state');
87 switch (rejection.status) {
89 var globalLoginUrl = rejection.headers()['global-login-url'];
91 window.location = globalLoginUrl +
92 (globalLoginUrl.indexOf('?') === -1 ? '?' : '') +
93 '&retUrl=' + encodeURI(window.location);
98 //handle internal server error
100 return $q.reject(rejection);
104 $httpProvider.interceptors.push(interceptor);
106 }).run(($http, CacheFactory) => {
107 //default configuration for cache factory
108 $http.defaults.cache = CacheFactory('defaultCache', {
109 maxAge: 15 * 60 * 1000, // Items added to this cache expire after 15 minutes
110 cacheFlushInterval: 60 * 60 * 1000, // This cache will clear itself every hour
111 deleteOnExpire: 'aggressive' // Items will be deleted from this cache when they expire
116 angular.module( 'ecompApp' ).config( [
118 function( $compileProvider )
120 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|chrome-extension):/);