diff options
author | 2020-01-09 17:19:45 +0530 | |
---|---|---|
committer | 2020-01-13 18:16:46 +0000 | |
commit | 6787d78d2678772551b5e6c902b1e3fb5b5cb17d (patch) | |
tree | 5497971446220f5b2a0500c13dbec755db6162d6 /cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog | |
parent | e9b1dfd73a2298cc9679e527ae90a651f5025dd2 (diff) |
Adding changes to Controller catalog
Adding new changes for integration in controller catalog
Change-Id: I5a014ff35d01213545d09db79886c6c4fd9f827d
Issue-ID: CCSDK-810
Signed-off-by: swapnalipode <sp00501638@techmahindra.com>
Diffstat (limited to 'cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog')
3 files changed, 81 insertions, 56 deletions
diff --git a/cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/catalog-data-dialog/catalog-data-dialog.component.ts b/cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/catalog-data-dialog/catalog-data-dialog.component.ts index b2748d871..6f9e6534b 100644 --- a/cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/catalog-data-dialog/catalog-data-dialog.component.ts +++ b/cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/catalog-data-dialog/catalog-data-dialog.component.ts @@ -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); } } diff --git a/cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/search-catalog.component.html b/cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/search-catalog.component.html index 5262f1744..ed963a682 100644 --- a/cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/search-catalog.component.html +++ b/cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/search-catalog.component.html @@ -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> diff --git a/cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/search-catalog.component.ts b/cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/search-catalog.component.ts index 3fb4530e6..efafe5e8f 100644 --- a/cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/search-catalog.component.ts +++ b/cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/search-catalog.component.ts @@ -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'); + }) + } + }); + } } } |