Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: global search, keyboard shortcuts / hotkey support #6449

Merged
merged 61 commits into from May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
b7a0c0e
Basic global search api endpoint
shamoon Mar 29, 2024
5fdda05
Move serializer
shamoon Apr 7, 2024
4c976bf
Initial frontend global search
shamoon Mar 30, 2024
eaecac0
Global search UI improvements, coverage
shamoon Mar 31, 2024
9004000
Add basic object perms for global search
shamoon Mar 31, 2024
6e6454e
Respect model perms for global search
shamoon Apr 1, 2024
ed10c7e
Re-add search icon
shamoon Apr 1, 2024
2653985
Select button instead of dropdown-item
shamoon Apr 1, 2024
7a73ce8
Nice button transitions
shamoon Apr 1, 2024
7737b24
Better hover & keyboard interaction
shamoon Apr 1, 2024
f8d4877
Loading indicator, hide shortcut key on focus
shamoon Apr 1, 2024
9113d71
Show document date
shamoon Apr 2, 2024
8faf449
Fix keyboard nav inside search input
shamoon Apr 2, 2024
23b2b77
Fix colors / transitions
shamoon Apr 2, 2024
c52bf34
Test fixes
shamoon Apr 2, 2024
9f7f5ca
Fix cases when dom order differs from querylist
shamoon Apr 2, 2024
ddc6be0
Adjust search form container sizing
shamoon Apr 2, 2024
0460e12
Color tweaks
shamoon Apr 3, 2024
6447d08
Disable action buttons if user have perms
shamoon Apr 3, 2024
117b0b4
Toasts for edit dialogs
shamoon Apr 3, 2024
8cbb15b
Proper data type enum
shamoon Apr 3, 2024
008c786
Fix tag filter type
shamoon Apr 3, 2024
5d22fc7
circular keyboard navigation, fix with no results
shamoon Apr 3, 2024
2f21046
Add missing mail rules & accounts
shamoon Apr 3, 2024
500699d
Fix user / group permissions label
shamoon Apr 3, 2024
da08a87
Fix keyup vs down bug
shamoon Apr 3, 2024
0bee478
Disable search input spellcheck
shamoon Apr 3, 2024
4ee76f4
Search document titles first
shamoon Apr 4, 2024
5bb577a
Hotkey service
shamoon Apr 5, 2024
2a81816
Add hotkey help dialog, auto-meta key for macOS
shamoon Apr 5, 2024
9d28183
Add some app keyboard shortcuts
shamoon Apr 5, 2024
8919482
Blur search field on escape if empty
shamoon Apr 5, 2024
6315758
Blur filter editor on escape when empty
shamoon Apr 5, 2024
097566e
Changed my mind about shortcut keys
shamoon Apr 5, 2024
f189da2
Basic shortcuts for filter editor, blur input on esc empty
shamoon Apr 5, 2024
a0f9e99
Blur search field on click first entry
shamoon Apr 5, 2024
478b6e6
Add settings shortcut
shamoon Apr 6, 2024
e9b4404
Add back autocomplete to filter editor, where it belongs
shamoon Apr 6, 2024
f643938
Only reset on escape if filtered
shamoon Apr 7, 2024
57b129d
Add select page shortcut key
shamoon Apr 7, 2024
ae5639c
Color fix
shamoon Apr 7, 2024
1f25d7a
Only reset selection / filters if no menus open
shamoon Apr 8, 2024
26ec011
Revert "Only reset selection / filters if no menus open"
shamoon Apr 8, 2024
53e5f72
Do the filtering of reset / clear selection in one line
shamoon Apr 8, 2024
c7a1b5b
Support opening selected document
shamoon Apr 8, 2024
a72adb0
Add shortcut keys for filters
shamoon Apr 8, 2024
00cfea7
Trim search queries
shamoon Apr 9, 2024
8d7ee4c
Allow disabling advanced search in global search
shamoon Apr 10, 2024
0549579
Re-open dropdown on enter if just closed
shamoon Apr 15, 2024
314e34c
Include saved views in global search
shamoon Apr 19, 2024
3eaaa56
Complete coverage
shamoon Apr 19, 2024
f4f9b18
Add docs
shamoon Apr 20, 2024
b4dc218
Fix translation files from merge
shamoon Apr 25, 2024
03438e2
Merge branch 'dev' into feature-global-search
shamoon Apr 26, 2024
12be856
Fix translation strings from merge
shamoon Apr 26, 2024
b9dd89e
Merge branch 'dev' into feature-global-search
shamoon Apr 26, 2024
9972e26
Add link for advanced search if helpful
shamoon Apr 28, 2024
6d78930
Merge branch 'dev' into feature-global-search
shamoon Apr 30, 2024
4877a8e
Merge branch 'dev' into feature-global-search
shamoon May 2, 2024
05b4ba5
Update messages.xlf
shamoon May 2, 2024
75578ef
Merge branch 'dev' into feature-global-search
shamoon May 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 34 additions & 1 deletion docs/api.md
Expand Up @@ -11,7 +11,7 @@ The API provides the following main endpoints:
- `/api/correspondents/`: Full CRUD support.
- `/api/custom_fields/`: Full CRUD support.
- `/api/documents/`: Full CRUD support, except POSTing new documents.
See below.
See [below](#posting-documents-file-uploads).
- `/api/document_types/`: Full CRUD support.
- `/api/groups/`: Full CRUD support.
- `/api/logs/`: Read-Only.
Expand All @@ -24,6 +24,7 @@ The API provides the following main endpoints:
- `/api/tasks/`: Read-only.
- `/api/users/`: Full CRUD support.
- `/api/workflows/`: Full CRUD support.
- `/api/search/` GET, see [below](#global-search).

All of these endpoints except for the logging endpoint allow you to
fetch (and edit and delete where appropriate) individual objects by
Expand Down Expand Up @@ -188,6 +189,38 @@ The REST api provides four different forms of authentication.
[configuration](configuration.md#PAPERLESS_ENABLE_HTTP_REMOTE_USER_API)),
you can authenticate against the API using Remote User auth.

## Global search

A global search endpoint is available at `/api/search/` and requires a search term
of > 2 characters e.g. `?query=foo`. This endpoint returns a maximum of 3 results
across nearly all objects, e.g. documents, tags, saved views, mail rules, etc.
Results are only included if the requesting user has the appropriate permissions.

Results are returned in the following format:

```json
{
total: number
documents: []
saved_views: []
correspondents: []
document_types: []
storage_paths: []
tags: []
users: []
groups: []
mail_accounts: []
mail_rules: []
custom_fields: []
workflows: []
}
```

Global search first searches objects by name (or title for documents) matching the query.
If the optional `db_only` parameter is set, only document titles will be searched. Otherwise,
if the amount of documents returned by a simple title string search is < 3, results from the
search index will also be included.

## Searching for documents

Full text searching is available on the `/api/documents/` endpoint. Two
Expand Down
16 changes: 16 additions & 0 deletions docs/usage.md
Expand Up @@ -550,6 +550,16 @@ collection.

## Searching {#basic-usage_searching}

### Global search

The top search bar in the web UI performs a "global" search of the various
objects Paperless-ngx uses, including documents, tags, workflows, etc. Only
objects for which the user has appropriate permissions are returned. For
documents, if there are < 3 results, "advanced" search results (which use
the document index) will also be included. This can be disabled under settings.

### Document searches

Paperless offers an extensive searching mechanism that is designed to
allow you to quickly find a document you're looking for (for example,
that thing that just broke and you bought a couple months ago, that
Expand Down Expand Up @@ -605,6 +615,12 @@ language](https://whoosh.readthedocs.io/en/latest/querylang.html). For
details on what date parsing utilities are available, see [Date
parsing](https://whoosh.readthedocs.io/en/latest/dates.html#parsing-date-queries).

## Keyboard shortcuts / hotkeys

A list of available hotkeys can be shown on any page using <kbd>Shift</kbd> +
<kbd>?</kbd>. The help dialog shows only the keys that are currently available
based on which area of Paperless-ngx you are using.

## The recommended workflow {#usage-recommended-workflow}

Once you have familiarized yourself with paperless and are ready to use
Expand Down
10 changes: 5 additions & 5 deletions src-ui/e2e/document-list/document-list.spec.ts
Expand Up @@ -45,8 +45,8 @@ test('basic filtering', async ({ page }) => {
test('text filtering', async ({ page }) => {
await page.routeFromHAR(REQUESTS_HAR2, { notFound: 'fallback' })
await page.goto('/documents')
await page.getByRole('textbox').click()
await page.getByRole('textbox').fill('test')
await page.getByRole('main').getByRole('combobox').click()
await page.getByRole('main').getByRole('combobox').fill('test')
await expect(page.locator('pngx-document-list')).toHaveText(/32 documents/)
await expect(page).toHaveURL(/title_content=test/)
await page.getByRole('button', { name: 'Title & content' }).click()
Expand All @@ -59,12 +59,12 @@ test('text filtering', async ({ page }) => {
await expect(page.locator('pngx-document-list')).toHaveText(/26 documents/)
await page.getByRole('button', { name: 'Advanced search' }).click()
await page.getByRole('button', { name: 'ASN' }).click()
await page.getByRole('textbox').fill('1123')
await page.getByRole('main').getByRole('combobox').nth(1).fill('1123')
await expect(page).toHaveURL(/archive_serial_number=1123/)
await expect(page.locator('pngx-document-list')).toHaveText(/one document/i)
await page.locator('select').selectOption('greater')
await page.getByRole('textbox').click()
await page.getByRole('textbox').fill('1123')
await page.getByRole('main').getByRole('combobox').nth(1).click()
await page.getByRole('main').getByRole('combobox').nth(1).fill('1123')
await expect(page).toHaveURL(/archive_serial_number__gt=1123/)
await expect(page.locator('pngx-document-list')).toHaveText(/5 documents/)
await page.locator('select').selectOption('less')
Expand Down