From eafc8865d856cc282e0e0845c67ff232b1a5b805 Mon Sep 17 00:00:00 2001 From: Ahmedeldeeb50 Date: Thu, 3 Dec 2020 17:03:10 +0200 Subject: [PATCH] add Enrich&Deploy function in designer Issue-ID: CCSDK-2900 Signed-off-by: Ahmedeldeeb50 Change-Id: I098fc6bbb35953fbf3728b3863e7990918305edb --- .../src/app/common/constants/app-constants.ts | 1 + .../action-attributes.component.html | 14 ++++++------ .../packages/designer/designer.component.html | 7 +++--- .../packages/designer/designer.component.ts | 6 +++-- .../package-creation/package-creation.service.ts | 9 ++++++++ cds-ui/designer-client/src/styles.css | 2 +- .../src/controllers/blueprint-rest.controller.ts | 26 ++++++++++++++++++++++ 7 files changed, 52 insertions(+), 13 deletions(-) diff --git a/cds-ui/designer-client/src/app/common/constants/app-constants.ts b/cds-ui/designer-client/src/app/common/constants/app-constants.ts index e29748535..51b183640 100644 --- a/cds-ui/designer-client/src/app/common/constants/app-constants.ts +++ b/cds-ui/designer-client/src/app/common/constants/app-constants.ts @@ -94,6 +94,7 @@ export const BlueprintURLs = { save: '/controllerblueprint/create-blueprint', publish: '/controllerblueprint/publish', enrich: '/controllerblueprint/enrich-blueprint', + enrichandpublish: '/controllerblueprint/enrichandpublish', download: '/controllerblueprint/download-blueprint/', deploy: '/controllerblueprint/deploy-blueprint', getMetaDate: '/controllerblueprint/meta-data/', diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.html index 415179735..340ff2f48 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.html @@ -326,7 +326,7 @@ + [checked]="suggestedAttributes[0]?.includes(suggestedAttribute)"> {{suggestedAttribute}} @@ -358,7 +358,7 @@ + [checked]="currentArtifacts[0]?.includes(suggestedArtifact)"> {{suggestedArtifact}} @@ -389,7 +389,7 @@ --> + [checked]="suggestedMappingParameters[0]?.includes(suggestedMappingParameter)"> {{suggestedMappingParameter}} @@ -645,17 +645,17 @@
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.html index 87ef61c27..18ce515b5 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.html @@ -92,11 +92,12 @@
  • Save
  • -
  • +
  • - Deploy + + Enrich & Deploy
  • diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.ts index 3347aa3ac..f3dc2fc4a 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.ts @@ -493,15 +493,17 @@ export class DesignerComponent implements OnInit, OnDestroy { this.create(); this.zipFile.generateAsync({ type: 'blob' }) .then(blob => { - this.packageCreationService.enrichPackage(blob).subscribe(response => { + this.packageCreationService.enrichAndDeployPackage(blob).subscribe(response => { + // this.packageCreationService.enrichPackage(blob).subscribe(response => { console.log('success'); const blobInfo = new Blob([response], { type: 'application/octet-stream' }); this.packageCreationStore.clear(); this.packageCreationExtractionService.extractBlobToStore(blobInfo); - this.toastService.success('Enriched successfully '); + this.toastService.success('Enriched & Deployed successfully '); }, err => { console.log(err); this.toastService.error(err.message, 'Enrich Failed'); + this.ngxService.stop(); }, () => { this.ngxService.stop(); }); diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.service.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.service.ts index ed3db4286..2625dc8b3 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.service.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.service.ts @@ -63,6 +63,10 @@ export class PackageCreationService { return this.api.post(BlueprintURLs.enrich, body, {responseType: 'blob'}); } + private enrichandpublish(body: any | null, options?: any): Observable { + return this.api.post(BlueprintURLs.enrichandpublish, body, {responseType: 'blob'}); + } + private deployBluePrint(body: any | null, options?: any): Observable { return this.api.post(BlueprintURLs.deploy, body, {responseType: 'text'}); } @@ -86,6 +90,11 @@ export class PackageCreationService { return this.enrichBlueprint(formData); } + enrichAndDeployPackage(blob) { + const formData = this.getFormData(blob); + return this.enrichandpublish(formData); + } + deploy(blob) { const formData = this.getFormData(blob); return this.deployBluePrint(formData); diff --git a/cds-ui/designer-client/src/styles.css b/cds-ui/designer-client/src/styles.css index f24b5f9ec..c52788aa3 100644 --- a/cds-ui/designer-client/src/styles.css +++ b/cds-ui/designer-client/src/styles.css @@ -855,7 +855,7 @@ height: 40px; .dropdown-content{ position: absolute; top: 32px; - width: 140px; + width: 160px; margin: 0; padding: 0; opacity: 0; diff --git a/cds-ui/server/src/controllers/blueprint-rest.controller.ts b/cds-ui/server/src/controllers/blueprint-rest.controller.ts index 91d7e66e3..86fdeda86 100644 --- a/cds-ui/server/src/controllers/blueprint-rest.controller.ts +++ b/cds-ui/server/src/controllers/blueprint-rest.controller.ts @@ -256,6 +256,32 @@ export class BlueprintRestController { }); } + @post('/controllerblueprint/enrichandpublish') + async enrichAndPublish( + @requestBody({ + description: 'multipart/form-data value.', + required: true, + content: { + 'multipart/form-data': { + // Skip body parsing + 'x-parser': 'stream', + schema: { type: 'object' }, + }, + }, + }) + request: Request, + @inject(RestBindings.Http.RESPONSE) response: Response, + ): Promise { + return new Promise((resolve, reject) => { + this.getFileFromMultiPartForm(request).then(file => { + if (appConfig.action.grpcEnabled) + return this.uploadFileToBlueprintProcessorGrpc(file, 'ENRICH', response); + else + return this.uploadFileToBlueprintController(file, '/blueprint-model/enrichandpublish/', response); + }); + }); + } + @get('/controllerblueprint/download-blueprint/{name}/{version}') async download( @param.path.string('name') name: string, -- 2.16.6