Merge pull request #16115 from silentoplayz/draggable-pinned-models
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Details
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Details
Create and publish Docker images with specific build args / build-main-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-main-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-cuda126-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-cuda126-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Details
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Details
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Details
Create and publish Docker images with specific build args / merge-cuda126-images (push) Blocked by required conditions
Details
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Details
Frontend Build / Format & Build Frontend (push) Waiting to run
Details
Frontend Build / Frontend Unit Tests (push) Waiting to run
Details
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Details
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Details
Create and publish Docker images with specific build args / build-main-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-main-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-cuda126-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-cuda126-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Details
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Details
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Details
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Details
Create and publish Docker images with specific build args / merge-cuda126-images (push) Blocked by required conditions
Details
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Details
Frontend Build / Format & Build Frontend (push) Waiting to run
Details
Frontend Build / Frontend Unit Tests (push) Waiting to run
Details
feat: allow draggable reorganization of pinned models in chat sidebar
This commit is contained in:
commit
cd6eb9a9e2
|
@ -59,6 +59,8 @@
|
||||||
import Search from '../icons/Search.svelte';
|
import Search from '../icons/Search.svelte';
|
||||||
import SearchModal from './SearchModal.svelte';
|
import SearchModal from './SearchModal.svelte';
|
||||||
import FolderModal from './Sidebar/Folders/FolderModal.svelte';
|
import FolderModal from './Sidebar/Folders/FolderModal.svelte';
|
||||||
|
import Sortable from 'sortablejs';
|
||||||
|
import { updateUserSettings } from '$lib/apis/users';
|
||||||
|
|
||||||
const BREAKPOINT = 768;
|
const BREAKPOINT = 768;
|
||||||
|
|
||||||
|
@ -79,6 +81,28 @@
|
||||||
let folders = {};
|
let folders = {};
|
||||||
let newFolderId = null;
|
let newFolderId = null;
|
||||||
|
|
||||||
|
const initPinnedModelsSortable = () => {
|
||||||
|
const pinnedModelsList = document.getElementById('pinned-models-list');
|
||||||
|
if (pinnedModelsList) {
|
||||||
|
new Sortable(pinnedModelsList, {
|
||||||
|
animation: 150,
|
||||||
|
onUpdate: async (event) => {
|
||||||
|
const modelId = event.item.dataset.id;
|
||||||
|
const newIndex = event.newIndex;
|
||||||
|
|
||||||
|
const pinnedModels = $settings.pinnedModels;
|
||||||
|
const oldIndex = pinnedModels.indexOf(modelId);
|
||||||
|
|
||||||
|
pinnedModels.splice(oldIndex, 1);
|
||||||
|
pinnedModels.splice(newIndex, 0, modelId);
|
||||||
|
|
||||||
|
settings.set({ ...$settings, pinnedModels: pinnedModels });
|
||||||
|
await updateUserSettings(localStorage.token, { ui: $settings });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const initFolders = async () => {
|
const initFolders = async () => {
|
||||||
const folderList = await getFolders(localStorage.token).catch((error) => {
|
const folderList = await getFolders(localStorage.token).catch((error) => {
|
||||||
toast.error(`${error}`);
|
toast.error(`${error}`);
|
||||||
|
@ -373,6 +397,7 @@
|
||||||
|
|
||||||
await initChannels();
|
await initChannels();
|
||||||
await initChatList();
|
await initChatList();
|
||||||
|
initPinnedModelsSortable();
|
||||||
|
|
||||||
window.addEventListener('keydown', onKeyDown);
|
window.addEventListener('keydown', onKeyDown);
|
||||||
window.addEventListener('keyup', onKeyUp);
|
window.addEventListener('keyup', onKeyUp);
|
||||||
|
@ -673,12 +698,15 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="relative flex flex-col flex-1 overflow-y-auto overflow-x-hidden">
|
<div class="relative flex flex-col flex-1 overflow-y-auto overflow-x-hidden">
|
||||||
|
<div class="mt-0.5" id="pinned-models-list">
|
||||||
{#if ($models ?? []).length > 0 && ($settings?.pinnedModels ?? []).length > 0}
|
{#if ($models ?? []).length > 0 && ($settings?.pinnedModels ?? []).length > 0}
|
||||||
<div class="mt-0.5">
|
|
||||||
{#each $settings.pinnedModels as modelId (modelId)}
|
{#each $settings.pinnedModels as modelId (modelId)}
|
||||||
{@const model = $models.find((model) => model.id === modelId)}
|
{@const model = $models.find((model) => model.id === modelId)}
|
||||||
{#if model}
|
{#if model}
|
||||||
<div class="px-1.5 flex justify-center text-gray-800 dark:text-gray-200">
|
<div
|
||||||
|
class="px-1.5 flex justify-center text-gray-800 dark:text-gray-200 cursor-grab"
|
||||||
|
data-id={modelId}
|
||||||
|
>
|
||||||
<a
|
<a
|
||||||
class="grow flex items-center space-x-2.5 rounded-lg px-2 py-[7px] hover:bg-gray-100 dark:hover:bg-gray-900 transition"
|
class="grow flex items-center space-x-2.5 rounded-lg px-2 py-[7px] hover:bg-gray-100 dark:hover:bg-gray-900 transition"
|
||||||
href="/?model={modelId}"
|
href="/?model={modelId}"
|
||||||
|
@ -711,8 +739,8 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
{#if $config?.features?.enable_channels && ($user?.role === 'admin' || $channels.length > 0)}
|
{#if $config?.features?.enable_channels && ($user?.role === 'admin' || $channels.length > 0)}
|
||||||
<Folder
|
<Folder
|
||||||
|
|
Loading…
Reference in New Issue