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', [
57 'pascalprecht.translate'
59 .config(($stateProvider, $translateProvider, $urlRouterProvider, $locationProvider, $httpProvider, ngDialogProvider, $controllerProvider, hammerDefaultOptsProvider) => {
60 app.controllerProvider = $controllerProvider;
61 $urlRouterProvider.otherwise('/error404');
62 $locationProvider.html5Mode(true);
63 var lang = window.localStorage.lang||'EN';
64 $translateProvider.preferredLanguage(lang);
65 $translateProvider.useStaticFilesLoader({
66 prefix: '././assets/i18n/',
69 //initialize get if not there
70 if (!$httpProvider.defaults.headers.get) {
71 $httpProvider.defaults.headers.get = {};
74 myHostName = location.host;
77 //withCredentials flag on the XHR object - add cookie to XHR requests
78 if (!(myHostName.includes("localhost"))) { // Don't load this for Mock
79 $httpProvider.defaults.withCredentials = true;
82 $httpProvider.defaults.useXDomain = true;
83 $httpProvider.defaults.timeout = 30000;
85 //default configuration for ngDialog modal
86 ngDialogProvider.setDefaults({
87 className: 'ngdialog-theme-default',
89 closeByDocument: false,
93 //hammer defaults for gestures
94 hammerDefaultOptsProvider.set({
95 recognizers: [[Hammer.Pan, 'enabled']]
98 if (!(myHostName.includes("localhost"))) {
99 $httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
100 $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
101 $httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
106 var interceptor = function ($q, $injector, $log) {
108 'responseError': function (rejection) {
109 $log.error('Interceptor rejection: ' + JSON.stringify(rejection));
110 var $state = $injector.get('$state');
111 var $sanitize = $injector.get('$sanitize');
112 switch (rejection.status) {
114 var globalLoginUrl = rejection.headers()['global-login-url'];
115 if (globalLoginUrl) {
116 window.location = $sanitize(globalLoginUrl +
117 (globalLoginUrl.indexOf('?') === -1 ? '?' : '') +
118 '&retUrl=' + encodeURI(window.location));
123 //handle internal server error
125 return $q.reject(rejection);
129 $httpProvider.interceptors.push(interceptor);
131 }).run(($http, CacheFactory) => {
132 //default configuration for cache factory
133 $http.defaults.cache = CacheFactory('defaultCache', {
134 maxAge: 15 * 60 * 1000, // Items added to this cache expire after 15 minutes
135 cacheFlushInterval: 60 * 60 * 1000, // This cache will clear itself every hour
136 deleteOnExpire: 'aggressive' // Items will be deleted from this cache when they expire
141 angular.module( 'ecompApp' ).config( [
143 function( $compileProvider )
145 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|chrome-extension):/);