Skip to content

Commit 7dd9758

Browse files
Add task executor bar chart, add system version string (#11155)
### What problem does this PR solve? - Add task executor bar chart - Add read version string ### Type of change - [x] New Feature (non-breaking change which adds functionality)
1 parent 26cf513 commit 7dd9758

File tree

16 files changed

+315
-78
lines changed

16 files changed

+315
-78
lines changed

web/src/components/ui/dialog.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ const DialogContent = React.forwardRef<
3838
<DialogPrimitive.Content
3939
ref={ref}
4040
className={cn(
41-
'outline-0 fixed left-[50%] top-[50%] z-50 grid w-full max-w-xl translate-x-[-50%] translate-y-[-50%] gap-4 border bg-bg-base p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
41+
'outline-0 fixed left-[50%] top-[50%] rounded-lg z-50 grid w-full max-w-xl translate-x-[-50%] translate-y-[-50%] gap-4',
42+
'border-0.5 border-border-button bg-bg-base p-6 shadow-lg duration-200 sm:rounded-lg',
43+
'data-[state=open]:animate-in data-[state=closed]:animate-out',
44+
'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
45+
'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
46+
'data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]',
47+
'data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]',
4248
className,
4349
)}
4450
{...props}
@@ -66,6 +72,7 @@ const DialogHeader = ({
6672
}: React.HTMLAttributes<HTMLDivElement>) => (
6773
<div
6874
className={cn(
75+
'-mx-6 -mt-6 p-6 border-b-0.5 border-border-button',
6976
'flex flex-col space-y-1.5 text-center sm:text-left',
7077
className,
7178
)}
@@ -80,6 +87,7 @@ const DialogFooter = ({
8087
}: React.HTMLAttributes<HTMLDivElement>) => (
8188
<div
8289
className={cn(
90+
// '-mx-6 -mb-6 px-12 pt-4 pb-8',
8391
'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-4',
8492
className,
8593
)}

web/src/components/ui/input.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
4040
ref={ref}
4141
type={isPasswordInput && showPassword ? 'text' : type}
4242
className={cn(
43+
'peer/input',
4344
'flex h-8 w-full rounded-md border-0.5 border-input bg-bg-input px-3 py-2 outline-none text-sm text-text-primary',
4445
'file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-text-disabled',
4546
'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent-primary',
@@ -79,7 +80,12 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
7980
<Button
8081
variant="transparent"
8182
type="button"
82-
className="border-0 absolute right-1 top-[50%] translate-y-[-50%]"
83+
className="
84+
absolute border-0 right-1 top-[50%] translate-y-[-50%]
85+
dark:peer-autofill/input:text-text-secondary-inverse
86+
dark:peer-autofill/input:hover:text-text-primary-inverse
87+
dark:peer-autofill/input:focus-visible:text-text-primary-inverse
88+
"
8389
onClick={() => setShowPassword(!showPassword)}
8490
>
8591
{showPassword ? (

web/src/components/ui/switch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const Switch = React.forwardRef<
1313
className={cn(
1414
'group/switch inline-flex h-4 w-7 shrink-0 cursor-pointer items-center rounded-full',
1515
'border-2 border-transparent overflow-hidden transition-colors',
16-
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary',
16+
'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary',
1717
'disabled:cursor-not-allowed disabled:opacity-50',
1818
'data-[state=checked]:bg-accent-primary data-[state=unchecked]:bg-text-sub-title',
1919
className,

web/src/locales/en.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@ Important structured information may include: names, dates, locations, events, k
19111911
processing: 'Processing',
19121912
},
19131913
admin: {
1914-
loginTitle: 'RAGFlow ADMIN',
1914+
loginTitle: 'Admin Console',
19151915
title: 'RAGFlow admin',
19161916
confirm: 'Confirm',
19171917
close: 'Close',
@@ -1998,6 +1998,7 @@ Important structured information may include: names, dates, locations, events, k
19981998

19991999
extraInfo: 'Extra information',
20002000
serviceDetail: `Service {{name}} detail`,
2001+
taskExecutorDetail: 'Task executor detail',
20012002

20022003
whitelistManagement: 'Whitelist management',
20032004
exportAsExcel: 'Export Excel',

web/src/pages/admin/layouts/navigation-layout.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
22
import { useTranslation } from 'react-i18next';
33
import { NavLink, Outlet, useNavigate } from 'umi';
44

5-
import { useMutation } from '@tanstack/react-query';
5+
import { useMutation, useQuery } from '@tanstack/react-query';
66

77
import {
88
LucideMonitor,
@@ -15,7 +15,7 @@ import {
1515
import { Button } from '@/components/ui/button';
1616
import { cn } from '@/lib/utils';
1717
import { Routes } from '@/routes';
18-
import { logout } from '@/services/admin-service';
18+
import { getSystemVersion, logout } from '@/services/admin-service';
1919

2020
import authorizationUtil from '@/utils/authorization-util';
2121

@@ -26,6 +26,11 @@ const AdminNavigationLayout = () => {
2626
const { t } = useTranslation();
2727
const navigate = useNavigate();
2828

29+
const { data: version } = useQuery({
30+
queryKey: ['admin/version'],
31+
queryFn: async () => (await getSystemVersion())?.data?.data?.version,
32+
});
33+
2934
const navItems = useMemo(
3035
() => [
3136
{
@@ -109,8 +114,8 @@ const AdminNavigationLayout = () => {
109114

110115
<div className="mt-auto space-y-4">
111116
<div className="flex justify-between items-center">
112-
<span className="text-accent-primary">
113-
vmm.ss.rr-nnn-commithash
117+
<span className="leading-none text-xs text-accent-primary">
118+
{version}
114119
</span>
115120

116121
<ThemeSwitch />

web/src/pages/admin/roles.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -280,24 +280,24 @@ function AdminRoles() {
280280
{/* Add role modal */}
281281
<Dialog open={isAddRoleModalOpen} onOpenChange={setAddRoleModalOpen}>
282282
<DialogContent
283-
className="max-w-2xl p-0 border-border-button"
283+
className="max-w-2xl"
284284
onAnimationEnd={() => {
285285
if (!isAddRoleModalOpen) {
286286
createRoleForm.form.reset();
287287
}
288288
}}
289289
>
290-
<DialogHeader className="p-6 border-b-0.5 border-border-button">
290+
<DialogHeader>
291291
<DialogTitle>{t('admin.addNewRole')}</DialogTitle>
292292
</DialogHeader>
293293

294-
<section className="px-12 py-4">
294+
<section className="px-6">
295295
<createRoleForm.FormComponent
296296
onSubmit={createRoleMutation.mutate}
297297
/>
298298
</section>
299299

300-
<DialogFooter className="flex justify-end gap-4 px-12 pt-4 pb-8">
300+
<DialogFooter className="gap-4 px-6 py-4">
301301
<Button
302302
className="px-4 h-10 dark:border-border-button"
303303
variant="outline"
@@ -324,18 +324,17 @@ function AdminRoles() {
324324
onOpenChange={setEditRoleDescriptionModalOpen}
325325
>
326326
<DialogContent
327-
className="p-0 border-border-button"
328327
onAnimationEnd={() => {
329328
if (!isEditRoleDescriptionModalOpen) {
330329
setRoleToMakeAction(null);
331330
}
332331
}}
333332
>
334-
<DialogHeader className="p-6 border-b-0.5 border-border-button">
333+
<DialogHeader>
335334
<DialogTitle>{t('admin.editRoleDescription')}</DialogTitle>
336335
</DialogHeader>
337336

338-
<section className="px-12 py-4">
337+
<section className="px-6">
339338
<form
340339
id={editRoleDescriptionFormId}
341340
onSubmit={(evt) => {
@@ -360,7 +359,7 @@ function AdminRoles() {
360359
</form>
361360
</section>
362361

363-
<DialogFooter className="flex justify-end gap-4 px-12 pt-4 pb-8">
362+
<DialogFooter className="gap-4 px-6 py-4">
364363
<Button
365364
className="px-4 h-10 dark:border-border-button"
366365
variant="outline"
@@ -383,18 +382,17 @@ function AdminRoles() {
383382
{/* Delete role modal */}
384383
<Dialog open={deleteModalOpen} onOpenChange={setDeleteModalOpen}>
385384
<DialogContent
386-
className="p-0 border-border-button"
387385
onAnimationEnd={() => {
388386
if (!deleteModalOpen) {
389387
setRoleToMakeAction(null);
390388
}
391389
}}
392390
>
393-
<DialogHeader className="p-6 border-b-0.5 border-border-button">
391+
<DialogHeader>
394392
<DialogTitle>{t('admin.deleteRole')}</DialogTitle>
395393
</DialogHeader>
396394

397-
<section className="px-12 py-4">
395+
<section className="px-6">
398396
<DialogDescription className="text-text-primary">
399397
{t('admin.deleteRoleConfirmation')}
400398
</DialogDescription>
@@ -404,7 +402,7 @@ function AdminRoles() {
404402
</div>
405403
</section>
406404

407-
<DialogFooter className="flex justify-end gap-4 px-12 pt-4 pb-8">
405+
<DialogFooter className="gap-4 px-6 py-4">
408406
<Button
409407
className="px-4 h-10 dark:border-border-button"
410408
variant="outline"

web/src/pages/admin/service-detail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function ServiceDetail({ content }: ServiceDetailProps) {
6868

6969
if (typeof content === 'string') {
7070
return (
71-
<div className="rounded-lg p-4 bg-bg-card text-sm text-text-primary">
71+
<div className="rounded-xl p-4 bg-bg-card text-sm text-text-primary">
7272
<pre>
7373
<code>
7474
{typeof content === 'string'

web/src/pages/admin/service-status.tsx

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
import {
3535
Dialog,
3636
DialogContent,
37+
DialogDescription,
3738
DialogFooter,
3839
DialogHeader,
3940
DialogTitle,
@@ -66,7 +67,9 @@ import {
6667
getSortIcon,
6768
} from './utils';
6869

70+
import JsonView from 'react18-json-view';
6971
import ServiceDetail from './service-detail';
72+
import TaskExecutorDetail from './task-executor-detail';
7073

7174
const columnHelper = createColumnHelper<AdminService.ListServicesItem>();
7275
const globalFilterFn = createFuzzySearchFn<AdminService.ListServicesItem>([
@@ -381,7 +384,7 @@ function AdminServiceStatus() {
381384
{/* Extra info modal*/}
382385
<Dialog open={extraInfoModalOpen} onOpenChange={setExtraInfoModalOpen}>
383386
<DialogContent
384-
className="p-0 border-border-button"
387+
className="flex flex-col max-h-[calc(100vh-4rem)] p-0 overflow-hidden"
385388
onAnimationEnd={() => {
386389
if (!extraInfoModalOpen) {
387390
setItemToMakeAction(null);
@@ -392,15 +395,16 @@ function AdminServiceStatus() {
392395
<DialogTitle>{t('admin.extraInfo')}</DialogTitle>
393396
</DialogHeader>
394397

395-
<section className="px-12 pt-6 pb-4">
396-
<div className="rounded-lg p-4 bg-bg-input">
397-
<pre className="text-sm">
398-
<code>
399-
{JSON.stringify(itemToMakeAction?.extra ?? {}, null, 2)}
400-
</code>
401-
</pre>
398+
<DialogDescription className="sr-only" />
399+
400+
<ScrollArea className="h-0 flex-1 grid">
401+
<div className="px-12">
402+
<JsonView
403+
src={itemToMakeAction?.extra ?? {}}
404+
className="rounded-lg p-4 bg-bg-card break-words text-text-secondary"
405+
/>
402406
</div>
403-
</section>
407+
</ScrollArea>
404408

405409
<DialogFooter className="flex justify-end gap-4 px-12 pt-4 pb-8">
406410
<Button
@@ -417,7 +421,7 @@ function AdminServiceStatus() {
417421
{/* Service details modal */}
418422
<Dialog open={detailModalOpen} onOpenChange={setDetailModalOpen}>
419423
<DialogContent
420-
className="flex flex-col max-h-[calc(100vh-4rem)] max-w-6xl p-0 border-border-button"
424+
className="flex flex-col max-h-[calc(100vh-4rem)] max-w-6xl p-0 overflow-hidden"
421425
onAnimationEnd={() => {
422426
if (!detailModalOpen) {
423427
setItemToMakeAction(null);
@@ -426,14 +430,30 @@ function AdminServiceStatus() {
426430
>
427431
<DialogHeader className="p-6 border-b-0.5 border-border-button">
428432
<DialogTitle>
429-
<Trans i18nKey="admin.serviceDetail">
430-
{{ name: itemToMakeAction?.name }}
431-
</Trans>
433+
{itemToMakeAction?.service_type === 'task_executor' ? (
434+
t('admin.taskExecutorDetail')
435+
) : (
436+
<Trans i18nKey="admin.serviceDetail">
437+
{{ name: itemToMakeAction?.name }}
438+
</Trans>
439+
)}
432440
</DialogTitle>
433441
</DialogHeader>
434442

435-
<ScrollArea className="pt-6 pb-4 px-12 h-0 flex-1 text-text-secondary flex flex-col">
436-
<ServiceDetail content={serviceDetails?.message} />
443+
<DialogDescription className="sr-only" />
444+
445+
<ScrollArea className="h-0 flex-1 text-text-secondary grid">
446+
<div className="px-12">
447+
{itemToMakeAction?.service_type === 'task_executor' ? (
448+
<TaskExecutorDetail
449+
content={
450+
serviceDetails?.message as AdminService.TaskExecutorInfo
451+
}
452+
/>
453+
) : (
454+
<ServiceDetail content={serviceDetails?.message} />
455+
)}
456+
</div>
437457
</ScrollArea>
438458

439459
<DialogFooter className="flex justify-end gap-4 px-12 pt-4 pb-8">

0 commit comments

Comments
 (0)