From 6787d78d2678772551b5e6c902b1e3fb5b5cb17d Mon Sep 17 00:00:00 2001 From: swapnalipode Date: Thu, 9 Jan 2020 17:19:45 +0530 Subject: Adding changes to Controller catalog Adding new changes for integration in controller catalog Change-Id: I5a014ff35d01213545d09db79886c6c4fd9f827d Issue-ID: CCSDK-810 Signed-off-by: swapnalipode --- .../src/app/common/constants/app-constants.ts | 9 +- .../create-catalog/create-catalog.component.ts | 29 +++-- .../catalog-data-dialog.component.ts | 3 - .../search-catalog/search-catalog.component.html | 3 +- .../search-catalog/search-catalog.component.ts | 131 +++++++++++++-------- 5 files changed, 102 insertions(+), 73 deletions(-) (limited to 'cds-ui/client/src') diff --git a/cds-ui/client/src/app/common/constants/app-constants.ts b/cds-ui/client/src/app/common/constants/app-constants.ts index 5beb6af74..1b4720c4a 100644 --- a/cds-ui/client/src/app/common/constants/app-constants.ts +++ b/cds-ui/client/src/app/common/constants/app-constants.ts @@ -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 diff --git a/cds-ui/client/src/app/feature-modules/controller-catalog/create-catalog/create-catalog.component.ts b/cds-ui/client/src/app/feature-modules/controller-catalog/create-catalog/create-catalog.component.ts index 3b8294db9..ad74a9fc3 100644 --- a/cds-ui/client/src/app/feature-modules/controller-catalog/create-catalog/create-catalog.component.ts +++ b/cds-ui/client/src/app/feature-modules/controller-catalog/create-catalog/create-catalog.component.ts @@ -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) { 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; 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, @Inject(MAT_DIALOG_DATA) public item: any,private formBuilder: FormBuilder, private store: Store ) { 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 @@
- @@ -36,6 +36,7 @@ + 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'); + }) + } + }); + } } } -- cgit 1.2.3-korg