Merge "Adding changes for catalog edit and create"
authorBrinda Santh Muthuramalingam <brindasanth@in.ibm.com>
Tue, 26 Nov 2019 16:15:10 +0000 (16:15 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 26 Nov 2019 16:15:10 +0000 (16:15 +0000)
cds-ui/client/src/app/common/core/store/models/catalog.model.ts
cds-ui/client/src/app/feature-modules/controller-catalog/create-catalog/create-catalog.component.html
cds-ui/client/src/app/feature-modules/controller-catalog/create-catalog/create-catalog.component.ts
cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/catalog-data-dialog/catalog-data-dialog.component.html
cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/catalog-data-dialog/catalog-data-dialog.component.ts
cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/search-catalog.component.html
cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/search-catalog.component.ts

index 2344f33..6a86185 100644 (file)
 */\r
 \r
 export interface ICatalog { \r
-      Model_Name: string;\r
-      User_id: string;\r
-      _tags: string;\r
-      _type: string;\r
-      Derived_From: string;\r
-      _description : string;\r
-      definition: object[];\r
+      modelName: string;\r
+      derivedFrom: string;\r
+      definitionType : string;\r
+      definition: object;\r
+      description: string;\r
+      version: String;\r
+      tags: String;\r
+      creationDate: String;\r
+      updatedBy: String;     \r
 }
\ No newline at end of file
index 8c71edf..ba32a2e 100644 (file)
   <mat-card-content>
 <form [formGroup]="CatalogFormData" (ngSubmit)="CreateCatalog()">
   <mat-form-field class="form-field">
-   <input matInput placeholder="Model Name" formControlName="Model_Name">
+   <input matInput placeholder="Model Name" formControlName="modelName">
  </mat-form-field>
  <mat-form-field class="form-field" >
-  <input matInput placeholder="User Id" formControlName="User_id">
+  <input matInput placeholder="User Id" formControlName="updatedBy">
 </mat-form-field>
  <mat-form-field class="form-field">
-   <input matInput placeholder="Tags" formControlName="_tags">
+   <input matInput placeholder="Tags" formControlName="tags">
  </mat-form-field>
  <mat-form-field class="form-field">
-   <mat-select matInput placeholder="Definition Type" formControlName="_type">
-     <mat-option [value]="item" *ngFor="let item of definitionType">{{item.definitionType}}</mat-option>
+   <mat-select matInput placeholder="Definition Type" formControlName="definitionType">
+     <mat-option [value]="item" *ngFor="let item of definitionType">{{item}}</mat-option>
    </mat-select>
  </mat-form-field>
  <mat-form-field class="form-field" >
-   <mat-select matInput placeholder="Derived From" formControlName="Derived_From">
-    <mat-option [value]="item" *ngFor="let item of derivedFrom">{{item.derivedFrom}}</mat-option>
+   <mat-select matInput placeholder="Derived From" formControlName="derivedFrom">
+    <mat-option [value]="item" *ngFor="let item of derivedFrom">{{item}}</mat-option>
    </mat-select>
  </mat-form-field>
  <mat-form-field class="form-field" >
-   <textarea matInput placeholder="Description" formControlName="_description"></textarea>
+   <textarea matInput placeholder="Description" formControlName="description"></textarea>
  </mat-form-field>
   <br>
   <div >
index 91c6f28..3b8294d 100644 (file)
@@ -41,21 +41,21 @@ export class CreateCatalogComponent implements OnInit {
   @ViewChild(JsonEditorComponent) editor: JsonEditorComponent;
   options = new JsonEditorOptions();
   data:any;
-  derivedFrom: any[] = [{derivedFrom: 'tosca.nodes.Component'},{derivedFrom:'tosca.nodes.VNF'},{derivedFrom:'tosca.nodes.Artifact'},{derivedFrom:'tosca.nodes.ResourceSource'}, {derivedFrom:'tosca.nodes.Workflow'},{derivedFrom:'tosca.nodes.Root'}];
-  definitionType: any[] = [{definitionType: 'node_type'}];
+  derivedFrom: any[] = ['tosca.nodes.Component','tosca.nodes.VNF','tosca.nodes.Artifact','tosca.nodes.ResourceSource','tosca.nodes.Workflow','tosca.nodes.Root'];
+  definitionType: any[] = ['node_type'];
   ccState: Observable<ICatalogState>;
   catalog: ICatalog;
 
   constructor(private formBuilder: FormBuilder, private store: Store<IAppState>, private catalogCreateService: CreateCatalogService, private alertService: NotificationHandlerService) { 
     this.ccState = this.store.select('catalog');
     this.CatalogFormData = this.formBuilder.group({
-      Model_Name: ['', Validators.required],
-      User_id: ['', Validators.required],
-      _tags: ['', Validators.required],
-      _type: ['', Validators.required],
-      Derived_From: ['', Validators.required],
-      _description : ['', Validators.required]
-    });   
+        modelName: ['', Validators.required],
+        updatedBy: ['', Validators.required],
+        tags: ['', Validators.required],
+        definitionType: ['', Validators.required],
+        derivedFrom: ['', Validators.required],
+        description : ['', Validators.required]
+      });    
   }
   ngOnInit() {
     this.options.mode = 'text';
@@ -90,8 +90,14 @@ export class CreateCatalogComponent implements OnInit {
 //    })
   }
   CreateCatalog(){
-    this.catalog = Object.assign({}, this.CatalogFormData.value);
-    this.catalog.definition=this.data;
+         this.catalog.modelName=this.CatalogFormData.controls['modelName'].value;
+           this.catalog.updatedBy=this.CatalogFormData.controls['updatedBy'].value
+           this.catalog.tags=this.CatalogFormData.controls['tags'].value
+           this.catalog.definitionType=this.CatalogFormData.controls['definitionType'].value
+           this.catalog.derivedFrom=this.CatalogFormData.controls['derivedFrom'].value
+           this.catalog.description=this.CatalogFormData.controls['description'].value
+           this.catalog.definition=this.data;
+           console.log(this.catalog);
     let catalogState = {
       catalog: this.catalog
     }
index ca4a679..34502bc 100644 (file)
 <div>
   <h1 mat-dialog-title>Details</h1>
   <mat-dialog-content [formGroup]="CatalogFormData">
-  <mat-form-field class="form-field">
-   <input matInput placeholder="Model Name" formControlName="Model_Name">
-  </mat-form-field>
-  <mat-form-field class="form-field" >
-       <input matInput placeholder="User Id" formControlName="User_id">
-  </mat-form-field>
-  <mat-form-field class="form-field">
-   <input matInput placeholder="Tags" formControlName="_tags">
-  </mat-form-field>
-  <mat-form-field class="form-field">
+   <mat-form-field class="form-field">
+    <input matInput placeholder="Model Name" formControlName="modelName">
+   </mat-form-field>
+   <mat-form-field class="form-field" >
+    <input matInput placeholder="User Id" formControlName="updatedBy">
+   </mat-form-field>
+   <mat-form-field class="form-field">
+    <input matInput placeholder="Tags" formControlName="tags">
+   </mat-form-field>
+   <mat-form-field class="form-field">
    <!-- <mat-select matInput placeholder="Definition Type" formControlName="_type">
      <mat-option [value]="item" *ngFor="let item of definitionType">{{item.definitionType}}</mat-option>
    </mat-select> -->
-   <input matInput placeholder="Definition Type" formControlName="_type">
-  </mat-form-field>
-  <mat-form-field class="form-field" >
+   <input matInput placeholder="Definition Type" formControlName="definitionType">
+   </mat-form-field>
+   <mat-form-field class="form-field" >
    <!-- <mat-select matInput placeholder="Derived From" formControlName="Derived_From">
     <mat-option [value]="item" *ngFor="let item of derivedFrom">{{item.derivedFrom}}</mat-option>
    </mat-select> -->
-   <input matInput placeholder="Derived From" formControlName="Derived_From">
-  </mat-form-field>
+    <input matInput placeholder="Derived From" formControlName="derivedFrom">
+   </mat-form-field>
+   <mat-form-field class="form-field" >
+    <textarea matInput placeholder="Definition" formControlName="definition"></textarea>
+   </mat-form-field>
   <br>
   </mat-dialog-content>
   <mat-dialog-actions *ngIf="!isDisabled">
index 215f311..b2748d8 100644 (file)
@@ -62,12 +62,13 @@ export class CatalogDataDialogComponent implements OnInit{
 
     this.ccState = this.store.select('catalog');
     this.CatalogFormData = this.formBuilder.group({
-      Model_Name: [{value:this.property[0], disabled: this.isDisabled}, Validators.required],
-      User_id: [{value:this.property[8], disabled: this.isDisabled}, Validators.required],
-      _tags: [{value:this.property[6], disabled: this.isDisabled}, Validators.required],
-      _type: [{value:this.property[2], disabled: this.isDisabled}, Validators.required],
-      Derived_From: [{value:this.property[1], disabled: this.isDisabled}, Validators.required],
-    });   
+        modelName: [{value:this.property[0], disabled: this.isDisabled}, Validators.required],
+        derivedFrom: [{value:this.property[1], disabled: this.isDisabled}, Validators.required],
+        definitionType: [{value:this.property[2], disabled: this.isDisabled}, Validators.required],
+        definition: [{value:JSON.stringify(this.property[3]), disabled: this.isDisabled}, Validators.required],
+        tags: [{value:this.property[6], disabled: this.isDisabled}, Validators.required],
+        updatedBy: [{value:this.property[8], disabled: this.isDisabled}, Validators.required],    
+      });  
   }
   
   ngOnInit(){
index c8452e2..5262f17 100644 (file)
@@ -19,7 +19,7 @@
 */--> 
 <form class="search-form" [formGroup]="myControl">
   <mat-form-field class="search-full-width">
-      <input matInput type="text" [(ngModel)]="searchText" placeholder="Search Catalog" formControlName="search_input">
+      <input matInput type="text" placeholder="Search Catalog" formControlName="search_input" #searchText>
       <button matSuffix mat-icon-button (click)="fetchCatalogByName()">
     <mat-icon>search</mat-icon>
   </button>
index 717e108..3fb4530 100644 (file)
@@ -109,19 +109,20 @@ export class SearchCatalogComponent implements OnInit {
         if(result == undefined || result == null){
           console.log("dialogbox is closed");
         }else{
-          this.catalog.Model_Name=result['Model_Name'];
-          this.catalog.User_id=result['User_id'];
-          this.catalog._tags=result['_tags'];
-          this.catalog._type=result['_type'];
-          this.catalog.Derived_From=result['Derived_From'];
-          console.log(this.catalog);
-          this.catalogCreateService.saveCatalog(this.catalog)
-          .subscribe(response=>{
+               this.catalog.modelName=result['modelName'];
+            this.catalog.derivedFrom=result['derivedFrom'];
+            this.catalog.definitionType=result['definitionType'];
+            this.catalog.definition=result['definition'];
+            this.catalog.tags=result['tags'];
+            this.catalog.updatedBy=result['updatedBy'];
+            console.log(this.catalog);
+            this.catalogCreateService.saveCatalog(this.catalog)
+            .subscribe(response=>{
               this.alertService.success("save success"+ response)
-          },
-          error=>{
-          this.alertService.error('Error saving resources');
-          })  
+            },
+                 error=>{
+                 this.alertService.error('Error saving resources');
+                 })  
         } 
       });
   }