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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
import { Component, OnInit, OnDestroy } from '@angular/core';
import { DesignerStore } from '../designer.store';
import { PackageCreationUtils } from '../../package-creation/package-creation.utils';
import { RouterLink, Router, ActivatedRoute } from '@angular/router';
import { Subject } from 'rxjs';
import { BluePrintDetailModel } from '../../model/BluePrint.detail.model';
import { viewClassName } from '@angular/compiler';
import { SourceViewService } from './source-view.service';
@Component({
selector: 'app-designer-source-view',
templateUrl: './source-view.component.html',
// styleUrls: ['./source-view.component.css']
styleUrls: ['../designer.component.css']
})
export class DesignerSourceViewComponent implements OnInit, OnDestroy {
content = '';
lang = 'json';
controllerSideBar: boolean;
ngUnsubscribe = new Subject();
viewedPackage: BluePrintDetailModel = new BluePrintDetailModel();
public customActionName = '';
cl = 'editBar';
packageId: string;
constructor(
private store: DesignerStore,
private packageCreationUtils: PackageCreationUtils,
private router: Router,
private route: ActivatedRoute,
private sourceViewService: SourceViewService) {
this.controllerSideBar = true;
}
_toggleSidebar1() {
this.controllerSideBar = !this.controllerSideBar;
if (this.controllerSideBar === false) {
this.cl = 'editBar2';
}
if (this.controllerSideBar === true) {
this.cl = 'editBar';
}
}
ngOnInit() {
this.store.state$.subscribe(
state => {
console.log(state);
this.content = this.packageCreationUtils.transformToJson(state.template);
});
const id = this.route.snapshot.paramMap.get('id');
this.sourceViewService.getPagedPackages(id).subscribe(
(bluePrintDetailModels) => {
if (bluePrintDetailModels) {
this.viewedPackage = bluePrintDetailModels[0];
}
});
this.route.paramMap.subscribe(res => {
this.packageId = res.get('id');
});
}
convertAndOpenInDesingerView(id) {
// TODO validate json against scheme
console.log('convertAndOpenInDesingerView ...', this.content);
this.store.saveSourceContent(this.content);
this.router.navigate(['/packages/designer', this.packageId, { actionName: this.customActionName }]);
}
ngOnDestroy() {
this.ngUnsubscribe.next();
this.ngUnsubscribe.complete();
}
}
|