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', [
38 .config(($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider, ngDialogProvider) => {
39 $urlRouterProvider.otherwise('/error404');
40 $locationProvider.html5Mode(true);
42 //initialize get if not there
43 if (!$httpProvider.defaults.headers.get) {
44 $httpProvider.defaults.headers.get = {};
47 //withCredentials flag on the XHR object - add cookie to XHR requests
48 $httpProvider.defaults.withCredentials = true;
49 $httpProvider.defaults.useXDoain = true;
50 $httpProvider.defaults.timeout = 30000;
52 //default configuration for ngDialog modal
53 ngDialogProvider.setDefaults({
54 className: 'ngdialog-theme-default',
56 closeByDocument: false,
62 myHostName = location.host;
64 if (!(myHostName.includes("localhost"))) {
65 $httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
66 $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
67 $httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
72 var interceptor = function ($q, $injector, $log) {
74 'responseError': function (rejection) {
75 $log.error('Interceptor rejection: ' + JSON.stringify(rejection));
76 var $state = $injector.get('$state');
77 switch (rejection.status) {
79 var globalLoginUrl = rejection.headers()['global-login-url'];
81 window.location = globalLoginUrl +
82 (globalLoginUrl.indexOf('?') === -1 ? '?' : '') +
83 '&retUrl=' + encodeURI(window.location);
88 // $state.go('root.applicationsHome');
89 //handle forbidden error
92 // $state.go('/login.htm');
93 // //handle forbidden error
96 //handle internal server error
98 return $q.reject(rejection);
102 $httpProvider.interceptors.push(interceptor);
104 }).run(($http, CacheFactory) => {
105 //default configuration for cache factory
106 $http.defaults.cache = CacheFactory('defaultCache', {
107 maxAge: 15 * 60 * 1000, // Items added to this cache expire after 15 minutes
108 cacheFlushInterval: 60 * 60 * 1000, // This cache will clear itself every hour
109 deleteOnExpire: 'aggressive' // Items will be deleted from this cache when they expire
114 angular.module( 'ecompApp' ).config( [
116 function( $compileProvider )
118 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|chrome-extension):/);