add debounce for search

This commit is contained in:
Peter Clement 2023-02-23 14:33:15 +00:00
parent 163556ffb1
commit c1db2c0c3e
2 changed files with 12 additions and 3 deletions

View File

@ -27,6 +27,7 @@
import TimeRenderer from "./_components/TimeRenderer.svelte" import TimeRenderer from "./_components/TimeRenderer.svelte"
import AppColumnRenderer from "./_components/AppColumnRenderer.svelte" import AppColumnRenderer from "./_components/AppColumnRenderer.svelte"
import { cloneDeep } from "lodash" import { cloneDeep } from "lodash"
import { Utils } from "@budibase/frontend-core"
const schema = { const schema = {
date: { width: "0.8fr" }, date: { width: "0.8fr" },
@ -68,7 +69,7 @@
let selectedLog let selectedLog
let sidePanelVisible = false let sidePanelVisible = false
let wideSidePanel = false let wideSidePanel = false
let timer
let startDate = new Date() let startDate = new Date()
startDate.setDate(startDate.getDate() - 30) startDate.setDate(startDate.getDate() - 30)
let endDate = new Date() let endDate = new Date()
@ -89,6 +90,14 @@
$: enrichedList = enrich($users.data || [], selectedUsers) $: enrichedList = enrich($users.data || [], selectedUsers)
$: sortedList = sort(enrichedList) $: sortedList = sort(enrichedList)
const debounce = value => {
console.log(value)
clearTimeout(timer)
timer = setTimeout(() => {
logSearchTerm = value
}, 400)
}
const fetchUsers = async (userPage, search) => { const fetchUsers = async (userPage, search) => {
if ($userPageInfo.loading) { if ($userPageInfo.loading) {
return return
@ -286,7 +295,7 @@
/> />
</div> </div>
<div class="freeSearch"> <div class="freeSearch">
<Search placeholder="Search" bind:value={logSearchTerm} /> <Search placeholder="Search" on:change={e => debounce(e.detail)} />
</div> </div>
<div class=""> <div class="">

View File

@ -35,7 +35,7 @@ const buildOpts = ({
if (appIds.length) { if (appIds.length) {
opts.appIds = appIds opts.appIds = appIds
} }
console.log(opts)
return opts return opts
} }