aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cds-ui/designer-client/src/app/common/core/services/api.typed.service.ts15
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html26
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts21
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.service.ts17
-rw-r--r--cds-ui/server/src/controllers/blueprint-rest.controller.ts58
-rw-r--r--cds-ui/server/src/datasources/blueprint.datasource-template.ts152
-rw-r--r--cds-ui/server/src/services/blueprint.service.ts23
7 files changed, 192 insertions, 120 deletions
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<T> {
@@ -40,7 +40,7 @@ export class ApiService<T> {
httpParams = httpParams.append(key, params[key]);
}
}
- const options = {params: httpParams};
+ const options = { params: httpParams };
return this.httpClient.get<T[]>(url, options);
}
@@ -49,6 +49,11 @@ export class ApiService<T> {
return this.httpClient.post(url, body, options);
}
+ delete(url: string, body: any | null): Observable<any> {
+
+ return this.httpClient.delete(url, body);
+ }
+
getOne(url: string, params?: {}): Observable<T> {
console.log('params', params);
let httpParams = new HttpParams();
@@ -57,7 +62,7 @@ export class ApiService<T> {
httpParams = httpParams.append(key, params[key]);
}
}
- const options = {params: httpParams};
+ const options = { params: httpParams };
return this.httpClient.get<T>(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 @@
<span>Download</span>
</a>
- <a class="action-button delete">
+ <a data-target="#removePackageModal" data-toggle="modal" class="action-button">
<i class="icon-delete-sm" aria-hidden="true"></i>
<span>Delete</span>
</a>
@@ -720,4 +720,28 @@
</div>
</div>
</div>
+</div>
+
+
+<!-- Delete Modal -->
+<div class="modal fade" id="removePackageModal" tabindex="-1" role="dialog" aria-labelledby="removePackageModalLabel"
+ aria-hidden="true">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h5 class="modal-title" id="removePackageModalLabel">Delete Script</h5>
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
+ </div>
+ <div class="modal-body">
+ <p>Are you sure you want to delete this package?</p>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
+ <button type="button" (click)="deletePackage()" data-dismiss="modal"
+ class="btn btn-primary">Delete</button>
+ </div>
+ </div>
+ </div>
</div> \ 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<any> {
- 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' });
}
}
diff --git a/cds-ui/server/src/controllers/blueprint-rest.controller.ts b/cds-ui/server/src/controllers/blueprint-rest.controller.ts
index 2319e0a5e..870f9793f 100644
--- a/cds-ui/server/src/controllers/blueprint-rest.controller.ts
+++ b/cds-ui/server/src/controllers/blueprint-rest.controller.ts
@@ -20,16 +20,16 @@ limitations under the License.
*/
-import {get, param, post, Request, requestBody, Response, RestBindings} from '@loopback/rest';
-import {Blueprint} from '../models';
-import {inject} from '@loopback/core';
-import {BlueprintService} from '../services';
+import { get, param, post, Request, requestBody, Response, RestBindings, del } from '@loopback/rest';
+import { Blueprint } from '../models';
+import { inject } from '@loopback/core';
+import { BlueprintService } from '../services';
import * as fs from 'fs';
import * as multiparty from 'multiparty';
import * as request_lib from 'request';
-import {appConfig, processorApiConfig} from '../config/app-config';
-import {bluePrintManagementServiceGrpcClient} from '../clients/blueprint-management-service-grpc-client';
-import {BlueprintDetail} from '../models/blueprint.detail.model';
+import { appConfig, processorApiConfig } from '../config/app-config';
+import { bluePrintManagementServiceGrpcClient } from '../clients/blueprint-management-service-grpc-client';
+import { BlueprintDetail } from '../models/blueprint.detail.model';
export class BlueprintRestController {
constructor(
@@ -42,7 +42,7 @@ export class BlueprintRestController {
responses: {
'200': {
description: 'Blueprint model instance',
- content: {'application/json': {schema: {'x-ts-type': Blueprint}}},
+ content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
},
},
})
@@ -54,7 +54,7 @@ export class BlueprintRestController {
responses: {
'200': {
description: 'Blueprint model instance',
- content: {'application/json': {schema: {'x-ts-type': BlueprintDetail}}},
+ content: { 'application/json': { schema: { 'x-ts-type': BlueprintDetail } } },
},
},
})
@@ -62,12 +62,24 @@ export class BlueprintRestController {
return await this.bpservice.getOneBluePrint(id);
}
+ @del('/controllerblueprint/{id}', {
+ responses: {
+ '200': {
+ description: 'Blueprint model instance',
+ content: { 'application/json': { schema: { 'x-ts-type': BlueprintDetail } } },
+ },
+ },
+ })
+ async deleteBluePrint(@param.path.string('id') id: string) {
+ return await this.bpservice.deleteBluePrint(id);
+ }
+
@get('/controllerblueprint/paged', {
responses: {
'200': {
description: 'Blueprint model instance with pagination',
- content: {'application/json': {schema: {'x-ts-type': Blueprint}}},
+ content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
},
},
})
@@ -83,7 +95,7 @@ export class BlueprintRestController {
responses: {
'200': {
description: 'Blueprint model instance with pagination',
- content: {'application/json': {schema: {'x-ts-type': Blueprint}}},
+ content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
},
},
})
@@ -100,7 +112,7 @@ export class BlueprintRestController {
responses: {
'200': {
description: 'Blueprint model instance',
- content: {'application/json': {schema: {'x-ts-type': Blueprint}}},
+ content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
},
},
})
@@ -112,7 +124,7 @@ export class BlueprintRestController {
responses: {
'200': {
description: 'Blueprint model instance',
- content: {'application/json': {schema: {'x-ts-type': Blueprint}}},
+ content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
},
},
})
@@ -123,7 +135,7 @@ export class BlueprintRestController {
@get('/controllerblueprint/searchByTags/{tags}', {
responses: {
'200': {
- content: {'application/json': {}},
+ content: { 'application/json': {} },
},
},
})
@@ -140,11 +152,11 @@ export class BlueprintRestController {
'multipart/form-data': {
// Skip body parsing
'x-parser': 'stream',
- schema: {type: 'object'},
+ schema: { type: 'object' },
},
},
})
- request: Request,
+ request: Request,
@inject(RestBindings.Http.RESPONSE) response: Response,
): Promise<Response> {
return new Promise((resolve, reject) => {
@@ -180,11 +192,11 @@ export class BlueprintRestController {
'multipart/form-data': {
// Skip body parsing
'x-parser': 'stream',
- schema: {type: 'object'},
+ schema: { type: 'object' },
},
},
})
- request: Request,
+ request: Request,
@inject(RestBindings.Http.RESPONSE) response: Response,
): Promise<Response> {
return new Promise((resolve, reject) => {
@@ -220,11 +232,11 @@ export class BlueprintRestController {
'multipart/form-data': {
// Skip body parsing
'x-parser': 'stream',
- schema: {type: 'object'},
+ schema: { type: 'object' },
},
},
})
- request: Request,
+ request: Request,
@inject(RestBindings.Http.RESPONSE) response: Response,
): Promise<Response> {
return new Promise((resolve, reject) => {
@@ -261,7 +273,7 @@ export class BlueprintRestController {
async getFileFromMultiPartForm(request: Request): Promise<multiparty.File> {
return new Promise((resolve, reject) => {
let form = new multiparty.Form();
- form.parse(request, (err: any, fields: any, files: {[x: string]: any[];}) => {
+ form.parse(request, (err: any, fields: any, files: { [x: string]: any[]; }) => {
if (err) reject(err);
let file = files['file'][0]; // get the file from the returned files object
if (!file) {
@@ -282,11 +294,11 @@ export class BlueprintRestController {
'multipart/form-data': {
// Skip body parsing
'x-parser': 'stream',
- schema: {type: 'object'},
+ schema: { type: 'object' },
},
},
})
- request: Request,
+ request: Request,
@inject(RestBindings.Http.RESPONSE) response: Response,
): Promise<Response> {
return new Promise((resolve, reject) => {
diff --git a/cds-ui/server/src/datasources/blueprint.datasource-template.ts b/cds-ui/server/src/datasources/blueprint.datasource-template.ts
index 9b8e06a13..3b502d334 100644
--- a/cds-ui/server/src/datasources/blueprint.datasource-template.ts
+++ b/cds-ui/server/src/datasources/blueprint.datasource-template.ts
@@ -1,4 +1,4 @@
-import {processorApiConfig} from '../config/app-config';
+import { processorApiConfig } from '../config/app-config';
export default {
"name": "blueprint",
@@ -37,84 +37,100 @@ export default {
}
},
-
- {
- "template": {
- "method": "GET",
- "url": processorApiConfig.http.url + "/blueprint-model/search/{tags}",
- "headers": {
- "accepts": "application/json",
- "content-type": "application/json",
- "authorization": processorApiConfig.http.authToken
- },
- "responsePath": "$.*"
+ {
+ "template": {
+ "method": "DELETE",
+ "url": processorApiConfig.http.url + "/blueprint-model/{id}",
+ "headers": {
+ "accepts": "application/json",
+ "content-type": "application/json",
+ "authorization": processorApiConfig.http.authToken
},
- "functions": {
- "getByTags": ["tags"]
-
- }
+ "responsePath": "$.*"
},
- {
- "template": {
- "method": "GET",
- "url": processorApiConfig.http.url + "/blueprint-model/meta-data/{keyword}",
- "headers": {
- "accepts": "application/json",
- "content-type": "application/json",
- "authorization": processorApiConfig.http.authToken
- },
- "responsePath": "$.*"
+ "functions": {
+ "deleteBluePrint": ["id"]
+
+ }
+ },
+
+ {
+ "template": {
+ "method": "GET",
+ "url": processorApiConfig.http.url + "/blueprint-model/search/{tags}",
+ "headers": {
+ "accepts": "application/json",
+ "content-type": "application/json",
+ "authorization": processorApiConfig.http.authToken
},
- "functions": {
- "getBlueprintsByKeyword": ["keyword"]
+ "responsePath": "$.*"
+ },
+ "functions": {
+ "getByTags": ["tags"]
- }
+ }
+ },
+ {
+ "template": {
+ "method": "GET",
+ "url": processorApiConfig.http.url + "/blueprint-model/meta-data/{keyword}",
+ "headers": {
+ "accepts": "application/json",
+ "content-type": "application/json",
+ "authorization": processorApiConfig.http.authToken
+ },
+ "responsePath": "$.*"
},
- {
- "template": {
- "method": "GET",
- "url": processorApiConfig.http.url + "/blueprint-model/paged?limit={limit}&offset={offset}&sort={sort}&sortType={sortType}",
- "headers": {
- "accepts": "application/json",
- "content-type": "application/json",
- "authorization": processorApiConfig.http.authToken
- },
- "responsePath": "$",
+ "functions": {
+ "getBlueprintsByKeyword": ["keyword"]
+
+ }
+ },
+ {
+ "template": {
+ "method": "GET",
+ "url": processorApiConfig.http.url + "/blueprint-model/paged?limit={limit}&offset={offset}&sort={sort}&sortType={sortType}",
+ "headers": {
+ "accepts": "application/json",
+ "content-type": "application/json",
+ "authorization": processorApiConfig.http.authToken
},
- "functions": {
- "getPagedBueprints": ["limit", "offset", "sort","sortType"],
- }
+ "responsePath": "$",
},
- {
- "template": {
- "method": "GET",
- "url": processorApiConfig.http.url + "/blueprint-model/paged/meta-data/{keyword}?limit={limit}&offset={offset}&sort={sort}&sortType={sortType}",
- "headers": {
- "accepts": "application/json",
- "content-type": "application/json",
- "authorization": processorApiConfig.http.authToken
- },
- "responsePath": "$",
+ "functions": {
+ "getPagedBueprints": ["limit", "offset", "sort", "sortType"],
+ }
+ },
+ {
+ "template": {
+ "method": "GET",
+ "url": processorApiConfig.http.url + "/blueprint-model/paged/meta-data/{keyword}?limit={limit}&offset={offset}&sort={sort}&sortType={sortType}",
+ "headers": {
+ "accepts": "application/json",
+ "content-type": "application/json",
+ "authorization": processorApiConfig.http.authToken
},
- "functions": {
- "getMetaDataPagedBlueprints": ["limit", "offset", "sort", "keyword","sortType"],
- }
+ "responsePath": "$",
},
- {
- "template": {
- "method": "GET",
- "url": processorApiConfig.http.url + "/blueprint-model/by-name/{name}/version/{version}",
- "headers": {
- "accepts": "application/json",
- "content-type": "application/json",
- "authorization": processorApiConfig.http.authToken
- },
- "responsePath": "$",
+ "functions": {
+ "getMetaDataPagedBlueprints": ["limit", "offset", "sort", "keyword", "sortType"],
+ }
+ },
+ {
+ "template": {
+ "method": "GET",
+ "url": processorApiConfig.http.url + "/blueprint-model/by-name/{name}/version/{version}",
+ "headers": {
+ "accepts": "application/json",
+ "content-type": "application/json",
+ "authorization": processorApiConfig.http.authToken
},
- "functions": {
- "getBlueprintByNameAndVersion": ["name", "version"],
- }
+ "responsePath": "$",
},
+ "functions": {
+ "getBlueprintByNameAndVersion": ["name", "version"],
+ }
+ },
]
};
diff --git a/cds-ui/server/src/services/blueprint.service.ts b/cds-ui/server/src/services/blueprint.service.ts
index 2680e105a..379f8d4d5 100644
--- a/cds-ui/server/src/services/blueprint.service.ts
+++ b/cds-ui/server/src/services/blueprint.service.ts
@@ -1,15 +1,16 @@
-import {getService} from '@loopback/service-proxy';
-import {inject, Provider} from '@loopback/core';
-import {BlueprintDataSource} from '../datasources';
+import { getService } from '@loopback/service-proxy';
+import { inject, Provider } from '@loopback/core';
+import { BlueprintDataSource } from '../datasources';
export interface BlueprintService {
- getOneBluePrint(id: string): any;
- getAllblueprints(): Promise<any>;
- getBlueprintsByKeyword(keyword: string): Promise<any>;
- getByTags(tags: string): Promise<JSON>;
- getPagedBueprints(limit: number, offset: number , sort: string,sortType: String): Promise<any>;
- getMetaDataPagedBlueprints(limit: number, offset: number, sort: string, keyword: string,sortType: String): Promise<any>;
- getBlueprintByNameAndVersion(name:string, version:string): Promise<any>;
+ getOneBluePrint(id: string): any;
+ deleteBluePrint(id: string): any;
+ getAllblueprints(): Promise<any>;
+ getBlueprintsByKeyword(keyword: string): Promise<any>;
+ getByTags(tags: string): Promise<JSON>;
+ getPagedBueprints(limit: number, offset: number, sort: string, sortType: String): Promise<any>;
+ getMetaDataPagedBlueprints(limit: number, offset: number, sort: string, keyword: string, sortType: String): Promise<any>;
+ getBlueprintByNameAndVersion(name: string, version: string): Promise<any>;
}
@@ -19,7 +20,7 @@ export class BlueprintServiceProvider implements Provider<BlueprintService> {
// blueprint must match the name property in the datasource json file
@inject('datasources.blueprint')
protected dataSource: BlueprintDataSource = new BlueprintDataSource(),
- ) {}
+ ) { }
value(): Promise<BlueprintService> {
return getService(this.dataSource);