summaryrefslogtreecommitdiffstats
path: root/src/app/vnfs/build-artifacts/parameter-definitions
diff options
context:
space:
mode:
authorasgar <ma926a@us.att.com>2019-03-01 15:32:47 +0530
committerTakamune Cho <takamune.cho@att.com>2019-03-04 19:52:20 +0000
commit611c9da62c2e266f9facd97dc9f340ce311060a3 (patch)
treee471d6c851cefd46ed83380c6e41d20f54fe2666 /src/app/vnfs/build-artifacts/parameter-definitions
parent9ccb0353f1c59bd7d49ff17c54e5d00c0960ea82 (diff)
multiple asible servers support
multiple asible servers support for CDT Issue-ID: APPC-1510 Change-Id: Id1b1b02274487cfbf6f108a57211a192924a6b08 Signed-off-by: Mohamed Asgar Samiulla <ma926a@us.att.com>
Diffstat (limited to 'src/app/vnfs/build-artifacts/parameter-definitions')
-rw-r--r--src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts145
-rw-r--r--src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.html7
-rw-r--r--src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts118
3 files changed, 181 insertions, 89 deletions
diff --git a/src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts b/src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts
index 14af6ab..2bd1bc9 100644
--- a/src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts
+++ b/src/app/vnfs/build-artifacts/parameter-definitions/parameter-definition.service.ts
@@ -31,6 +31,8 @@ import {UtilityService} from '../../../shared/services/utilityService/utility.se
import {NotificationsService} from 'angular2-notifications';
import 'rxjs/add/operator/map';
import { appConstants } from '../../../../constants/app-constants';
+import { HttpUtilService } from '../../../shared/services/httpUtil/http-util.service';
+
let YAML = require('yamljs');
@@ -38,7 +40,7 @@ declare var $: any;
@Injectable()
export class ParameterDefinitionService {
-
+ clName= "ParameterDefinitionSvc";
public vnfcTypeData: string = '';
public selectedUploadType: string;
@ViewChild(ModalComponent) modalComponent: ModalComponent;
@@ -63,9 +65,12 @@ export class ParameterDefinitionService {
private selectedActionReference: any;
private apiToken = localStorage['apiToken'];
private userId = localStorage['userId'];
+ public versionNoForApiCall=require('../../../../cdt.application.properties.json').versionNoForApiCall;
+
constructor(private mappingEditorService: MappingEditorService,
private paramShareService: ParamShareService,
private nService: NotificationsService,
+ private httpService: HttpUtilService,
private utilService: UtilityService) {
}
@@ -79,6 +84,8 @@ export class ParameterDefinitionService {
this.protocol = protocol;
this.action = action;
this.artifact_fileName = artifactName;
+ this.appDataObject = this.mappingEditorService.appDataObject;
+ this.downloadDataObject = this.mappingEditorService.downloadDataObject;
}
public afterInit(artifactName, displayParamObjects) {
@@ -89,7 +96,8 @@ export class ParameterDefinitionService {
/* Saves pd to appc */
public sendPD(yamlString: String) {
let result: any;
- let payload = '{"userID": "' + this.userId + '","vnf-type" : "' + this.vnfType + '","action" : "' + this.action + '","artifact-name" : "' + this.artifact_fileName + '","artifact-type" : "APPC-CONFIG","artifact-version" : "0.0.1","artifact-contents" : ' + yamlString + '}';
+ let input = this.utilService.createPayLoadForSave("pd_data",this.vnfType,this.action,this.artifact_fileName, this.versionNoForApiCall, yamlString);
+ /*let payload = '{"userID": "' + this.userId + '","vnf-type" : "' + this.vnfType + '","action" : "' + this.action + '","artifact-name" : "' + this.artifact_fileName + '","artifact-type" : "APPC-CONFIG","artifact-version" : "0.0.1","artifact-contents" : ' + yamlString + '}';
let input = {
'input': {
'design-request': {
@@ -98,7 +106,7 @@ export class ParameterDefinitionService {
'payload': payload
}
}
- };
+ };*/
this.appDataObject.pd = input;
}
@@ -114,26 +122,78 @@ export class ParameterDefinitionService {
return result;
}
- //========================== End of removeUnwantedvalues() Method============================================
- populateDataUponSource(displayParamObjects) {
- displayParamObjects.forEach(parameter => {
- if (parameter.source == 'A&AI') {
- parameter.ruleTypeValues = [null, 'vnf-name', 'vm-name-list', 'vnfc-name-list', 'vnf-oam-ipv4-address', 'vnfc-oam-ipv4-address-list'];
- if (parameter['rule-type'] == 'vm-name-list' || parameter['rule-type'] == 'vnfc-name-list' || parameter['rule-type'] == 'vnfc-oam-ipv4-address-list') {
- parameter.showFilterFields = true;
- parameter.enableFilterByValue = false;
- } else {
- parameter.showFilterFields = false;
- }
-
- } else if (parameter.source == 'Manual') {
+ //.. setup display of each parameter row depending on the paramater name,
+ // pre-set values of source and rule-type fields (columns)
+ populateDataUponSource( displayParamObjects) {
+ var methName= "populateDataUponSource";
+ if( this.utilService.getTracelvl() > 0 )
+ console.log( this.clName+": "+methName+": start: displayParamObjects "+
+ "length="+displayParamObjects.length );
+ displayParamObjects.forEach( parameter => {
+ if( this.utilService.getTracelvl() > 0 )
+ console.log( this.clName+": "+methName+": param: name:["+
+ parameter.name+"] source:["+
+ parameter.source+"] rule-type:["+parameter['rule-type']+"]");
+ if( parameter.name == 'NodeList-DD') {
+ if( this.utilService.getTracelvl() > 0 )
+ console.log( this.clName+": "+methName+": the Param is NodeList");
+ parameter.source= "DataDictionary";
+ }
+ else if( parameter.name == 'vnfName-DD' ) {
+ if( this.utilService.getTracelvl() > 0 )
+ console.log( this.clName+": "+methName+": the Param's vnfName-DD");
+ parameter.source= "A&AI";
+ parameter['rule-type']= "vnf-name";
+ };
+ if( parameter.source == 'A&AI') {
+ parameter.ruleTypeValues = [null, 'vnf-name', 'vm-name-list', 'vnfc-name-list', 'vnf-oam-ipv4-address', 'vnfc-oam-ipv4-address-list'];
+ if( parameter['rule-type'] == 'vm-name-list' ||
+ parameter['rule-type'] == 'vnfc-name-list' ||
+ parameter['rule-type'] == 'vnfc-oam-ipv4-address-list')
+ {
+ parameter.showFilterFields = true;
+ parameter.enableFilterByValue = false;
+ } else {
+ parameter.showFilterFields = false;
+ }
+ }
+ else if( parameter.source == 'Manual') {
parameter.ruleTypeValues = [null];
}
+ else if( parameter.source == 'DataDictionary') {
+ parameter.sourceValues = ['DataDictionary'];
+ parameter.ruleTypeValues = ['NodeList'];
+ parameter['rule-type']= 'NodeList';
+ }
else {
parameter.ruleTypeValues = [parameter['rule-type']];
}
+ //.. print-out the parameter's drop-downs for source and rule-type
+ if( this.utilService.getTracelvl() > 1 ) {
+ if( parameter.sourceValues != null &&
+ parameter.sourceValues != undefined )
+ {
+ console.log( this.clName+": "+methName+": sourceValues length="+
+ parameter.sourceValues.length );
+ if( parameter.sourceValues.length > 0 ) {
+ for( var i0=0; i0 < parameter.sourceValues.length; i0++ )
+ console.log( methName+": sourceValues["+i0+"]:["+
+ parameter.sourceValues[i0]+"]");
+ };
+ };
+ if( parameter.ruleTypeValues != null &&
+ parameter.ruleTypeValues != undefined )
+ {
+ console.log( this.clName+": "+methName+": ruleTypeValues length="+
+ parameter.ruleTypeValues.length );
+ if( parameter.ruleTypeValues.length > 0 ) {
+ for( var i0=0; i0 < parameter.ruleTypeValues.length; i0++ )
+ console.log( methName+": ruleTypeValues["+i0+"]:["+
+ parameter.ruleTypeValues[i0]+"]");
+ };
+ };
+ };
});
-
}
//========================== End of getPD() Method============================================
@@ -142,7 +202,7 @@ export class ParameterDefinitionService {
//Added code to deserialize, serialize and format the response keys for display purposes ??May be unneessary?? To Do: - Check
let fileObj = JSON.parse(fileContent);
this.displayParamObjects = this.formatFileContentForDisplay(fileObj);
- this.populateDataUponSource(this.displayParamObjects);
+ this.populateDataUponSource( this.displayParamObjects);
this.formatResponseForKey(this.displayParamObjects);
if (undefined !== this.displayParamObjects)
this.modelParamDefinitionObjects = this.displayParamObjects;
@@ -152,7 +212,6 @@ export class ParameterDefinitionService {
return this.displayParamObjects;
}
- //========================== End of populatePD() Method============================================
/* Formats each object read from YAML file as per page expectations */
formatResponseForKey(param: any[]) {
for (var i = 0; i < param.length; i++) {
@@ -200,8 +259,8 @@ export class ParameterDefinitionService {
}
}
}
-
//========================== End of formatKeys() Method============================================
+
//Send null if there are no keys present - Check with key names being absent
formatKeysForFileGeneration() {
for (var i = 0; i < this.modelParamDefinitionObjects.length; i++) {
@@ -269,7 +328,7 @@ export class ParameterDefinitionService {
}
delete fileModel[i]['response-keys'];
fileModel[i]['response-keys'] = fileModel[i]['response-keys-new'];
- delete fileModel[i]['response-keys=new'];
+ delete fileModel[i]['response-keys-new'];
}
}
return fileModel;
@@ -305,14 +364,22 @@ export class ParameterDefinitionService {
return result;
}
-
- public prepareFileName(): any {
- let fileNameObject: any = this.mappingEditorService.latestAction;
- this.appDataObject = this.mappingEditorService.appDataObject;
- this.downloadDataObject = this.mappingEditorService.downloadDataObject;
- return fileNameObject;
+ //========================== End of clearSessionStorageForParam() Method============================================
+ isValidateSourceAndResponseKeys(objs: any[]) {
+ let isValid = true;
+ if (undefined != objs || null != objs) {
+ for (var i = 0; i < objs.length; i++) {
+ if (objs[i].source == 'INSTAR' && (null == objs[i]['response-keys'] || undefined == objs[i]['response-keys'])) {
+ isValid = false;
+ return isValid;
+ }
+ }
+ }
+ return isValid;
}
+
+
public destroy(displayParamObjects) {
this.displayParamObjects = displayParamObjects;
if (this.mappingEditorService.referenceNameObjects) {
@@ -338,6 +405,8 @@ export class ParameterDefinitionService {
jsonString = jsonString.replace(/"null"/g, 'null');
let saveModel = JSON.parse(jsonString);
let pdFileObject = this.processResponseKeys(saveModel);
+ //Validate for Source =INSTAR and responsekeys present
+ if (this.isValidateSourceAndResponseKeys(pdFileObject)) {
let yamlObject = {
'kind': 'Property Definition',
'version': 'V1',
@@ -362,7 +431,14 @@ export class ParameterDefinitionService {
else {
this.sendPD(JSON.stringify(yamlString));
}
-
+ }
+ else {
+ for (var i = 0; i < this.modelParamDefinitionObjects.length; i++) {
+ this.formatKeys(this.modelParamDefinitionObjects[i]);
+ }
+ this.nService.error('Error', 'Response Keys cannot be empty if source is INSTAR');
+ return;
+ }
//Restore Keys for display
for (var i = 0; i < this.modelParamDefinitionObjects.length; i++) {
this.formatKeys(this.modelParamDefinitionObjects[i]);
@@ -410,7 +486,18 @@ export class ParameterDefinitionService {
}
parameterDefinitionObject['source'] = fields[0];
parameterDefinitionObject['rule-type'] = fields[1];
- }
+ } else {
+ if (parameterDefinitionObject['source'] === 'INSTAR') {
+ parameterDefinitionObject['source'] = 'Manual';
+ parameterDefinitionObject['ruleTypeValues'] = [null];
+ parameterDefinitionObject['rule-type'] = null;
+ parameterDefinitionObject['showFilterFields'] = false;
+ for (let x = 0; x < 5; x++) {
+ parameterDefinitionObject['response-keys'][x]['key-name'] = null;
+ parameterDefinitionObject['response-keys'][x]['key-value'] = null;
+ }
+ }
+ }
this.formatKeys(parameterDefinitionObject); //Ensure there are 3 elements for response-keys, request-keys for display purposes
if (!result.present) { //only push if not present
this.modelParamDefinitionObjects.push(parameterDefinitionObject);
diff --git a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.html b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.html
index 799627b..6cae750 100644
--- a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.html
+++ b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.html
@@ -40,10 +40,11 @@ limitations under the License.
<label>Vnf Type</label><input class="form-control" type="text" disabled value="{{vnfType}}" />
</div>
<div class="col-lg-3 col-sm-6 col-md-3 col-xs-12" *ngIf="vnfcType">
- <label>Vnfc Type</label><input class="form-control" type="text" disabled value="{{vnfcType}}" />
+ <label>Vnfc Type</label> <label style="font-size:12px;">(NFC Function)</label>
+ <input class="form-control" type="text" disabled value="{{vnfcType}}" />
</div>
<div class="col-lg-3 col-sm-6 col-md-3 col-xs-12" *ngIf="!vnfcType">
-
+
</div>
<div class="col-lg-3 col-sm-6 col-md-3 col-xs-12">
<label>Protocol</label><input class="form-control" type="text" disabled value="{{protocol}}" />
@@ -142,7 +143,7 @@ limitations under the License.
<option *ngFor="let src of sourceValues"
[value]="src"
[selected]="src === obj.source"
- >
+ [disabled]="(obj.name == 'NodeList-DD' && src != 'DataDictionary')||(obj.name == 'vnfName-DD' && src == 'DataDictionary')||(obj.name != 'NodeList-DD' && obj.name != 'vnfName-DD' && src == 'INSTAR')">
{{src}}
</option>
diff --git a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts
index f7d1837..6ba8e52 100644
--- a/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts
+++ b/src/app/vnfs/build-artifacts/parameter-definitions/parameter.component.ts
@@ -38,6 +38,7 @@ import 'rxjs/add/operator/map';
import { NgProgress } from 'ngx-progressbar';
import { NgxSpinnerService } from 'ngx-spinner';
import { appConstants } from '../../../../constants/app-constants';
+import { APIService } from "../../../shared/services/cdt.apicall";
let YAML = require('yamljs');
@@ -50,9 +51,11 @@ declare var $: any;
providers: [ParameterDefinitionService]
})
export class ParameterComponent implements OnInit {
+ clName= "ParameterCompon";
public paramForm: any;
public actionType: any;
public showFilterFields: boolean;
+
public filterByFieldvalues = appConstants.filterByFieldvalues;
public ruleTypeConfiguaration = appConstants.ruleTypeConfiguaration;
public requiredValues: boolean[] = appConstants.requiredValues;
@@ -106,11 +109,12 @@ export class ParameterComponent implements OnInit {
public artifactName;
public appDataObject: any;
public downloadDataObject: any;
- public artifact_fileName = "";
+ public artifact_fileName="";
template_id: any;
private selectedActionReference: any;
constructor(private httpService: HttpUtilService,
+ private apiService:APIService,
private parameterDefinitionService: ParameterDefinitionService,
private paramShareService: ParamShareService,
private mappingEditorService: MappingEditorService,
@@ -122,33 +126,26 @@ export class ParameterComponent implements OnInit {
}
ngOnInit() {
- this.selectedActionReference = this.parameterDefinitionService.prepareFileName();
+ var methName= "ngOnInit";
+ this.selectedActionReference = this.mappingEditorService.newObject;
if (this.selectedActionReference && this.selectedActionReference != undefined) {
-
- this.vnfType = this.selectedActionReference.scope['vnf-type'];
- this.vnfcType = this.selectedActionReference.scope['vnfc-type'];
- this.protocol = this.selectedActionReference['device-protocol'];
- this.action = this.selectedActionReference.action;
-
- for (let i = 0; i < this.selectedActionReference['artifact-list'].length; i++) {
- let artifactList = this.selectedActionReference['artifact-list'];
- if (artifactList[i]['artifact-type'] === 'parameter_definitions') {
- var artifactName = artifactList[i]['artifact-name'];
- var artifactNameWithoutExtension = '';
- if (artifactName) {
- artifactNameWithoutExtension = artifactName.substring(0, artifactName.lastIndexOf("."));
- }
- if (this.mappingEditorService.identifier) {
- if (artifactNameWithoutExtension.endsWith(this.mappingEditorService.identifier)) {
- this.artifact_fileName = artifactName;
- }
-
- }
- else {
- this.artifact_fileName = artifactName;
- }
- }
+ this.vnfType = this.selectedActionReference.vnf;
+ this.protocol = this.selectedActionReference.protocol;
+ this.action = this.selectedActionReference.action;
+ if( this.utilService.getTracelvl() > 0 )
+ console.log( this.clName+": "+methName+": vnfType:["+this.vnfType+
+ "] action:["+this.action+"] protocol:["+this.protocol+"]");
+ if(this.selectedActionReference.vnfc) {
+ this.vnfcType = this.selectedActionReference.vnfc;
+ if( this.utilService.getTracelvl() > 0 )
+ console.log( this.clName+": "+methName+": have vnfcType:["+
+ this.vnfcType+"]");
+ }
+ if( this.action === 'ConfigScaleOut'){
+ // this.template_id = this.selectedActionReference.templateId;
+ this.template_id = this.mappingEditorService.identifier;
}
+ this.artifact_fileName = this.selectedActionReference.pd_artifact;
this.parameterDefinitionService.setValues(this.vnfType, this.vnfcType, this.protocol, this.action, this.artifact_fileName);
}
else {
@@ -165,22 +162,26 @@ export class ParameterComponent implements OnInit {
'scopeType': ''
};
}
-
- this.template_id = this.mappingEditorService.identifier;
+ //let path = this.location.path
+ /* this.activeRoutes.url.subscribe(UrlSegment => {
+ this.actionType = UrlSegment[0].path
+ })
+ */
}
ngAfterViewInit() {
- if (this.mappingEditorService.latestAction) {
+ if( this.mappingEditorService.latestAction) {
this.displayParamObjects = [];
this.modelParamDefinitionObjects = [];
- if (this.paramShareService.getSessionParamData() != undefined && this.paramShareService.getSessionParamData().length > 0) {
- this.getPDFromSession();
+ this.displayParamObjects= this.paramShareService.getSessionParamData();
+ // if( this.paramShareService.getSessionParamData() != undefined &&
+ // this.paramShareService.getSessionParamData().length > 0)
+ if( this.displayParamObjects != undefined &&
+ this.displayParamObjects.length > 0 )
+ {
+ this.parameterDefinitionService.populateDataUponSource( this.displayParamObjects);
} else {
- this.ngProgress.start();
- this.getPD();
- setTimeout(() => {
- this.ngProgress.done();
- }, 3500);
+ this.getPD();
}
} else {
this.nService.error(appConstants.errors.error, appConstants.errors["noAction&VNFTypeInRDscreenError"]);
@@ -191,19 +192,20 @@ export class ParameterComponent implements OnInit {
public getPD() {
let result: any;
- let input=this.utilService.createPayloadForRetrieve(false, this.action, this.vnfType,this.artifact_fileName);
+ let input=
+ this.utilService.createPayloadForRetrieve( false, this.action, this.vnfType,this.artifact_fileName);
let artifactContent: any;
- return this.httpService.post({
- url: environment.getDesigns,
- data: input
- }).subscribe(data => {
- if (this.utilService.checkResult(data)) {
- let result: any = JSON.parse(data.output.data.block).artifactInfo[0];
+ this.ngProgress.start();
+ return this.apiService.callGetArtifactsApi(input).subscribe( data => {
+ if( this.utilService.checkResult(data)) {
+ let result: any = JSON.parse(data.output.data.block).artifactInfo[0];
var pdObject = YAML.parse(result['artifact-content']);
let fileModel = pdObject['vnf-parameter-list'];
this.displayParamObjects = this.parameterDefinitionService.populatePD(fileModel);
}
-
+ else {
+ }
+ this.ngProgress.done();
},
error => this.nService.error(appConstants.errors.error, appConstants.errors.connectionError));
@@ -212,20 +214,19 @@ export class ParameterComponent implements OnInit {
public getPDFromSession() {
- this.ngProgress.start();
+ this.ngProgress.start();
return this.httpService.get({
url: 'testurl',
- }).subscribe(data => {
- this.displayParamObjects = this.paramShareService.getSessionParamData();
- this.ngProgress.done();
+ }).subscribe( data => {
+ this.displayParamObjects = this.paramShareService.getSessionParamData();
+ this.ngProgress.done();
},
- error => {
- this.displayParamObjects = this.paramShareService.getSessionParamData();
- this.ngProgress.done();
- });
+ error => {
+ this.displayParamObjects = this.paramShareService.getSessionParamData();
+ this.ngProgress.done();
+ });
}
- //========================== End of NGInit() Method============================================
selectedNavItem(item: any) {
this.item = item;
}
@@ -266,6 +267,10 @@ export class ParameterComponent implements OnInit {
// Create the file reader
let reader = new FileReader();
this.readFile(input.files[0], reader, (result) => {
+ if ('keyfile' === uploadType) {
+ this.myKeyFileName = input.files[0].name;
+ this.displayParamObjects = this.parameterDefinitionService.processKeyFile(this.myKeyFileName, result);
+ }
if ('pdfile' === uploadType) {
this.myPdFileName = input.files[0].name;
this.displayParamObjects = this.parameterDefinitionService.processPDfile(this.myPdFileName, result);
@@ -294,8 +299,7 @@ export class ParameterComponent implements OnInit {
let obj: any = fileInput.target.files;
}
-
- sourceChanged(data, obj) {
+ sourceChanged( data, obj) {
if (data == 'A&AI') {
obj.ruleTypeValues = appConstants.ruleTypeValues;
for (let x = 0; x < 5; x++) {
@@ -317,7 +321,7 @@ export class ParameterComponent implements OnInit {
}
//========================== End of sourceChanged() Method============================================
- ruleTypeChanged(data, obj) {
+ ruleTypeChanged( data, obj) {
if (data == null || data == undefined || data == 'null') {
obj.showFilterFields = false;
obj['rule-type'] = null;
@@ -340,7 +344,7 @@ export class ParameterComponent implements OnInit {
}
for (let x = 0; x < sourceObject.length; x++) {
obj['response-keys'][x]['key-name'] = sourceObject[x]['key-name'];
- obj['response-keys'][x]['key-value'] = sourceObject[x]['key-value'];
+ obj['response-keys'][x]['key-value'] = sourceObject[x]['key-value'];
}
}