fix: refresh model list manually
This commit is contained in:
@@ -0,0 +1,129 @@
|
|||||||
|
import Chart from '@/components/echarts/chart';
|
||||||
|
import useChartConfig from '@/components/echarts/config';
|
||||||
|
import EmptyData from '@/components/empty-data';
|
||||||
|
import _ from 'lodash';
|
||||||
|
import React, { memo, useMemo } from 'react';
|
||||||
|
import { ChartProps } from './types';
|
||||||
|
|
||||||
|
const MixLineBarChart: React.FC<
|
||||||
|
ChartProps & {
|
||||||
|
chartData: {
|
||||||
|
line: any[];
|
||||||
|
bar: any[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
> = (props) => {
|
||||||
|
const {
|
||||||
|
seriesData,
|
||||||
|
xAxisData,
|
||||||
|
yAxisName,
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
labelFormatter,
|
||||||
|
tooltipValueFormatter = null,
|
||||||
|
legendData = [],
|
||||||
|
smooth,
|
||||||
|
title,
|
||||||
|
chartData
|
||||||
|
} = props;
|
||||||
|
const {
|
||||||
|
grid,
|
||||||
|
legend,
|
||||||
|
lineItemConfig,
|
||||||
|
title: titleConfig,
|
||||||
|
tooltip,
|
||||||
|
xAxis,
|
||||||
|
yAxis
|
||||||
|
} = useChartConfig();
|
||||||
|
|
||||||
|
const { line: lineSeriesData, bar: barSeriesData } = chartData;
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
title: {
|
||||||
|
text: ''
|
||||||
|
},
|
||||||
|
grid,
|
||||||
|
tooltip: {
|
||||||
|
...tooltip,
|
||||||
|
formatter(params: any) {
|
||||||
|
return tooltipValueFormatter
|
||||||
|
? tooltip.formatter(params, tooltipValueFormatter)
|
||||||
|
: tooltip.formatter(params);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
...xAxis,
|
||||||
|
axisLabel: {
|
||||||
|
...xAxis.axisLabel,
|
||||||
|
formatter: labelFormatter
|
||||||
|
}
|
||||||
|
},
|
||||||
|
yAxis,
|
||||||
|
legend: {
|
||||||
|
...legend,
|
||||||
|
data: legendData.map((item: any) => {
|
||||||
|
return {
|
||||||
|
name: item,
|
||||||
|
icon: 'circle'
|
||||||
|
};
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
series: []
|
||||||
|
};
|
||||||
|
|
||||||
|
const dataOptions = useMemo((): any => {
|
||||||
|
const data = _.map(seriesData, (item: any) => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
...lineItemConfig,
|
||||||
|
smooth: smooth,
|
||||||
|
itemStyle: {
|
||||||
|
...lineItemConfig.itemStyle,
|
||||||
|
color: item.color
|
||||||
|
},
|
||||||
|
lineStyle: {
|
||||||
|
...lineItemConfig.lineStyle,
|
||||||
|
color: item.color
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
...options,
|
||||||
|
animation: false,
|
||||||
|
title: {
|
||||||
|
...titleConfig,
|
||||||
|
text: title
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
...options.yAxis,
|
||||||
|
name: yAxisName,
|
||||||
|
nameTextStyle: {
|
||||||
|
fontSize: 12,
|
||||||
|
align: 'right'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
...options.xAxis,
|
||||||
|
data: xAxisData
|
||||||
|
},
|
||||||
|
series: data
|
||||||
|
};
|
||||||
|
}, [seriesData, xAxisData, yAxisName, title, smooth, legendData, options]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{!seriesData.length ? (
|
||||||
|
<EmptyData height={height} title={title}></EmptyData>
|
||||||
|
) : (
|
||||||
|
<Chart
|
||||||
|
height={height}
|
||||||
|
options={dataOptions}
|
||||||
|
width={width || '100%'}
|
||||||
|
></Chart>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default memo(MixLineBarChart);
|
||||||
@@ -27,6 +27,8 @@ const RequestTokenInner: React.FC<RequestTokenInnerProps> = (props) => {
|
|||||||
const { requestData, tokenData, xAxisData } = props;
|
const { requestData, tokenData, xAxisData } = props;
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
|
console.log('usage===========', requestData, tokenData, xAxisData);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CardWrapper style={{ width: '100%' }}>
|
<CardWrapper style={{ width: '100%' }}>
|
||||||
<Row style={{ width: '100%' }}>
|
<Row style={{ width: '100%' }}>
|
||||||
@@ -49,6 +51,17 @@ const RequestTokenInner: React.FC<RequestTokenInnerProps> = (props) => {
|
|||||||
></BarChart>
|
></BarChart>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
{/* <MixLineBar
|
||||||
|
title={intl.formatMessage({ id: 'dashboard.apirequest' })}
|
||||||
|
chartData={{
|
||||||
|
line: requestData,
|
||||||
|
bar: tokenData
|
||||||
|
}}
|
||||||
|
seriesData={[]}
|
||||||
|
xAxisData={xAxisData}
|
||||||
|
height={360}
|
||||||
|
labelFormatter={labelFormatter}
|
||||||
|
></MixLineBar> */}
|
||||||
</CardWrapper>
|
</CardWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { PageContainer } from '@ant-design/pro-components';
|
import { PageContainer } from '@ant-design/pro-components';
|
||||||
import { Spin } from 'antd';
|
import { Spin } from 'antd';
|
||||||
import { memo, useState } from 'react';
|
import { useState } from 'react';
|
||||||
import DashboardInner from './components/dahboard-inner';
|
import DashboardInner from './components/dahboard-inner';
|
||||||
|
|
||||||
const Dashboard: React.FC = () => {
|
const Dashboard: React.FC = () => {
|
||||||
@@ -25,4 +25,4 @@ const Dashboard: React.FC = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default memo(Dashboard);
|
export default Dashboard;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ import ModelTag from './model-tag';
|
|||||||
import UpdateModel from './update-modal';
|
import UpdateModel from './update-modal';
|
||||||
import ViewLogsModal from './view-logs-modal';
|
import ViewLogsModal from './view-logs-modal';
|
||||||
interface ModelsProps {
|
interface ModelsProps {
|
||||||
handleSearch: () => void;
|
handleSearch: (params?: any) => void;
|
||||||
handleNameChange: (e: any) => void;
|
handleNameChange: (e: any) => void;
|
||||||
handleShowSizeChange?: (page: number, size: number) => void;
|
handleShowSizeChange?: (page: number, size: number) => void;
|
||||||
handlePageChange: (page: number, pageSize: number | undefined) => void;
|
handlePageChange: (page: number, pageSize: number | undefined) => void;
|
||||||
@@ -94,6 +94,7 @@ interface ModelsProps {
|
|||||||
onCancelViewLogs: () => void;
|
onCancelViewLogs: () => void;
|
||||||
handleOnToggleExpandAll: () => void;
|
handleOnToggleExpandAll: () => void;
|
||||||
onStop?: (ids: number[]) => void;
|
onStop?: (ids: number[]) => void;
|
||||||
|
onStart?: () => void;
|
||||||
queryParams: {
|
queryParams: {
|
||||||
page: number;
|
page: number;
|
||||||
perPage: number;
|
perPage: number;
|
||||||
@@ -134,6 +135,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
handleCategoryChange,
|
handleCategoryChange,
|
||||||
handleOnToggleExpandAll,
|
handleOnToggleExpandAll,
|
||||||
onStop,
|
onStop,
|
||||||
|
onStart,
|
||||||
modelFileOptions,
|
modelFileOptions,
|
||||||
deleteIds,
|
deleteIds,
|
||||||
dataSource,
|
dataSource,
|
||||||
@@ -262,7 +264,6 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
const handleStopModel = async (row: ListItem) => {
|
const handleStopModel = async (row: ListItem) => {
|
||||||
await updateModel(getFormattedData(row, { replicas: 0 }));
|
await updateModel(getFormattedData(row, { replicas: 0 }));
|
||||||
removeExpandedRowKey([row.id]);
|
removeExpandedRowKey([row.id]);
|
||||||
onStop?.([row.id]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleModalOk = useCallback(
|
const handleModalOk = useCallback(
|
||||||
@@ -478,6 +479,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
await handleStartModel(row);
|
await handleStartModel(row);
|
||||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
||||||
updateExpandedRowKeys([row.id, ...expandedRowKeys]);
|
updateExpandedRowKeys([row.id, ...expandedRowKeys]);
|
||||||
|
onStart?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val === 'api') {
|
if (val === 'api') {
|
||||||
@@ -493,6 +495,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
name: row.name,
|
name: row.name,
|
||||||
async onOk() {
|
async onOk() {
|
||||||
await handleStopModel(row);
|
await handleStopModel(row);
|
||||||
|
onStop?.([row.id]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -560,6 +563,7 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
async onOk() {
|
async onOk() {
|
||||||
await handleBatchRequest(rowSelection.selectedRows, handleStartModel);
|
await handleBatchRequest(rowSelection.selectedRows, handleStartModel);
|
||||||
rowSelection.clearSelections();
|
rowSelection.clearSelections();
|
||||||
|
onStart?.();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -260,11 +260,23 @@ const Models: React.FC = () => {
|
|||||||
setTimeout(resolve, 300);
|
setTimeout(resolve, 300);
|
||||||
});
|
});
|
||||||
setModelInstances(cacheInsDataListRef.current);
|
setModelInstances(cacheInsDataListRef.current);
|
||||||
|
fetchData({
|
||||||
|
loadingVal: false
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleSearch = useCallback(async () => {
|
const handleOnStart = useCallback(() => {
|
||||||
await fetchData();
|
fetchData({
|
||||||
}, [fetchData]);
|
loadingVal: false
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleSearch = useCallback(
|
||||||
|
async (params?: any) => {
|
||||||
|
await fetchData(params);
|
||||||
|
},
|
||||||
|
[fetchData]
|
||||||
|
);
|
||||||
|
|
||||||
const debounceUpdateFilter = _.debounce((e: any) => {
|
const debounceUpdateFilter = _.debounce((e: any) => {
|
||||||
setQueryParams({
|
setQueryParams({
|
||||||
@@ -469,6 +481,7 @@ const Models: React.FC = () => {
|
|||||||
onViewLogs={handleOnViewLogs}
|
onViewLogs={handleOnViewLogs}
|
||||||
onCancelViewLogs={handleOnCancelViewLogs}
|
onCancelViewLogs={handleOnCancelViewLogs}
|
||||||
onStop={handleOnStop}
|
onStop={handleOnStop}
|
||||||
|
onStart={handleOnStart}
|
||||||
queryParams={queryParams}
|
queryParams={queryParams}
|
||||||
loading={dataSource.loading}
|
loading={dataSource.loading}
|
||||||
loadend={dataSource.loadend}
|
loadend={dataSource.loadend}
|
||||||
|
|||||||
Reference in New Issue
Block a user