diff options
author | Patrick Brady <patrick.brady@att.com> | 2019-03-06 12:11:34 -0800 |
---|---|---|
committer | Patrick Brady <patrick.brady@att.com> | 2019-03-06 12:12:36 -0800 |
commit | eedac3e312c66499ca5ff9d72388c31b25813225 (patch) | |
tree | 4cc2f22a0a36ba97823b70fe27ed667383173f0a /src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts | |
parent | 611c9da62c2e266f9facd97dc9f340ce311060a3 (diff) |
Revert "multiple asible servers support"
Some functionality was accidentally removed
This reverts commit 611c9da62c2e266f9facd97dc9f340ce311060a3.
Change-Id: I1aefbbc0ede8cdda59acc8bdf7b047e506aad813
Signed-off-by: Patrick Brady <patrick.brady@att.com>
Issue-ID: APPC-1510
Diffstat (limited to 'src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts')
-rw-r--r-- | src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts | 106 |
1 files changed, 73 insertions, 33 deletions
diff --git a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts index a4e0539..40a5291 100644 --- a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts +++ b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts @@ -44,7 +44,6 @@ import { NgProgress } from 'ngx-progressbar'; import * as XLSX from 'xlsx'; import { NgxSpinnerService } from 'ngx-spinner'; import {UtilityService} from '../../../../shared/services/utilityService/utility.service'; -import { APIService } from "../../../../shared/services/cdt.apicall"; declare var $: any; @@ -102,13 +101,14 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { @ViewChild('myInputParam') myInputParam: any; @ViewChild(ModalComponent) modalComponent: ModalComponent; @ContentChildren(Tab) tabs: QueryList<Tab>; - public subscription: any; + public subscription: Subscription; public item: any = {}; vnfType: any = ''; vnfcType: any = ''; protocol: any = ''; refObj: any; - public paramsContent:any; + public paramsContent = localStorage['paramsContent']; + nameValueSubscription: Subscription; constructor( private buildDesignComponent: BuildDesignComponent, @@ -122,9 +122,7 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { private nService: NotificationsService, private ngProgress: NgProgress, private spinner: NgxSpinnerService, - private apiService:APIService, - private utilityService: UtilityService - + private utilityService: UtilityService, ) { this.artifactRequest.action = ''; this.artifactRequest.version = ''; @@ -134,27 +132,29 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { ngOnInit() { var refObj = this.refObj = this.prepareFileName(); if (refObj && refObj != undefined) { - try{ - this.paramsContent=JSON.stringify(JSON.parse(localStorage['paramsContent'])) - } - catch(e) - { - console.log("error parsing param values"); - } if (this.paramsContent && this.paramsContent != undefined && this.paramsContent !== '{}') { this.artifactRequest.paramsContent = this.formatNameValuePairs(this.paramsContent); - + // this.artifactRequest.paramsContent = this.paramsContent; + } else { this.artifactRequest.paramsContent = '{}'; } + // refObj = refObj[refObj.length - 1]; this.item = refObj; - this.vnfType = this.item.vnf; - this.vnfcType = this.item.vnfc; - this.protocol = this.item.protocol; + this.vnfType = this.item.scope['vnf-type']; + this.vnfcType = this.item.scope['vnfc-type']; + this.protocol = this.item['device-protocol']; this.action = this.item.action; var artifactList = this.item['artifact-list']; + for (var i = 0; i < artifactList.length; i++) { + var artifactName = artifactList[i]['artifact-name']; + var array = artifactName.split('_'); + if (array[0].toUpperCase() === 'TEMPLATE') { + this.artifactName = artifactName; + } + } } else { this.item = { @@ -170,9 +170,18 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { 'scopeType': '' }; } + this.initialAction = this.item.action; + this.subscription = this.activeRoutes.url.subscribe(UrlSegment => { + this.actionType = UrlSegment[0].path; + }); + + if (this.actionType === 'myTemplates') { + this.mappingEditorService.fromScreen = 'MappingScreen'; + } this.mappingEditorService.paramData = []; this.identifier = this.mappingEditorService.identifier; + } //========================== End of ngOnInit() Method============================================ @@ -181,20 +190,25 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { } //========================== End of browseOption() Method============================================ + ngOnDestroy() { this.prepareFileName(); if( this.subscription ) { this.subscription.unsubscribe(); } - // if( this.nameValueSubscription ) { this.nameValueSubscription.unsubscribe(); } + if( this.nameValueSubscription ) { this.nameValueSubscription.unsubscribe(); } } //========================== End of ngOnDestroy() Method============================================ ngAfterViewInit() { - this.configMappingEditorContent = this.mappingEditorService.getTemplateMappingDataFromStore(); - this.fileType = sessionStorage.getItem('fileType'); - if (this.configMappingEditorContent) - this.mappingEditorService.initialise(this.mappingComponent.templateeditor.getEditor(), this.configMappingEditorContent); - + if (this.mappingEditorService.fromScreen === 'MappingScreen') { + this.configMappingEditorContent = this.mappingEditorService.getTemplateMappingDataFromStore(); + this.fileType = sessionStorage.getItem('fileType'); + if (this.configMappingEditorContent) + this.mappingEditorService.initialise(this.mappingComponent.templateeditor.getEditor(), this.configMappingEditorContent, this.modal); + } if (this.refObj) { + + this.artifactRequest.action = this.item.action; + this.artifactRequest.vnfType = this.vnfType; if (this.vnfcType && this.vnfcType.length != 0) { this.scopeName = this.vnfcType; } @@ -220,11 +234,13 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { // Create the file reader let reader = new FileReader(); this.readFile(input.files[0], reader, (result) => { - var jsonObject = JSON.parse(result); - this.artifactRequest.paramsContent = JSON.stringify(jsonObject, null, 1); - this.notificationService.notifySuccessMessage('Configuration Template file successfully uploaded..'); - this.mappingEditorService.setParamContent(this.artifactRequest.paramsContent); - localStorage['paramsContent'] = this.artifactRequest.paramsContent; + if ('Mapping Data' === this.selectedUploadType) { + var jsonObject = JSON.parse(result); + this.artifactRequest.paramsContent = JSON.stringify(jsonObject, null, 1); + this.notificationService.notifySuccessMessage('Configuration Template file successfully uploaded..'); + this.mappingEditorService.setParamContent(this.artifactRequest.paramsContent); + localStorage['paramsContent'] = this.artifactRequest.paramsContent; + } this.enableMerge = true; this.initialData = result; setTimeout(() => { @@ -262,6 +278,7 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { // callback with the results callback(reader.result); }; + this.notificationService.notifySuccessMessage('Uploading File ' + file.name + ':' + file.type + ':' + file.size); // Read the file reader.readAsText(file, 'UTF-8'); } @@ -273,23 +290,44 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { } //========================== End of onParamChanges() Method============================================ + + updateFileName(action: any, scopeName: any, versionNo: any) { + let fileName = 'param_' + action + '_' + scopeName + '_' + versionNo + 'V.json'; + this.downloadedFileName = fileName; + return fileName; + } + + //========================== End of updateFileName() Method============================================ + updateFileNameForConfigScaleOut(action: any, scopeName: any, versionNo: any, id: any) { + let fileName = 'param_' + action + '_' + scopeName + '_' + versionNo + 'V_' + id + '.json'; + this.downloadedFileName = fileName; + return fileName; + } + //========================== End of updateFileNameForConfigScaleOut() Method============================================ prepareFileName(): any { - let fileNameObject: any = this.mappingEditorService.newObject; + let fileNameObject: any = this.mappingEditorService.latestAction; return fileNameObject; } //========================== End of prepareFileName() Method============================================ + retrieveNameValueFromAppc() { let refObj = this.refObj; if (refObj && refObj != undefined) { this.enableMerge = true; var scopeName = this.scopeName.replace(/ /g, '').replace(new RegExp('/', "g"), '_').replace(/ /g, ''); let fileName = ''; - fileName=refObj["param_artifact"] + let id = this.mappingEditorService.identifier; + if (id) fileName = this.updateFileNameForConfigScaleOut(this.item.action, scopeName, this.versionNo, id); + else fileName = this.updateFileName(this.item.action, scopeName, this.versionNo); + let input=this.utilityService.createPayloadForRetrieve(false, this.item.action, this.vnfType, fileName); let artifactContent: any; this.ngProgress.start(); - this.apiService.callGetArtifactsApi(input).subscribe(resp => { + this.nameValueSubscription = this.httpUtil.post({ + url: environment.getDesigns, + data: input + }).subscribe(resp => { if (resp.output.status.code === '400' && resp.output.status.message === 'success') { this.nService.success('Success', 'Name/value pairs retrieved successfully from APPC'); this.enableMerge = true; @@ -324,6 +362,7 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { } //========================== End of retrieveNameValueFromAppc() Method============================================ + formatNameValuePairs(namevaluePairs: string) { var string = namevaluePairs.substring(1, namevaluePairs.length - 1); var stringArr = string.split(','); @@ -417,7 +456,7 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { 'ruleTypeValues': arr2item.ruleTypeValues }; pdDataArrayForSession.splice(i, 1, json); - + } }); @@ -432,8 +471,9 @@ export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy { } } catch (error) { + console.log('Error occured in syncing param names' + JSON.stringify(error)); this.nService.error('Error', 'Error synchronising with name values. Please check the format of json uploaded/ retrieved'); } } -}
\ No newline at end of file +} |