argos/dmp-frontend/src/app/datasets/dataset-referenced-models-h.../services/services-referenced-model-h...

41 lines
1.4 KiB
TypeScript

import { Component, Inject, OnInit, ViewEncapsulation } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { ActivatedRoute, Router } from '@angular/router';
import { takeUntil } from 'rxjs/operators';
import { BaseComponent } from '../../../core/common/base/base.component';
import { ServiceModel } from '../../../models/services/ServiceModel';
import { ServicesDataService } from '../../../services/services/services-data.service';
@Component({
selector: 'app-services-referenced-model-helper',
templateUrl: 'services-referenced-model-helper.component.html',
styleUrls: ['./services-referenced-model-helper.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class ServicesReferencedModelHelperComponent extends BaseComponent implements OnInit {
public formGroup: FormGroup;
constructor(
private registryService: ServicesDataService,
private route: ActivatedRoute,
public router: Router,
public dialogRef: MatDialogRef<ServicesReferencedModelHelperComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { super(); }
ngOnInit(): void {
const serviceModel = new ServiceModel();
this.formGroup = serviceModel.buildForm();
}
send() {
this.registryService.create(this.formGroup.value)
.pipe(takeUntil(this._destroyed))
.subscribe(
(item) => this.dialogRef.close(item)
);
}
}