Updated Sparky to add ECOMP functionality Browse, Specialized Search, BYOQ, and the...
[aai/sparky-fe.git] / src / utils / GlobalExtConstants.js
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2021 AT&T Intellectual Property. All rights reserved.
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
10  *
11  *       http://www.apache.org/licenses/LICENSE-2.0
12  *
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  * ============LICENSE_END=========================================================
19  */
20
21
22 const appConfigJson = require('app/assets/configuration/app_config.json');
23 const BACKEND_IP_ADDRESS = document.location.hostname;
24 const BACKEND_PORT_NUMBER = window.location.port;
25 const PROTOCOL = window.location.protocol;
26 var url = window.location.href;
27 var environment = '';
28 if(url.includes('localhost')){
29   var regTitle = new RegExp(appConfigJson.APP_TITLE_REGX_LOCAL);
30   environment = url.match(regTitle)[1].toUpperCase() + '_LOCALHOST_';
31 }else if (url.includes('ecompc_')){
32   environment = url.split('/')[3] + '_';
33 }else{
34   var regTitle = new RegExp(appConfigJson.APP_TITLE_REGX);
35   environment = url.match(regTitle)[1].toUpperCase() + '_NON_WEBJUNCTION_';
36 }
37
38 let pathNameVar = sessionStorage.getItem(environment + 'PAGE_TITLE');
39 let apertureService = JSON.parse(sessionStorage.getItem(environment + 'APERTURE_SERVICE'));
40 console.log('GlobalExtConstants apertureService************',apertureService);
41 if (!pathNameVar || pathNameVar === '' || pathNameVar === null) {
42   if(url.includes('localhost')){
43     var regTitle = new RegExp(appConfigJson.APP_TITLE_REGX_LOCAL);
44     sessionStorage.setItem(environment + 'PAGE_TITLE',url.match(regTitle)[1].toUpperCase());
45   }else{
46     var regTitle = new RegExp(appConfigJson.APP_TITLE_REGX);
47     sessionStorage.setItem(environment + 'PAGE_TITLE',url.match(regTitle)[1].toUpperCase());
48   }
49 }
50
51 console.log('sessionStorage.getItem(PAGE_TITLE)>>>>>',sessionStorage.getItem(environment + 'PAGE_TITLE'));
52 pathNameVar = sessionStorage.getItem(environment + 'PAGE_TITLE').toLowerCase();
53 if(pathNameVar === 'a&ai'){
54   pathNameVar = 'aai';
55 }
56 const appName = appConfigJson[pathNameVar.toUpperCase()];
57 const inventoryList =  require('app/assets/configuration/' + pathNameVar + '/' + appName.INVLIST);
58
59 var base = '';
60 var url = window.location.href;
61 if(url.includes('ecompc_')){
62   base = PROTOCOL + '//' + BACKEND_IP_ADDRESS + '/' + url.split('/')[3];
63 }else{
64   base = PROTOCOL + '//' + BACKEND_IP_ADDRESS + ':' + BACKEND_PORT_NUMBER;
65 }
66 const baseURL = base;
67
68 var overrideDomain = baseURL;
69 if(inventoryList.NODESERVER){
70   overrideDomain = 'https://' + inventoryList.NODESERVER;
71 }
72 /*
73 REGEX - will use the REGEXP operation
74 EQ
75 CONTAINS - will use the LIKE operation in mysql (case insensitive by default)
76 STARTS_WITH - will use the LIKE operation in mysql (case insensitive by default)
77 ENDS_WITH - will use the LIKE operation in mysql (case insensitive by default)
78 GT
79 LT
80 GTE
81 LTE
82 */
83
84
85 var filterTypeList = ['EQ','NEQ','CONTAINS','NOT_CONTAINS','STARTS_WITH','NOT_STARTS_WITH','ENDS_WITH','NOT_ENDS_WITH','GT','LT','GTE','LTE','REGEX','NOT_REGEX'];
86 var tabularFilterType = (apertureService) ? 'CONTAINS' : '=';
87 var uriDelimiter = '*';
88
89
90 export const GlobalExtConstants = {
91   TITLE : appName.TITLE,
92   ENVIRONMENT : environment,
93   PATHNAME : pathNameVar,
94   BASE_URL : baseURL,
95   OVERRIDE_DOMAIN: overrideDomain,
96   CUSTOMQUERYLIST :  require('app/assets/configuration/' + pathNameVar + '/' + appName.CUSTQUERYLIST),
97   INVLIST : inventoryList,
98   EDGERULES : require('app/assets/configuration/' + pathNameVar + '/dbedgeRules.json'),
99   OXM : JSON.stringify(require('app/assets/configuration/' + pathNameVar + '/' + appName.OXM)),
100   COLOR_BLUE : '#009fdb',
101   PAGINATION_CONSTANT : { RESULTS_PER_PAGE : 50 , PAGE_RANGE_DISPLAY : 10},
102   DOWNLOAD_ALL : 500,
103   EXCELCELLS : ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'],
104   DOWNLOAD_TOOLTIP : 'Downloads Current Page Results',
105   APERTURE_SERVICE : apertureService,
106   FILTER_TYPES: filterTypeList,
107   TABULAR_FILTER_TYPE: tabularFilterType,
108   URI_DELIMITCHAR: uriDelimiter,
109   EMAIL_EXT: '@test.com'
110 };