mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-28 16:11:43 -05:00
refac
This commit is contained in:
1 parent
53fc70aea7
commit
680cd3a0f3
3 files changed
+27
-17
No files matched your search
@@ -41,6 +41,7 @@ from open_webui.utils.access_control import (
|
||||
)
|
||||
from open_webui.utils.access_control.files import can_read_all_folder_files, get_accessible_folder_files
|
||||
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||
from open_webui.utils.machines import machine_id_of
|
||||
from pydantic import BaseModel, Field
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
@@ -157,6 +158,7 @@ async def get_folders(
|
||||
class ActiveFolderResponse(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
machine_id: str | None = None
|
||||
directory: str | None = None
|
||||
waiting: bool = False
|
||||
running: bool = False
|
||||
@@ -181,7 +183,10 @@ async def get_active_folders(
|
||||
|
||||
active = {
|
||||
folder.id: ActiveFolderResponse(
|
||||
id=folder.id, name=folder.name, directory=(folder.data or {}).get('working_directory')
|
||||
id=folder.id,
|
||||
name=folder.name,
|
||||
machine_id=machine_id_of(folder.data or {}),
|
||||
directory=(folder.data or {}).get('working_directory'),
|
||||
)
|
||||
for folder in folders.values()
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ export const createNewFolder = async (token: string, folderForm: FolderForm) =>
|
||||
export type ActiveFolder = {
|
||||
id: string;
|
||||
name: string;
|
||||
machine_id?: string | null;
|
||||
directory?: string | null;
|
||||
waiting: boolean;
|
||||
running: boolean;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { getContext, onMount } from 'svelte';
|
||||
import { activeFolders, folders, refreshActiveFolders } from '$lib/stores';
|
||||
import { activeFolders, folders, machines, refreshActiveFolders } from '$lib/stores';
|
||||
import { formatDateDetails, formatElapsedShort, formatShortDate } from '$lib/utils';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
<ul aria-labelledby="continue-folders-heading">
|
||||
{#each $activeFolders as folder (folder.id)}
|
||||
{@const machine = ($machines ?? []).find(({ id }) => id === folder.machine_id)}
|
||||
{@const unread = ($folders as any[]).find(({ id }) => id === folder.id)?.unread_count ?? 0}
|
||||
<li>
|
||||
<a
|
||||
@@ -36,6 +37,7 @@
|
||||
class="group flex items-center gap-2 h-7 -mx-2 px-2 rounded-lg text-sm transition-colors duration-75 hover:bg-base-50 dark:hover:bg-base-850"
|
||||
title={[
|
||||
folder.name,
|
||||
machine?.name,
|
||||
folder.directory,
|
||||
formatDateDetails(folder.updated_at, $i18n.language)
|
||||
]
|
||||
@@ -51,24 +53,26 @@
|
||||
{:else if folder.running}
|
||||
<span class="shrink-0"><Spinner className="size-3" /></span>
|
||||
{/if}
|
||||
<span
|
||||
dir="auto"
|
||||
class="min-w-0 truncate text-base-500 dark:text-base-400 transition-colors duration-75 group-hover:text-base-900 dark:group-hover:text-base-100"
|
||||
>
|
||||
{folder.name}
|
||||
</span>
|
||||
{#if unread > 0}
|
||||
<span class="flex flex-1 min-w-0 items-center gap-2">
|
||||
<span
|
||||
class="inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-md bg-sky-500/10 px-1 text-[0.625rem] font-semibold leading-4 text-sky-600 dark:bg-sky-400/10 dark:text-sky-300"
|
||||
title={$i18n.t('Unread or waiting for approval')}
|
||||
dir="auto"
|
||||
class="min-w-0 truncate text-base-500 dark:text-base-400 transition-colors duration-75 group-hover:text-base-900 dark:group-hover:text-base-100"
|
||||
>
|
||||
{unread.toLocaleString($i18n.language)}
|
||||
{folder.name}
|
||||
</span>
|
||||
{#if unread > 0}
|
||||
<span
|
||||
class="inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-md bg-sky-500/10 px-1 text-[0.625rem] font-semibold leading-4 text-sky-600 dark:bg-sky-400/10 dark:text-sky-300"
|
||||
title={$i18n.t('Unread or waiting for approval')}
|
||||
>
|
||||
{unread.toLocaleString($i18n.language)}
|
||||
</span>
|
||||
{/if}
|
||||
<span
|
||||
class="flex-1 min-w-0 translate-y-[0.03125rem] truncate font-mono text-[0.6875rem] text-base-400 dark:text-base-600"
|
||||
>
|
||||
{[machine?.name, shortenHome(folder.directory ?? '')].filter(Boolean).join(' ')}
|
||||
</span>
|
||||
{/if}
|
||||
<span
|
||||
class="flex-1 min-w-0 truncate font-mono text-[0.6875rem] text-base-400 dark:text-base-600"
|
||||
>
|
||||
{shortenHome(folder.directory ?? '')}
|
||||
</span>
|
||||
{#if folder.terminals}
|
||||
<span
|
||||
|
||||
Reference in new issue
Block a user