1 import { Component, OnInit, OnDestroy } from '@angular/core';
2 import { DesignerStore } from '../designer.store';
3 import { PackageCreationUtils } from '../../package-creation/package-creation.utils';
4 import { RouterLink, Router, ActivatedRoute } from '@angular/router';
5 import { Subject } from 'rxjs';
6 import { BluePrintDetailModel } from '../../model/BluePrint.detail.model';
7 import { viewClassName } from '@angular/compiler';
8 import { SourceViewService } from './source-view.service';
11 selector: 'app-designer-source-view',
12 templateUrl: './source-view.component.html',
13 styleUrls: ['./source-view.component.css']
15 export class DesignerSourceViewComponent implements OnInit, OnDestroy {
19 private controllerSideBar: boolean;
20 private ngUnsubscribe = new Subject();
21 viewedPackage: BluePrintDetailModel = new BluePrintDetailModel();
22 public customActionName = '';
24 constructor(private store: DesignerStore,
25 private packageCreationUtils: PackageCreationUtils,
26 private router: Router,
27 private route: ActivatedRoute,
28 private sourceViewService: SourceViewService) {
29 this.controllerSideBar = true;
33 this.store.state$.subscribe(
36 this.content = this.packageCreationUtils.transformToJson(state.template);
39 const id = this.route.snapshot.paramMap.get('id');
40 this.sourceViewService.getPagedPackages(id).subscribe(
41 (bluePrintDetailModels) => {
42 if (bluePrintDetailModels) {
43 this.viewedPackage = bluePrintDetailModels[0];
48 convertAndOpenInDesingerView(id) {
49 // TODO validate json against scheme
50 console.log('convertAndOpenInDesingerView ...', this.content);
51 this.store.saveSourceContent(this.content);
52 this.router.navigate(['/packages/designer', id, {actionName: this.customActionName}]);
56 this.ngUnsubscribe.next();
57 this.ngUnsubscribe.complete();