diff options
author | 2020-12-15 11:17:29 +0200 | |
---|---|---|
committer | 2020-12-15 16:35:04 +0200 | |
commit | 398ae83b6b18fdff202dd7f64ee57d8e3d700937 (patch) | |
tree | d83d36db7fa090a39968b6f5ff4fd16c4f597e95 /cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.ts | |
parent | 981573b5b00cdb47cd9f2bbd002735ccc0c362fc (diff) |
Stop clearing angular store after deploy to avoid script problem.
Issue-ID: CCSDK-3042
Signed-off-by: Ahmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Change-Id: I5eb109c6f27600be63714e93a3748f4d5ecfe37f
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.ts')
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.component.ts | 132 |
1 files changed, 70 insertions, 62 deletions
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 0f6e38c38..cc7de5f41 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 @@ -25,35 +25,35 @@ 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 {saveAs} from 'file-saver'; -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 {NgxUiLoaderService} from 'ngx-ui-loader'; +import { saveAs } from 'file-saver'; +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 { NgxUiLoaderService } from 'ngx-ui-loader'; @Component({ selector: 'app-designer', @@ -77,7 +77,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(); @@ -127,7 +127,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); @@ -173,7 +173,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); }); } @@ -236,7 +236,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 = []; @@ -474,11 +474,10 @@ export class DesignerComponent implements OnInit, OnDestroy { enrichBluePrint() { this.ngxService.start(); + console.log('start enrich ------------'); this.packageCreationStore.addTopologyTemplate(this.cbaPackage.templateTopology); this.formTreeData(); this.enrichPackage(); - this.designerStore.clear(); - this.packageCreationStore.clear(); } private formTreeData() { @@ -493,14 +492,18 @@ export class DesignerComponent implements OnInit, OnDestroy { private enrichPackage() { this.create(); - this.zipFile.generateAsync({type: 'blob'}) + this.zipFile.generateAsync({ type: 'blob' }) .then(blob => { this.packageCreationService.enrichAndDeployPackage(blob).subscribe(response => { // this.packageCreationService.enrichPackage(blob).subscribe(response => { + response = JSON.parse(response); + console.log(response); console.log('success'); - const blobInfo = new Blob([response], {type: 'application/octet-stream'}); - this.packageCreationStore.clear(); - this.packageCreationExtractionService.extractBlobToStore(blobInfo); + const id = response['blueprintModel']['id']; + this.router.navigate(['/packages/designer/' + id]); + // const blobInfo = new Blob([response], { type: 'application/octet-stream' }); + // this.packageCreationStore.clear(); + // this.packageCreationExtractionService.extractBlobToStore(blobInfo); this.toastService.success('Enriched & Deployed successfully '); }, err => { console.log(err); @@ -528,22 +531,22 @@ 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 => { - this.toastService.success('Package is successfully updated '); - const id = bluePrintDetailModels.toString().split('id')[1].split(':')[1].split('"')[1]; - this.router.navigate(['/packages/designer/' + id]); - console.log('success'); - }, error => { - this.toastService.error('Error occured when editing ' + error.message); - console.log('Error -' + error.message); - }, () => { - this.ngxService.stop(); - }); - }, err => { - }, + this.packageCreationService.savePackage(blob).subscribe( + bluePrintDetailModels => { + this.toastService.info('success updating the package'); + const id = bluePrintDetailModels.toString().split('id')[1].split(':')[1].split('"')[1]; + this.router.navigate(['/packages/designer/' + id]); + console.log('success'); + }, error => { + this.toastService.error('error happened when editing ' + error.message); + console.log('Error -' + error.message); + }, () => { + this.ngxService.stop(); + }); + }, err => { + }, () => { this.ngxService.stop(); }); @@ -566,12 +569,17 @@ 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] + try { + // console.log(this.currentActionName + " -- " + stepname) + return this.designerState.template.workflows[this.currentActionName] ['steps'][stepname]['target']; + } catch (e) { + // console.log(e); + } } downloadPackage() { @@ -579,16 +587,16 @@ export class DesignerComponent implements OnInit, OnDestroy { this.ngxService.start(); this.packageCreationService.downloadPackage(this.viewedPackage.artifactName + '/' + this.viewedPackage.artifactVersion).subscribe(response => { - const blob = new Blob([response], {type: 'application/octet-stream'}); - saveAs(blob, this.viewedPackage.artifactName + '-' + this.viewedPackage.artifactVersion + '-CBA.zip'); - - }, err => { - this.toastService.error('Package ' + this.viewedPackage.artifactName + 'has error when downloading' + - err.message); - this.ngxService.stop(); - }, () => { - this.toastService.success('Package ' + this.viewedPackage.artifactName + 'has been downloaded successfully'); - this.ngxService.stop(); - }); + const blob = new Blob([response], { type: 'application/octet-stream' }); + saveAs(blob, this.viewedPackage.artifactName + '-' + this.viewedPackage.artifactVersion + '-CBA.zip'); + + }, err => { + this.toastService.error('package ' + this.viewedPackage.artifactName + 'has error when downloading' + + err.message); + this.ngxService.stop(); + }, () => { + this.toastService.success('package ' + this.viewedPackage.artifactName + 'downloaded successfully'); + this.ngxService.stop(); + }); } } |