mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-06-28 05:25:11 +00:00
Added deadline for counting documents
Set a deadline for counting documents, and added a button to count documents if the deadline has been exceeded.
This commit is contained in:
@ -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 @@
|
||||
</div>
|
||||
|
||||
<div class="controls">
|
||||
<div>
|
||||
{#key result}
|
||||
<span class="flash-green">Results: {result.total || 0}</span>
|
||||
{/key}
|
||||
<div class="count">
|
||||
{#if counting}
|
||||
<span>Counting items…</span>
|
||||
{:else if countResult?.error}
|
||||
<span>{countResult.error}</span>
|
||||
{:else if countResult?.total === -1}
|
||||
<span>Something went wrong</span>
|
||||
{:else if countResult?.total}
|
||||
<!-- svelte-ignore a11y-invalid-attribute -->
|
||||
<a href="" on:click|preventDefault={countItems}>Results: {countResult.total}</a>
|
||||
{:else if result?.total === -1}
|
||||
<!-- svelte-ignore a11y-invalid-attribute -->
|
||||
<a href="" on:click|preventDefault={countItems}>Count items</a>
|
||||
{:else if result?.total}
|
||||
{#key result}
|
||||
<span class="flash-green">Results: {result.total || 0}</span>
|
||||
{/key}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="field inline">
|
||||
<select bind:value={collection.viewKey}>
|
||||
@ -388,4 +416,8 @@
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.count {
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
|
2
frontend/wailsjs/go/app/App.d.ts
generated
vendored
2
frontend/wailsjs/go/app/App.d.ts
generated
vendored
@ -12,6 +12,8 @@ export function Aggregate(arg1:string,arg2:string,arg3:string,arg4:string,arg5:s
|
||||
|
||||
export function AskConfirmation(arg1:string):Promise<boolean>;
|
||||
|
||||
export function CountItems(arg1:string,arg2:string,arg3:string,arg4:string):Promise<app.CountItemsResult>;
|
||||
|
||||
export function CreateIndex(arg1:string,arg2:string,arg3:string,arg4:string):Promise<string>;
|
||||
|
||||
export function DropCollection(arg1:string,arg2:string,arg3:string):Promise<boolean>;
|
||||
|
4
frontend/wailsjs/go/app/App.js
generated
4
frontend/wailsjs/go/app/App.js
generated
@ -14,6 +14,10 @@ export function AskConfirmation(arg1) {
|
||||
return window['go']['app']['App']['AskConfirmation'](arg1);
|
||||
}
|
||||
|
||||
export function CountItems(arg1, arg2, arg3, arg4) {
|
||||
return window['go']['app']['App']['CountItems'](arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
export function CreateIndex(arg1, arg2, arg3, arg4) {
|
||||
return window['go']['app']['App']['CreateIndex'](arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
Reference in New Issue
Block a user