Skip to content

Commit 62e7e0b

Browse files
tjbckpljones
andcommitted
refac
Co-Authored-By: Peter L Jones <1549463+pljones@users.noreply.github.com>
1 parent 7a16e49 commit 62e7e0b

1 file changed

Lines changed: 48 additions & 2 deletions

File tree

src/lib/components/admin/Settings/Models.svelte

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import EllipsisHorizontal from '$lib/components/icons/EllipsisHorizontal.svelte';
4040
import EyeSlash from '$lib/components/icons/EyeSlash.svelte';
4141
import Eye from '$lib/components/icons/Eye.svelte';
42+
import CheckCircle from '$lib/components/icons/CheckCircle.svelte';
43+
import Minus from '$lib/components/icons/Minus.svelte';
4244
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
4345
import { goto } from '$app/navigation';
4446
import { DropdownMenu } from 'bits-ui';
@@ -121,6 +123,28 @@
121123
);
122124
};
123125
126+
const showAllHandler = async () => {
127+
const modelsToShow = filteredModels.filter((m) => m?.meta?.hidden === true);
128+
// Optimistic UI update
129+
modelsToShow.forEach((m) => {
130+
m.meta = { ...m.meta, hidden: false };
131+
});
132+
models = models;
133+
// Sync with server
134+
await Promise.all(modelsToShow.map((model) => upsertModelHandler(model)));
135+
};
136+
137+
const hideAllHandler = async () => {
138+
const modelsToHide = filteredModels.filter((m) => !(m?.meta?.hidden ?? false));
139+
// Optimistic UI update
140+
modelsToHide.forEach((m) => {
141+
m.meta = { ...m.meta, hidden: true };
142+
});
143+
models = models;
144+
// Sync with server
145+
await Promise.all(modelsToHide.map((model) => upsertModelHandler(model)));
146+
};
147+
124148
const downloadModels = async (models) => {
125149
let blob = new Blob([JSON.stringify(models)], {
126150
type: 'application/json'
@@ -485,7 +509,7 @@
485509
enableAllHandler();
486510
}}
487511
>
488-
<Eye className="size-4" />
512+
<CheckCircle className="size-4" />
489513
<div class="flex items-center">{$i18n.t('Enable All')}</div>
490514
</DropdownMenu.Item>
491515

@@ -495,9 +519,31 @@
495519
disableAllHandler();
496520
}}
497521
>
498-
<EyeSlash className="size-4" />
522+
<Minus className="size-4" />
499523
<div class="flex items-center">{$i18n.t('Disable All')}</div>
500524
</DropdownMenu.Item>
525+
526+
<hr class="border-gray-100 dark:border-gray-800 my-1" />
527+
528+
<DropdownMenu.Item
529+
class="select-none flex gap-2 items-center px-3 py-1.5 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md"
530+
on:click={() => {
531+
showAllHandler();
532+
}}
533+
>
534+
<Eye className="size-4" />
535+
<div class="flex items-center">{$i18n.t('Show All')}</div>
536+
</DropdownMenu.Item>
537+
538+
<DropdownMenu.Item
539+
class="select-none flex gap-2 items-center px-3 py-1.5 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md"
540+
on:click={() => {
541+
hideAllHandler();
542+
}}
543+
>
544+
<EyeSlash className="size-4" />
545+
<div class="flex items-center">{$i18n.t('Hide All')}</div>
546+
</DropdownMenu.Item>
501547
</DropdownMenu.Content>
502548
</div>
503549
</Dropdown>

0 commit comments

Comments
 (0)