Revize 5da39206
Přidáno uživatelem castic96 před asi 4 roky(ů)
fe/fulltextsearch/src/app/components/shared-components/search-box/search-box.component.ts | ||
---|---|---|
1 |
import { Component, OnInit } from '@angular/core';
|
|
1 |
import {Component, OnDestroy, OnInit} from '@angular/core';
|
|
2 | 2 |
import { SearchRequest } from '../../../model/SearchRequest'; |
3 | 3 |
import { QueryService } from '../../../services/query.service'; |
4 | 4 |
import { Router } from '@angular/router'; |
5 |
import { DataHolderService } from '../../../services/data-holder/data-holder.service'; |
|
6 |
import {SearchComponent} from '../../pages/search/search.component'; |
|
7 |
import {Subscription} from 'rxjs'; |
|
5 | 8 |
|
6 | 9 |
@Component({ |
7 | 10 |
selector: 'app-search-box', |
8 | 11 |
templateUrl: './search-box.component.html', |
9 | 12 |
styleUrls: ['./search-box.component.css'] |
10 | 13 |
}) |
11 |
export class SearchBoxComponent implements OnInit { |
|
14 |
export class SearchBoxComponent implements OnInit, OnDestroy {
|
|
12 | 15 |
expression: string; |
16 |
private queryServiceSubscription$: Subscription; |
|
13 | 17 |
|
14 |
|
|
15 |
constructor(private queryService: QueryService, private router: Router) { } |
|
18 |
constructor(private queryService: QueryService, private router: Router, private dataHolderService: DataHolderService) { } |
|
16 | 19 |
|
17 | 20 |
ngOnInit(): void { |
18 | 21 |
} |
19 | 22 |
|
20 | 23 |
onSubmit() { |
21 | 24 |
const searchRequest: SearchRequest = new SearchRequest(this.expression, new Date()); |
25 |
console.log('odeslano: ' + JSON.stringify(searchRequest)); |
|
22 | 26 |
|
23 |
//TODO: naimplementovat searchPost |
|
24 |
/* |
|
25 |
this.queryService.searchPost(searchRequest).subscribe (() => { |
|
26 |
//TODO: ulozit objekt SearchResponse[] |
|
27 |
|
|
28 |
this.router.navigate(['/search']); |
|
27 |
this.queryServiceSubscription$ = this.queryService.searchPost(searchRequest).subscribe (data => { |
|
28 |
this.dataHolderService.setData(data); |
|
29 |
if (this.router.url === '/') { |
|
30 |
this.router.navigate(['/search']); |
|
31 |
} |
|
29 | 32 |
}); |
30 |
*/ |
|
33 |
} |
|
34 |
|
|
35 |
ngOnDestroy(): void { |
|
36 |
this.queryServiceSubscription$.unsubscribe(); |
|
31 | 37 |
} |
32 | 38 |
} |
Také k dispozici: Unified diff
Re #7801: Přesměrování na search page s response
- přesměrování na /search
- oprava BE
- vykreslení dokumentů z BE