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();
23 constructor(private store: DesignerStore,
24 private packageCreationUtils: PackageCreationUtils,
25 private router: Router,
26 private route: ActivatedRoute,
27 private sourceViewService: SourceViewService) {
28 this.controllerSideBar = true;
32 this.store.state$.subscribe(
35 this.content = this.packageCreationUtils.transformToJson(state.template);
38 const id = this.route.snapshot.paramMap.get('id');
39 this.sourceViewService.getPagedPackages(id).subscribe(
40 (bluePrintDetailModels) => {
41 if (bluePrintDetailModels) {
42 this.viewedPackage = bluePrintDetailModels[0];
47 convertAndOpenInDesingerView(id) {
48 // TODO validate json against scheme
49 console.log('convertAndOpenInDesingerView ...', this.content);
50 this.store.saveSourceContent(this.content);
51 this.router.navigate(['/packages/designer', id]);
55 this.ngUnsubscribe.next();
56 this.ngUnsubscribe.complete();