Merge "Fixed defect CCSDK-1610"
authorBrinda Santh Muthuramalingam <brindasanth@in.ibm.com>
Thu, 29 Aug 2019 14:29:03 +0000 (14:29 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 29 Aug 2019 14:29:03 +0000 (14:29 +0000)
1  2 
cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts

@@@ -48,8 -48,7 +48,8 @@@ export class MetadataComponent implemen
    blueprintName: string;
    uploadedFileName: string;
    entryDefinition: string;
 -  
 +  viewOnly: boolean = true;
 +  options: string;
    constructor(private formBuilder: FormBuilder, private store: Store<IAppState>,
      private loader: LoaderService, private dataService: SelectTemplateService) {
      this.bpState = this.store.select('blueprint');
    ngOnInit() {
      this.dataService.currentMessage.subscribe(
        res => {
 -        let options = res;
 -        console.log(options + " data from service ngoninit" + res);
 +        this.options = res;
 +        // this.metdataFormfields(res);
        }
      );
 -    
      this.bpState.subscribe(
        blueprintdata => {
          var blueprintState: IBlueprintState = { blueprint: blueprintdata.blueprint, isLoadSuccess: blueprintdata.isLoadSuccess, isSaveSuccess: blueprintdata.isSaveSuccess, isUpdateSuccess: blueprintdata.isUpdateSuccess };
          }
          let temp_author = metadatavalues[0];
          console.log(temp_author);
 +        if(this.options=='2'){
 +          this.CBAMetadataForm = this.formBuilder.group({
 +            template_author: ['', Validators.required],
 +            author_email: ['', Validators.required],
 +            user_groups: [metadatavalues[2], Validators.required],
 +            template_name: ['', Validators.required],
 +            template_version: ['', Validators.required],
 +            template_tags: [metadatavalues[5], Validators.required]
 +          });
 +        } 
 +        else if(this.options=='3'){
 +          this.CBAMetadataForm = this.formBuilder.group({
 +            template_author: [metadatavalues[0]],
 +            author_email: [metadatavalues[1]],
 +            user_groups: [metadatavalues[2]],
 +            template_name: [metadatavalues[3]],
 +            template_version: [metadatavalues[4]],
 +            template_tags: [metadatavalues[5]]
 +          });
 +          this.CBAMetadataForm.disable();
 +        }
 +          else{
          this.CBAMetadataForm = this.formBuilder.group({
            template_author: [metadatavalues[0], Validators.required],
            author_email: [metadatavalues[1], Validators.required],
            template_version: [metadatavalues[4], Validators.required],
            template_tags: [metadatavalues[5], Validators.required]
          });
 +      }
 +      
        })
 +
 +
    }
 -  
 +
 +  metdataFormfields(options: string) {
 +    if (options == '2') {
 +      this.CBAMetadataForm.setValue({
 +        template_author: ["", Validators.required],
 +        author_email: ["", Validators.required],
 +        template_name: ["", Validators.required],
 +        template_version: ["1.0.0", Validators.required]
 +
 +      })
 +    }
 +    if (options == '3') {
 +      this.CBAMetadataForm.disable();
 +    }
 +  }
 +
    UploadMetadata() {
      this.loader.showLoader();
      this.metadata = Object.assign({}, this.CBAMetadataForm.value);
      this.blueprint.metadata = this.metadata;
-     /*if (this.blueprint &&
-       this.blueprint['topology_template'] &&
-       this.blueprint['topology_template'].workflows &&
-       this.blueprint['topology_template'].workflows['resource-assignment'] &&
-       this.blueprint['topology_template'].workflows['resource-assignment'].name) {
-       delete this.blueprint['topology_template'].workflows['resource-assignment'].name;
-     }*/
      this.filesData.forEach((fileNode) => {
        if (fileNode.name.includes(this.blueprintName) && fileNode.name == this.entryDefinition) {
-         fileNode.data = JSON.stringify(this.blueprint, null, "\t");
+         let tempNodeData = JSON.parse(fileNode.data);
+         tempNodeData.metadata = this.blueprint.metadata;
+         fileNode.data = JSON.stringify(tempNodeData, null, "\t");
        }
      });
      let blueprintState = {