Skip to content

Commit 6bdca1c

Browse files
committed
feat: show json
1 parent 6b93638 commit 6bdca1c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
</div>
6161
</div>
6262
} @else {
63-
<p class="result-text">{{responseText}}</p>
63+
<p *ngIf="!!responseText" class="result-text">{{responseText}}</p>
64+
<p *ngIf="!!responseJson?.author" class="result-text">{{responseJson | json}}</p>
6465
<!--
6566
<mat-tree
6667
[dataSource]="dataSource"

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
Validators,
2727
} from '@angular/forms';
2828
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
29-
import { Book, FunctionResponse, FunctionSearch } from '../model/functions';
29+
import { Book, FunctionResponse, FunctionSearch, JsonResult } from '../model/functions';
3030
import { FunctionSearchService } from '../service/function-search.service';
3131
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
3232
import { Subscription, interval, map, tap } from 'rxjs';
@@ -71,6 +71,7 @@ export class FunctionSearchComponent {
7171
);
7272
protected dataSource = new MatTreeNestedDataSource<TreeNode>();
7373
protected responseText = '';
74+
protected responseJson = {author: "", books: []} as JsonResult;
7475
protected resultFormats = ['text','json'];
7576
protected resultFormatControl = new FormControl(this.resultFormats[0]);
7677

@@ -110,9 +111,9 @@ export class FunctionSearchComponent {
110111
takeUntilDestroyed(this.destroyRef),
111112
tap(() => (this.searching = false))
112113
)
113-
.subscribe(value => this.responseText = value.result ?? ''
114+
.subscribe(value => this.resultFormatControl.value === this.resultFormats[0] ?
115+
this.responseText = value.result || '' : this.responseJson = value.jsonResult || this.responseJson
114116
);
115-
//.subscribe((value) => (this.dataSource.data = this.mapResult(value)));
116117
}
117118

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

0 commit comments

Comments
 (0)