summaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/topology-template/topology-template.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/topology-template/topology-template.component.ts')
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/topology-template/topology-template.component.ts56
1 files changed, 56 insertions, 0 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/topology-template/topology-template.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/topology-template/topology-template.component.ts
new file mode 100644
index 000000000..8fce6954d
--- /dev/null
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/topology-template/topology-template.component.ts
@@ -0,0 +1,56 @@
+import {Component, OnDestroy, OnInit} from '@angular/core';
+import {distinctUntilChanged, takeUntil} from 'rxjs/operators';
+import {DesignerStore} from '../../designer/designer.store';
+import {Subject} from 'rxjs';
+import {PackageCreationUtils} from '../package-creation.utils';
+import {PackageCreationStore} from '../package-creation.store';
+
+@Component({
+ selector: 'app-topology-template',
+ templateUrl: './topology-template.component.html',
+ styleUrls: ['./topology-template.component.css']
+})
+export class TopologyTemplateComponent implements OnInit, OnDestroy {
+
+ ngUnsubscribe = new Subject();
+ content = ' ';
+ private cbaPackage: any;
+ private designerState: any;
+
+ constructor(private designerStore: DesignerStore,
+ private packageCreationUtils: PackageCreationUtils,
+ private packageCreationStore: PackageCreationStore) {
+
+ 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.content =
+ this.packageCreationUtils.transformToJson(state.template);
+ console.log(this.content);
+ console.log(state.template);
+ });
+ }
+
+ ngOnInit() {
+ }
+
+ textChanged($event: {}) {
+ this.cbaPackage.templateTopology.content = this.content;
+ this.designerState.template = JSON.parse(this.content);
+
+ }
+
+ ngOnDestroy() {
+ this.ngUnsubscribe.next();
+ this.ngUnsubscribe.complete();
+ }
+}