aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/vnfs/build-artifacts/template-holder/template-configuration
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/vnfs/build-artifacts/template-holder/template-configuration')
-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
3 files changed, 73 insertions, 37 deletions
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();