Adding changes to Controller catalog 22/100122/3
authorswapnalipode <sp00501638@techmahindra.com>
Thu, 9 Jan 2020 11:49:45 +0000 (17:19 +0530)
committerKAPIL SINGAL <ks220y@att.com>
Mon, 13 Jan 2020 18:16:46 +0000 (18:16 +0000)
Adding new changes for integration in controller catalog

Change-Id: I5a014ff35d01213545d09db79886c6c4fd9f827d
Issue-ID: CCSDK-810
Signed-off-by: swapnalipode <sp00501638@techmahindra.com>
cds-ui/client/src/app/common/constants/app-constants.ts
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.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 5beb6af..1b4720c 100644 (file)
@@ -115,8 +115,9 @@ export const ResourceDictionaryURLs = {
 }
 
 export const ControllerCatalogURLs = {
-                searchControllerCatalogByTags: '/controllercatalog/search',
-                saveControllerCatalog: '/controllercatalog/save',
-                getDefinition: '/controllercatalog/model-type/by-definition',
-                getDerivedFrom: '/controllercatalog/model-type/by-derivedfrom'
+       searchControllerCatalogByTags: '/controllercatalog/search',
+       saveControllerCatalog: '/controllercatalog/save',
+       getDefinition: '/controllercatalog/model-type/by-definition',
+       getDerivedFrom: '/controllercatalog/model-type/by-derivedfrom',
+       deleteCatalog: '/controllercatalog/model-type'
 }
\ No newline at end of file
index 3b8294d..ad74a9f 100644 (file)
@@ -97,20 +97,23 @@ export class CreateCatalogComponent implements OnInit {
            this.catalog.derivedFrom=this.CatalogFormData.controls['derivedFrom'].value
            this.catalog.description=this.CatalogFormData.controls['description'].value
            this.catalog.definition=this.data;
+           this.catalog.version="";
+           this.catalog.creationDate="";
            console.log(this.catalog);
-    let catalogState = {
-      catalog: this.catalog
-    }
-    this.store.dispatch(new SetCatalogState(catalogState));
-    
-      this.catalogCreateService.saveCatalog(this.catalog)
-      .subscribe(response=>{
-        this.alertService.success("save success")
-      },
-      error=>{
-        this.alertService.error('Error saving resources');
-      })
+           let catalogState = {
+               catalog: this.catalog
+           }
+           this.store.dispatch(new SetCatalogState(catalogState));
+
+           this.catalogCreateService.saveCatalog(this.catalog)
+               .subscribe(response=>{
+                  this.alertService.success("save success")
+                },
+                error=>{
+                  console.log(error);
+                  this.alertService.error('Error saving resources');
+                 })
+
   }
 
   onChange($event) {
index b2748d8..6f9e653 100644 (file)
@@ -40,8 +40,6 @@ export class CatalogDataDialogComponent implements OnInit{
   ccState: Observable<ICatalogState>;
   isDisabled: boolean=true;
   optionSelected:string;
-  // 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'}];
   property:any=[];
   constructor(public dialogRef: MatDialogRef<CatalogDataDialogComponent>, @Inject(MAT_DIALOG_DATA) public item: any,private formBuilder: FormBuilder, private store: Store<IAppState> ) {
     console.log(item);
@@ -79,7 +77,6 @@ export class CatalogDataDialogComponent implements OnInit{
   }
 
   onClickSave(){
-    //this.catalog = Object.assign({}, this.CatalogFormData.value);
     this.dialogRef.close(this.CatalogFormData.value);
   }
 }
index 5262f17..ed963a6 100644 (file)
@@ -20,7 +20,7 @@
 <form class="search-form" [formGroup]="myControl">
   <mat-form-field class="search-full-width">
       <input matInput type="text" placeholder="Search Catalog" formControlName="search_input" #searchText>
-      <button matSuffix mat-icon-button (click)="fetchCatalogByName()">
+      <button matSuffix mat-icon-button (click)="fetchCatalogByName(searchText.value)">
     <mat-icon>search</mat-icon>
   </button>
   </mat-form-field>
@@ -36,6 +36,7 @@
               <mat-card-actions class="flexBox">
                   <button class="matStepNextBtn" matStepperNext mat-menu-item (click)="editInfo(option,'Info')">Info</button>
                   <button class="matStepNextBtn" matStepperNext mat-menu-item (click)="editInfo(option,'Edit')">Edit</button>
+                  <button class="matStepNextBtn" matStepperNext mat-menu-item (click)="editInfo(option,'Delete')">Delete</button>
               </mat-card-actions>
           </mat-card>
       </div>
index 3fb4530..efafe5e 100644 (file)
@@ -32,6 +32,7 @@ import { CreateCatalogService } from '../create-catalog/create-catalog.service';
 import { NotificationHandlerService } from 'src/app/common/core/services/notification-handler.service';
 import { ICatalogState } from 'src/app/common/core/store/models/catalogState.model';
 import { IAppState } from 'src/app/common/core/store/state/app.state';
+import { SetCatalogState } from 'src/app/common/core/store/actions/catalog.action';
 
 
 @Component({
@@ -67,63 +68,89 @@ export class SearchCatalogComponent implements OnInit {
       search_input: ['', Validators.required]
     });
   }
-  fetchCatalogByName() {
-    // this.searchCatalogService.searchByTags(this.searchText)
-    // .subscribe(data=>{
-    //     console.log(data);
-    //     data.forEach(element => {
-    //       this.options.push(element)
-    //     });          
-    //   this.catalogSelect.openPanel();
-    // }, error=>{
-    //   window.alert('Catalog not matching the search tag' + error);
-    // })
+   fetchCatalogByName(search_input) {
+      console.log(search_input);
+      this.options=[];
+      this.searchCatalogService.searchByTags(search_input)
+      .subscribe(data=>{
+        console.log(data);
+        data.forEach(element => {
+          this.options.push(element);
+        });
+        console.log(this.options);
+      //this.catalogSelect.openPanel();
+    }, error=>{
+      window.alert('Catalog not matching the search tag' + error);
+    })
 
-    this.options=[  {
-      "modelName": "tosca.nodes.Artifact",
-      "derivedFrom": "tosca.nodes.Root",
-      "definitionType": "node_type",
-      "definition": {
-        "description": "This is Deprecated Artifact Node Type.",
-        "version": "1.0.0",
-        "derived_from": "tosca.nodes.Root"
-      },
-      "description": "This is Deprecated Artifact Node Type.",
-      "version": "1.0.0",
-      "tags": "tosca.nodes.Artifact,tosca.nodes.Root,node_type",
-      "creationDate": "2019-09-16T07:35:24.000Z",
-      "updatedBy": "System"
-    }];
+//     this.options=[  {
+//       "modelName": "tosca.nodes.Artifact",
+//       "derivedFrom": "tosca.nodes.Root",
+//       "definitionType": "node_type",
+//       "definition": {
+//         "description": "This is Deprecated Artifact Node Type.",
+//         "version": "1.0.0",
+//         "derived_from": "tosca.nodes.Root"
+//       },
+//       "description": "This is Deprecated Artifact Node Type.",
+//       "version": "1.0.0",
+//       "tags": "tosca.nodes.Artifact,tosca.nodes.Root,node_type",
+//       "creationDate": "2019-09-16T07:35:24.000Z",
+//       "updatedBy": "System"
+//     }];
    }
 
    editInfo(item: ICatalog, option: string) {
 
-      this.dialogRef = this.dialog.open(CatalogDataDialogComponent, {
-        height: '500px',
-        width: '700px',
-        disableClose: true,
-        data: {item, option}
-      });
+          if(option == 'Delete'){
+//           this.catalogCreateService.deleteCatalog(item.modelName)
+//           .subscribe(response=>{
+//              this.alertService.success("Delete Success"+ response)
+//             },
+//                 error=>{
+//                 console.log(error);
+//                    this.alertService.error('Error while deleting catalog'+ error);
+//
+//                  })
+       }
+       else{
+       this.dialogRef = this.dialog.open(CatalogDataDialogComponent, {
+            height: '500px',
+            width: '700px',
+            disableClose: true,
+            data: {item, option}
+        });
 
-      this.dialogRef.afterClosed().subscribe(result => {
-        if(result == undefined || result == null){
-          console.log("dialogbox is closed");
-        }else{
-               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');
-                 })  
-        } 
-      });
+        this.dialogRef.afterClosed().subscribe(result => {
+           if(result == undefined || result == null){
+              console.log("dialogbox is closed");
+           }else{
+                   this.catalog.modelName=result['modelName'];
+                   this.catalog.derivedFrom=result['derivedFrom'];
+                   this.catalog.definitionType=result['definitionType'];
+                   this.catalog.definition=JSON.parse(result['definition']);
+                   this.catalog.tags=result['tags'];
+                   this.catalog.updatedBy=result['updatedBy'];
+                   this.catalog.description= "";
+                   this.catalog.version= "";
+                   this.catalog.creationDate="";
+                   console.log(this.catalog);
+                   let catalogState = {
+                       catalog: this.catalog,
+                       isLoadSuccess: true,
+                       isUpdateSuccess:true,
+                       isSaveSuccess:true
+                   }
+                   this.store.dispatch(new SetCatalogState(catalogState));
+                   this.catalogCreateService.saveCatalog(this.catalog)
+                   .subscribe(response=>{
+                     this.alertService.success("save success"+ response)
+                   },
+                         error=>{
+                         this.alertService.error('Error saving resources');
+                        })
+             }
+          });
+       }
   }
 }