aboutsummaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app
diff options
context:
space:
mode:
@@ -1,4 +1,4 @@
-import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
+import {Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {BluePrintDetailModel} from '../model/BluePrint.detail.model';
import {PackageCreationStore} from '../package-creation/package-creation.store';
@@ -18,13 +18,15 @@ import {NgxFileDropEntry} from 'ngx-file-drop';
import {PackageCreationService} from '../package-creation/package-creation.service';
import {ComponentCanDeactivate} from '../../../../common/core/canDactivate/ComponentCanDeactivate';
import {PackageCreationExtractionService} from '../package-creation/package-creation-extraction.service';
+import {distinctUntilChanged, takeUntil} from 'rxjs/operators';
+import {Subject} from 'rxjs';
@Component({
selector: 'app-configuration-dashboard',
templateUrl: './configuration-dashboard.component.html',
styleUrls: ['./configuration-dashboard.component.css'],
})
-export class ConfigurationDashboardComponent extends ComponentCanDeactivate implements OnInit {
+export class ConfigurationDashboardComponent extends ComponentCanDeactivate implements OnInit, OnDestroy {
viewedPackage: BluePrintDetailModel = new BluePrintDetailModel();
@ViewChild(MetadataTabComponent, {static: false})
metadataTabComponent: MetadataTabComponent;
@@ -47,6 +49,8 @@ export class ConfigurationDashboardComponent extends ComponentCanDeactivate impl
metadataClasses = 'nav-item nav-link active';
private cbaPackage: CBAPackage = new CBAPackage();
dataTarget: any = '';
+ ngUnsubscribe = new Subject();
+ private designerState: any;
constructor(
private route: ActivatedRoute,
@@ -61,15 +65,25 @@ export class ConfigurationDashboardComponent extends ComponentCanDeactivate impl
) {
super();
- this.packageCreationStore.state$.subscribe(
- cbaPackage => {
- this.cbaPackage = cbaPackage;
- });
+
}
ngOnInit() {
this.vlbDefinition.topology_template = new TemplateTopology();
-
+ this.packageCreationStore.state$
+ .pipe(distinctUntilChanged((a: any, b: any) => JSON.stringify(a) === JSON.stringify(b)),
+ takeUntil(this.ngUnsubscribe))
+ .subscribe(
+ cbaPackage => {
+ this.cbaPackage = cbaPackage;
+ });
+ this.designerStore.state$.pipe(
+ distinctUntilChanged((a: any, b: any) => JSON.stringify(a) === JSON.stringify(b)),
+ takeUntil(this.ngUnsubscribe))
+ .subscribe(state => {
+ this.designerState = state;
+ this.vlbDefinition.topology_template.content = this.packageCreationUtils.transformToJson(state.template);
+ });
this.elementRef.nativeElement.focus();
this.refreshCurrentPackage();
const regexp = RegExp(this.versionPattern);
@@ -206,13 +220,17 @@ export class ConfigurationDashboardComponent extends ComponentCanDeactivate impl
}
textChanged($event: {}) {
- this.packageCreationStore.addTopologyTemplate(this.vlbDefinition.topology_template);
+ this.cbaPackage.templateTopology.node_templates = this.designerState.template.node_templates;
+ this.cbaPackage.templateTopology.workflows = this.designerState.template.workflows;
+ this.cbaPackage.templateTopology.content = this.vlbDefinition.topology_template.content;
}
enrichBluePrint() {
-
+ this.packageCreationStore.addTopologyTemplate(this.cbaPackage.templateTopology);
this.formTreeData();
this.enrichPackage();
+ this.designerStore.clear();
+ this.packageCreationStore.clear();
}
@@ -259,13 +277,18 @@ export class ConfigurationDashboardComponent extends ComponentCanDeactivate impl
return this.isSaveEnabled;
}
+ ngOnDestroy() {
+ this.ngUnsubscribe.next();
+ this.ngUnsubscribe.complete();
+ }
+
checkSkipTypesOfAction() {
console.log(this.cbaPackage);
if (this.cbaPackage.templateTopology.node_templates && this.cbaPackage.templateTopology.workflows) {
- console.log('eeeeee');
this.goToDesignerMode(this.id);
} else {
this.dataTarget = '#exampleModalLong';
}
}
}
+
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 099d96615..19d000f8f 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,32 +25,32 @@ 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 {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';
@Component({
selector: 'app-designer',
@@ -74,7 +74,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();
@@ -117,7 +117,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);
@@ -164,7 +164,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);
});
}
@@ -226,9 +226,10 @@ 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 = [];
for (const workflowsKey in topologtTemplate.workflows) {
if (workflowsKey && !this.actions.includes(workflowsKey)) {
this.actions.push(workflowsKey);
@@ -455,7 +456,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 => {
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 0d20f9662..e07fbb94d 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
@@ -144,4 +144,9 @@ export class DesignerStore extends Store<DesignerDashboardState> {
}
});
}
+
+ clear() {
+ this.setState(new DesignerDashboardState());
+ }
+
}