import { Component, OnInit, NgZone } from '@angular/core'; import { Subject } from 'rxjs'; import { MainPageService } from '../../../main-page.service'; @Component({ selector: 'app-pipering-family-managment', templateUrl: './pipering-family-managment.component.html', styleUrls: ['./pipering-family-managment.component.scss'] }) export class PiperingFamilyManagmentComponent implements OnInit { public piperingFamilyData: any; public isPiperingFamilyNew: boolean = false; public stateSubject: Subject = new Subject(); public graphicalRepresentationsArray: string[]= []; constructor(private mainPageService: MainPageService, private zone: NgZone) { } public ngOnInit(): void { } loadData(): void { this.graphicalRepresentationsArray = this.mainPageService.getPipeRingGraphicalRepresentationsArray(); } public showManagmentPage(sender, isNew?) { this.piperingFamilyData = sender; this.isPiperingFamilyNew = isNew; this.loadData(); } save(): void { this.mainPageService.updatePiperingFamilyInDb(JSON.stringify(this.piperingFamilyData)).subscribe((res) => { }); if (this.isPiperingFamilyNew) { this.isPiperingFamilyNew = false; } } returnHandler() { if (this.isPiperingFamilyNew) { this.mainPageService.removePiperingFamily(this.piperingFamilyData._id).subscribe(() => { }); this.mainPageService.deletePiperingFamilySubject.next(this.piperingFamilyData._id); this.piperingFamilyData = null; } this.stateSubject.next(this.piperingFamilyData); this.piperingFamilyData = null; } }