2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 import {encrypt } from './Crypto.js';
24 import { decrypt } from '../utils/Crypto.js';
27 export function changeUrlAddress(pathObj, historyObj) {
28 let toGo = '/' + pathObj.route;
29 // left global search to act the same as before for our 2 static views for now
30 // until we decide to change those 2 views too to act like extensible views.
31 if (pathObj.route === 'schema' || pathObj.route === 'vnfSearch') {
32 if (pathObj.filterValues && pathObj.filterValues.length > 0) {
34 for (let index in pathObj.filterValues) {
35 if (pathObj.filterValues[index].filterValue !== undefined) {
36 filterList.push(pathObj.filterValues[index].filterId +
38 pathObj.filterValues[index].filterValue);
40 filterList.push(pathObj.filterValues[index].filterId + '=');
43 toGo = toGo + '/' + filterList.toString();
45 toGo = toGo + '/' + pathObj.hashId;
48 toGo += '/' + encrypt(JSON.stringify(pathObj));
50 historyObj.push(toGo, {lastRoute: pathObj.route});
53 export function buildRouteObjWithHash(routePath, routeHash) {
61 export function decryptParamsForView(params) {
64 function isJson(str) {
76 stringParams = decrypt(params);
78 //add inline message in next story
79 //happens when user changes the url.
82 if(!isJson(stringParams)) {
86 jsonParam = JSON.parse(stringParams);
90 export function buildRouteObjWithFilters(routePath, routeFiltersObj) {
91 let filterValues = [];
92 if (routeFiltersObj !== undefined) {
93 for (let id in routeFiltersObj) {
94 if (routeFiltersObj[id] !== undefined) {
98 'filterValue': routeFiltersObj[id]
114 filterValues: filterValues