Skip to content

Commit 8698c4b

Browse files
committed
feat: structured result step 1
1 parent ca17d4b commit 8698c4b

File tree

5 files changed

+36
-3
lines changed

5 files changed

+36
-3
lines changed

backend/src/main/java/ch/xxx/aidoclibchat/domain/model/dto/FunctionSearch.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,18 @@
1212
*/
1313
package ch.xxx.aidoclibchat.domain.model.dto;
1414

15-
public record FunctionSearch(String question) { }
15+
import com.fasterxml.jackson.annotation.JsonValue;
16+
17+
public record FunctionSearch(String question, ResultFormat resultFormat) {
18+
public enum ResultFormat {Text("text"), Json("json");
19+
private final String value;
20+
21+
private ResultFormat(String value) {
22+
this.value = value;
23+
}
24+
@JsonValue
25+
public String getValue() {
26+
return this.value;
27+
}
28+
}
29+
}

frontend/src/angular/src/app/function-search/function-search.component.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,16 @@
2727
<div class="search-bar">
2828
<mat-form-field class="example-full-width">
2929
<mat-label i18n="@@search">Search</mat-label>
30-
<textarea matInput [formControl]="searchValueControl"></textarea>
30+
<textarea matInput rows="5" [formControl]="searchValueControl"></textarea>
3131
</mat-form-field>
3232
<div class="search-button-box">
33+
<mat-radio-group
34+
class="my-radio-group"
35+
[formControl]="resultFormatControl">
36+
@for (myResultFormat of resultFormats; track myResultFormat) {
37+
<mat-radio-button class="example-radio-button" [value]="myResultFormat">{{myResultFormat.charAt(0).toUpperCase() + myResultFormat.slice(1)}}</mat-radio-button>
38+
}
39+
</mat-radio-group>
3340
<button
3441
mat-flat-button
3542
color="primary"

frontend/src/angular/src/app/function-search/function-search.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
margin: 10px;
3939
}
4040

41+
.my-radio-group {
42+
display: flex;
43+
flex-direction: column;
44+
align-items: flex-start;
45+
}
46+
4147
.spinner-container {
4248
display: flex;
4349
align-content: center;

frontend/src/angular/src/app/function-search/function-search.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
3232
import { Subscription, interval, map, tap } from 'rxjs';
3333
import { NestedTreeControl } from '@angular/cdk/tree';
3434
import { MatIconModule } from '@angular/material/icon';
35+
import {MatRadioModule} from '@angular/material/radio';
3536

3637
interface TreeNode {
3738
name: string;
@@ -48,6 +49,7 @@ interface TreeNode {
4849
MatTooltipModule,
4950
MatTreeModule,
5051
MatIconModule,
52+
MatRadioModule,
5153
MatFormFieldModule,
5254
FormsModule,
5355
ReactiveFormsModule,
@@ -69,6 +71,8 @@ export class FunctionSearchComponent {
6971
);
7072
protected dataSource = new MatTreeNestedDataSource<TreeNode>();
7173
protected response = '';
74+
protected resultFormats = ['text','json'];
75+
protected resultFormatControl = new FormControl(this.resultFormats[0]);
7276

7377
constructor(
7478
private router: Router,
@@ -98,7 +102,8 @@ export class FunctionSearchComponent {
98102
);
99103
this.functionSearchService
100104
.postLibraryFunction({
101-
question: this.searchValueControl.value
105+
question: this.searchValueControl.value,
106+
resultFormat: this.resultFormatControl.value
102107
} as FunctionSearch)
103108
.pipe(
104109
tap(() => this.repeatSub?.unsubscribe()),

frontend/src/angular/src/app/model/functions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
export interface FunctionSearch {
1414
question: string;
15+
resultFormat: string;
1516
}
1617

1718
export interface Book {

0 commit comments

Comments
 (0)