summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/utils
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2018-08-29 17:01:32 +0300
committerIttay Stern <ittay.stern@att.com>2019-02-18 18:35:30 +0200
commit6f900cc45d7dd7f97430812b86b5c1d1693c8ae3 (patch)
tree936005c364dc5a7264d6304d4777c3d83494db22 /vid-webpack-master/src/app/utils
parent67d99f816cc583643c35193197594cf78d8ce60a (diff)
merge from ecomp a88f0072 - Modern UI
Issue-ID: VID-378 Change-Id: Ibcb23dd27f550cf32ce2fe0239f0f496ae014ff6 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/utils')
-rw-r--r--vid-webpack-master/src/app/utils/utils.ts271
1 files changed, 0 insertions, 271 deletions
diff --git a/vid-webpack-master/src/app/utils/utils.ts b/vid-webpack-master/src/app/utils/utils.ts
deleted file mode 100644
index dc4db3e4f..000000000
--- a/vid-webpack-master/src/app/utils/utils.ts
+++ /dev/null
@@ -1,271 +0,0 @@
-import { Constants } from '../shared/utils/constants';
-import Parameter = Constants.Parameter;
-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.invariantUuid][networkModel.version] = networkModel;
- // need a network model to test this
- 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);
- };
-}