diff options
author | 2020-09-22 11:56:38 +0200 | |
---|---|---|
committer | 2020-09-22 22:29:23 +0200 | |
commit | 81d82489f5592770a9e5f9ee137bfc1558b48153 (patch) | |
tree | 0cb464ad59e1477462faa4c0f2e409431b5821eb /cds-ui/designer-client/src/app/modules/feature-modules/packages/designer | |
parent | 2c2fa8779bc21dabbe8b5367eca5dec55afae3c2 (diff) |
adding saving simple function at designer
Issue-ID: CCSDK-2298
Signed-off-by: ShaabanEltanany <shaaban.eltanany.ext@orange.com>
Change-Id: Id4ebd3413103d6433e84b3513c4f651176a9833f
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/designer')
3 files changed, 34 insertions, 18 deletions
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 4c0835741..88923229b 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 @@ -10,7 +10,7 @@ </li> <i class="fa fa-angle-right ml-2 mr-2"></i> <li class="breadcrumb-item"> - <a href="/package/{{viewedPackage.id}}">{{viewedPackage.artifactName}}</a> + <a href="/packages/package/{{viewedPackage.id}}">{{viewedPackage.artifactName}}</a> <button type="button" class="btn package-info-btn" data-toggle="modal" data-target="#exampleModalLong"> <i class="icon-info" aria-hidden="true"></i> 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 e4bcdfe7a..0509b1d0e 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 @@ -47,6 +47,7 @@ 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'; @Component({ @@ -75,6 +76,7 @@ export class DesignerComponent implements OnInit, OnDestroy { filesData: any = []; folder: FolderNodeElement = new FolderNodeElement(); zipFile: JSZip = new JSZip(); + private cbaPackage: CBAPackage; constructor( private designerStore: DesignerStore, @@ -85,7 +87,8 @@ export class DesignerComponent implements OnInit, OnDestroy { private graphGenerator: GraphGenerator, private route: ActivatedRoute, private designerService: DesignerService, - private packageCreationService: PackageCreationService) { + private packageCreationService: PackageCreationService, + private packageCreationExtractionService: PackageCreationExtractionService) { this.controllerSideBar = true; this.attributesSideBar = false; this.showAction = false; @@ -137,8 +140,19 @@ export class DesignerComponent implements OnInit, OnDestroy { (bluePrintDetailModels) => { if (bluePrintDetailModels) { this.viewedPackage = bluePrintDetailModels[0]; + this.packageCreationService.downloadPackage(this.viewedPackage.artifactName + '/' + + this.viewedPackage.artifactVersion) + .subscribe(response => { + const blob = new Blob([response], {type: 'application/octet-stream'}); + this.packageCreationExtractionService.extractBlobToStore(blob); + }); } }); + this.packageCreationStore.state$.subscribe(cba => { + this.cbaPackage = cba; + console.log(cba.templateTopology.content); + this.designerStore.saveSourceContent(cba.templateTopology.content); + }); /** * the code to retrieve from server is commented */ @@ -386,17 +400,16 @@ export class DesignerComponent implements OnInit, OnDestroy { } saveBluePrint() { - let cbaPackage: CBAPackage = JSON.parse(sessionStorage.getItem('cba')); - console.log(cbaPackage); + FilesContent.clear(); let packageCreationModes: PackageCreationModes; - cbaPackage = PackageCreationModes.mapModeType(cbaPackage); - cbaPackage.metaData = PackageCreationModes.setEntryPoint(cbaPackage.metaData); - packageCreationModes = PackageCreationBuilder.getCreationMode(cbaPackage); + this.cbaPackage = PackageCreationModes.mapModeType(this.cbaPackage); + this.cbaPackage.metaData = PackageCreationModes.setEntryPoint(this.cbaPackage.metaData); + packageCreationModes = PackageCreationBuilder.getCreationMode(this.cbaPackage); this.designerStore.state$.subscribe(state => { - cbaPackage.templateTopology.content = this.packageCreationUtils.transformToJson(state.template); + this.cbaPackage.templateTopology.content = this.packageCreationUtils.transformToJson(state.template); }); - packageCreationModes.execute(cbaPackage, this.packageCreationUtils); + packageCreationModes.execute(this.cbaPackage, this.packageCreationUtils); this.filesData.push(this.folder.TREE_DATA); this.saveBluePrintToDataBase(); diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts index ba8b2f0f1..0d20f9662 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts @@ -23,8 +23,8 @@ import {Injectable} from '@angular/core'; import {Store} from '../../../../common/core/stores/Store'; import {DesignerService} from './designer.service'; import {DesignerDashboardState} from './model/designer.dashboard.state'; -import { DeclarativeWorkflow } from './model/designer.workflow'; -import { NodeTemplate } from './model/desinger.nodeTemplate.model'; +import {DeclarativeWorkflow} from './model/designer.workflow'; +import {NodeTemplate} from './model/desinger.nodeTemplate.model'; @Injectable({ @@ -54,7 +54,7 @@ export class DesignerStore extends Store<DesignerDashboardState> { }); } - addStepToDeclarativeWorkFlow(workflowName: string, stepName: string, stepType: string) { + addStepToDeclarativeWorkFlow(workflowName: string, stepName: string, stepType: string) { this.setState({ ...this.state, template: { @@ -76,12 +76,15 @@ export class DesignerStore extends Store<DesignerDashboardState> { } saveSourceContent(code: string) { - const topologyTemplate = JSON.parse(code); - this.setState({ - ...this.state, - sourceContent: code, - template: topologyTemplate - }); + console.log(code); + if (code) { + const topologyTemplate = JSON.parse(code); + this.setState({ + ...this.state, + sourceContent: code, + template: topologyTemplate + }); + } } |