Skip to content

Commit 8e083e0

Browse files
committed
feat: functions first step
1 parent 7e91fb6 commit 8e083e0

File tree

9 files changed

+588
-842
lines changed

9 files changed

+588
-842
lines changed

backend/src/main/java/ch/xxx/aidoclibchat/adapter/controller/FunctionController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.springframework.web.bind.annotation.RequestMapping;
1919
import org.springframework.web.bind.annotation.RestController;
2020

21+
import ch.xxx.aidoclibchat.domain.model.dto.FunctionResult;
2122
import ch.xxx.aidoclibchat.domain.model.dto.FunctionSearch;
2223
import ch.xxx.aidoclibchat.usecase.service.FunctionService;
2324

@@ -37,8 +38,8 @@ public FunctionController(FunctionService functionService) {
3738
// }
3839

3940
@PostMapping(path="/books", produces = MediaType.APPLICATION_JSON_VALUE)
40-
public String postQuestion(@RequestBody FunctionSearch functionSearch) {
41-
return this.functionService.functionCall(functionSearch.question(), functionSearch.resultsAmount());
41+
public FunctionResult postQuestion(@RequestBody FunctionSearch functionSearch) {
42+
return new FunctionResult(this.functionService.functionCall(functionSearch.question(), functionSearch.resultAmount()));
4243
}
4344

4445
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Copyright 2023 Sven Loesekann
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package ch.xxx.aidoclibchat.domain.model.dto;
14+
15+
public record FunctionResult(String result) { }

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

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

15-
public record FunctionSearch(String question, Long resultsAmount) { }
15+
public record FunctionSearch(String question, Long resultAmount) { }

frontend/src/angular/i18n/messages.de.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"locale": "de",
33
"translations": {
4-
"bookImportHeading": "Book Import",
5-
"bookImportBookList": " Booklist ",
4+
"bookImportHeading": "Buch Import",
5+
"bookImportBookList": " Bücher Liste ",
6+
"logout": " Logout ",
67
"bookImportAddChapter": "Add Chapter",
78
"bookListHeading": "Book List",
89
"back": " Back ",

frontend/src/angular/package-lock.json

Lines changed: 550 additions & 833 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
</div>
5454
</div>
5555
} @else {
56+
<p>{{response}}</p>
57+
<!--
5658
<mat-tree
5759
[dataSource]="dataSource"
5860
[treeControl]="treeControl"
@@ -62,6 +64,7 @@
6264
{{ node.name }}
6365
</mat-tree-node>
6466
<!-- This is the tree node template for expandable nodes -->
67+
<!--
6568
<mat-nested-tree-node *matTreeNodeDef="let node; when: hasChild">
6669
<div class="mat-tree-node">
6770
<button
@@ -77,6 +80,7 @@
7780
</div>
7881
<!-- There is inline padding applied to this div using styles.
7982
This padding value depends on the mat-icon-button width. -->
83+
<!--
8084
<div
8185
[class.example-tree-invisible]="!treeControl.isExpanded(node)"
8286
role="group"
@@ -85,4 +89,5 @@
8589
</div>
8690
</mat-nested-tree-node>
8791
</mat-tree>
92+
-->
8893
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export class FunctionSearchComponent {
6868
(node) => node.children
6969
);
7070
protected dataSource = new MatTreeNestedDataSource<TreeNode>();
71+
protected response = '';
7172

7273
constructor(
7374
private router: Router,
@@ -105,7 +106,9 @@ export class FunctionSearchComponent {
105106
takeUntilDestroyed(this.destroyRef),
106107
tap(() => (this.searching = false))
107108
)
108-
.subscribe((value) => (this.dataSource.data = this.mapResult(value)));
109+
.subscribe(value => this.response = value.result
110+
);
111+
//.subscribe((value) => (this.dataSource.data = this.mapResult(value)));
109112
}
110113

111114
private mapResult(functionResponse: FunctionResponse): TreeNode[] {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ export interface FunctionResponse {
3535
numFoundExact: boolean;
3636
docs: Book[];
3737
}
38+
39+
export interface FunctionResult {
40+
result: string;
41+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import { HttpClient } from '@angular/common/http';
1414
import { Injectable } from '@angular/core';
1515
import { Observable } from 'rxjs';
16-
import { FunctionResponse, FunctionSearch } from '../model/functions';
16+
import { FunctionResult, FunctionSearch } from '../model/functions';
1717

1818
@Injectable({
1919
providedIn: 'root',
@@ -23,8 +23,8 @@ export class FunctionSearchService {
2323

2424
postLibraryFunction(
2525
functionSearch: FunctionSearch
26-
): Observable<FunctionResponse> {
27-
return this.httpClient.post<FunctionResponse>(
26+
): Observable<FunctionResult> {
27+
return this.httpClient.post<FunctionResult>(
2828
'/rest/function/books',
2929
functionSearch
3030
);

0 commit comments

Comments
 (0)