mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	Suppport search term PDF open parameter
This commit is contained in:
		@@ -11,6 +11,7 @@ import { FilterRule } from 'src/app/data/filter-rule';
 | 
				
			|||||||
import { FILTER_ADDED_AFTER, FILTER_ADDED_BEFORE, FILTER_ASN, FILTER_CORRESPONDENT, FILTER_CREATED_AFTER, FILTER_CREATED_BEFORE, FILTER_DOCUMENT_TYPE, FILTER_HAS_ANY_TAG, FILTER_HAS_TAG, FILTER_TITLE, FILTER_TITLE_CONTENT } from 'src/app/data/filter-rule-type';
 | 
					import { FILTER_ADDED_AFTER, FILTER_ADDED_BEFORE, FILTER_ASN, FILTER_CORRESPONDENT, FILTER_CREATED_AFTER, FILTER_CREATED_BEFORE, FILTER_DOCUMENT_TYPE, FILTER_HAS_ANY_TAG, FILTER_HAS_TAG, FILTER_TITLE, FILTER_TITLE_CONTENT } from 'src/app/data/filter-rule-type';
 | 
				
			||||||
import { FilterableDropdownSelectionModel } from '../../common/filterable-dropdown/filterable-dropdown.component';
 | 
					import { FilterableDropdownSelectionModel } from '../../common/filterable-dropdown/filterable-dropdown.component';
 | 
				
			||||||
import { ToggleableItemState } from '../../common/filterable-dropdown/toggleable-dropdown-button/toggleable-dropdown-button.component';
 | 
					import { ToggleableItemState } from '../../common/filterable-dropdown/toggleable-dropdown-button/toggleable-dropdown-button.component';
 | 
				
			||||||
 | 
					import { DocumentService } from 'src/app/services/rest/document.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const TEXT_FILTER_TARGET_TITLE = "title"
 | 
					const TEXT_FILTER_TARGET_TITLE = "title"
 | 
				
			||||||
const TEXT_FILTER_TARGET_TITLE_CONTENT = "title-content"
 | 
					const TEXT_FILTER_TARGET_TITLE_CONTENT = "title-content"
 | 
				
			||||||
@@ -64,7 +65,8 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
 | 
				
			|||||||
  constructor(
 | 
					  constructor(
 | 
				
			||||||
    private documentTypeService: DocumentTypeService,
 | 
					    private documentTypeService: DocumentTypeService,
 | 
				
			||||||
    private tagService: TagService,
 | 
					    private tagService: TagService,
 | 
				
			||||||
    private correspondentService: CorrespondentService
 | 
					    private correspondentService: CorrespondentService,
 | 
				
			||||||
 | 
					    private documentService: DocumentService
 | 
				
			||||||
  ) { }
 | 
					  ) { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  tags: PaperlessTag[] = []
 | 
					  tags: PaperlessTag[] = []
 | 
				
			||||||
@@ -223,6 +225,7 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
 | 
				
			|||||||
      distinctUntilChanged()
 | 
					      distinctUntilChanged()
 | 
				
			||||||
    ).subscribe(text => {
 | 
					    ).subscribe(text => {
 | 
				
			||||||
      this._textFilter = text
 | 
					      this._textFilter = text
 | 
				
			||||||
 | 
					      this.documentService.setSearchQuery(text)
 | 
				
			||||||
      this.updateRules()
 | 
					      this.updateRules()
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,7 @@ import { DocumentTypeService } from './document-type.service';
 | 
				
			|||||||
import { TagService } from './tag.service';
 | 
					import { TagService } from './tag.service';
 | 
				
			||||||
import { FILTER_RULE_TYPES } from 'src/app/data/filter-rule-type';
 | 
					import { FILTER_RULE_TYPES } from 'src/app/data/filter-rule-type';
 | 
				
			||||||
import { PaperlessDocumentSuggestions } from 'src/app/data/paperless-document-suggestions';
 | 
					import { PaperlessDocumentSuggestions } from 'src/app/data/paperless-document-suggestions';
 | 
				
			||||||
 | 
					import { ActivatedRoute } from '@angular/router';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const DOCUMENT_SORT_FIELDS = [
 | 
					export const DOCUMENT_SORT_FIELDS = [
 | 
				
			||||||
  { field: 'archive_serial_number', name: $localize`ASN` },
 | 
					  { field: 'archive_serial_number', name: $localize`ASN` },
 | 
				
			||||||
@@ -39,8 +40,14 @@ export interface SelectionData {
 | 
				
			|||||||
})
 | 
					})
 | 
				
			||||||
export class DocumentService extends AbstractPaperlessService<PaperlessDocument> {
 | 
					export class DocumentService extends AbstractPaperlessService<PaperlessDocument> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(http: HttpClient, private correspondentService: CorrespondentService, private documentTypeService: DocumentTypeService, private tagService: TagService) {
 | 
					  private searchQuery: string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  constructor(http: HttpClient, private correspondentService: CorrespondentService, private documentTypeService: DocumentTypeService, private tagService: TagService, private route: ActivatedRoute) {
 | 
				
			||||||
    super(http, 'documents')
 | 
					    super(http, 'documents')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this.route.queryParamMap.subscribe(paramMap => {
 | 
				
			||||||
 | 
					      this.searchQuery = paramMap.get('query')
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private filterRulesToQueryParams(filterRules: FilterRule[]) {
 | 
					  private filterRulesToQueryParams(filterRules: FilterRule[]) {
 | 
				
			||||||
@@ -92,6 +99,7 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  getPreviewUrl(id: number, original: boolean = false): string {
 | 
					  getPreviewUrl(id: number, original: boolean = false): string {
 | 
				
			||||||
    let url = this.getResourceUrl(id, 'preview')
 | 
					    let url = this.getResourceUrl(id, 'preview')
 | 
				
			||||||
 | 
					    if (this.searchQuery) url += `#search="${this.searchQuery}"`
 | 
				
			||||||
    if (original) {
 | 
					    if (original) {
 | 
				
			||||||
      url += "?original=true"
 | 
					      url += "?original=true"
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -138,4 +146,8 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>
 | 
				
			|||||||
    return this.http.post(this.getResourceUrl(null, 'bulk_download'), {"documents": ids, "content": content}, { responseType: 'blob' })
 | 
					    return this.http.post(this.getResourceUrl(null, 'bulk_download'), {"documents": ids, "content": content}, { responseType: 'blob' })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public setSearchQuery(query: string) {
 | 
				
			||||||
 | 
					    this.searchQuery = query
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user