chore: add watch for worker and gpu updating
This commit is contained in:
@@ -7,14 +7,18 @@ import _ from 'lodash';
|
||||
import qs from 'query-string';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
export default function useTableFetch<ListItem>(options: {
|
||||
API?: string;
|
||||
watch?: boolean;
|
||||
fetchAPI: (params: any) => Promise<Global.PageResponse<ListItem>>;
|
||||
deleteAPI?: (id: number, params?: any) => Promise<any>;
|
||||
contentForDelete?: string;
|
||||
defaultData?: any[];
|
||||
}) {
|
||||
type WatchConfig =
|
||||
| { watch?: false | undefined; API?: string }
|
||||
| { watch: true; API: string };
|
||||
|
||||
export default function useTableFetch<ListItem>(
|
||||
options: {
|
||||
fetchAPI: (params: any) => Promise<Global.PageResponse<ListItem>>;
|
||||
deleteAPI?: (id: number, params?: any) => Promise<any>;
|
||||
contentForDelete?: string;
|
||||
defaultData?: any[];
|
||||
} & WatchConfig
|
||||
) {
|
||||
const {
|
||||
fetchAPI,
|
||||
deleteAPI,
|
||||
|
||||
@@ -478,7 +478,7 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
|
||||
return (
|
||||
<TooltipOverlayScroller
|
||||
toolTipProps={{
|
||||
trigger: 'click',
|
||||
trigger: 'hover',
|
||||
overlayInnerStyle: {
|
||||
width: 'max-content',
|
||||
maxWidth: '520px',
|
||||
|
||||
@@ -475,6 +475,9 @@ const Models: React.FC<ModelsProps> = ({
|
||||
await handleStartModel(row);
|
||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
||||
updateExpandedRowKeys([row.id, ...expandedRowKeys]);
|
||||
setTimeout(() => {
|
||||
handleSearch?.();
|
||||
}, 150);
|
||||
}
|
||||
|
||||
if (val === 'api') {
|
||||
@@ -490,6 +493,9 @@ const Models: React.FC<ModelsProps> = ({
|
||||
name: row.name,
|
||||
async onOk() {
|
||||
await handleStopModel(row);
|
||||
setTimeout(() => {
|
||||
handleSearch?.();
|
||||
}, 150);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -465,7 +465,11 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||
</Checkbox>
|
||||
</Tooltip>
|
||||
|
||||
<Button size="middle" onClick={handleAddText}>
|
||||
<Button
|
||||
size="middle"
|
||||
onClick={handleAddText}
|
||||
disabled={loading}
|
||||
>
|
||||
<PlusOutlined />
|
||||
{intl.formatMessage({ id: 'playground.embedding.addtext' })}
|
||||
</Button>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { useIntl } from '@umijs/max';
|
||||
import { ConfigProvider, Empty, Table } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
import { queryGpuDevicesList } from '../apis';
|
||||
import { GPU_DEVICES_API, queryGpuDevicesList } from '../apis';
|
||||
import { GPUDeviceItem } from '../config/types';
|
||||
const { Column } = Table;
|
||||
|
||||
@@ -48,7 +48,9 @@ const GPUList: React.FC = () => {
|
||||
handleSearch,
|
||||
handleNameChange
|
||||
} = useTableFetch<GPUDeviceItem>({
|
||||
fetchAPI: queryGpuDevicesList
|
||||
fetchAPI: queryGpuDevicesList,
|
||||
watch: true,
|
||||
API: GPU_DEVICES_API
|
||||
});
|
||||
|
||||
const intl = useIntl();
|
||||
|
||||
@@ -547,7 +547,7 @@ const ModelFiles = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const columns = [
|
||||
const columns: any[] = [
|
||||
{
|
||||
title: intl.formatMessage({ id: 'models.form.source' }),
|
||||
dataIndex: 'source',
|
||||
|
||||
@@ -18,7 +18,12 @@ import { ConfigProvider, Empty, Table, Tooltip, message } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { deleteWorker, queryWorkersList, updateWorker } from '../apis';
|
||||
import {
|
||||
WORKERS_API,
|
||||
deleteWorker,
|
||||
queryWorkersList,
|
||||
updateWorker
|
||||
} from '../apis';
|
||||
import { WorkerStatusMapValue, status } from '../config';
|
||||
import { Filesystem, GPUDeviceItem, ListItem } from '../config/types';
|
||||
import AddWorker from './add-worker';
|
||||
@@ -100,7 +105,9 @@ const Workers: React.FC = () => {
|
||||
} = useTableFetch<ListItem>({
|
||||
fetchAPI: queryWorkersList,
|
||||
deleteAPI: deleteWorker,
|
||||
contentForDelete: 'worker'
|
||||
contentForDelete: 'worker',
|
||||
watch: true,
|
||||
API: WORKERS_API
|
||||
});
|
||||
|
||||
const intl = useIntl();
|
||||
|
||||
Reference in New Issue
Block a user