summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/utils
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src/app/shared/utils')
-rw-r--r--vid-webpack-master/src/app/shared/utils/constants.ts9
-rw-r--r--vid-webpack-master/src/app/shared/utils/httpInterceptor/httpInterceptor.service.ts27
-rw-r--r--vid-webpack-master/src/app/shared/utils/log/log.service.spec.ts46
-rw-r--r--vid-webpack-master/src/app/shared/utils/util.spec.ts31
-rw-r--r--vid-webpack-master/src/app/shared/utils/utils.ts267
5 files changed, 362 insertions, 18 deletions
diff --git a/vid-webpack-master/src/app/shared/utils/constants.ts b/vid-webpack-master/src/app/shared/utils/constants.ts
index c78e12e28..f69517cf2 100644
--- a/vid-webpack-master/src/app/shared/utils/constants.ts
+++ b/vid-webpack-master/src/app/shared/utils/constants.ts
@@ -34,9 +34,10 @@ export module Constants {
public static AAI_GET_SERVICES_BY_TYPE = 'aai_get_models_by_service_type';
public static AAI_GET_TENANTS = '../../aai_get_tenants/';
public static AAI_SUB_DETAILS_PATH = '../../aai_sub_details/';
+ public static AAI_GET_SERVICE_INSTANCE_TOPOLOGY_PATH = '../../aai_get_service_instance_topology/';
+ public static AAI_GET_SERVICE_GROUP_MEMBERS_PATH = '../../aai_search_group_members/';
public static AAI_GET_VERSION_BY_INVARIANT_ID = 'aai_get_version_by_invariant_id/';
public static SEARCH_SERVICE_INSTANCES = 'search_service_instances';
- public static AAI_GET_VNF_DATA_PATH = 'aai_get_vnf_data/';
public static AAI_GET_VNF_BY_CUSTOMERID_AND_SERVICETYPE = 'get_vnf_data_by_globalid_and_service_type/';
public static AAI_GET_SERVICES_BY_OWNING_ENTITY_ID = 'aai_get_services_by_owning_entity_id';
public static AAI_GET_VNF_INFO = 'aai_get_vnf_information';
@@ -87,10 +88,12 @@ export module Constants {
public static WELCOME_PATH = 'welcome.htm';
public static IS_PERMITTED_SUB_PATH = '&isPermitted=';
public static SERVICES_JOB_INFO_PATH = '../../asyncInstantiation';
+ public static SERVICES_RETRY_TOPOLOGY = '../../asyncInstantiation/bulkForRetry';
public static CONFIGURATION_PATH = '../../get_property/{name}/defaultvalue';
public static SERVICES_JOB_AUDIT_PATH = '/auditStatus';
public static SERVICES_PROBE_PATH = "../../probe";
public static FEATURES_FLAG_PATH ="../../flags";
+ public static AUDIT_STATUS_FOR_RETRY_PATH = '../../asyncInstantiation/auditStatusForRetry';
// Test Environment Urls =
public static OPERATIONAL_ENVIRONMENT_CREATE = 'operationalEnvironment/create';
@@ -284,4 +287,8 @@ export module Constants {
export class AuditInfoModal{
public static TITLE = 'Service Instantiation Information';
}
+
+ export class LegacyRegion {
+ public static MEGA_REGION = ['JANET25'];
+ }
}
diff --git a/vid-webpack-master/src/app/shared/utils/httpInterceptor/httpInterceptor.service.ts b/vid-webpack-master/src/app/shared/utils/httpInterceptor/httpInterceptor.service.ts
index be9ade080..daa31a33f 100644
--- a/vid-webpack-master/src/app/shared/utils/httpInterceptor/httpInterceptor.service.ts
+++ b/vid-webpack-master/src/app/shared/utils/httpInterceptor/httpInterceptor.service.ts
@@ -1,19 +1,19 @@
-import { Injectable } from '@angular/core';
-import {
- HttpInterceptor,
- HttpRequest,
- HttpHandler,
- HttpEvent, HttpErrorResponse
-} from '@angular/common/http';
+import {Injectable} from '@angular/core';
+import {HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';
-import { Observable } from 'rxjs/Observable';
-import { ErrorMessage, ErrorService } from '../../components/error/error.component.service';
-import { SpinnerComponent } from '../../components/spinner/spinner.component';
+import {Observable} from 'rxjs';
+import {ErrorMessage, ErrorService} from '../../components/error/error.component.service';
+import {SpinnerComponent, SpinnerInfo} from '../../components/spinner/spinner.component';
+import {of} from "rxjs";
@Injectable()
export class HttpInterceptorService implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
- SpinnerComponent.showSpinner.next(true);
+ if (request.headers.get('x-show-spinner') !== false.toString()) {
+ let spinnerInfo : SpinnerInfo = new SpinnerInfo(true, request.url, request.responseType);
+ SpinnerComponent.showSpinner.next(spinnerInfo);
+ }
+
return next.handle(request)
.catch((err: HttpErrorResponse) => {
if (err.status === 500) {
@@ -21,11 +21,12 @@ export class HttpInterceptorService implements HttpInterceptor {
'It appears that one of the backend servers is not responding.\n Please try later.',
500);
ErrorService.showErrorWithMessage(errorMessage);
- return Observable.of(null);
+ return of(null);
}
return Observable.throw(err);
}).finally(() => {
- SpinnerComponent.showSpinner.next(false);
+ let spinnerInfo : SpinnerInfo = new SpinnerInfo(false, request.url, request.responseType);
+ SpinnerComponent.showSpinner.next(spinnerInfo);
});
}
}
diff --git a/vid-webpack-master/src/app/shared/utils/log/log.service.spec.ts b/vid-webpack-master/src/app/shared/utils/log/log.service.spec.ts
index ea0eb0499..15a840f76 100644
--- a/vid-webpack-master/src/app/shared/utils/log/log.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/utils/log/log.service.spec.ts
@@ -1,16 +1,24 @@
import {LogService} from "./log.service";
+import {TestBed} from "@angular/core/testing";
describe('log service service', () => {
+
let logService : LogService;
- beforeEach(() => {
+ beforeAll(done => (async () => {
+ TestBed.configureTestingModule({
+
+ });
+ await TestBed.compileComponents();
logService = new LogService();
- });
- it('check all ILogger function are defined', ()=>{
+ })().then(done).catch(done.fail));
+
+
+ test('check all ILogger function are defined', ()=>{
expect(logService.log).toBeDefined();
expect(logService.assert).toBeDefined();
expect(logService.error).toBeDefined();
@@ -20,10 +28,40 @@ describe('log service service', () => {
expect(logService.warn).toBeDefined();
});
- it('test getPrefixLog function', ()=> {
+ test('test getPrefixLog function: with data', ()=> {
let args = ['message', [1,2,3,4,5]];
let result = LogService.getPrefixLog(args);
expect(result).toBeDefined();
});
+ test('log assert', ()=> {
+ jest.spyOn(console, 'assert');
+ logService.assert('someArg');
+ expect(console.assert).toHaveBeenCalled();
+ });
+
+ test('log group', ()=> {
+ jest.spyOn(console, 'group');
+ logService.group('someArg');
+ expect(console.group).toHaveBeenCalled();
+ });
+
+ test('log groupEnd', ()=> {
+ jest.spyOn(console, 'groupEnd');
+ logService.groupEnd('someArg');
+ expect(console.groupEnd).toHaveBeenCalled();
+ });
+
+ test('log log', ()=> {
+ jest.spyOn(console, 'log');
+ logService.log('someArg');
+ expect(console.log).toHaveBeenCalled();
+ });
+
+ test('log warn', ()=> {
+ spyOn(console, 'warn');
+ logService.warn('someArg');
+ expect(console.warn).toHaveBeenCalled();
+ });
+
});
diff --git a/vid-webpack-master/src/app/shared/utils/util.spec.ts b/vid-webpack-master/src/app/shared/utils/util.spec.ts
new file mode 100644
index 000000000..2f9142f9c
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/utils/util.spec.ts
@@ -0,0 +1,31 @@
+import {Utils} from "./utils";
+import {TestBed} from "@angular/core/testing";
+
+
+describe('Util', () => {
+ let util: Utils;
+
+ beforeAll(done => (async () => {
+ TestBed.configureTestingModule({
+
+ });
+ await TestBed.compileComponents();
+
+ util = new Utils();
+
+ })().then(done).catch(done.fail));
+
+ test('should be defined', () => {
+ expect(util).toBeDefined();
+ });
+
+ test('hasContents should return false if object is undefined or null or empty', () => {
+ expect(Utils.hasContents(undefined)).toBeFalsy();
+ expect(Utils.hasContents(null)).toBeFalsy();
+ expect(Utils.hasContents("")).toBeFalsy();
+ });
+
+ test('hasContents should return true if object is not undefined and not null and not empty', () => {
+ expect(Utils.hasContents("someValue")).toBeTruthy();
+ });
+});
diff --git a/vid-webpack-master/src/app/shared/utils/utils.ts b/vid-webpack-master/src/app/shared/utils/utils.ts
new file mode 100644
index 000000000..d63a3c997
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/utils/utils.ts
@@ -0,0 +1,267 @@
+import * as _ from 'lodash'
+
+export class Utils {
+
+ public static clampNumber = (number, min, max) => {
+ return Math.max(min, Math.min(number, max));
+ };
+
+ public static hasContents(object: Object): boolean {
+ if (object === undefined || object === null || object === "") {
+ return false;
+ }
+ return true;
+ };
+
+ public static convertModel(serviceModel) {
+
+ let isNewFlow:boolean = false;
+
+ for (let networkCustomizationName in serviceModel.networks) {
+ let networkModel = serviceModel.networks[networkCustomizationName];
+ if ( networkModel.customizationUuid != null ) {
+ isNewFlow = true;
+ break;
+ }
+ }
+ if ( !isNewFlow ) {
+ for (let vnfCustomizationName in serviceModel.vnfs) {
+ let vnfModel = serviceModel.vnfs[vnfCustomizationName];
+ if ( vnfModel.customizationUuid != null ) {
+ isNewFlow = true;
+ break;
+ }
+ }
+ }
+ if ( isNewFlow ) {
+ return (Utils.convertNewModel (serviceModel) );
+ }
+ else {
+ return (Utils.convertOldModel (serviceModel) );
+ }
+ };
+
+ private static convertNewModel (serviceModel ) {
+ let completeResources = new Array();
+ let resource = {};
+ let convertedAsdcModel = {
+ "service": serviceModel.service,
+ "networks": {},
+ "vnfs": {},
+ "pnfs": serviceModel.pnfs,
+ "serviceProxies": serviceModel.serviceProxies,
+ "completeDisplayInputs": {},
+ "isNewFlow": true
+ };
+
+ for(let key in serviceModel.service.inputs) {
+ if(_.includes(["instance_node_target", "naming_policy", "vf_instance_name"], key)) {
+ delete convertedAsdcModel.service.inputs[key];
+ }
+ }
+
+ for (let networkCustomizationName in serviceModel.networks) {
+ let networkModel = serviceModel.networks[networkCustomizationName];
+
+ convertedAsdcModel.networks[networkModel.customizationUuid] = {
+ "uuid": networkModel.uuid,
+ "invariantUuid": networkModel.invariantUuid,
+ "version": networkModel.version,
+ "name": networkModel.name,
+ "modelCustomizationName": networkModel.modelCustomizationName,
+ "customizationUuid": networkModel.customizationUuid,
+ "inputs": "",
+ "description": networkModel.description,
+ "commands": {},
+ "displayInputs": {}
+ };
+
+ resource = {
+ "name": networkModel.modelCustomizationName,
+ "description": networkModel.description
+ };
+
+ completeResources.push (resource);
+
+ }
+
+ _.forEach(serviceModel.configurations, function(element) {
+ element.isConfig = true;
+ });
+ _.forEach(serviceModel.pnfs, function(element, key) {
+ element.isPnf= true;
+ element.modelCustomizationName= key;
+ });
+ let mergedVnfs = Object.assign(serviceModel.vnfs, serviceModel.configurations, serviceModel.pnfs);
+
+ for (let vnfCustomizationName in mergedVnfs) {
+ let vnfModel = mergedVnfs[vnfCustomizationName];
+ let vnfCustomizationUuid = vnfModel.customizationUuid;
+ convertedAsdcModel.vnfs[vnfModel.customizationUuid] = {
+ "uuid": vnfModel.uuid,
+ "invariantUuid": vnfModel.invariantUuid,
+ "version": vnfModel.version,
+ "name": vnfModel.name,
+ "modelCustomizationName": vnfModel.modelCustomizationName,
+ "customizationUuid": vnfModel.customizationUuid,
+ "inputs": "",
+ "description": vnfModel.description,
+ "vfModules": {},
+ "volumeGroups": {},
+ "commands": {},
+ "displayInputs": {},
+ "properties": {},
+ "nfRole": "",
+ "nfType": "",
+ "sourceNodes": vnfModel.sourceNodes,
+ "collectorNodes": vnfModel.collectorNodes,
+ "isConfigurationByPolicy": vnfModel.configurationByPolicy ? vnfModel.configurationByPolicy : false,
+ "isConfig": vnfModel.isConfig ? vnfModel.isConfig : false,
+ "isPnf": vnfModel.isPnf ? vnfModel.isPnf : false
+ };
+
+ resource = {
+ "name": vnfModel.modelCustomizationName,
+ "description": vnfModel.description
+ };
+ completeResources.push (resource);
+
+ if (vnfModel.commands != null) {
+ /*
+ * commands: {
+ * internal_net_param_ntu: {
+ * command: get_input,
+ * displaName: internal_net_param_ntu,
+ * inputName: vccfd1_internal_net_param_ntu // pointer to input key
+ * }
+ * If the input name (ptr) is one of instance_node_target, naming_policy or vf_instance_name
+ * then ignore it
+ *
+ */
+
+ convertedAsdcModel.vnfs[vnfCustomizationUuid].properties=vnfModel.properties;
+ //
+ let vnf_type = "";
+ let vnf_role = "";
+ let vnf_function = "";
+ let vnf_code = "";
+ if ( !( _.isEmpty(vnfModel.properties) ) ) {
+ if (this.hasContents (vnfModel.properties.nf_type) ) {
+ vnf_type = vnfModel.properties.nf_type;
+ }
+ if (this.hasContents (vnfModel.properties.nf_role) ) {
+ vnf_role = vnfModel.properties.nf_role;
+ }
+ if (this.hasContents (vnfModel.properties.nf_function) ) {
+ vnf_function = vnfModel.properties.nf_function;
+ }
+ if (this.hasContents (vnfModel.properties.nf_naming_code) ) {
+ vnf_code = vnfModel.properties.nf_naming_code;
+ }
+ }
+ convertedAsdcModel.vnfs[vnfCustomizationUuid]["nfType"] = vnf_type;
+ convertedAsdcModel.vnfs[vnfCustomizationUuid]["nfRole"] = vnf_role;
+ convertedAsdcModel.vnfs[vnfCustomizationUuid]["nfFunction"] = vnf_function;
+ convertedAsdcModel.vnfs[vnfCustomizationUuid]["nfCode"] = vnf_code;
+ //
+ for (let vfModuleCustomizationName in serviceModel.vnfs[vnfCustomizationName].vfModules) {
+ let vfModuleModel = serviceModel.vnfs[vnfCustomizationName].vfModules[vfModuleCustomizationName];
+ convertedAsdcModel.vnfs[vnfCustomizationUuid].vfModules[vfModuleModel.customizationUuid] = vfModuleModel;
+ }
+
+ for (let volumeGroupCustomizationName in serviceModel.vnfs[vnfCustomizationName].volumeGroups) {
+ let volumeGroupModel = serviceModel.vnfs[vnfCustomizationName].volumeGroups[volumeGroupCustomizationName];
+ convertedAsdcModel.vnfs[vnfCustomizationUuid].volumeGroups[volumeGroupModel.customizationUuid] = volumeGroupModel;
+ }
+ }
+ }
+
+ return (convertedAsdcModel);
+ };
+
+ private static convertOldModel(serviceModel ) {
+ let resource = {};
+ let convertedAsdcModel = {
+ "service": serviceModel.service,
+ "networks": {},
+ "vnfs": {},
+ "pnfs": serviceModel.pnfs,
+ "serviceProxies": serviceModel.serviceProxies,
+ "completeDisplayInputs": {},
+ "isNewFlow": false
+ };
+ let completeResources = new Array();
+ for (let networkCustomizationName in serviceModel.networks) {
+ let networkModel = serviceModel.networks[networkCustomizationName];
+ convertedAsdcModel.networks[networkModel.invariantUuid] = {};
+ convertedAsdcModel.networks[networkModel.uuid] = {
+ "uuid": networkModel.uuid,
+ "invariantUuid": networkModel.invariantUuid,
+ "version": networkModel.version,
+ "name": networkModel.name,
+ "modelCustomizationName": networkModel.modelCustomizationName,
+ "customizationUuid": networkModel.customizationUuid,
+ "inputs": "",
+ "description": networkModel.description,
+ "commands": {},
+ "displayInputs": {}
+ };
+ resource = {
+ "name": networkModel.modelCustomizationName,
+ "description": networkModel.description
+ };
+ completeResources.push (resource);
+ }
+
+ _.forEach(serviceModel.configurations, function(element) {
+ element.isConfig = true;
+ });
+ _.forEach(serviceModel.pnfs, function(element, key) {
+ element.isPnf= true;
+ element.modelCustomizationName= key;
+ });
+ let mergedVnfs = Object.assign(serviceModel.vnfs, serviceModel.configurations, serviceModel.pnfs);
+
+ for (let vnfCustomizationName in mergedVnfs) {
+ let vnfModel = mergedVnfs[vnfCustomizationName];
+ convertedAsdcModel.vnfs[vnfModel.uuid] = {
+ "uuid": vnfModel.uuid,
+ "invariantUuid": vnfModel.invariantUuid,
+ "version": vnfModel.version,
+ "name": vnfModel.name,
+ "modelCustomizationName": vnfModel.modelCustomizationName,
+ "customizationUuid": vnfModel.customizationUuid,
+ "inputs": "",
+ "description": vnfModel.description,
+ "vfModules": {},
+ "volumeGroups": {},
+ "commands": {},
+ "displayInputs": {},
+ "sourceNodes": vnfModel.sourceNodes,
+ "collectorNodes": vnfModel.collectorNodes,
+ "isConfigurationByPolicy": vnfModel.configurationByPolicy ? vnfModel.configurationByPolicy : false,
+ "isConfig": vnfModel.isConfig ? vnfModel.isConfig : false,
+ "isPnf": vnfModel.isPnf ? vnfModel.isPnf : false
+ };
+ resource = {
+ "name": vnfModel.modelCustomizationName,
+ "description": vnfModel.description
+ };
+ completeResources.push (resource);
+
+ for (let vfModuleCustomizationName in serviceModel.vnfs[vnfCustomizationName].vfModules) {
+ let vfModuleModel = serviceModel.vnfs[vnfCustomizationName].vfModules[vfModuleCustomizationName];
+ convertedAsdcModel.vnfs[vnfModel.uuid].vfModules[vfModuleModel.uuid] = vfModuleModel;
+ }
+
+ for (let volumeGroupCustomizationName in serviceModel.vnfs[vnfCustomizationName].volumeGroups) {
+ let volumeGroupModel = serviceModel.vnfs[vnfCustomizationName].volumeGroups[volumeGroupCustomizationName];
+ convertedAsdcModel.vnfs[vnfModel.uuid].volumeGroups[volumeGroupModel.uuid] = volumeGroupModel;
+ }
+ }
+
+ let completeDisplayInputs = {};
+
+ return (convertedAsdcModel);
+ };
+}