import { HttpClient } from '@angular/common/http'; import { Component } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { MatDialogRef } from '@angular/material/dialog'; @Component({ selector: 'app-create-pxe-template', templateUrl: './create-pxe-template.component.html', styleUrls: ['./create-pxe-template.component.css'] }) export class CreatePxeTemplateComponent { templateForm!: FormGroup; previewContent: string = ''; constructor( public dialogRef: MatDialogRef, private http: HttpClient, private fb: FormBuilder ) {} ngOnInit() { this.templateForm = this.fb.group({ name: ['', Validators.required], templateContent: ['', Validators.required] }); } onCreate(): void { const formValues = this.templateForm.value; const payload = { name: formValues.name, templateContent: formValues.templateContent }; console.log(payload); this.http.post('http://127.0.0.1:8080/pxe-templates', payload).subscribe({ next: data => { console.log('Plantilla PXE creada:', data); this.dialogRef.close(true); }, error: error => { console.error('Error al crear la plantilla PXE:', error); this.dialogRef.close(false); } }); } onCancel(): void { this.dialogRef.close(false); } }