import { Component, Input, OnInit, OnDestroy } from '@angular/core'; import { Router } from '@angular/router'; import { Observable, Subscription } from 'rxjs'; import { PimpConfig, PimpRule } from '../../../schema/config'; @Component({ selector: 'app-config-preview-tile', template: `

Pimp rules

`, }) export class ConfigPreviewTileComponent implements OnInit, OnDestroy { @Input() config:Observable; private rules:PimpRule[]; private sub:Subscription; constructor(private router:Router) { } ngOnInit() { this.sub = this.config.subscribe(pimpRules => { if(pimpRules) { this.rules = pimpRules.pimpCmds; } else { this.rules = []; } }); } private onClickEdit() { this.router.navigate(['/configuration', { selectedTabIndex: 1 }]); } ngOnDestroy() { this.sub.unsubscribe(); } }