feat: monitor button

This commit is contained in:
jialin
2026-02-04 20:14:25 +08:00
parent 47596fdb1a
commit 4e8b5e26ae
40 changed files with 352 additions and 176 deletions
@@ -1,3 +1,4 @@
import { systemConfigAtom } from '@/atoms/system';
import AutoTooltip from '@/components/auto-tooltip';
import DropdownButtons from '@/components/drop-down-buttons';
import IconFont from '@/components/icon-font';
@@ -24,6 +25,7 @@ import {
import { useIntl } from '@umijs/max';
import { Button, Col, Progress, Row, Tooltip, notification } from 'antd';
import dayjs from 'dayjs';
import { useAtomValue } from 'jotai';
import _ from 'lodash';
import React, { useCallback, useEffect, useMemo } from 'react';
import styled from 'styled-components';
@@ -435,6 +437,7 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
defaultOpenId,
handleChildSelect
}) => {
const systemConfig = useAtomValue(systemConfigAtom);
const { goToGrafana } = useGranfanaLink({ type: 'instance' });
const { runBenchmarkOnInstance } = useBenchmarkTargetInstance();
const [api, contextHolder] = notification.useNotification({
@@ -453,9 +456,12 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
if (action.status && action.status.length > 0) {
return action.status.includes(instanceData.state);
}
if (action.key === 'metrics') {
return systemConfig.showMonitoring;
}
return true;
});
}, [instanceData.state, modelData]);
}, [instanceData.state, modelData, systemConfig.showMonitoring]);
const createFileName = (name: string) => {
const timestamp = dayjs().format('YYYY-MM-DD_HH-mm-ss');
+5 -2
View File
@@ -9,6 +9,7 @@ import SealTable from '@/components/seal-table';
import { TableOrder } from '@/components/seal-table/types';
import { PageAction } from '@/config';
import { TABLE_SORT_DIRECTIONS } from '@/config/settings';
import { PageActionType } from '@/config/types';
import useBodyScroll from '@/hooks/use-body-scroll';
import useExpandedRowKeys from '@/hooks/use-expanded-row-keys';
import useTableRowSelection from '@/hooks/use-table-row-selection';
@@ -170,8 +171,9 @@ const Models: React.FC<ModelsProps> = ({
useEffect(() => {
fetchTargets({});
}, []);
const { goToGrafana } = useGranfanaLink({
type: 'model'
const { goToGrafana, ActionButton } = useGranfanaLink({
type: 'model',
dataList: dataSource || []
});
const [openLogModal, setOpenLogModal] = useState(false);
@@ -660,6 +662,7 @@ const Models: React.FC<ModelsProps> = ({
}
right={
<Space size={16}>
{ActionButton()}
{page !== 'clusters' && (
<DropDownActions
menu={{
+6 -6
View File
@@ -39,11 +39,6 @@ export const ActionList: ActionItem[] = [
key: 'edit',
icon: icons.EditOutlined
},
{
label: 'resources.metrics.details',
key: 'metrics',
icon: icons.Metrics
},
{
label: 'models.openinplayground',
key: 'chat',
@@ -51,7 +46,7 @@ export const ActionList: ActionItem[] = [
},
{
key: 'copy',
label: 'common.button.duplicate',
label: 'common.button.clone',
icon: icons.CopyOutlined
},
{
@@ -64,6 +59,11 @@ export const ActionList: ActionItem[] = [
key: 'stop',
icon: icons.Stop
},
{
label: 'resources.metrics.details',
key: 'metrics',
icon: icons.Metrics
},
{
label: 'common.button.delete',
key: 'delete',
+1 -1
View File
@@ -38,7 +38,7 @@ const BackendFields: React.FC = () => {
const [showDeprecated, setShowDeprecated] = React.useState<boolean>(false);
const handleBackendVersionOnChange = (value: any, option: any) => {
if (Object.keys(option.data.env || {}).length > 0) {
if (Object.keys(option.data?.env || {}).length > 0) {
form.setFieldValue('env', { ...(option?.data?.env || {}) });
}
@@ -34,7 +34,8 @@ const useEditDeployment = () => {
currentData: {
isGGUF: false,
data: formData,
row: row
row: row,
realAction: PageAction.EDIT
},
title: intl.formatMessage({ id: 'models.title.edit' })
});
@@ -1,4 +1,5 @@
// columns.ts
import { systemConfigAtom } from '@/atoms/system';
import AutoTooltip from '@/components/auto-tooltip';
import DropdownButtons from '@/components/drop-down-buttons';
import { SealColumnProps } from '@/components/seal-table/types';
@@ -9,6 +10,7 @@ import { useIntl } from '@umijs/max';
import { useMemoizedFn } from 'ahooks';
import { Tooltip } from 'antd';
import dayjs from 'dayjs';
import { useAtomValue } from 'jotai';
import _ from 'lodash';
import { useMemo } from 'react';
import ModelTag from '../../_components/model-tag';
@@ -31,6 +33,7 @@ const useModelsColumns = ({
targetList
}: ModelsColumnsHookProps & { targetList: any[] }): SealColumnProps[] => {
const intl = useIntl();
const systemConfig = useAtomValue(systemConfigAtom);
const setModelActionList = useMemoizedFn((record: any) => {
return _.filter(ActionList, (action: any) => {
@@ -52,6 +55,9 @@ const useModelsColumns = ({
if (action.key === 'stop') {
return record.replicas > 0;
}
if (action.key === 'metrics') {
return systemConfig.showMonitoring;
}
return true;
});
+3 -3
View File
@@ -146,15 +146,15 @@ const UserModels: React.FC = () => {
};
const getStatus = useCallback((model: any) => {
if (!model.replicas && !model.ready_endpoints) {
if (!model.targets && !model.ready_targets) {
return MyModelsStatusValueMap.Inactive;
}
if (model.replicas > 0 && !model.ready_endpoints) {
if (model.targets > 0 && !model.ready_targets) {
return MyModelsStatusValueMap.Degrade;
}
if (model.ready_endpoints > 0 && model.replicas > 0) {
if (model.ready_targets > 0 && model.targets > 0) {
return MyModelsStatusValueMap.Active;
}
return MyModelsStatusValueMap.Degrade;