From 34862b8ae117126e055f3cb71b464e448d2c5827 Mon Sep 17 00:00:00 2001 From: AhmedEldeeb50 Date: Sun, 28 Jun 2020 15:29:33 +0200 Subject: Add package deletion button Issue-ID: CCSDK-2483 Signed-off-by: AhmedEldeeb50 Change-Id: I7e1c0f80eb9e6073a1eb472bd6f042e8545c5ab7 --- .../app/common/core/services/api.typed.service.ts | 15 ++++++++----- .../configuration-dashboard.component.html | 26 +++++++++++++++++++++- .../configuration-dashboard.component.ts | 21 ++++++++++++----- .../configuration-dashboard.service.ts | 17 ++++++++------ 4 files changed, 61 insertions(+), 18 deletions(-) (limited to 'cds-ui/designer-client/src') diff --git a/cds-ui/designer-client/src/app/common/core/services/api.typed.service.ts b/cds-ui/designer-client/src/app/common/core/services/api.typed.service.ts index d4851ded5..b73d48ed9 100644 --- a/cds-ui/designer-client/src/app/common/core/services/api.typed.service.ts +++ b/cds-ui/designer-client/src/app/common/core/services/api.typed.service.ts @@ -22,9 +22,9 @@ limitations under the License. ============LICENSE_END============================================ */ -import {Injectable} from '@angular/core'; -import {HttpClient, HttpParams} from '@angular/common/http'; -import {Observable} from 'rxjs'; +import { Injectable } from '@angular/core'; +import { HttpClient, HttpParams } from '@angular/common/http'; +import { Observable } from 'rxjs'; @Injectable() export class ApiService { @@ -40,7 +40,7 @@ export class ApiService { httpParams = httpParams.append(key, params[key]); } } - const options = {params: httpParams}; + const options = { params: httpParams }; return this.httpClient.get(url, options); } @@ -49,6 +49,11 @@ export class ApiService { return this.httpClient.post(url, body, options); } + delete(url: string, body: any | null): Observable { + + return this.httpClient.delete(url, body); + } + getOne(url: string, params?: {}): Observable { console.log('params', params); let httpParams = new HttpParams(); @@ -57,7 +62,7 @@ export class ApiService { httpParams = httpParams.append(key, params[key]); } } - const options = {params: httpParams}; + const options = { params: httpParams }; return this.httpClient.get(url, options); } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html index 18c9277eb..8e2ae5dbb 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html @@ -48,7 +48,7 @@ Download - + Delete @@ -720,4 +720,28 @@ + + + + + \ No newline at end of file diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts index 0ff8d952f..0e1d4cd11 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts @@ -36,6 +36,7 @@ export class ConfigurationDashboardComponent implements OnInit { zipFile: JSZip = new JSZip(); filesData: any = []; folder: FolderNodeElement = new FolderNodeElement(); + id: any; currentBlob = new Blob(); @@ -46,15 +47,14 @@ export class ConfigurationDashboardComponent implements OnInit { private packageCreationUtils: PackageCreationUtils, private router: Router, private designerStore: DesignerStore, - private designerService: DesignerService, private toastService: ToastrService ) { } ngOnInit() { this.elementRef.nativeElement.focus(); - const id = this.route.snapshot.paramMap.get('id'); - this.configurationDashboardService.getPagedPackages(id).subscribe( + this.id = this.route.snapshot.paramMap.get('id'); + this.configurationDashboardService.getPagedPackages(this.id).subscribe( (bluePrintDetailModels) => { if (bluePrintDetailModels) { this.viewedPackage = bluePrintDetailModels[0]; @@ -62,8 +62,11 @@ export class ConfigurationDashboardComponent implements OnInit { this.packageCreationStore.clear(); } }); - } + if (this.route.snapshot.paramMap.has('id')) { + console.log('The id is equal to ' + this.route.snapshot.paramMap.get('id')); + } + } private downloadCBAPackage(bluePrintDetailModels: BluePrintDetailModel) { this.configurationDashboardService.downloadResource( @@ -185,7 +188,15 @@ export class ConfigurationDashboardComponent implements OnInit { }); } - + deletePackage() { + this.configurationDashboardService.deletePackage(this.id).subscribe(res => { + console.log('Deleted'); + console.log(res); + this.router.navigate(['/packages']); + }, err => { + console.log(err); + }); + } create() { this.zipFile = new JSZip(); FilesContent.getMapOfFilesNamesAndContent().forEach((value, key) => { diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.service.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.service.ts index 164d76601..c7f557121 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.service.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.service.ts @@ -1,8 +1,8 @@ -import {Injectable} from '@angular/core'; -import {ApiService} from '../../../../common/core/services/api.typed.service'; -import {BlueprintURLs} from '../../../../common/constants/app-constants'; -import {Observable} from 'rxjs'; -import {BluePrintDetailModel} from '../model/BluePrint.detail.model'; +import { Injectable } from '@angular/core'; +import { ApiService } from '../../../../common/core/services/api.typed.service'; +import { BlueprintURLs } from '../../../../common/constants/app-constants'; +import { Observable } from 'rxjs'; +import { BluePrintDetailModel } from '../model/BluePrint.detail.model'; @Injectable({ @@ -22,10 +22,13 @@ export class ConfigurationDashboardService { } public downloadResource(path: string) { - return this.api.getCustomized(BlueprintURLs.download + path, {responseType: 'blob'}); + return this.api.getCustomized(BlueprintURLs.download + path, { responseType: 'blob' }); } deployPost(body: any | null): Observable { - return this.api.post(BlueprintURLs.deploy, body, {responseType: 'text'}); + return this.api.post(BlueprintURLs.deploy, body, { responseType: 'text' }); + } + deletePackage(id: string) { + return this.api.delete(BlueprintURLs.getOneBlueprint + '/' + id, { observe: 'response' }); } } -- cgit 1.2.3-korg