2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
40 var app = angular.module('ecompApp', [
58 .config(($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider, ngDialogProvider, $controllerProvider, hammerDefaultOptsProvider, $sanitizeProvider) => {
59 app.controllerProvider = $controllerProvider;
60 $urlRouterProvider.otherwise('/error404');
61 $locationProvider.html5Mode(true);
63 //initialize get if not there
64 if (!$httpProvider.defaults.headers.get) {
65 $httpProvider.defaults.headers.get = {};
68 myHostName = location.host;
71 //withCredentials flag on the XHR object - add cookie to XHR requests
72 if (!(myHostName.includes("localhost"))) { // Don't load this for Mock
73 $httpProvider.defaults.withCredentials = true;
76 $httpProvider.defaults.useXDomain = true;
77 $httpProvider.defaults.timeout = 30000;
79 //default configuration for ngDialog modal
80 ngDialogProvider.setDefaults({
81 className: 'ngdialog-theme-default',
83 closeByDocument: false,
87 //hammer defaults for gestures
88 hammerDefaultOptsProvider.set({
89 recognizers: [[Hammer.Pan, 'enabled']]
92 if (!(myHostName.includes("localhost"))) {
93 $httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
94 $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
95 $httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
100 var interceptor = function ($q, $injector, $log) {
102 'responseError': function (rejection) {
103 $log.error('Interceptor rejection: ' + JSON.stringify(rejection));
104 var $state = $injector.get('$state');
105 var $sanitize = $injector.get('$sanitize');
106 switch (rejection.status) {
108 var globalLoginUrl = rejection.headers()['global-login-url'];
109 if (globalLoginUrl) {
110 window.location = $sanitize(globalLoginUrl +
111 (globalLoginUrl.indexOf('?') === -1 ? '?' : '') +
112 '&retUrl=' + encodeURI(window.location));
117 //handle internal server error
119 return $q.reject(rejection);
123 $httpProvider.interceptors.push(interceptor);
125 }).run(($http, CacheFactory) => {
126 //default configuration for cache factory
127 $http.defaults.cache = CacheFactory('defaultCache', {
128 maxAge: 15 * 60 * 1000, // Items added to this cache expire after 15 minutes
129 cacheFlushInterval: 60 * 60 * 1000, // This cache will clear itself every hour
130 deleteOnExpire: 'aggressive' // Items will be deleted from this cache when they expire
135 angular.module( 'ecompApp' ).config( [
137 function( $compileProvider )
139 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|chrome-extension):/);