add Enrich&Deploy function in designer 78/116078/1
authorAhmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Thu, 3 Dec 2020 15:03:10 +0000 (17:03 +0200)
committerAhmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Thu, 3 Dec 2020 15:03:10 +0000 (17:03 +0200)
Issue-ID: CCSDK-2900

Signed-off-by: Ahmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Change-Id: I098fc6bbb35953fbf3728b3863e7990918305edb

cds-ui/designer-client/src/app/common/constants/app-constants.ts
cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.html
cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.html
cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.ts
cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.service.ts
cds-ui/designer-client/src/styles.css
cds-ui/server/src/controllers/blueprint-rest.controller.ts

index e297485..51b1836 100644 (file)
@@ -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/',
index 4151797..340ff2f 100644 (file)
                                                         </span>
                                                         <input type="radio" name="options"
                                                             [id]="suggestedAttribute+'.,.'" autocomplete="off"
-                                                            [checked]="suggestedAttributes[0].includes(suggestedAttribute)">
+                                                            [checked]="suggestedAttributes[0]?.includes(suggestedAttribute)">
                                                         {{suggestedAttribute}}
                                                         <i class="icon-required-star" type="button"
                                                             aria-hidden="true"></i>
                                                         <input type="radio" name="options" [id]="suggestedArtifact"
                                                             autocomplete="off"
                                                             (click)="addArtifactFile(suggestedArtifact)"
-                                                            [checked]="currentArtifacts[0].includes(suggestedArtifact)">
+                                                            [checked]="currentArtifacts[0]?.includes(suggestedArtifact)">
                                                         {{suggestedArtifact}}
                                                     </label>
 
                                                     --> <input type="radio" name="options"
                                                             [id]="suggestedMappingParameter" autocomplete="off"
                                                             (click)="addSuggestedMappingParameter(suggestedMappingParameter)"
-                                                            [checked]="suggestedMappingParameters[0].includes(suggestedMappingParameter)">
+                                                            [checked]="suggestedMappingParameters[0]?.includes(suggestedMappingParameter)">
                                                         {{suggestedMappingParameter}}
                                                     </label>
 
                         <div class="col-sm-9">
                             <div class="list-group list-group-horizontal">
                                 <button type="button" class="list-group-item list-group-item-action"
-                                    [className]="suggestedEditedAttribute.type.includes('string')?'' +
+                                    [className]="suggestedEditedAttribute?.type?.includes('string')?'' +
                                  'list-group-item list-group-item-action active':'list-group-item list-group-item-action'">String
                                 </button>
                                 <button type="button" class="list-group-item list-group-item-action"
-                                    [className]="suggestedEditedAttribute.type.includes('integer')?'' +
+                                    [className]="suggestedEditedAttribute?.type?.includes('integer')?'' +
                                          ' list-group-item list-group-item-action active':'list-group-item list-group-item-action'">Integer</button>
                                 <button type="button" class="list-group-item list-group-item-action"
-                                    [className]="suggestedEditedAttribute.type.includes('boolean')?'' +
+                                    [className]="suggestedEditedAttribute?.type?.includes('boolean')?'' +
                                          'list-group-item list-group-item-action active':'list-group-item list-group-item-action'">Boolean</button>
                                 <button type="button" class="list-group-item list-group-item-action"
-                                    [className]="suggestedEditedAttribute.type.includes('list')?'' +
+                                    [className]="suggestedEditedAttribute?.type?.includes('list')?'' +
                                          'list-group-item list-group-item-action active':'list-group-item list-group-item-action'">List</button>
                                 <button type="button" class="list-group-item list-group-item-action">Other
                                 </button>
index 87ef61c..18ce515 100644 (file)
                             <li>
                                 <a (click)="saveBluePrint()"><i class="icon-save-sm" aria-hidden="true"></i> Save</a>
                             </li>
-                            <li>
+                            <!-- <li>
                                 <a (click)="enrichBluePrint()"><i class="icon-enrich" aria-hidden="true"></i> Enrich</a>
-                            </li>
+                            </li> -->
                             <li>
-                                <a (click)="publishBluePrint()"><i class="fa fa-play-circle" aria-hidden="true"></i> Deploy</a>
+                                <a (click)="enrichBluePrint()"><i class="fa fa-play-circle" aria-hidden="true"></i>
+                                    Enrich & Deploy</a>
                             </li>
                         </ul>
                     </div>
index 3347aa3..f3dc2fc 100644 (file)
@@ -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();
                 });
index ed3db42..2625dc8 100644 (file)
@@ -63,6 +63,10 @@ export class PackageCreationService {
         return this.api.post(BlueprintURLs.enrich, body, {responseType: 'blob'});
     }
 
+    private enrichandpublish(body: any | null, options?: any): Observable<any> {
+        return this.api.post(BlueprintURLs.enrichandpublish, body, {responseType: 'blob'});
+    }
+
     private deployBluePrint(body: any | null, options?: any): Observable<any> {
         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);
index f24b5f9..c52788a 100644 (file)
@@ -855,7 +855,7 @@ height: 40px;
 .dropdown-content{
   position: absolute;
   top: 32px;
-  width: 140px;
+  width: 160px;
   margin: 0;
   padding: 0;
   opacity: 0;
index 91d7e66..86fdeda 100644 (file)
@@ -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<Response> {
+    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,