Adding delete catalog 23/105523/1
authorswapnalipode <sp00501638@techmahindra.com>
Mon, 2 Mar 2020 07:27:20 +0000 (12:57 +0530)
committerDan Timoney <dtimoney@att.com>
Wed, 8 Apr 2020 15:43:01 +0000 (15:43 +0000)
 Adding delete catalog functionality in client ui

Change-Id: I56bcba1c09d949b80155b3ac9368203e85eb4f99
Issue-ID: CCSDK-815
Signed-off-by: swapnalipode <sp00501638@techmahindra.com>
(cherry picked from commit 7cc92c22ac6172d6b51425d8628e431350593bca)

cds-ui/client/src/app/common/constants/app-constants.ts
cds-ui/client/src/app/common/core/services/api.service.ts
cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/search-catalog.component.ts
cds-ui/client/src/app/feature-modules/controller-catalog/search-catalog/search-catalog.service.ts
cds-ui/server/src/controllers/controller-catalog.controller.ts
cds-ui/server/src/datasources/controller-catalog.datasource-template.ts
cds-ui/server/src/services/controller-catalog.service.ts

index 1b4720c..30b4ece 100644 (file)
@@ -119,5 +119,5 @@ export const ControllerCatalogURLs = {
        saveControllerCatalog: '/controllercatalog/save',
        getDefinition: '/controllercatalog/model-type/by-definition',
        getDerivedFrom: '/controllercatalog/model-type/by-derivedfrom',
-       deleteCatalog: '/controllercatalog/model-type'
+       deleteCatalog:'/controllercatalog'
 }
\ No newline at end of file
index addf51c..af93787 100644 (file)
@@ -30,20 +30,21 @@ export class ApiService {
   
   constructor(private _http: HttpClient) {
   }
+
   get(url: string, params?: any): Observable<any> {
     return this._http.get(url,params);
   }
 
   post(url: string, body: any | null, options?:any): Observable<any> {
-
     return this._http.post(url, body,options);
   }
+  
   put() {
     // to do
   }
 
-  delete() {
-    // to do
+  delete(url: string, params?: any): Observable<any> {
+    return this._http.delete(url,params);
   }
 
 }
\ No newline at end of file
index efafe5e..7c37959 100644 (file)
@@ -82,37 +82,20 @@ export class SearchCatalogComponent implements OnInit {
     }, 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"
-//     }];
    }
 
    editInfo(item: ICatalog, option: string) {
 
-          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);
-//
-//                  })
-       }
+    if(option == 'Delete'){
+      this.searchCatalogService.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',
index 4789605..362eab0 100644 (file)
@@ -33,4 +33,8 @@ export class SearchCatalogService {
   searchByTags(tag) {
     return this.api.get(ControllerCatalogURLs.searchControllerCatalogByTags + '/' + tag);
   }
+
+  deleteCatalog(modelName) {
+    return this.api.delete(ControllerCatalogURLs.deleteCatalog + '/' + modelName);
+  }
 }
index 20e1cde..b55785d 100644 (file)
@@ -60,14 +60,14 @@ export class ControllerCatalogController {
     return await this.Ccservice.getDefinitionTypes(definitionType);
   }
 
-  @del('/controllercatalog/model-type/{name}', {
-      responses: {
-        '200': {
-          content: { 'application/json': {} }
-        }
-      },
-    })
-    async delete(@param.path.string('name') name: string): Promise<JSON>  {
-      return await this.Ccservice.deleteCatalog(name);
-    }
+  @del('/controllercatalog/{name}', {
+    responses: {
+      '200': {
+        content: { 'application/json': {} }
+      }
+    },
+  })
+  async delete(@param.path.string('name') name: string) {
+    return await this.Ccservice.delete(name);
+  }
 }
index e457415..dcd732a 100644 (file)
@@ -57,20 +57,20 @@ export default {
 \r
            }\r
         },\r
-           {\r
-             "template": {\r
-                   "method": "DEL",\r
-                   "url": processorApiConfig.http.url + "/model-type/{name}",\r
-                   "headers": {\r
-                       "accepts": "application/json",\r
-                       "content-type": "application/json",\r
-                       "authorization": processorApiConfig.http.authToken\r
-                   },\r
-                   "responsePath": "$.*"\r
-             },\r
-             "functions": {\r
-                  "delete": ["name"]\r
-             }\r
-           }\r
+        {\r
+         "template": {\r
+                    "method": "DELETE",\r
+                    "url": processorApiConfig.http.url + "/model-type/{name}",\r
+                    "headers": {\r
+                        "accepts": "application/json",\r
+                        "content-type": "application/json",\r
+                        "authorization": processorApiConfig.http.authToken\r
+                    },\r
+                    "responsePath": "$.*"\r
+              },\r
+              "functions": {\r
+                   "delete": ["name"]\r
+              }\r
+        }\r
     ]\r
 };
\ No newline at end of file
index 9b48805..db8d856 100644 (file)
@@ -6,7 +6,7 @@ export interface ControllerCatalogService {
   getByTags(tags: string): Promise<JSON>;\r
   save(controllerCatalog: JSON): Promise<JSON>;\r
   getDefinitionTypes(definitionType: string): Promise<JSON>;\r
-  deleteCatalog(name: string): Promise<JSON>;\r
+  delete(name: string): Promise<JSON>;\r
 }\r
 \r
 export class ControllerCatalogServiceProvider implements Provider<ControllerCatalogService> {\r