Skip to content

Commit

Permalink
Feat behaviour statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
yang1666204 authored Mar 28, 2024
1 parent 8453102 commit d57ad62
Show file tree
Hide file tree
Showing 27 changed files with 622 additions and 103 deletions.
12 changes: 8 additions & 4 deletions ui/src/components/TopoComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import { useRequest,useUpdateEffect } from 'ahooks';
import { message } from 'antd';
import _ from 'lodash';
import { ReactElement,useEffect,useMemo,useRef,useState } from 'react';
import { useModel } from '@umijs/max';

import showDeleteConfirm from '@/components/customModal/DeleteModal';
import OperateModal from '@/components/customModal/OperateModal';
import { RESULT_STATUS } from '@/constants';
import BasicInfo from '@/pages/Cluster/Detail/Overview/BasicInfo';
import { getClusterFromTenant,getOriginResourceUsages,getZonesOptions } from '@/pages/Tenant/helper';
import { deleteObcluster,deleteObzone,getClusterDetailReq } from '@/services';
import { getClusterFromTenant, getOriginResourceUsages, getZonesOptions } from '@/pages/Tenant/helper';
import { getClusterDetailReq } from '@/services';
import { deleteClusterReportWrap, deleteObzoneReportWrap } from '@/services/reportRequest/clusterReportReq';
import { deleteObtenantPool } from '@/services/tenant';
import { getNSName } from '../../pages/Cluster/Detail/Overview/helper';
import { ReactNode,config } from './G6register';
Expand Down Expand Up @@ -46,6 +48,7 @@ export default function TopoComponent({
refreshTenant,
defaultUnitCount,
}: TopoProps) {
const { appInfo } = useModel('global');
const clusterOperateList = tenantReplicas
? clusterOperateOfTenant
: clusterOperate;
Expand Down Expand Up @@ -121,18 +124,19 @@ export default function TopoComponent({
};
//delete cluster
const clusterDelete = async () => {
const res = await deleteObcluster({ ns, name });
const res = await deleteClusterReportWrap({ ns, name, version: appInfo.version });
if (res.successful) {
message.success(res.message);
getTopoData({ ns, name, useFor: 'topo', tenantReplicas });
}
};
//delete zone
const zoneDelete = async () => {
const res = await deleteObzone({
const res = await deleteObzoneReportWrap({
ns,
name,
zoneName: chooseZoneName.current,
version: appInfo.version
});
if (res.successful) {
message.success(
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/customModal/ActivateTenantModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export default function ActivateTenantModal({
}),
);
setVisible(false);
successCallback();
if(successCallback)successCallback();
}
},
});
const handleSubmit = async () => {
const [ns, name] = getNSName();
await activateTenant({ ns, name });
await activateTenant({ ns, name, failover: true });
};
const handleCancel = () => setVisible(false);

Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/customModal/AddNSModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function AddNSModal({
}),
);
setVisible(false);
successCallback(newNamespace.current);
if(successCallback)successCallback(newNamespace.current);
}
},
});
Expand Down
9 changes: 5 additions & 4 deletions ui/src/components/customModal/AddZoneModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { Form, Input, message } from 'antd';

import { RULER_ZONE } from '@/constants/rules';
import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { addObzone } from '@/services';
import { addObzoneReportWrap } from '@/services/reportRequest/clusterReportReq';
import InputNumber from '../InputNumber';
import { useModel } from '@umijs/max';
import type { CommonModalType } from '.';
import CustomModal from '.';
import NodeSelector from '../NodeSelector';
Expand All @@ -19,7 +20,7 @@ export default function AddZoneModal({
successCallback,
}: CommonModalType) {
const [form] = Form.useForm();

const { appInfo } = useModel('global');
const handleSubmit = async () => {
try {
await form.validateFields();
Expand All @@ -33,10 +34,10 @@ export default function AddZoneModal({
}
const onFinish = async (values: any) => {
const [namespace, name] = getNSName();
const res = await addObzone({ namespace, name, ...values });
const res = await addObzoneReportWrap({ namespace, name, ...values, version: appInfo.version });
if (res.successful) {
message.success(res.message);
successCallback();
if(successCallback) successCallback();
form.resetFields();
setVisible(false);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/customModal/LogReplayModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function LogReplayModal({
const res = await replayLogOfTenant({ namespace, name, ...values });
if (res.successful) {
message.success(res.message);
successCallback();
if(successCallback) successCallback();
form.resetFields();
setVisible(false);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/customModal/ModifyPasswordModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function ModifyPasswordModal({
});
if (res.successful) {
message.success(res.message);
successCallback();
if(successCallback) successCallback();
form.resetFields();
setVisible(false);
}
Expand Down
12 changes: 9 additions & 3 deletions ui/src/components/customModal/ModifyUnitDetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ import {
findMinParameter,
modifyZoneCheckedStatus,
} from '@/pages/Tenant/helper';
import { createObtenantPool,patchObtenantPool } from '@/services/tenant';
import {
patchObtenantPoolReportWrap,
createTenantReportWrap
} from '@/services/reportRequest/tenantReportReq';
import { formatPatchPoolData } from '@/utils/helper';
import { intl } from '@/utils/intl';
import { useEffect,useState } from 'react';
import SelectWithTooltip from '../SelectWithTooltip';
import { useModel } from '@umijs/max';

import { Col,Form,Row,Select,message } from 'antd';
import type { CommonModalType } from '.';
Expand Down Expand Up @@ -80,6 +84,7 @@ export default function ModifyUnitDetailModal({
zoneName,
},
}: CommonModalType & UnitConfigType) {
const { appInfo } = useModel('global');
const [form] = Form.useForm<PoolDetailType>();
const [maxResource, setMaxResource] = useState<MaxResourceType>({});
const [minResource, setMinResource] = useState<MinResourceConfig>(
Expand All @@ -90,8 +95,8 @@ export default function ModifyUnitDetailModal({
);
const selectZone = Form.useWatch('selectZone', form);
const obtenantPoolReq = newResourcePool
? createObtenantPool
: patchObtenantPool;
? createTenantReportWrap
: patchObtenantPoolReportWrap;

const handleSubmit = async () => {
try {
Expand All @@ -118,6 +123,7 @@ export default function ModifyUnitDetailModal({
ns,
name,
zoneName,
version:appInfo.version,
...reqData,
});
if (res.successful) {
Expand Down
9 changes: 6 additions & 3 deletions ui/src/components/customModal/ModifyUnitModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { patchTenantConfiguration } from '@/services/tenant';
import { modifyUnitNumReportWrap } from '@/services/reportRequest/tenantReportReq';
import { useModel } from '@umijs/max';
import { intl } from '@/utils/intl';
import { Form,InputNumber,message } from 'antd';
import { useEffect } from 'react';
Expand All @@ -18,6 +19,7 @@ export default function ModifyUnitModal({
},
successCallback,
}: CommonModalType & { params: { defaultUnitCount: number } }) {
const { appInfo } = useModel('global');
const [form] = Form.useForm();
const { defaultUnitCount } = params;
const handleSubmit = async () => {
Expand All @@ -30,10 +32,11 @@ export default function ModifyUnitModal({
const handleCancel = () => setVisible(false);
const onFinish = async (values: any) => {
const [namespace, name] = getNSName();
const res = await patchTenantConfiguration({
const res = await modifyUnitNumReportWrap({
ns: namespace,
name,
...values,
version: appInfo.version
});
if (res.successful) {
message.success(
Expand All @@ -43,7 +46,7 @@ export default function ModifyUnitModal({
defaultMessage: '修改成功',
}),
);
successCallback();
if(successCallback) successCallback();
form.resetFields();
setVisible(false);
}
Expand Down
9 changes: 6 additions & 3 deletions ui/src/components/customModal/ScaleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { Form, InputNumber, message } from 'antd';
import CustomModal from '.';

import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { scaleObserver } from '@/services';
import { scaleObserverReportWrap } from '@/services/reportRequest/clusterReportReq';
import { useModel } from '@umijs/max';
import { useEffect } from 'react';
import type { CommonModalType } from '.';

Expand All @@ -20,6 +21,7 @@ export default function ScaleModal({
successCallback,
params,
}: ScaleModalProps & CommonModalType) {
const { appInfo } = useModel('global');
const zoneName = params?.zoneName;
const defaultValue = params?.defaultValue;
const [form] = Form.useForm();
Expand All @@ -32,15 +34,16 @@ export default function ScaleModal({
const onFinish = async (val: any) => {
if (!zoneName) throw new Error('zoneName is not defined');
const [namespace, name] = getNSName();
const res = await scaleObserver({
const res = await scaleObserverReportWrap({
namespace,
name,
zoneName,
replicas: val.replicas,
version: appInfo.version
});
if (res.successful) {
message.success(res.message);
successCallback();
if(successCallback) successCallback();
form.resetFields();
setVisible(false);
}
Expand Down
11 changes: 3 additions & 8 deletions ui/src/components/customModal/SwitchTenantModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,15 @@ export default function SwitchTenantModal({
manual: true,
onSuccess: ({ successful }) => {
if (successful) {
message.success(
intl.formatMessage({
id: 'Dashboard.components.customModal.SwitchTenantModal.TheStandbyTenantHasBeen',
defaultMessage: '激活备租户成功',
}),
);
message.success('操作成功');
setVisible(false);
successCallback();
if(successCallback) successCallback();
}
},
});
const handleSubmit = async () => {
const [ns, name] = getNSName();
await activateTenant({ ns, name });
await activateTenant({ ns, name, switchover: true });
};
const handleCancel = () => setVisible(false);

Expand Down
9 changes: 5 additions & 4 deletions ui/src/components/customModal/UpgradeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { intl } from '@/utils/intl';
import { Form, Input, message } from 'antd';

import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { upgradeObcluster } from '@/services';
import { upgradeClusterReportWrap } from '@/services/reportRequest/clusterReportReq';
import { useModel } from '@umijs/max';
import type { CommonModalType } from '.';
import CustomModal from '.';

Expand All @@ -15,7 +16,7 @@ export default function UpgradeModal({
successCallback,
}: CommonModalType) {
const [form] = Form.useForm();

const { appInfo } = useModel('global');
const handleSubmit = async () => {
try {
await form.validateFields();
Expand All @@ -26,10 +27,10 @@ export default function UpgradeModal({
const handleCancel = () => setVisible(false);
const onFinish = async ({ image }: any) => {
const [ns, name] = getNSName();
const res = await upgradeObcluster({ ns, name, image });
const res = await upgradeClusterReportWrap({ ns, name, image, version: appInfo.version });
if (res.successful) {
message.success(res.message);
successCallback();
if(successCallback) successCallback();
form.resetFields();
setVisible(false);
}
Expand Down
8 changes: 4 additions & 4 deletions ui/src/components/customModal/UpgradeTenantModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useRequest } from 'ahooks';
import { message } from 'antd';

import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
import { changeTenantRole } from '@/services/tenant';
import { upgradeTenantCompatibilityVersion } from '@/services/tenant';
import type { CommonModalType } from '.';
import CustomModal from '.';

Expand All @@ -12,7 +12,7 @@ export default function UpgradeTenantModal({
setVisible,
successCallback,
}: CommonModalType) {
const { run: activateTenant } = useRequest(changeTenantRole, {
const { run: upgradeTenant } = useRequest(upgradeTenantCompatibilityVersion, {
manual: true,
onSuccess: ({ successful }) => {
if (successful) {
Expand All @@ -23,13 +23,13 @@ export default function UpgradeTenantModal({
}),
);
setVisible(false);
successCallback();
if(successCallback) successCallback();
}
},
});
const handleSubmit = async () => {
const [ns, name] = getNSName();
await activateTenant({ ns, name });
await upgradeTenant({ ns, name });
};
const handleCancel = () => setVisible(false);

Expand Down
8 changes: 6 additions & 2 deletions ui/src/pages/Cluster/Detail/Overview/ZoneTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import type { ColumnType } from 'antd/es/table';

import showDeleteConfirm from '@/components/customModal/DeleteModal';
import { COLOR_MAP } from '@/constants';
import { deleteObzone } from '@/services';
import { deleteObzoneReportWrap } from '@/services/reportRequest/clusterReportReq';
import { useModel } from '@umijs/max';
import { getNSName } from './helper';

interface ZoneTableProps {
Expand All @@ -24,6 +25,8 @@ export default function ZoneTable({
setChooseServerNum,
clusterStatus,
}: ZoneTableProps) {
const { appInfo } = useModel('global');

const getZoneColumns = (remove, clickScale) => {
const columns: ColumnType<API.Zone> = [
{
Expand Down Expand Up @@ -134,10 +137,11 @@ export default function ZoneTable({
//删除的ns和name是集群的
const handleDelete = async (zoneName: string) => {
const [ns, name] = getNSName();
const res = await deleteObzone({
const res = await deleteObzoneReportWrap({
ns,
name,
zoneName,
version: appInfo.version
});
if (res.successful) {
message.success(
Expand Down
7 changes: 4 additions & 3 deletions ui/src/pages/Cluster/Detail/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import EventsTable from '@/components/EventsTable';
import showDeleteConfirm from '@/components/customModal/DeleteModal';
import OperateModal from '@/components/customModal/OperateModal';
import { REFRESH_CLUSTER_TIME } from '@/constants';
import { deleteObcluster,getClusterDetailReq } from '@/services';
import { getClusterDetailReq } from '@/services';
import { deleteClusterReportWrap } from '@/services/reportRequest/clusterReportReq';
import BasicInfo from './BasicInfo';
import ServerTable from './ServerTable';
import ZoneTable from './ZoneTable';
import { getNSName } from './helper';

//集群详情概览页
const ClusterOverview: React.FC = () => {
const { setChooseClusterName } = useModel('global');
const { setChooseClusterName, appInfo } = useModel('global');
const [operateModalVisible, setOperateModalVisible] =
useState<boolean>(false);
const [[ns, name]] = useState(getNSName());
Expand All @@ -43,7 +44,7 @@ const ClusterOverview: React.FC = () => {
},
);
const handleDelete = async () => {
const res = await deleteObcluster({ ns, name });
const res = await deleteClusterReportWrap({ ns, name, version: appInfo.version });
if (res.successful) {
message.success(
intl.formatMessage({
Expand Down
Loading

0 comments on commit d57ad62

Please sign in to comment.