Save package from function attribute button 40/114940/1
authorAhmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Mon, 16 Nov 2020 15:13:02 +0000 (17:13 +0200)
committerAhmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Mon, 16 Nov 2020 15:13:02 +0000 (17:13 +0200)
detect url change in breadcrumb

Issue-ID: CCSDK-2900

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

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/designer/designer.store.ts
cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.html
cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts

index 3ca377d..b0bfe8b 100644 (file)
@@ -10,7 +10,7 @@
                     </li>
                     <i class="fa fa-angle-right ml-2 mr-2"></i>
                     <li class="breadcrumb-item">
-                        <a routerLink="/packages/package/{{viewedPackage.id}}">{{viewedPackage.artifactName}}</a>
+                        <a routerLink="/packages/package/{{packageId}}">{{viewedPackage.artifactName}}</a>
                         <button type="button" class="btn package-info-btn tooltip-bottom" data-toggle="modal"
                             data-target="#exampleModalLong" data-tooltip="Package Details">
                             <i class="icon-info" aria-hidden="true"></i>
             <li class="nav-item">
                 <div class="btn-group viewBtns" role="group">
                     <button type="button" class="btn btn-secondary topologySource active">Designer</button>
-                    <button [routerLink]="['/designer/source', viewedPackage.id]" type="button"
+                    <button [routerLink]="['/designer/source', packageId]" type="button"
                         class="btn btn-secondary topologyView">Scripting
                     </button>
                 </div>
                             </div>
                         </div>
                     </div>
-                    <app-functions-attribute></app-functions-attribute>
+                    <app-functions-attribute (saveEvent)="saveBluePrint()"></app-functions-attribute>
                 </div>
             </div>
         </div>
index ff6406c..a2b57d6 100644 (file)
@@ -25,33 +25,33 @@ limitations under the License.
 
 import dagre from 'dagre';
 import graphlib from 'graphlib';
-import {Component, OnDestroy, OnInit, ViewEncapsulation} from '@angular/core';
+import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
 import * as joint from 'jointjs';
 import './jointjs/elements/palette.function.element';
 import './jointjs/elements/action.element';
 import './jointjs/elements/board.function.element';
-import {DesignerStore} from './designer.store';
-import {ActionElementTypeName} from 'src/app/common/constants/app-constants';
-import {GraphUtil} from './graph.util';
-import {GraphGenerator} from './graph.generator.util';
-import {FunctionsStore} from './functions.store';
-import {Subject} from 'rxjs';
-import {distinctUntilChanged, takeUntil} from 'rxjs/operators';
-import {BluePrintDetailModel} from '../model/BluePrint.detail.model';
-import {ActivatedRoute, Router} from '@angular/router';
-import {DesignerService} from './designer.service';
-import {FilesContent, FolderNodeElement} from '../package-creation/mapping-models/metadata/MetaDataTab.model';
-import {PackageCreationModes} from '../package-creation/creationModes/PackageCreationModes';
-import {PackageCreationBuilder} from '../package-creation/creationModes/PackageCreationBuilder';
-import {PackageCreationStore} from '../package-creation/package-creation.store';
-import {PackageCreationService} from '../package-creation/package-creation.service';
-import {PackageCreationUtils} from '../package-creation/package-creation.utils';
+import { DesignerStore } from './designer.store';
+import { ActionElementTypeName } from 'src/app/common/constants/app-constants';
+import { GraphUtil } from './graph.util';
+import { GraphGenerator } from './graph.generator.util';
+import { FunctionsStore } from './functions.store';
+import { Subject } from 'rxjs';
+import { distinctUntilChanged, takeUntil } from 'rxjs/operators';
+import { BluePrintDetailModel } from '../model/BluePrint.detail.model';
+import { ActivatedRoute, Router } from '@angular/router';
+import { DesignerService } from './designer.service';
+import { FilesContent, FolderNodeElement } from '../package-creation/mapping-models/metadata/MetaDataTab.model';
+import { PackageCreationModes } from '../package-creation/creationModes/PackageCreationModes';
+import { PackageCreationBuilder } from '../package-creation/creationModes/PackageCreationBuilder';
+import { PackageCreationStore } from '../package-creation/package-creation.store';
+import { PackageCreationService } from '../package-creation/package-creation.service';
+import { PackageCreationUtils } from '../package-creation/package-creation.utils';
 import * as JSZip from 'jszip';
-import {PackageCreationExtractionService} from '../package-creation/package-creation-extraction.service';
-import {CBAPackage} from '../package-creation/mapping-models/CBAPacakge.model';
-import {TopologyTemplate} from './model/designer.topologyTemplate.model';
-import {ToastrService} from 'ngx-toastr';
-import {DesignerDashboardState} from './model/designer.dashboard.state';
+import { PackageCreationExtractionService } from '../package-creation/package-creation-extraction.service';
+import { CBAPackage } from '../package-creation/mapping-models/CBAPacakge.model';
+import { TopologyTemplate } from './model/designer.topologyTemplate.model';
+import { ToastrService } from 'ngx-toastr';
+import { DesignerDashboardState } from './model/designer.dashboard.state';
 
 @Component({
     selector: 'app-designer',
@@ -75,7 +75,7 @@ export class DesignerComponent implements OnInit, OnDestroy {
     paletteGraph: joint.dia.Graph;
     palettePaper: joint.dia.Paper;
     ngUnsubscribe = new Subject();
-    opt = {tx: 100, ty: 100};
+    opt = { tx: 100, ty: 100 };
     filesData: any = [];
     folder: FolderNodeElement = new FolderNodeElement();
     zipFile: JSZip = new JSZip();
@@ -85,6 +85,7 @@ export class DesignerComponent implements OnInit, OnDestroy {
     steps: string[];
     designerState: DesignerDashboardState;
     currentActionName: string;
+    packageId: any;
 
     constructor(
         private designerStore: DesignerStore,
@@ -98,6 +99,7 @@ export class DesignerComponent implements OnInit, OnDestroy {
         private designerService: DesignerService,
         private packageCreationService: PackageCreationService,
         private packageCreationExtractionService: PackageCreationExtractionService,
+        private activatedRoute: ActivatedRoute,
         private toastService: ToastrService) {
         this.controllerSideBar = true;
         this.actionAttributesSideBar = false;
@@ -122,7 +124,7 @@ export class DesignerComponent implements OnInit, OnDestroy {
 
     publishBluePrint() {
         this.create();
-        this.zipFile.generateAsync({type: 'blob'})
+        this.zipFile.generateAsync({ type: 'blob' })
             .then(blob => {
                 const formData = new FormData();
                 formData.append('file', blob);
@@ -169,7 +171,7 @@ export class DesignerComponent implements OnInit, OnDestroy {
                     this.packageCreationService.downloadPackage(this.viewedPackage.artifactName + '/'
                         + this.viewedPackage.artifactVersion)
                         .subscribe(response => {
-                            const blob = new Blob([response], {type: 'application/octet-stream'});
+                            const blob = new Blob([response], { type: 'application/octet-stream' });
                             this.packageCreationExtractionService.extractBlobToStore(blob);
                         });
                 }
@@ -232,7 +234,7 @@ export class DesignerComponent implements OnInit, OnDestroy {
                         setLinkVertices: false,
                         marginX: 10,
                         marginY: 10,
-                        clusterPadding: {top: 100, left: 30, right: 10, bottom: 100},
+                        clusterPadding: { top: 100, left: 30, right: 10, bottom: 100 },
                         rankDir: 'TB'
                     });
                     this.actions = [];
@@ -254,6 +256,9 @@ export class DesignerComponent implements OnInit, OnDestroy {
 
         // action triggering
         this.functionStore.retrieveFuntions();
+        this.activatedRoute.paramMap.subscribe(res => {
+            this.packageId = res.get('id');
+        });
 
     }
 
@@ -475,7 +480,7 @@ export class DesignerComponent implements OnInit, OnDestroy {
 
     saveBluePrintToDataBase() {
         this.create();
-        this.zipFile.generateAsync({type: 'blob'})
+        this.zipFile.generateAsync({ type: 'blob' })
             .then(blob => {
                 this.packageCreationService.savePackage(blob).subscribe(
                     bluePrintDetailModels => {
@@ -507,11 +512,11 @@ export class DesignerComponent implements OnInit, OnDestroy {
         // console.log(this.designerState.template.workflows[this.currentActionName]
         // ['steps'][customFunctionName]['target']);
         this.designerStore.setCurrentFunction(this.designerState.template.workflows[this.currentActionName]
-            ['steps'][customFunctionName]['target']);
+        ['steps'][customFunctionName]['target']);
     }
 
     getTarget(stepname) {
         return this.designerState.template.workflows[this.currentActionName]
-            ['steps'][stepname]['target'];
+        ['steps'][stepname]['target'];
     }
 }
index 857654c..c9151c5 100644 (file)
@@ -78,7 +78,7 @@ export class DesignerStore extends Store<DesignerDashboardState> {
     }
 
     saveSourceContent(code: string) {
-        console.log(code);
+      //  console.log(code);
         if (code) {
             const topologyTemplate = JSON.parse(code);
             this.setState({
index ab5bb12..505844c 100644 (file)
             </div>
         </div>
     </div>
-    <button class="btn btn-info" (click)="saveFunctionData()">Save</button>
+    <button class="btn btn-info  btn-select-template m-auto" (click)="saveFunctionData()">Save</button>
 </div>
 
 <!--function - Select Template - Modal-->
index 347f304..8712367 100644 (file)
@@ -1,4 +1,4 @@
-import { Component, OnDestroy, OnInit } from '@angular/core';
+import { Component, EventEmitter, OnDestroy, OnInit, Output } from '@angular/core';
 import { DesignerStore } from '../designer.store';
 import { PackageCreationStore } from '../../package-creation/package-creation.store';
 import { Subject } from 'rxjs';
@@ -34,6 +34,7 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy {
     actionName = '';
     functionName = '';
     interfaceChildName = '';
+    @Output() saveEvent = new EventEmitter<string>();
 
 
     constructor(
@@ -132,7 +133,11 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy {
             if (inputs) {
                 for (const [key, value] of Object.entries(inputs)) {
                     console.log(key + ' - ' + value);
-                    this.currentFuncion.inputs[key] = value;
+                    if (typeof value === 'object') {
+                        this.currentFuncion.inputs[key] = JSON.stringify(value);
+                    } else {
+                        this.currentFuncion.inputs[key] = value;
+                    }
                 }
             }
             if (outputs) {
@@ -210,6 +215,7 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy {
         console.log(node_templates);
         // tslint:disable-next-line: no-unused-expression
         this.designerStore.addNodeTemplate(instanceName, type, node_templates[instanceName]);
+        this.saveEvent.emit('save');
     }
     // Template logic
     private setIsMappingOrTemplate(key: string, templateAndMapping: TemplateAndMapping, isFromTemplate: boolean) {
@@ -262,6 +268,7 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy {
     getObjectValue(object) {
         return Object.values(object);
     }
+
     getNodeType(nodeName: string) {
         this.functionStore.state$
             .subscribe(state => {