mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-23 05:54:48 -06:00
refac
This commit is contained in:
@@ -71,12 +71,12 @@
|
||||
let functions = null;
|
||||
let filteredItems = [];
|
||||
|
||||
$: if (query !== undefined) {
|
||||
const handleSearchInput = () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
setFilteredItems();
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
$: if (functions && selectedType !== undefined && viewOption !== undefined) {
|
||||
setFilteredItems();
|
||||
@@ -363,6 +363,7 @@
|
||||
<input
|
||||
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-hidden bg-transparent"
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
placeholder={$i18n.t('Search Functions')}
|
||||
/>
|
||||
|
||||
@@ -372,6 +373,7 @@
|
||||
class="p-0.5 rounded-full hover:bg-gray-100 dark:hover:bg-gray-900 transition"
|
||||
on:click={() => {
|
||||
query = '';
|
||||
handleSearchInput();
|
||||
}}
|
||||
>
|
||||
<XMark className="size-3" strokeWidth="2" />
|
||||
|
||||
@@ -84,13 +84,16 @@
|
||||
getUserList();
|
||||
}
|
||||
|
||||
$: if (query !== undefined) {
|
||||
const handleSearchInput = () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
page = 1;
|
||||
getUserList();
|
||||
if (page !== 1) {
|
||||
page = 1;
|
||||
} else {
|
||||
getUserList();
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
onDestroy(() => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
@@ -106,6 +109,7 @@
|
||||
<input
|
||||
class=" w-full text-sm pr-4 rounded-r-xl outline-hidden bg-transparent"
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
placeholder={$i18n.t('Search')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -100,13 +100,16 @@
|
||||
}
|
||||
};
|
||||
|
||||
$: if (query !== undefined) {
|
||||
const handleSearchInput = () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
page = 1;
|
||||
getUserList();
|
||||
if (page !== 1) {
|
||||
page = 1;
|
||||
} else {
|
||||
getUserList();
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
$: if (page !== null && orderBy !== null && direction !== null) {
|
||||
getUserList();
|
||||
@@ -210,6 +213,7 @@
|
||||
<input
|
||||
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-hidden bg-transparent"
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
aria-label={$i18n.t('Search')}
|
||||
placeholder={$i18n.t('Search')}
|
||||
/>
|
||||
|
||||
@@ -78,13 +78,14 @@
|
||||
}
|
||||
};
|
||||
|
||||
// Debounce only query changes
|
||||
$: if (query !== undefined && channel !== null) {
|
||||
const handleSearchInput = () => {
|
||||
if (channel === null) return;
|
||||
|
||||
clearTimeout(debounceTimer);
|
||||
debounceTimer = setTimeout(() => {
|
||||
getUserList();
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
// Immediate response to page/sort changes
|
||||
$: if (channel !== null && page && orderBy && direction) {
|
||||
@@ -142,6 +143,7 @@
|
||||
<input
|
||||
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-hidden bg-transparent"
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
placeholder={$i18n.t('Search')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -180,14 +180,14 @@
|
||||
await getItemsPage();
|
||||
};
|
||||
|
||||
$: if (query !== undefined) {
|
||||
const handleSearchInput = () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
if (loaded) {
|
||||
init();
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
$: if (loaded && sortKey !== undefined && permission !== undefined && viewOption !== undefined) {
|
||||
init();
|
||||
@@ -380,6 +380,7 @@
|
||||
<input
|
||||
class=" w-full text-sm py-1 rounded-r-xl outline-hidden bg-transparent"
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
placeholder={$i18n.t('Search Notes')}
|
||||
/>
|
||||
|
||||
@@ -389,6 +390,7 @@
|
||||
class="p-0.5 rounded-full hover:bg-gray-100 dark:hover:bg-gray-900 transition"
|
||||
on:click={() => {
|
||||
query = '';
|
||||
handleSearchInput();
|
||||
}}
|
||||
>
|
||||
<XMark className="size-3" strokeWidth="2" />
|
||||
|
||||
@@ -45,12 +45,12 @@
|
||||
let allItemsLoaded = false;
|
||||
let itemsLoading = false;
|
||||
|
||||
$: if (query !== undefined) {
|
||||
const handleSearchInput = () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
init();
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
onDestroy(() => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
@@ -199,6 +199,7 @@
|
||||
<input
|
||||
class=" w-full text-sm py-1 rounded-r-xl outline-hidden bg-transparent"
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
aria-label={$i18n.t('Search Knowledge')}
|
||||
placeholder={$i18n.t('Search Knowledge')}
|
||||
/>
|
||||
@@ -209,6 +210,7 @@
|
||||
aria-label={$i18n.t('Clear search')}
|
||||
on:click={() => {
|
||||
query = '';
|
||||
handleSearchInput();
|
||||
}}
|
||||
>
|
||||
<XMark className="size-3" strokeWidth="2" />
|
||||
|
||||
@@ -142,14 +142,17 @@
|
||||
await getItemsPage();
|
||||
};
|
||||
|
||||
// Debounce only query changes
|
||||
$: if (query !== undefined) {
|
||||
const handleSearchInput = () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
getItemsPage();
|
||||
if (currentPage !== 1) {
|
||||
currentPage = 1;
|
||||
} else {
|
||||
getItemsPage();
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
// Immediate response to filter/pagination changes
|
||||
$: if (
|
||||
@@ -163,15 +166,6 @@
|
||||
getItemsPage();
|
||||
}
|
||||
|
||||
$: if (
|
||||
query !== undefined &&
|
||||
viewOption !== undefined &&
|
||||
sortKey !== undefined &&
|
||||
direction !== undefined
|
||||
) {
|
||||
reset();
|
||||
}
|
||||
|
||||
const getItemsPage = async () => {
|
||||
if (knowledgeId === null) return;
|
||||
|
||||
@@ -1313,6 +1307,7 @@
|
||||
<input
|
||||
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-hidden bg-transparent"
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
aria-label={$i18n.t('Search Collection')}
|
||||
placeholder={$i18n.t('Search Collection')}
|
||||
on:focus={() => {
|
||||
|
||||
@@ -34,12 +34,12 @@
|
||||
|
||||
$: items = [...noteItems, ...knowledgeItems, ...fileItems];
|
||||
|
||||
$: if (query !== undefined) {
|
||||
const handleSearchInput = () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
getItems();
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
onDestroy(() => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
@@ -111,6 +111,7 @@
|
||||
if (e.detail === false) {
|
||||
onClose();
|
||||
query = '';
|
||||
handleSearchInput();
|
||||
}
|
||||
}}
|
||||
>
|
||||
@@ -128,6 +129,7 @@
|
||||
<input
|
||||
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-hidden bg-transparent"
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
placeholder={$i18n.t('Search')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -59,15 +59,17 @@
|
||||
|
||||
let page = 1;
|
||||
|
||||
// Debounce only query changes
|
||||
$: if (query !== undefined) {
|
||||
const handleSearchInput = () => {
|
||||
loading = true;
|
||||
clearTimeout(searchDebounceTimer);
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
page = 1;
|
||||
getPromptList();
|
||||
if (page !== 1) {
|
||||
page = 1;
|
||||
} else {
|
||||
getPromptList();
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
// Immediate response to page/filter changes
|
||||
$: if (page && selectedTag !== undefined && viewOption !== undefined) {
|
||||
@@ -332,6 +334,7 @@
|
||||
<input
|
||||
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-hidden bg-transparent"
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
aria-label={$i18n.t('Search Prompts')}
|
||||
placeholder={$i18n.t('Search Prompts')}
|
||||
/>
|
||||
@@ -343,6 +346,7 @@
|
||||
aria-label={$i18n.t('Clear search')}
|
||||
on:click={() => {
|
||||
query = '';
|
||||
handleSearchInput();
|
||||
}}
|
||||
>
|
||||
<XMark className="size-3" strokeWidth="2" />
|
||||
|
||||
@@ -78,15 +78,17 @@
|
||||
}
|
||||
};
|
||||
|
||||
// Debounce only query changes
|
||||
$: if (query !== undefined) {
|
||||
const handleSearchInput = () => {
|
||||
loading = true;
|
||||
clearTimeout(searchDebounceTimer);
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
page = 1;
|
||||
loadSkillItems();
|
||||
if (page !== 1) {
|
||||
page = 1;
|
||||
} else {
|
||||
loadSkillItems();
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
// Immediate response to page/filter changes
|
||||
$: if (page && viewOption !== undefined) {
|
||||
@@ -321,6 +323,7 @@
|
||||
<input
|
||||
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-hidden bg-transparent"
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
aria-label={$i18n.t('Search Skills')}
|
||||
placeholder={$i18n.t('Search Skills')}
|
||||
/>
|
||||
@@ -331,6 +334,7 @@
|
||||
aria-label={$i18n.t('Clear search')}
|
||||
on:click={() => {
|
||||
query = '';
|
||||
handleSearchInput();
|
||||
}}
|
||||
>
|
||||
<XMark className="size-3" strokeWidth="2" />
|
||||
|
||||
@@ -63,12 +63,12 @@
|
||||
|
||||
let showImportModal = false;
|
||||
|
||||
$: if (query !== undefined) {
|
||||
const handleSearchInput = () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
setFilteredItems();
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
$: if (tools && viewOption !== undefined) {
|
||||
setFilteredItems();
|
||||
@@ -325,6 +325,7 @@
|
||||
<input
|
||||
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-hidden bg-transparent"
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
aria-label={$i18n.t('Search Tools')}
|
||||
placeholder={$i18n.t('Search Tools')}
|
||||
/>
|
||||
@@ -335,6 +336,7 @@
|
||||
aria-label={$i18n.t('Clear search')}
|
||||
on:click={() => {
|
||||
query = '';
|
||||
handleSearchInput();
|
||||
}}
|
||||
>
|
||||
<XMark className="size-3" strokeWidth="2" />
|
||||
|
||||
@@ -63,12 +63,12 @@
|
||||
}
|
||||
};
|
||||
|
||||
$: if (query !== undefined) {
|
||||
const handleSearchInput = () => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
getUserList();
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
onDestroy(() => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
@@ -187,6 +187,7 @@
|
||||
<input
|
||||
class=" w-full text-sm pr-4 py-1 rounded-r-xl outline-hidden bg-transparent"
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
placeholder={$i18n.t('Search')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -50,15 +50,19 @@
|
||||
|
||||
let page = 1;
|
||||
|
||||
// Debounce only query changes (gate behind loaded to prevent double-fetch on mount)
|
||||
$: if (loaded && query !== undefined) {
|
||||
const handleSearchInput = () => {
|
||||
if (!loaded) return;
|
||||
|
||||
loading = true;
|
||||
clearTimeout(searchDebounceTimer);
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
page = 1;
|
||||
getAutomationList();
|
||||
if (page !== 1) {
|
||||
page = 1;
|
||||
} else {
|
||||
getAutomationList();
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
// Immediate response to page/filter changes (gate behind loaded)
|
||||
$: if (loaded && page && statusFilter !== undefined) {
|
||||
@@ -296,6 +300,7 @@
|
||||
<input
|
||||
class="w-full text-sm py-1 rounded-r-xl outline-hidden bg-transparent"
|
||||
bind:value={query}
|
||||
on:input={handleSearchInput}
|
||||
aria-label={$i18n.t('Search Automations')}
|
||||
placeholder={$i18n.t('Search Automations')}
|
||||
maxlength="500"
|
||||
@@ -308,6 +313,7 @@
|
||||
aria-label={$i18n.t('Clear search')}
|
||||
on:click={() => {
|
||||
query = '';
|
||||
handleSearchInput();
|
||||
}}
|
||||
>
|
||||
<XMark className="size-3" strokeWidth="2" />
|
||||
|
||||
Reference in New Issue
Block a user