From 933299168c453869d80a26da7ed068bb35f42f8e Mon Sep 17 00:00:00 2001 From: Angular2guy Date: Sat, 18 May 2024 07:36:40 +0200 Subject: [PATCH] fix: results --- .../usecase/service/ImageService.java | 2 +- frontend/src/angular/i18n/messages.de.json | 4 +- frontend/src/angular/src/app/app.routes.ts | 9 +- .../src/app/doc-list/doc-list.component.html | 2 +- .../src/app/doc-list/doc-list.component.ts | 6 +- .../function-search.component.html | 47 +++--- .../function-search.component.scss | 6 +- .../function-search.component.spec.ts | 2 +- .../function-search.component.ts | 155 ++++++++++++------ .../function-search/function-search.routes.ts | 1 - .../image-query/image-query.component.html | 122 ++++++++------ .../image-query/image-query.component.scss | 23 ++- .../image-query/image-query.component.spec.ts | 2 +- .../app/image-query/image-query.component.ts | 149 ++++++++++------- .../src/app/image-query/image-query.routes.ts | 3 +- .../src/angular/src/app/image-query/index.ts | 2 +- .../src/angular/src/app/model/functions.ts | 34 ++-- .../src/angular/src/app/model/image-file.ts | 15 +- .../service/function-search.service.spec.ts | 2 +- .../app/service/function-search.service.ts | 14 +- .../src/app/service/image.service.spec.ts | 3 +- .../angular/src/app/service/image.service.ts | 11 +- .../table-search/table-search.component.ts | 7 +- 23 files changed, 374 insertions(+), 247 deletions(-) diff --git a/backend/src/main/java/ch/xxx/aidoclibchat/usecase/service/ImageService.java b/backend/src/main/java/ch/xxx/aidoclibchat/usecase/service/ImageService.java index 8667e5e..2509bbb 100644 --- a/backend/src/main/java/ch/xxx/aidoclibchat/usecase/service/ImageService.java +++ b/backend/src/main/java/ch/xxx/aidoclibchat/usecase/service/ImageService.java @@ -83,7 +83,7 @@ public ImageDto importImage(ImageQueryDto imageDto, Image image) { } public List queryImage(String imageQuery) { - var aiDocuments = this.documentVsRepository.retrieve(imageQuery, MetaData.DataType.IMAGE).stream() + var aiDocuments = this.documentVsRepository.retrieve(imageQuery, MetaData.DataType.IMAGE, this.resultSize.intValue()).stream() .filter(myDoc -> myDoc.getMetadata().get(MetaData.DATATYPE).equals(DataType.IMAGE.toString())) .sorted((myDocA, myDocB) -> ((Float) myDocA.getMetadata().get(MetaData.DISTANCE)) .compareTo(((Float) myDocB.getMetadata().get(MetaData.DISTANCE)))) diff --git a/frontend/src/angular/i18n/messages.de.json b/frontend/src/angular/i18n/messages.de.json index 88c5c85..cfd2a4e 100644 --- a/frontend/src/angular/i18n/messages.de.json +++ b/frontend/src/angular/i18n/messages.de.json @@ -9,6 +9,7 @@ "cancel": "Cancel", "upload": "Upload", "doclistHeading": "Document List", + "imageQuery": "Image query", "function": "Function", "table": "Table", "search": "Search", @@ -28,7 +29,8 @@ "docSearchOtherDocuments": "Other Documents:", "functionSearchHeading": "Function Search", "imageQueryHeading": "Image Query", - "imagequeryQuery": "Image query", + "query": "Query", + "imageQueryPrompt": "Image prompt", "tableSearchHeading": "Table Search", "tableSearchDataImport": "A new DB instance needs a data import first.", "tableSearchImportData": " Import Data " diff --git a/frontend/src/angular/src/app/app.routes.ts b/frontend/src/angular/src/app/app.routes.ts index 6d9ebe2..c4c9217 100644 --- a/frontend/src/angular/src/app/app.routes.ts +++ b/frontend/src/angular/src/app/app.routes.ts @@ -26,12 +26,13 @@ export const routes: Routes = [ loadChildren: () => import('./table-search').then((mod) => mod.TABLESEARCH), }, { - path: 'functionsearch', - loadChildren: () => import('./function-search').then((mod) => mod.FUNCTIONSEARCH), + path: 'functionsearch', + loadChildren: () => + import('./function-search').then((mod) => mod.FUNCTIONSEARCH), }, { - path: 'imagequery', - loadChildren: () => import('./image-query').then((mod) => mod.IMAGEQUERY) + path: 'imagequery', + loadChildren: () => import('./image-query').then((mod) => mod.IMAGEQUERY), }, { path: '**', redirectTo: 'doclist' }, ]; diff --git a/frontend/src/angular/src/app/doc-list/doc-list.component.html b/frontend/src/angular/src/app/doc-list/doc-list.component.html index 1d2e75c..df51526 100644 --- a/frontend/src/angular/src/app/doc-list/doc-list.component.html +++ b/frontend/src/angular/src/app/doc-list/doc-list.component.html @@ -12,7 +12,7 @@ Image query -
+
} @else { - - - {{node.name}} + + + {{ node.name }} -
- - {{node.name}} -
- -
- +
+
- -} \ No newline at end of file + +} diff --git a/frontend/src/angular/src/app/function-search/function-search.component.scss b/frontend/src/angular/src/app/function-search/function-search.component.scss index 631af7b..a0dadfc 100644 --- a/frontend/src/angular/src/app/function-search/function-search.component.scss +++ b/frontend/src/angular/src/app/function-search/function-search.component.scss @@ -69,7 +69,7 @@ /* * This padding sets alignment of the nested nodes. */ -.example-tree .mat-nested-tree-node div[role=group] { +.example-tree .mat-nested-tree-node div[role="group"] { padding-left: 40px; } @@ -78,7 +78,7 @@ * Leaf nodes need to have padding so as to align with other non-leaf nodes * under the same parent. */ -.example-tree div[role=group] > .mat-tree-node { +.example-tree div[role="group"] > .mat-tree-node { padding-left: 40px; } @@ -91,4 +91,4 @@ justify-content: space-between; width: 60%; } -} \ No newline at end of file +} diff --git a/frontend/src/angular/src/app/function-search/function-search.component.spec.ts b/frontend/src/angular/src/app/function-search/function-search.component.spec.ts index 5e3acef..8744de0 100644 --- a/frontend/src/angular/src/app/function-search/function-search.component.spec.ts +++ b/frontend/src/angular/src/app/function-search/function-search.component.spec.ts @@ -21,4 +21,4 @@ describe('FunctionSearchComponent', () => { expect(component).toBeTruthy(); }); }); -*/ \ No newline at end of file +*/ diff --git a/frontend/src/angular/src/app/function-search/function-search.component.ts b/frontend/src/angular/src/app/function-search/function-search.component.ts index 7308f89..7f5da1c 100644 --- a/frontend/src/angular/src/app/function-search/function-search.component.ts +++ b/frontend/src/angular/src/app/function-search/function-search.component.ts @@ -12,21 +12,26 @@ */ import { Component, DestroyRef } from '@angular/core'; import { CommonModule } from '@angular/common'; -import {MatTreeNestedDataSource, MatTreeModule} from '@angular/material/tree'; +import { MatTreeNestedDataSource, MatTreeModule } from '@angular/material/tree'; import { MatToolbarModule } from '@angular/material/toolbar'; import { MatButtonModule } from '@angular/material/button'; import { Router } from '@angular/router'; import { MatInputModule } from '@angular/material/input'; import { MatTooltipModule } from '@angular/material/tooltip'; import { MatFormFieldModule } from '@angular/material/form-field'; -import { FormControl, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'; +import { + FormControl, + FormsModule, + ReactiveFormsModule, + Validators, +} from '@angular/forms'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { Book, FunctionResponse, FunctionSearch } from '../model/functions'; import { FunctionSearchService } from '../service/function-search.service'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { Subscription, interval, map, tap } from 'rxjs'; import { NestedTreeControl } from '@angular/cdk/tree'; -import {MatIconModule} from '@angular/material/icon'; +import { MatIconModule } from '@angular/material/icon'; interface TreeNode { name: string; @@ -36,7 +41,8 @@ interface TreeNode { @Component({ selector: 'app-function-search', standalone: true, - imports: [CommonModule, + imports: [ + CommonModule, MatToolbarModule, MatButtonModule, MatInputModule, @@ -46,34 +52,42 @@ interface TreeNode { MatFormFieldModule, FormsModule, ReactiveFormsModule, - MatProgressSpinnerModule], + MatProgressSpinnerModule, + ], templateUrl: './function-search.component.html', - styleUrl: './function-search.component.scss' + styleUrl: './function-search.component.scss', }) export class FunctionSearchComponent { private repeatSub: Subscription | null = null; - protected searchValueControl = new FormControl('', [ + protected searchValueControl = new FormControl('', [ Validators.required, Validators.minLength(3), ]); protected searching = false; protected msWorking = 0; - protected treeControl = new NestedTreeControl(node => node.children); + protected treeControl = new NestedTreeControl( + (node) => node.children + ); protected dataSource = new MatTreeNestedDataSource(); - - constructor(private router: Router,private destroyRef: DestroyRef, private functionSearchService: FunctionSearchService) { } - - protected hasChild = (_: number, node: TreeNode) => !!node.children && node.children.length > 0; - - protected showList(): void { - this.router.navigate(['/doclist']); - } - - protected search(): void { - this.searching = true; - this.dataSource.data = []; - const startDate = new Date(); - this.repeatSub?.unsubscribe(); + + constructor( + private router: Router, + private destroyRef: DestroyRef, + private functionSearchService: FunctionSearchService + ) {} + + protected hasChild = (_: number, node: TreeNode) => + !!node.children && node.children.length > 0; + + protected showList(): void { + this.router.navigate(['/doclist']); + } + + protected search(): void { + this.searching = true; + this.dataSource.data = []; + const startDate = new Date(); + this.repeatSub?.unsubscribe(); this.repeatSub = interval(100) .pipe( map(() => new Date()), @@ -82,36 +96,71 @@ export class FunctionSearchComponent { .subscribe( (newDate) => (this.msWorking = newDate.getTime() - startDate.getTime()) ); - this.functionSearchService.postLibraryFunction({question: this.searchValueControl.value, resultAmount: 10} as FunctionSearch) - .pipe(tap(() => this.repeatSub?.unsubscribe()),takeUntilDestroyed(this.destroyRef), tap(() => this.searching = false)).subscribe(value => this.dataSource.data = this.mapResult(value)); - } + this.functionSearchService + .postLibraryFunction({ + question: this.searchValueControl.value, + resultAmount: 10, + } as FunctionSearch) + .pipe( + tap(() => this.repeatSub?.unsubscribe()), + takeUntilDestroyed(this.destroyRef), + tap(() => (this.searching = false)) + ) + .subscribe((value) => (this.dataSource.data = this.mapResult(value))); + } + + private mapResult(functionResponse: FunctionResponse): TreeNode[] { + return functionResponse.docs.map((myBook) => this.mapBook(myBook)); + } + + private mapBook(book: Book): TreeNode { + const rootNode = { name: book.title, children: [] } as TreeNode; + rootNode.children?.push({ name: 'Title: ' + book.title } as TreeNode); + rootNode.children?.push({ name: 'Type: ' + book.type } as TreeNode); + rootNode.children?.push({ + name: 'Average Ratings: ' + book.ratings_average, + } as TreeNode); + rootNode.children?.push({ + name: 'Authors', + children: this.mapArray(book.author_name), + } as TreeNode); + rootNode.children?.push({ + name: 'Languages', + children: this.mapArray(book.language), + } as TreeNode); + rootNode.children?.push({ + name: 'Persons', + children: this.mapArray(book.person), + } as TreeNode); + rootNode.children?.push({ + name: 'Places', + children: this.mapArray(book.place), + } as TreeNode); + rootNode.children?.push({ + name: 'Publishdates', + children: this.mapArray(book.publish_date), + } as TreeNode); + rootNode.children?.push({ + name: 'Publishers', + children: this.mapArray(book.publisher), + } as TreeNode); + rootNode.children?.push({ + name: 'Subjects', + children: this.mapArray(book.subject), + } as TreeNode); + rootNode.children?.push({ + name: 'Times', + children: this.mapArray(book.time), + } as TreeNode); + console.log(rootNode); + return rootNode; + } + + private mapArray(values: string[]): TreeNode[] { + return !!values ? values.map((myStr) => ({ name: myStr } as TreeNode)) : []; + } - private mapResult(functionResponse: FunctionResponse): TreeNode[] { - return functionResponse.docs.map(myBook => this.mapBook(myBook)); - } - - private mapBook(book: Book): TreeNode { - const rootNode = {name: book.title, children: [] } as TreeNode; - rootNode.children?.push({name: 'Title: '+book.title} as TreeNode); - rootNode.children?.push({name: 'Type: '+book.type} as TreeNode); - rootNode.children?.push({name: 'Average Ratings: '+book.ratings_average} as TreeNode); - rootNode.children?.push({name: 'Authors', children: this.mapArray(book.author_name)} as TreeNode); - rootNode.children?.push({name: 'Languages', children: this.mapArray(book.language)} as TreeNode); - rootNode.children?.push({name: 'Persons', children: this.mapArray(book.person)} as TreeNode); - rootNode.children?.push({name: 'Places', children: this.mapArray(book.place)} as TreeNode); - rootNode.children?.push({name: 'Publishdates', children: this.mapArray(book.publish_date)} as TreeNode); - rootNode.children?.push({name: 'Publishers', children: this.mapArray(book.publisher)} as TreeNode); - rootNode.children?.push({name: 'Subjects', children: this.mapArray(book.subject)} as TreeNode); - rootNode.children?.push({name: 'Times', children: this.mapArray(book.time)} as TreeNode); - console.log(rootNode); - return rootNode; - } - - private mapArray(values: string[]): TreeNode[] { - return !!values ? values.map(myStr => ({name: myStr} as TreeNode)) : []; - } - - protected logout(): void { - console.log('logout'); - } + protected logout(): void { + console.log('logout'); + } } diff --git a/frontend/src/angular/src/app/function-search/function-search.routes.ts b/frontend/src/angular/src/app/function-search/function-search.routes.ts index c791019..40b6705 100644 --- a/frontend/src/angular/src/app/function-search/function-search.routes.ts +++ b/frontend/src/angular/src/app/function-search/function-search.routes.ts @@ -13,7 +13,6 @@ import { Routes } from '@angular/router'; import { FunctionSearchComponent } from './function-search.component'; - export const FUNCTIONSEARCH: Routes = [ { path: '', diff --git a/frontend/src/angular/src/app/image-query/image-query.component.html b/frontend/src/angular/src/app/image-query/image-query.component.html index 447bf86..9c81676 100644 --- a/frontend/src/angular/src/app/image-query/image-query.component.html +++ b/frontend/src/angular/src/app/image-query/image-query.component.html @@ -1,7 +1,7 @@
Image Query
-
+
+
-
+
+
+
} @else if(uiMode === 'query') { -
- - Image query - - - -
- @for(myresult of results; track myresult.answer) { -
-
-
{{myresult.answer}}
-
- } -
-
+
+ + Image query + + + +
+ @for(myresult of results; track myresult.answer) { +
+
+
{{ myresult.answer }}
+
+ } +
+
}
diff --git a/frontend/src/angular/src/app/image-query/image-query.component.scss b/frontend/src/angular/src/app/image-query/image-query.component.scss index 4a0d093..51dae1a 100644 --- a/frontend/src/angular/src/app/image-query/image-query.component.scss +++ b/frontend/src/angular/src/app/image-query/image-query.component.scss @@ -10,7 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ - .toolbar-content { +.toolbar-content { display: flex; align-items: center; justify-content: center; @@ -28,7 +28,7 @@ width: 100%; } .vertical-margin { - margin: 20px 10px; + margin: 20px 10px; } .search-bar { display: flex; @@ -36,8 +36,7 @@ align-items: center; } - - .example-full-width { +.example-full-width { width: 100%; } @@ -49,20 +48,20 @@ } .auto-margin { - margin: auto; - text-align: center; + margin: auto; + text-align: center; } .horizontal-container { - display: flex; + display: flex; } .images { - margin-top: 20px; - overflow-y: scroll; - height: calc(100vh - (36px + 21px + 64px)); + margin-top: 20px; + overflow-y: scroll; + height: calc(100vh - (36px + 21px + 64px)); } .my-button { - margin-left: 10px; -} \ No newline at end of file + margin-left: 10px; +} diff --git a/frontend/src/angular/src/app/image-query/image-query.component.spec.ts b/frontend/src/angular/src/app/image-query/image-query.component.spec.ts index d23df31..4ab7d7b 100644 --- a/frontend/src/angular/src/app/image-query/image-query.component.spec.ts +++ b/frontend/src/angular/src/app/image-query/image-query.component.spec.ts @@ -34,4 +34,4 @@ describe('ImageQueryComponent', () => { expect(component).toBeTruthy(); }); }); -*/ \ No newline at end of file +*/ diff --git a/frontend/src/angular/src/app/image-query/image-query.component.ts b/frontend/src/angular/src/app/image-query/image-query.component.ts index ce0b5e1..52fba81 100644 --- a/frontend/src/angular/src/app/image-query/image-query.component.ts +++ b/frontend/src/angular/src/app/image-query/image-query.component.ts @@ -13,98 +13,137 @@ import { Component, DestroyRef } from '@angular/core'; import { CommonModule } from '@angular/common'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; -import {MatInputModule} from '@angular/material/input'; +import { MatInputModule } from '@angular/material/input'; import { MatButtonModule } from '@angular/material/button'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { Subscription, interval, map, tap } from 'rxjs'; import { ImageService } from '../service/image.service'; import { ImageFile } from '../model/image-file'; -import { FormControl, FormGroup, Validators, ReactiveFormsModule } from '@angular/forms'; +import { + FormControl, + FormGroup, + Validators, + ReactiveFormsModule, +} from '@angular/forms'; import { Router } from '@angular/router'; import { MatToolbarModule } from '@angular/material/toolbar'; @Component({ selector: 'app-image-query', standalone: true, - imports: [CommonModule, MatProgressSpinnerModule, MatInputModule,MatButtonModule,ReactiveFormsModule,MatToolbarModule], + imports: [ + CommonModule, + MatProgressSpinnerModule, + MatInputModule, + MatButtonModule, + ReactiveFormsModule, + MatToolbarModule, + ], templateUrl: './image-query.component.html', - styleUrl: './image-query.component.scss' + styleUrl: './image-query.component.scss', }) export class ImageQueryComponent { //'What do you see in the image? Describe the background. Describe the colors.' protected imageForm = new FormGroup({ - file: new FormControl(null, Validators.required), - prompt: new FormControl('What do you see in the image? Describe the background. Describe the colors.', Validators.compose([Validators.required, Validators.minLength(3)])) + file: new FormControl(null, Validators.required), + prompt: new FormControl( + 'What do you see in the image? Describe the background. Describe the colors.', + Validators.compose([Validators.required, Validators.minLength(3)]) + ), }); - protected queryControl = new FormControl('', Validators.compose([Validators.required, Validators.minLength(3)])); + protected queryControl = new FormControl( + '', + Validators.compose([Validators.required, Validators.minLength(3)]) + ); protected uploading = false; protected result: ImageFile | null = null; protected results: ImageFile[] = []; protected msWorking = 0; protected uiMode: 'upload' | 'query' = 'upload'; - private repeatSub: Subscription | null = null; - - constructor(private imageService: ImageService, private destroyRef: DestroyRef, private router: Router) { } - + private repeatSub: Subscription | null = null; + + constructor( + private imageService: ImageService, + private destroyRef: DestroyRef, + private router: Router + ) {} + protected onFileInputChange($event: Event): void { - this.result = null; + this.result = null; const files = !$event.target ? null : ($event.target as HTMLInputElement).files; - this.imageForm.controls.file.setValue(!!files && files.length > 0 ? files[0] : null); + this.imageForm.controls.file.setValue( + !!files && files.length > 0 ? files[0] : null + ); } - + protected createImageUrl(myResult: ImageFile): ImageFile { - if(!!myResult) { - myResult.b64Image = 'data:image/'+myResult?.imageType+';base64,'+myResult?.b64Image; - } - return myResult + if (!!myResult) { + myResult.b64Image = + 'data:image/' + myResult?.imageType + ';base64,' + myResult?.b64Image; + } + return myResult; } - + protected switchToUpload(): void { - this.uiMode = 'upload'; + this.uiMode = 'upload'; } - + protected switchToQuery(): void { - this.uiMode = 'query'; + this.uiMode = 'query'; } - - protected query(): void { - //console.log(this.queryControl.invalid); - //console.log(this.queryControl.untouched); - const formData = new FormData(); - formData.append('query', this.queryControl.value as unknown as string); - formData.append('type', ''); - this.imageService.postQueryForm(formData).subscribe(myResults => this.results = myResults.map(myResult => myResult = this.createImageUrl(myResult))); + + protected query(): void { + //console.log(this.queryControl.invalid); + //console.log(this.queryControl.untouched); + const formData = new FormData(); + formData.append('query', this.queryControl.value as unknown as string); + formData.append('type', ''); + this.imageService + .postQueryForm(formData) + .subscribe( + (myResults) => + (this.results = myResults.map( + (myResult) => (myResult = this.createImageUrl(myResult)) + )) + ); } - + protected upload(): void { //console.log(this.file); if (!!this.imageForm.controls.file.value) { - const startDate = new Date(); - this.msWorking = 0; - this.result = null; - this.uploading = true; - this.repeatSub?.unsubscribe(); + const startDate = new Date(); + this.msWorking = 0; + this.result = null; + this.uploading = true; + this.repeatSub?.unsubscribe(); this.repeatSub = interval(100) - .pipe( - map(() => new Date()), - takeUntilDestroyed(this.destroyRef) - ) - .subscribe( - (newDate) => (this.msWorking = newDate.getTime() - startDate.getTime()) - ); + .pipe( + map(() => new Date()), + takeUntilDestroyed(this.destroyRef) + ) + .subscribe( + (newDate) => + (this.msWorking = newDate.getTime() - startDate.getTime()) + ); const formData = new FormData(); const myFile = this.imageForm.controls.file.value; formData.append('file', myFile as Blob, myFile?.name as string); - formData.append('query', this.imageForm.controls.prompt.value as unknown as string); - formData.append('type', (this.imageForm.controls.file.value as unknown as File)?.type); + formData.append( + 'query', + this.imageForm.controls.prompt.value as unknown as string + ); + formData.append( + 'type', + (this.imageForm.controls.file.value as unknown as File)?.type + ); //console.log(formData); //console.log(this.imageForm.controls.file.value); //console.log(this.imageForm.controls.query.value); this.imageService .postImageForm(formData) - .pipe( + .pipe( tap(() => { this.uploading = true; }), @@ -116,16 +155,16 @@ export class ImageQueryComponent { this.imageForm.controls.file.setValue(null); //console.log(result); }); - } else if(!this.uploading && !!this.result) { - this.result = null; - } + } else if (!this.uploading && !!this.result) { + this.result = null; + } + } + + protected showList(): void { + this.router.navigate(['/doclist']); } - - protected showList(): void { - this.router.navigate(['/doclist']); - } - + protected logout(): void { - console.log('logout'); + console.log('logout'); } } diff --git a/frontend/src/angular/src/app/image-query/image-query.routes.ts b/frontend/src/angular/src/app/image-query/image-query.routes.ts index 5b9ae41..3a9e5eb 100644 --- a/frontend/src/angular/src/app/image-query/image-query.routes.ts +++ b/frontend/src/angular/src/app/image-query/image-query.routes.ts @@ -13,11 +13,10 @@ import { Routes } from '@angular/router'; import { ImageQueryComponent } from './image-query.component'; - export const IMAGEQUERY: Routes = [ { path: '', component: ImageQueryComponent, }, { path: '**', redirectTo: '' }, -]; \ No newline at end of file +]; diff --git a/frontend/src/angular/src/app/image-query/index.ts b/frontend/src/angular/src/app/image-query/index.ts index 845bf4f..927ee1b 100644 --- a/frontend/src/angular/src/app/image-query/index.ts +++ b/frontend/src/angular/src/app/image-query/index.ts @@ -10,4 +10,4 @@ See the License for the specific language governing permissions and limitations under the License. */ -export * from './image-query.routes'; \ No newline at end of file +export * from './image-query.routes'; diff --git a/frontend/src/angular/src/app/model/functions.ts b/frontend/src/angular/src/app/model/functions.ts index db842ce..c9103f4 100644 --- a/frontend/src/angular/src/app/model/functions.ts +++ b/frontend/src/angular/src/app/model/functions.ts @@ -11,27 +11,27 @@ limitations under the License. */ export interface FunctionSearch { - question: string; + question: string; resultAmount: number; } export interface Book { - title: string; - type: string; - author_name: string[]; - language: string[]; - publish_date: string[]; - publisher: string[]; - subject: string[]; - place: string[]; - time: string[]; - person: string[]; - ratings_average: number; + title: string; + type: string; + author_name: string[]; + language: string[]; + publish_date: string[]; + publisher: string[]; + subject: string[]; + place: string[]; + time: string[]; + person: string[]; + ratings_average: number; } export interface FunctionResponse { - numFound: number; - start: number; - numFoundExact: boolean; - docs: Book[]; -} \ No newline at end of file + numFound: number; + start: number; + numFoundExact: boolean; + docs: Book[]; +} diff --git a/frontend/src/angular/src/app/model/image-file.ts b/frontend/src/angular/src/app/model/image-file.ts index 4b1f232..fbd54c0 100644 --- a/frontend/src/angular/src/app/model/image-file.ts +++ b/frontend/src/angular/src/app/model/image-file.ts @@ -10,10 +10,15 @@ See the License for the specific language governing permissions and limitations under the License. */ -export enum ImageType {JPEG='jpg', PNG='png', SVG='svg', UNKNOWN='unknown'} +export enum ImageType { + JPEG = 'jpg', + PNG = 'png', + SVG = 'svg', + UNKNOWN = 'unknown', +} export interface ImageFile { - answer: string; - b64Image: string; - imageType: ImageType; -} \ No newline at end of file + answer: string; + b64Image: string; + imageType: ImageType; +} diff --git a/frontend/src/angular/src/app/service/function-search.service.spec.ts b/frontend/src/angular/src/app/service/function-search.service.spec.ts index 39df652..48c499a 100644 --- a/frontend/src/angular/src/app/service/function-search.service.spec.ts +++ b/frontend/src/angular/src/app/service/function-search.service.spec.ts @@ -27,4 +27,4 @@ describe('FunctionSearchService', () => { expect(service).toBeTruthy(); }); }); -*/ \ No newline at end of file +*/ diff --git a/frontend/src/angular/src/app/service/function-search.service.ts b/frontend/src/angular/src/app/service/function-search.service.ts index b4a934f..11d1654 100644 --- a/frontend/src/angular/src/app/service/function-search.service.ts +++ b/frontend/src/angular/src/app/service/function-search.service.ts @@ -16,13 +16,17 @@ import { Observable } from 'rxjs'; import { FunctionResponse, FunctionSearch } from '../model/functions'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class FunctionSearchService { + constructor(private httpClient: HttpClient) {} - constructor(private httpClient: HttpClient) { } - - postLibraryFunction(functionSearch: FunctionSearch): Observable { - return this.httpClient.post('/rest/function/books', functionSearch); + postLibraryFunction( + functionSearch: FunctionSearch + ): Observable { + return this.httpClient.post( + '/rest/function/books', + functionSearch + ); } } diff --git a/frontend/src/angular/src/app/service/image.service.spec.ts b/frontend/src/angular/src/app/service/image.service.spec.ts index f1a2f47..38923f7 100644 --- a/frontend/src/angular/src/app/service/image.service.spec.ts +++ b/frontend/src/angular/src/app/service/image.service.spec.ts @@ -12,7 +12,6 @@ */ import { TestBed } from '@angular/core/testing'; - import { ImageService } from './image.service'; /* describe('ImageService', () => { @@ -27,4 +26,4 @@ describe('ImageService', () => { expect(service).toBeTruthy(); }); }); -*/ \ No newline at end of file +*/ diff --git a/frontend/src/angular/src/app/service/image.service.ts b/frontend/src/angular/src/app/service/image.service.ts index c13f7c5..e36db83 100644 --- a/frontend/src/angular/src/app/service/image.service.ts +++ b/frontend/src/angular/src/app/service/image.service.ts @@ -16,17 +16,16 @@ import { Observable } from 'rxjs'; import { ImageFile } from '../model/image-file'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class ImageService { + constructor(private httpClient: HttpClient) {} - constructor(private httpClient: HttpClient) { } - - public postImageForm(formData: FormData): Observable { + public postImageForm(formData: FormData): Observable { return this.httpClient.post('/rest/image/import', formData); } - + public postQueryForm(formData: FormData): Observable { - return this.httpClient.post('/rest/image/query', formData); + return this.httpClient.post('/rest/image/query', formData); } } diff --git a/frontend/src/angular/src/app/table-search/table-search.component.ts b/frontend/src/angular/src/app/table-search/table-search.component.ts index feec472..4d405c2 100644 --- a/frontend/src/angular/src/app/table-search/table-search.component.ts +++ b/frontend/src/angular/src/app/table-search/table-search.component.ts @@ -121,8 +121,11 @@ export class TableSearchComponent { //this.importing = !this.importing; this.tableService .getDataImport() - .pipe(tap(() => this.importing = true)) - .subscribe({next: (result) => (this.importing = !result), error: (ex) => this.importing = false}); + .pipe(tap(() => (this.importing = true))) + .subscribe({ + next: (result) => (this.importing = !result), + error: (ex) => (this.importing = false), + }); //console.log('importData'); }