import { Component, Inject, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { takeUntil } from 'rxjs/operators'; import { BaseComponent } from '../../../../../../core/common/base/base.component'; import { ExternalServiceService } from '../../../../../../core/services/external-sources/service/external-service.service'; import { ExternalServiceEditorModel } from '../../../dataset-wizard-editor.model'; @Component({ templateUrl: 'dataset-external-service-dialog-editor.component.html', styleUrls: ['./dataset-external-service-dialog-editor.component.scss'] }) export class DatasetExternalServiceDialogEditorComponent extends BaseComponent implements OnInit { public formGroup: FormGroup; constructor( private externalServiceService: ExternalServiceService, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any ) { super(); } ngOnInit(): void { const serviceModel = new ExternalServiceEditorModel(); this.formGroup = serviceModel.buildForm(); } send() { this.externalServiceService.create(this.formGroup.value) .pipe(takeUntil(this._destroyed)) .subscribe( (item) => this.dialogRef.close(item) ); } }