mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
infinite scroll for search results
This commit is contained in:
@@ -2,27 +2,9 @@ import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PaperlessDocument } from 'src/app/data/paperless-document';
|
||||
import { SearchResult } from 'src/app/data/search-result';
|
||||
import { environment } from 'src/environments/environment';
|
||||
|
||||
export class SearchResultHighlightedText {
|
||||
text?: string
|
||||
term?: number
|
||||
|
||||
toString(): string {
|
||||
return this.text
|
||||
}
|
||||
}
|
||||
|
||||
export class SearchResult {
|
||||
id?: number
|
||||
title?: string
|
||||
content?: string
|
||||
|
||||
score?: number
|
||||
highlights?: SearchResultHighlightedText[][]
|
||||
|
||||
document?: PaperlessDocument
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -31,8 +13,12 @@ export class SearchService {
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
search(query: string): Observable<SearchResult[]> {
|
||||
return this.http.get<SearchResult[]>(`${environment.apiBaseUrl}search/`, {params: new HttpParams().set('query', query)})
|
||||
search(query: string, page?: number): Observable<SearchResult> {
|
||||
let httpParams = new HttpParams().set('query', query)
|
||||
if (page) {
|
||||
httpParams = httpParams.set('page', page.toString())
|
||||
}
|
||||
return this.http.get<SearchResult>(`${environment.apiBaseUrl}search/`, {params: httpParams})
|
||||
}
|
||||
|
||||
autocomplete(term: string): Observable<string[]> {
|
||||
|
Reference in New Issue
Block a user