diff options
author | Sandeep J <sandeejh@in.ibm.com> | 2018-07-16 17:27:52 +0530 |
---|---|---|
committer | Takamune Cho <tc012c@att.com> | 2018-07-16 18:00:34 +0000 |
commit | 54f1c5e013bade034eca118467c9b620275c1b0c (patch) | |
tree | aa88ef51a168d2a78e0f72891886efc9d9bf56ac /src/app/vnfs/build-artifacts/reference-dataform | |
parent | 129dae2aaf5efe503ac9afaafec3a5dfd545c144 (diff) |
replaced if else logic to switch case
Replaced the if else logic in decideExtension and populateExistinAction
method with switch case for better presentation of the code as part of
plan for reference dataform code refactor
Issue-ID: APPC-1085
Change-Id: I002e61d53585ba61b96e1e6cb0f12443498df6e9
Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
Diffstat (limited to 'src/app/vnfs/build-artifacts/reference-dataform')
-rw-r--r-- | src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts | 68 |
1 files changed, 45 insertions, 23 deletions
diff --git a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts index acd99e0..e625ebd 100644 --- a/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts +++ b/src/app/vnfs/build-artifacts/reference-dataform/reference-dataform.component.ts @@ -3,7 +3,8 @@ =================================================================== Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. =================================================================== - +Copyright (C) 2018 IBM. +=================================================================== Unless otherwise specified, all software contained herein is licensed under the Apache License, Version 2.0 (the License); you may not use this software except in compliance with the License. @@ -401,7 +402,7 @@ export class ReferenceDataformComponent implements OnInit { //Reference object to create reference data prepareReferenceObject(isSaving?: any) { let scopeName = this.resetParamsOnVnfcType(); - let extension = this.decideExtension(); + let extension = this.decideExtension(this.referenceDataObject); this.prepareArtifactList(scopeName, extension); if (this.referenceDataObject.action === 'OpenStack Actions') { this.referenceDataObject['template'] = 'N'; @@ -832,7 +833,7 @@ export class ReferenceDataformComponent implements OnInit { let obj = $.extend(true, {}, this.tempAllData[existAction]); this.referenceDataObject = obj; this.referenceDataObject.scope['vnf-type'] = obj['scope']['vnf-type']; - this.referenceDataObject.scope['vnfc-type'] = obj['scope']['vnfc-type']; + this.referenceDataObject.scope['vnfc-type-list'] = obj['scope']['vnfc-type-list']; this.referenceDataObject['device-protocol'] = obj['device-protocol']; this.refernceScopeObj['sourceType'] = obj['scopeType']; } else { @@ -840,19 +841,34 @@ export class ReferenceDataformComponent implements OnInit { this.referenceDataObject.action = data; } //# iof healthCeck change deviceprotocol drp vaues - if (data == 'HealthCheck') { - this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'REST']; - this.actionHealthCheck = true; - } else if (data == 'UpgradeBackout' || data == 'ResumeTraffic' || data == 'QuiesceTraffic' || data == 'UpgradeBackup' || data == 'UpgradePostCheck' || data == 'UpgradePreCheck' || data == 'UpgradeSoftware' || data == 'ConfigBackup' || data == 'ConfigRestore' || data == 'StartApplication' || data == 'StopApplication' || data == 'GetRunningConfig') { - this.deviceProtocols = ['', 'CHEF', 'ANSIBLE']; - } else if (data == 'OpenStack Actions') { - this.deviceProtocols = ['', 'OpenStack']; - } else if (data == 'ConfigScaleOut') { - this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF']; - } - else { - this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'RESTCONF', 'CLI']; - this.actionHealthCheck = false; + switch (data) { + case 'HealthCheck': + this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'REST']; + this.actionHealthCheck = true; + break; + case 'UpgradeBackout': + case 'ResumeTraffic': + case 'QuiesceTraffic': + case 'UpgradeBackup': + case 'UpgradePostCheck': + case 'UpgradePreCheck': + case 'UpgradeSoftware': + case 'ConfigRestore': + case 'StartApplication': + case 'StopApplication': + case 'GetRunningConfig': + case 'ConfigBackup': + this.deviceProtocols = ['', 'CHEF', 'ANSIBLE']; + break; + case 'OpenStack Actions': + this.deviceProtocols = ['', 'OpenStack']; + break; + case 'ConfigScaleOut': + this.deviceProtocols = ['', 'CHEF', 'ANSIBLE', 'NETCONF-XML', 'RESTCONF']; + break; + default: + this.deviceProtocols = ['', 'ANSIBLE', 'CHEF', 'NETCONF-XML', 'RESTCONF', 'CLI']; + this.actionHealthCheck = false; } } @@ -1175,15 +1191,21 @@ export class ReferenceDataformComponent implements OnInit { } return scopeName } - decideExtension() { + decideExtension(obj) { //marking the extension based on the device-protocol selected by the user - let extension = 'json'; - if (this.referenceDataObject['device-protocol'] == 'ANSIBLE' || this.referenceDataObject['device-protocol'] == 'CHEF' || this.referenceDataObject['device-protocol'] == 'CLI') { - extension = 'json'; - } else if (this.referenceDataObject['device-protocol'] == 'NETCONF-XML' || this.referenceDataObject['device-protocol'] == 'REST') { - extension = 'xml'; + let extension = '.json'; + switch (obj['device-protocol']) { + case 'ANSIBLE': + case 'CHEF': + case 'CLI': + extension = '.json'; + break; + case 'NETCONF-XML': + case 'REST': + extension = '.xml'; + break; } - return extension + return extension; } prepareArtifactList(scopeName, extension) { this.referenceDataObject['artifact-list'] = []; |