2024-03-09 13:08:35 +01:00
|
|
|
import { Component } from '@angular/core';
|
2024-03-09 14:05:08 +01:00
|
|
|
import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
2024-03-09 13:08:35 +01:00
|
|
|
import { MatInputModule } from '@angular/material/input'
|
|
|
|
|
import { MatCheckboxModule } from '@angular/material/checkbox'
|
2024-03-09 14:05:08 +01:00
|
|
|
import { MatButtonModule } from '@angular/material/button'
|
|
|
|
|
import { BackendService } from '../backend.service';
|
2024-03-09 15:26:45 +01:00
|
|
|
import { GenericRequest, UserInputRequest, userInput } from '../requests-responses';
|
2024-03-09 13:08:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-case-input',
|
|
|
|
|
standalone: true,
|
|
|
|
|
imports: [
|
|
|
|
|
MatInputModule,
|
|
|
|
|
MatCheckboxModule,
|
|
|
|
|
ReactiveFormsModule,
|
2024-03-09 14:05:08 +01:00
|
|
|
MatButtonModule
|
2024-03-09 13:08:35 +01:00
|
|
|
],
|
|
|
|
|
templateUrl: './case-input.component.html',
|
|
|
|
|
styleUrl: './case-input.component.scss'
|
|
|
|
|
})
|
|
|
|
|
export class CaseInputComponent {
|
2024-03-09 14:05:08 +01:00
|
|
|
userInputForm: FormGroup;
|
|
|
|
|
userInput: userInput | null = null;
|
|
|
|
|
|
|
|
|
|
constructor(private fb: FormBuilder, private readonly backendService: BackendService) {
|
|
|
|
|
this.userInputForm = this.fb.group({
|
|
|
|
|
generic_input: [''],
|
|
|
|
|
trial_value: [0],
|
|
|
|
|
location: [''],
|
|
|
|
|
experts_called: [false],
|
|
|
|
|
witnesses_called: [false]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-09 18:07:28 +01:00
|
|
|
async onSubmit() {
|
|
|
|
|
this.userInput = this.userInputForm.value;
|
2024-03-09 14:05:08 +01:00
|
|
|
if(this.userInput !== null) {
|
2024-03-09 18:07:28 +01:00
|
|
|
const result = await this.backendService.sendMessage(new UserInputRequest(this.userInput));
|
|
|
|
|
console.log(`result: `, result);
|
|
|
|
|
} else {
|
|
|
|
|
console.error(`caseInputComponent, onSubmit, userInput is null!`)
|
2024-03-09 14:05:08 +01:00
|
|
|
}
|
2024-03-09 18:07:28 +01:00
|
|
|
}
|
2024-03-09 13:08:35 +01:00
|
|
|
}
|