blob: 8fce6954dc9c390e72cc28fb502c0263d2001488 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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();
}
}
|