Web: Display the icon of the currently used storage. (#2504)
Browse fileshttps://github.com/infiniflow/ragflow/issues/2503
### What problem does this PR solve?
_Briefly describe what this PR aims to solve. Include background context
that will help reviewers understand the purpose of the PR._
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
Before:
<img width="611" alt="image"
src="https://github.com/user-attachments/assets/02a3a1ee-7bfb-4fe0-9b15-11ced69cc8a3">
After:
<img width="796" alt="image"
src="https://github.com/user-attachments/assets/371136af-8d16-47aa-909b-26609d3ad60e">
<img width="557" alt="image"
src="https://github.com/user-attachments/assets/9268362f-2b6a-4ea1-9fe7-659f7292e5e1">
api/apps/system_app.py
CHANGED
@@ -18,11 +18,12 @@ import json
|
|
18 |
from flask_login import login_required
|
19 |
|
20 |
from api.db.services.knowledgebase_service import KnowledgebaseService
|
|
|
21 |
from api.utils.api_utils import get_json_result
|
22 |
from api.versions import get_rag_version
|
23 |
from rag.settings import SVR_QUEUE_NAME
|
24 |
from rag.utils.es_conn import ELASTICSEARCH
|
25 |
-
from rag.utils.storage_factory import STORAGE_IMPL
|
26 |
from timeit import default_timer as timer
|
27 |
|
28 |
from rag.utils.redis_conn import REDIS_CONN
|
@@ -48,16 +49,16 @@ def status():
|
|
48 |
st = timer()
|
49 |
try:
|
50 |
STORAGE_IMPL.health()
|
51 |
-
res["
|
52 |
except Exception as e:
|
53 |
-
res["
|
54 |
|
55 |
st = timer()
|
56 |
try:
|
57 |
KnowledgebaseService.get_by_id("x")
|
58 |
-
res["
|
59 |
except Exception as e:
|
60 |
-
res["
|
61 |
|
62 |
st = timer()
|
63 |
try:
|
|
|
18 |
from flask_login import login_required
|
19 |
|
20 |
from api.db.services.knowledgebase_service import KnowledgebaseService
|
21 |
+
from api.settings import DATABASE_TYPE
|
22 |
from api.utils.api_utils import get_json_result
|
23 |
from api.versions import get_rag_version
|
24 |
from rag.settings import SVR_QUEUE_NAME
|
25 |
from rag.utils.es_conn import ELASTICSEARCH
|
26 |
+
from rag.utils.storage_factory import STORAGE_IMPL, STORAGE_IMPL_TYPE
|
27 |
from timeit import default_timer as timer
|
28 |
|
29 |
from rag.utils.redis_conn import REDIS_CONN
|
|
|
49 |
st = timer()
|
50 |
try:
|
51 |
STORAGE_IMPL.health()
|
52 |
+
res["storage"] = {"storage": STORAGE_IMPL_TYPE.lower(), "status": "green", "elapsed": "{:.1f}".format((timer() - st)*1000.)}
|
53 |
except Exception as e:
|
54 |
+
res["storage"] = {"storage": STORAGE_IMPL_TYPE.lower(), "status": "red", "elapsed": "{:.1f}".format((timer() - st)*1000.), "error": str(e)}
|
55 |
|
56 |
st = timer()
|
57 |
try:
|
58 |
KnowledgebaseService.get_by_id("x")
|
59 |
+
res["database"] = {"database": DATABASE_TYPE.lower(), "status": "green", "elapsed": "{:.1f}".format((timer() - st)*1000.)}
|
60 |
except Exception as e:
|
61 |
+
res["database"] = {"database": DATABASE_TYPE.lower(), "status": "red", "elapsed": "{:.1f}".format((timer() - st)*1000.), "error": str(e)}
|
62 |
|
63 |
st = timer()
|
64 |
try:
|
rag/utils/storage_factory.py
CHANGED
@@ -27,4 +27,5 @@ class StorageFactory:
|
|
27 |
return cls.storage_mapping[storage]()
|
28 |
|
29 |
|
30 |
-
|
|
|
|
27 |
return cls.storage_mapping[storage]()
|
28 |
|
29 |
|
30 |
+
STORAGE_IMPL_TYPE = os.getenv('STORAGE_IMPL', 'MINIO')
|
31 |
+
STORAGE_IMPL = StorageFactory.create(Storage[STORAGE_IMPL_TYPE])
|
web/src/assets/svg/database.svg
ADDED
|
web/src/assets/svg/storage.svg
ADDED
|
web/src/interfaces/database/user-setting.ts
CHANGED
@@ -24,8 +24,8 @@ export type TaskExecutorElapsed = Record<string, number[]>;
|
|
24 |
|
25 |
export interface ISystemStatus {
|
26 |
es: Es;
|
27 |
-
|
28 |
-
|
29 |
redis: Redis;
|
30 |
task_executor: {
|
31 |
error?: string;
|
@@ -41,7 +41,13 @@ interface Redis {
|
|
41 |
pending: number;
|
42 |
}
|
43 |
|
44 |
-
export interface
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
status: string;
|
46 |
elapsed: number;
|
47 |
error: string;
|
|
|
24 |
|
25 |
export interface ISystemStatus {
|
26 |
es: Es;
|
27 |
+
storage: Storage;
|
28 |
+
database: Database;
|
29 |
redis: Redis;
|
30 |
task_executor: {
|
31 |
error?: string;
|
|
|
41 |
pending: number;
|
42 |
}
|
43 |
|
44 |
+
export interface Storage {
|
45 |
+
status: string;
|
46 |
+
elapsed: number;
|
47 |
+
error: string;
|
48 |
+
}
|
49 |
+
|
50 |
+
export interface Database {
|
51 |
status: string;
|
52 |
elapsed: number;
|
53 |
error: string;
|
web/src/pages/user-setting/setting-system/index.tsx
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import SvgIcon from '@/components/svg-icon';
|
2 |
import { useFetchSystemStatus } from '@/hooks/user-setting-hooks';
|
|
|
3 |
import {
|
4 |
ISystemStatus,
|
5 |
TaskExecutorElapsed,
|
@@ -24,12 +25,19 @@ enum Status {
|
|
24 |
|
25 |
const TitleMap = {
|
26 |
es: 'Elasticsearch',
|
27 |
-
|
28 |
redis: 'Redis',
|
29 |
-
|
30 |
task_executor: 'Task Executor',
|
31 |
};
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
const SystemInfo = () => {
|
34 |
const {
|
35 |
systemStatus,
|
@@ -56,7 +64,7 @@ const SystemInfo = () => {
|
|
56 |
{key === 'task_executor' ? (
|
57 |
<img src="/logo.svg" alt="" width={26} />
|
58 |
) : (
|
59 |
-
<SvgIcon name={key} width={26}></SvgIcon>
|
60 |
)}
|
61 |
<span className={styles.title}>
|
62 |
{TitleMap[key as keyof typeof TitleMap]}
|
|
|
1 |
import SvgIcon from '@/components/svg-icon';
|
2 |
import { useFetchSystemStatus } from '@/hooks/user-setting-hooks';
|
3 |
+
import { ISystemStatus, Storage } from '@/interfaces/database/userSetting';
|
4 |
import {
|
5 |
ISystemStatus,
|
6 |
TaskExecutorElapsed,
|
|
|
25 |
|
26 |
const TitleMap = {
|
27 |
es: 'Elasticsearch',
|
28 |
+
storage: 'Object Storage',
|
29 |
redis: 'Redis',
|
30 |
+
database: 'Database',
|
31 |
task_executor: 'Task Executor',
|
32 |
};
|
33 |
|
34 |
+
const IconMap = {
|
35 |
+
es: 'es',
|
36 |
+
storage: 'storage',
|
37 |
+
redis: 'redis',
|
38 |
+
database: 'database',
|
39 |
+
};
|
40 |
+
|
41 |
const SystemInfo = () => {
|
42 |
const {
|
43 |
systemStatus,
|
|
|
64 |
{key === 'task_executor' ? (
|
65 |
<img src="/logo.svg" alt="" width={26} />
|
66 |
) : (
|
67 |
+
<SvgIcon name={IconMap[key as keyof typeof IconMap]} width={26}></SvgIcon>
|
68 |
)}
|
69 |
<span className={styles.title}>
|
70 |
{TitleMap[key as keyof typeof TitleMap]}
|