mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
lots of changes for the new unified search
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { Route } from '@angular/compiler/src/core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { cloneFilterRules, FilterRule } from '../data/filter-rule';
|
||||
import { FILTER_FULLTEXT_MORELIKE, FILTER_FULLTEXT_QUERY } from '../data/filter-rule-type';
|
||||
import { PaperlessDocument } from '../data/paperless-document';
|
||||
import { PaperlessSavedView } from '../data/paperless-saved-view';
|
||||
import { DOCUMENT_LIST_SERVICE } from '../data/storage-keys';
|
||||
@@ -207,7 +209,11 @@ export class DocumentListViewService {
|
||||
this.activeListViewState.currentPage = 1
|
||||
this.reduceSelectionToFilter()
|
||||
this.saveDocumentListView()
|
||||
this.router.navigate(["documents"])
|
||||
if (this.router.url == "/documents") {
|
||||
this.reload()
|
||||
} else {
|
||||
this.router.navigate(["documents"])
|
||||
}
|
||||
}
|
||||
|
||||
getLastPage(): number {
|
||||
@@ -317,7 +323,7 @@ export class DocumentListViewService {
|
||||
return this.documents.map(d => d.id).indexOf(documentID)
|
||||
}
|
||||
|
||||
constructor(private documentService: DocumentService, private settings: SettingsService, private router: Router) {
|
||||
constructor(private documentService: DocumentService, private settings: SettingsService, private router: Router, private route: ActivatedRoute) {
|
||||
let documentListViewConfigJson = sessionStorage.getItem(DOCUMENT_LIST_SERVICE.CURRENT_VIEW_CONFIG)
|
||||
if (documentListViewConfigJson) {
|
||||
try {
|
||||
|
@@ -2,8 +2,6 @@ import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { PaperlessDocument } from 'src/app/data/paperless-document';
|
||||
import { SearchResult } from 'src/app/data/search-result';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { DocumentService } from './document.service';
|
||||
|
||||
@@ -13,30 +11,7 @@ import { DocumentService } from './document.service';
|
||||
})
|
||||
export class SearchService {
|
||||
|
||||
constructor(private http: HttpClient, private documentService: DocumentService) { }
|
||||
|
||||
search(query: string, page?: number, more_like?: number): Observable<SearchResult> {
|
||||
let httpParams = new HttpParams()
|
||||
if (query) {
|
||||
httpParams = httpParams.set('query', query)
|
||||
}
|
||||
if (page) {
|
||||
httpParams = httpParams.set('page', page.toString())
|
||||
}
|
||||
if (more_like) {
|
||||
httpParams = httpParams.set('more_like', more_like.toString())
|
||||
}
|
||||
return this.http.get<SearchResult>(`${environment.apiBaseUrl}search/`, {params: httpParams}).pipe(
|
||||
map(result => {
|
||||
result.results.forEach(hit => {
|
||||
if (hit.document) {
|
||||
this.documentService.addObservablesToDocument(hit.document)
|
||||
}
|
||||
})
|
||||
return result
|
||||
})
|
||||
)
|
||||
}
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
autocomplete(term: string): Observable<string[]> {
|
||||
return this.http.get<string[]>(`${environment.apiBaseUrl}search/autocomplete/`, {params: new HttpParams().set('term', term)})
|
||||
|
Reference in New Issue
Block a user