diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e1a979..2c9cf73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ * Preserve state after switching to another tab (#56). * Find view: ask for confirmation before negligently deleting documents when the user has clicked the '-' button (#58). * Build script recreates the build output directory after it has been removed (#62). - +* Set a deadline for counting documents, and added a button to count documents if the deadline has been exceeded. ## [v0.2.2] * Added Excel export format (#46). diff --git a/frontend/src/organisms/connection/collection/find.svelte b/frontend/src/organisms/connection/collection/find.svelte index 2df4e68..0034c6c 100644 --- a/frontend/src/organisms/connection/collection/find.svelte +++ b/frontend/src/organisms/connection/collection/find.svelte @@ -10,7 +10,7 @@ import applicationSettings from '$lib/stores/settings'; import views from '$lib/stores/views'; import { convertLooseJson, stringCouldBeID } from '$lib/strings'; - import { FindItems, RemoveItemById, UpdateFoundDocument } from '$wails/go/app/App'; + import { CountItems, FindItems, RemoveItemById, UpdateFoundDocument } from '$wails/go/app/App'; import { EJSON } from 'bson'; export let collection; @@ -26,11 +26,13 @@ let form = { ...defaults }; let result = {}; + let countResult = {}; let submittedForm = {}; let queryField; let activePath = []; let objectViewerData; let querying = false; + let counting = false; let objectViewerSuccessMessage = ''; let viewsForCollection = {}; @@ -71,6 +73,17 @@ querying = false; } + async function countItems() { + counting = true; + countResult = await CountItems( + collection.hostKey, + collection.dbKey, + collection.key, + convertLooseJson(form.query) || defaults.query + ); + counting = false; + } + async function refresh() { if ($applicationSettings.autosubmitQuery) { await submitQuery(); @@ -290,11 +303,26 @@
-
- {#key result} - Results: {result.total || 0} - {/key} +
+ {#if counting} + Counting items… + {:else if countResult?.error} + {countResult.error} + {:else if countResult?.total === -1} + Something went wrong + {:else if countResult?.total} + + Results: {countResult.total} + {:else if result?.total === -1} + + Count items + {:else if result?.total} + {#key result} + Results: {result.total || 0} + {/key} + {/if}
+