aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/vnfs/build-artifacts/template-holder
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/vnfs/build-artifacts/template-holder')
-rw-r--r--src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.spec.ts1
-rw-r--r--src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts42
-rw-r--r--src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.html3
-rw-r--r--src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.spec.ts40
-rw-r--r--src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts67
5 files changed, 100 insertions, 53 deletions
diff --git a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.spec.ts b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.spec.ts
index c9a7c4d..0ec9d9f 100644
--- a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.spec.ts
+++ b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.spec.ts
@@ -223,6 +223,7 @@ describe('GoldenConfigurationMappingComponent', () => {
component.vnfType = "testVnf";
component.userId = "abc";
component.item.action = "Configure";
+ mappingEditorService.identifier="id1";
component.retrieveNameValueFromAppc();
expect(localStorage["localStorage['paramsContent']"]).not.toBe(null);
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 a3c5a8e..b098ab7 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
@@ -51,7 +51,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
enableMappingSave: boolean = false;
aceText: string = '';
fileName: string = '';
- actionType: any='';
+ actionType: any = '';
modal: any;
configMappingEditorContent: any;
fileType: any = '';
@@ -69,8 +69,8 @@ export class GoldenConfigurationMappingComponent implements OnInit {
enableDownload: boolean = false;
showMappingDownloadDiv: boolean = false;
mapppingDownloadType: any;
- action: any='';
- artifactName: any='';
+ action: any = '';
+ artifactName: any = '';
enableMerge: boolean = false;
apiToken = localStorage['apiToken'];
userId = localStorage['userId'];
@@ -98,13 +98,13 @@ export class GoldenConfigurationMappingComponent implements OnInit {
@ContentChildren(Tab) tabs: QueryList<Tab>;
public subscription: any;
public item: any = {};
- vnfType: any='';
- vnfcType: any='';
- protocol: any='';
+ vnfType: any = '';
+ vnfcType: any = '';
+ protocol: any = '';
refObj: any;
public paramsContent = localStorage['paramsContent'];
- constructor (private buildDesignComponent: BuildDesignComponent, private paramShareService: ParamShareService, private router: Router, private httpUtil: HttpUtilService, private dialogService: DialogService, private activeRoutes: ActivatedRoute, private mappingEditorService: MappingEditorService, private notificationService: NotificationService, private nService: NotificationsService, private ngProgress: NgProgress) {
+ constructor(private buildDesignComponent: BuildDesignComponent, private paramShareService: ParamShareService, private router: Router, private httpUtil: HttpUtilService, private dialogService: DialogService, private activeRoutes: ActivatedRoute, private mappingEditorService: MappingEditorService, private notificationService: NotificationService, private nService: NotificationsService, private ngProgress: NgProgress) {
this.artifactRequest.action = '';
this.artifactRequest.version = '';
this.artifactRequest.paramKeysContent = '';
@@ -155,7 +155,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
this.activeRoutes.url.subscribe(UrlSegment => {
this.actionType = UrlSegment[0].path;
});
-
+
if (this.actionType === 'myTemplates') {
this.mappingEditorService.fromScreen = 'MappingScreen';
}
@@ -171,7 +171,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
}
//========================== End of browseOption() Method============================================
-
+
ngOnDestroy() {
this.prepareFileName();
}
@@ -201,8 +201,8 @@ export class GoldenConfigurationMappingComponent implements OnInit {
}
//========================== End of ngAfterViewInit() Method============================================
-
-
+
+
public fileParamChange(input) {
if (input.files && input.files[0]) {
this.enableMappingSave = true;
@@ -264,7 +264,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
}
//========================== End of onParamChanges() Method============================================
-
+
updateFileName(action: any, scopeName: any, versionNo: any) {
let fileName = 'param_' + action + '_' + scopeName + '_' + versionNo + 'V.json';
this.downloadedFileName = fileName;
@@ -272,19 +272,29 @@ export class GoldenConfigurationMappingComponent implements OnInit {
}
//========================== 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.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 = this.updateFileName(this.item.action, scopeName, this.versionNo);
+ let fileName = '';
+ 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 payload = '{"userID": "' + this.userId + '", "action": "' + this.item.action + '", "vnf-type" : "' + this.vnfType + '", "artifact-type":"APPC-CONFIG", "artifact-name":"' + fileName + '"}';
let input = {
'input': {
@@ -337,7 +347,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
}
//========================== End of retrieveNameValueFromAppc() Method============================================
-
+
formatNameValuePairs(namevaluePairs: string) {
var string = namevaluePairs.substring(1, namevaluePairs.length - 1);
var stringArr = string.split(',');
@@ -431,7 +441,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
'ruleTypeValues': arr2item.ruleTypeValues
};
pdDataArrayForSession.splice(i, 1, json);
-
+
}
});
diff --git a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.html b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.html
index 02b5a02..52a2734 100644
--- a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.html
+++ b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.html
@@ -41,7 +41,8 @@ limitations under the License.
<label>Protocol</label><input class="form-control" type="text" disabled value="{{protocol}}" />
</div>
<div *ngIf="(action === 'ConfigScaleOut')" class="col-lg-3 col-sm-6 col-md-3 col-xs-12">
- <label>Template Identifier</label><input class="form-control" type="text" disabled value="{{identifier}}" />
+ <label>Template Identifier</label><input class="form-control" type="text" [(ngModel)]="identifier" disabled />
+
</div>
</div>
</div>
diff --git a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.spec.ts b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.spec.ts
index da422c3..8ad635b 100644
--- a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.spec.ts
+++ b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.spec.ts
@@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
@@ -218,6 +217,7 @@ describe('GoldenConfigurationComponent', () => {
component.userId = "sj108s";
component.apiToken = "87264736473";
+ mappingEditorService.identifier = "id1";
component.prepareAppData();
var paramData = { "input": ({ "design-request": ({ "request-id": '87264736473', "action": 'uploadArtifact', "payload": '{"userID":"sj108s","vnf-type":"testVnf","action":"Configure","artifact-name":"param_Configure_testVnf_0.0.1V.json","artifact-type":"APPC-CONFIG","artifact-version":"0.0.1","artifact-contents":"[{\"sync_auto-pop_name1\":\"10.0.1.34\",\"sync_auto-pop_address1\":\"\",\"node0_tacplus_server_name2\":\"192.34.45.5\"}]"}' }) }) };
var templateData = { input: ({ "design-request": ({ "request-id": '87264736473', "action": 'uploadArtifact', "payload": '{"userID":"sj108s","vnf-type":"testVnf","action":"Configure","artifact-name":"template_Configure_test_0.0.1V.json","artifact-type":"APPC-CONFIG","artifact-version":"0.0.1","artifact-contents":"<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" \n xmlns:a=\"http://xml.juniper.net/junos/15.1X49/junos\" >\n<version>15.1X49-D50.3</version>\n <groups>\n <name>node0</name>\n <system>\n <tacplus-server>\n <name>${sync_auto-pop_name1}</name>\n <source-address>${sync_auto-pop_address1}</source-address>\n </tacplus-server>\n <tacplus-server>\n <name>${node0_tacplus_server_name2}</name>\n <source-address>${sync_auto-pop_address1}</source-address>\n </tacplus-server>\n </system> \n </groups>\n </configuration>"}' }) }) };
@@ -375,54 +375,54 @@ describe('GoldenConfigurationComponent', () => {
// fileChange method
it('Should validatte fileChange method if file type is xml', async(() => {
let reader = new FileReader();
- let file = new File(["testing"], "foo.xml", {type: "text/xml"});
- let input = {files: [file]};
+ let file = new File(["testing"], "foo.xml", { type: "text/xml" });
+ let input = { files: [file] };
component.refObj = true;
component.fileChange(input);
- component.readFile(input.files[0], reader,(res) => {
+ component.readFile(input.files[0], reader, (res) => {
expect(component.selectedUploadType).toEqual('Generated Template');
expect(component.configMappingEditorContent).toEqual(res);
expect(component.artifactRequest.templateContent).toEqual(res);
- });
+ });
}));
it('Should validatte fileChange method if file type is json', async(() => {
let reader = new FileReader();
- let file = new File(["testing"], "foo.json", {type: "text/json"});
- let input = {files: [file]};
+ let file = new File(["testing"], "foo.json", { type: "text/json" });
+ let input = { files: [file] };
component.refObj = true;
component.fileChange(input);
- component.readFile(input.files[0], reader,(res) => {
+ component.readFile(input.files[0], reader, (res) => {
expect(component.selectedUploadType).toEqual('Generated Template');
expect(component.configMappingEditorContent).toEqual(res);
expect(component.artifactRequest.templateContent).toEqual(res);
- });
+ });
}));
it('Should validatte fileChange method if file type is none ', async(() => {
let reader = new FileReader();
- let file = new File(["testing"], "foo", {type: ""});
- let input = {files: [file]};
+ let file = new File(["testing"], "foo", { type: "" });
+ let input = { files: [file] };
component.refObj = true;
component.fileChange(input);
- component.readFile(input.files[0], reader,(res) => {
+ component.readFile(input.files[0], reader, (res) => {
expect(typeof sessionStorage.getItem('fileType')).toEqual('string')
expect(component.selectedUploadType).toEqual('Generated Template');
expect(component.configMappingEditorContent).toEqual(res);
expect(component.artifactRequest.templateContent).toEqual(res);
- });
+ });
}));
it('Should validate if files is false', () => {
let spy = spyOn(NotificationsService.prototype, 'error');
let reader = new FileReader();
- let input = {files: []};
+ let input = { files: [] };
component.refObj = true;
component.fileChange(input);
@@ -433,7 +433,7 @@ describe('GoldenConfigurationComponent', () => {
it('Should validate if refObj is undefined', () => {
let spy = spyOn(NotificationsService.prototype, 'error');
let reader = new FileReader();
- let input = {files: []};
+ let input = { files: [] };
component.refObj = undefined;
component.fileChange(input);
@@ -443,4 +443,14 @@ describe('GoldenConfigurationComponent', () => {
// End fileChange method
+ it('should give the correct template artifact name when multiple template identifiers are provided from reference page', inject([MappingEditorService], (mappingEditorService: MappingEditorService) => {
+ fixture = TestBed.createComponent(GoldenConfigurationComponent);
+ component = fixture.componentInstance;
+ mappingEditorService.identifier = "id1";
+ mappingEditorService.latestAction = { "action": "ConfigScaleOut", "action-level": "vnf", "scope": { "vnf-type": "test", "vnfc-type": "" }, "template": "Y", "vm": [], "device-protocol": "CHEF", "user-name": "", "port-number": "", "artifact-list": [{ "artifact-name": "template_ConfigScaleOut_test_0.0.1V_id1.json", "artifact-type": "config_template" }, { "artifact-name": "pd_ConfigScaleOut_test_0.0.1V_id1.yaml", "artifact-type": "parameter_definitions" }, { "artifact-name": "template_ConfigScaleOut_test_0.0.1V_id2.json", "artifact-type": "config_template" }, { "artifact-name": "pd_ConfigScaleOut_test_0.0.1V_id2.yaml", "artifact-type": "parameter_definitions" }], "template-id-list": ["id1", "id2"], "scopeType": "vnf-type" };
+ component.ngAfterViewInit();
+ expect(component.artifactName).toBe("template_ConfigScaleOut_test_0.0.1V_id1.json");
+ }));
+
+
});
diff --git a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
index 750b979..3868485 100644
--- a/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
+++ b/src/app/vnfs/build-artifacts/template-holder/template-configuration/template-configuration.component.ts
@@ -129,9 +129,9 @@ export class GoldenConfigurationComponent implements OnInit {
enableValidateTemplate: boolean = false;;
public selectedUploadType: string = this.uploadTypes[0].value;
identifier: any;
- public tempRetrievalResponse:any;
- public mergeStatus:boolean=false;
-
+ public tempRetrievalResponse: any;
+ public mergeStatus: boolean = false;
+
//======================================Start of ngOnInit() Method============================================
ngOnInit() {
var refObj = this.refObj = this.prepareFileName();
@@ -186,7 +186,19 @@ export class GoldenConfigurationComponent implements OnInit {
for (let i = 0; i < this.refNameObj['artifact-list'].length; i++) {
let artifactList = this.refNameObj['artifact-list'];
if (artifactList[i]['artifact-type'] === 'config_template') {
- this.artifactName = artifactList[i]['artifact-name'];
+ var artifactName = artifactList[i]['artifact-name'];
+ var artifactNameWithoutExtension = '';
+ if (artifactName) artifactNameWithoutExtension = artifactName.substring(0, artifactName.lastIndexOf("."))
+ var identifier = artifactNameWithoutExtension.split("_");
+ var id = '';
+ if (identifier) id = identifier[identifier.length - 1];
+ if (this.mappingEditorService.identifier) {
+ if (id === this.mappingEditorService.identifier) this.artifactName = artifactName;
+ }
+ else {
+ this.artifactName = artifactName;
+ }
+
}
}
}
@@ -255,7 +267,7 @@ export class GoldenConfigurationComponent implements OnInit {
if (this.fileType === '') {
sessionStorage.setItem('fileType', '');
}
- }
+ }
}
//========================== End of saveTemplate() Method============================================
retrieveTemplateFromAppc() {
@@ -281,7 +293,7 @@ export class GoldenConfigurationComponent implements OnInit {
}).subscribe(resp => {
if (resp.output.status.code === '400' && resp.output.status.message === "success") {
this.nService.success("Success", "Template retrieved successfully from APPC");
- this.tempRetrievalResponse=resp;
+ this.tempRetrievalResponse = resp;
let result = JSON.parse(resp.output.data.block).artifactInfo[0];
result = result['artifact-content'];
if ('Generated Template' === this.selectedUploadType) {
@@ -303,7 +315,7 @@ export class GoldenConfigurationComponent implements OnInit {
}
this.ngProgress.done();
},
- error => this.nService.error("Error", "Error in connecting to APPC Server"));
+ error => this.nService.error("Error", "Error in connecting to APPC Server"));
setTimeout(() => {
this.ngProgress.done();
}, 3500);
@@ -324,7 +336,11 @@ export class GoldenConfigurationComponent implements OnInit {
this.showTemplateVersionDiv = true;
let action = this.item.action;
var scopeName = this.scopeName.replace(/ /g, '').replace(new RegExp('/', "g"), '_').replace(/ /g, '');
- let fileName = this.updateParamFileName(refObj.action, scopeName, this.templateVersionNo);
+ var fileName = '';
+ let id = this.mappingEditorService.identifier;
+ if (id) fileName = this.updateFileNameForConfigScaleOut(this.item.action, scopeName, this.templateVersionNo, id);
+ else fileName = this.updateParamFileName(this.item.action, scopeName, this.templateVersionNo);
+
let vnfType = this.vnfType;
let Json = [paramsKeyValueFromEditor];
let slashedPayload = this.appendSlashes(JSON.stringify(Json));
@@ -349,7 +365,7 @@ export class GoldenConfigurationComponent implements OnInit {
}
}
}
- this.appDataObject.template.nameValueData = data;
+ this.appDataObject.template.nameValueData = data;
}
if (this.configMappingEditorContent) {
let actualContent = this.configMappingEditorContent;
@@ -412,7 +428,7 @@ export class GoldenConfigurationComponent implements OnInit {
let refObj = this.refObj;
if (refObj) {
let paramsKeyValueFromEditor: JSON;
- try {
+ try {
paramsKeyValueFromEditor = JSON.parse(localStorage["paramsContent"]);
}
catch (error) {
@@ -425,7 +441,10 @@ export class GoldenConfigurationComponent implements OnInit {
this.showTemplateVersionDiv = true;
let fileName: any;
var scopeName = this.scopeName.replace(/ /g, '').replace(new RegExp('/', "g"), '_').replace(/ /g, '');
- fileName = this.updateParamFileName(refObj.action, scopeName, this.templateVersionNo);
+ let id = this.mappingEditorService.identifier;
+ if (id) fileName = this.updateFileNameForConfigScaleOut(this.item.action, scopeName, this.templateVersionNo, id);
+ else fileName = this.updateParamFileName(this.item.action, scopeName, this.templateVersionNo);
+
this.downloadDataObject.template.nameValueData = theJSON;
this.downloadDataObject.template.nameValueFileName = fileName;
}
@@ -441,13 +460,19 @@ export class GoldenConfigurationComponent implements OnInit {
return fileName;
}
//========================== End of updateParamFileName() Method============================================
+ updateFileNameForConfigScaleOut(action: any, scopeName: any, versionNo: any, id: any) {
+ let fileName = 'param_' + action + '_' + scopeName + '_' + versionNo + 'V_' + id + '.json';
+ this.downloadedParamFileName = fileName;
+ return fileName;
+ }
+ //========================== End of updateFileNameForConfigScaleOut() Method============================================
public onDownloadTemplate(artifact: string) {
let actualContent = this.configMappingEditorContent;
var textToSaveAsBlob: any;
var config_template_fileName: any
let refObj = this.refObj;
let versionandFileType: string;
- if (artifact == 'Template' && this.artifactRequest && this.configMappingEditorContent && refObj) {
+ if (artifact == 'Template' && this.artifactRequest && this.configMappingEditorContent && refObj) {
this.showTemplateVersionDiv = true;
if (this.fileType === "text/xml") {
textToSaveAsBlob = new Blob([this.configMappingEditorContent], {
@@ -523,7 +548,7 @@ export class GoldenConfigurationComponent implements OnInit {
this.saveTemplate();
});
- }
+ }
else {
this.nService.error("Error", "Failed to read file");
}
@@ -582,11 +607,11 @@ export class GoldenConfigurationComponent implements OnInit {
var templateData = this.mappingEditorService.paramData; //template data array
var pdData = this.paramShareService.getSessionParamData(); //PD data array
var paramsContent = localStorage["paramsContent"];
-
+
if (paramsContent && paramsContent != undefined) {
try {
var paramTabData = JSON.parse(paramsContent);
- }
+ }
catch (error) {
console.log("error is : " + error)
}
@@ -693,7 +718,7 @@ export class GoldenConfigurationComponent implements OnInit {
"ruleTypeValues": arr2item.ruleTypeValues
};
resultArr.splice(i, 1, json)
- }
+ }
});
@@ -723,7 +748,7 @@ export class GoldenConfigurationComponent implements OnInit {
public handleAnnotation(modal) {
this.selectedWord = this.templateeditor.getEditor().session.getTextRange(this.templateeditor.getEditor().selectionRange);
- if(this.selectedWord && this.selectedWord!=undefined) modal.open();
+ if (this.selectedWord && this.selectedWord != undefined) modal.open();
}
//========================== End of handleAnnotations() Method============================================
public submitNameValues() {
@@ -732,14 +757,14 @@ export class GoldenConfigurationComponent implements OnInit {
if (this.selectedWord) {
if (this.selectedWord.startsWith('${(')) {
- var replaceWord: any =this.replaceWord = this.selectedWord.substring(3, this.selectedWord.indexOf(')=(')) + this.tempName;
+ var replaceWord: any = this.replaceWord = this.selectedWord.substring(3, this.selectedWord.indexOf(')=(')) + this.tempName;
this.templateeditor.getEditor().session.replace(this.templateeditor.getEditor().session.selection.getRange(), replaceWord);
-
+
} else {
let mappingKey = this.mappingEditorService.getKeysForValues(this.selectedWord);
- var replaceWord: any = this.replaceWord='${(' + this.selectedWord + ')=(' + this.tempName + ')}';
+ var replaceWord: any = this.replaceWord = '${(' + this.selectedWord + ')=(' + this.tempName + ')}';
this.templateeditor.getEditor().session.replace(this.templateeditor.getEditor().session.selection.getRange(), replaceWord);
-
+
}
}
this.mappingEditorService.refreshEditor();