mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-03 06:28:53 +00:00
refactor(web): wip pagination
This commit is contained in:
1 parent
3c199c2217
commit
e06c61d292
7 files changed
+51
-28
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { derived, writable } from 'svelte/store';
|
||||
|
||||
export const search = writable('');
|
||||
let timeout: NodeJS.Timeout;
|
||||
export const debouncedSearch = derived(search, (value, set: (value: string) => void) => {
|
||||
timeout = setTimeout(() => set(value), 500);
|
||||
return () => clearTimeout(timeout);
|
||||
});
|
||||
|
||||
export const resources = writable<string[]>([]);
|
||||
|
||||
export const filteredResources = derived(
|
||||
[resources, debouncedSearch],
|
||||
([$resources, $debouncedSearch], set: (value: string[]) => void) => {
|
||||
if ($debouncedSearch === '' || !$debouncedSearch) return set($resources);
|
||||
|
||||
const query = $debouncedSearch.toLowerCase();
|
||||
|
||||
return set($resources.filter((resource) => resource.toLowerCase().includes(query)));
|
||||
}
|
||||
);
|
||||
|
||||
export const generalData = writable({
|
||||
queries: 0,
|
||||
timeQuerying: 0,
|
||||
slowQueries: 0,
|
||||
});
|
||||
Reference in new issue
Block a user