Skip to content

Commit

Permalink
Feat statistics (#275)
Browse files Browse the repository at this point in the history
* feat: Statistics

* fix: Padding ajustment
  • Loading branch information
yang1666204 authored Mar 31, 2024
1 parent ccb5dbe commit b42863c
Show file tree
Hide file tree
Showing 31 changed files with 556 additions and 297 deletions.
201 changes: 104 additions & 97 deletions ui/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,110 +5,117 @@ export default [
routes: [
{
path: '/',
component: 'Layouts/BasicLayout',
component: 'Layouts/StatisticsLayout',
name: '系统布局',
routes: [
{
path: 'cluster',
component: 'Cluster',
name: '集群页',
},
{
path:'cluster/new',
component:'Cluster/New',
name: '创建集群',
},
{
path:'tenant',
component:'Tenant',
name:'租户页'
},
{
path:'tenant/new',
component:'Tenant/New',
name:'创建租户'
},
{
path: 'overview',
component: 'Overview',
name: '系统概览页',
},
{
path: '/',
redirect: 'overview',
name: '系统概览页',
},
],
},
{
path: 'cluster/:clusterId',
component: 'Cluster/Detail',
name: '集群详情',
routes: [
{
path: 'overview',
component: 'Cluster/Detail/Overview',
name: '概览页',
},
{
path: 'topo',
component: 'Cluster/Detail/Topo',
name: '集群拓扑图',
},
{
path:'monitor',
component:'Cluster/Detail/Monitor',
name:'集群详情监控'
},
{
path:'tenant',
component:'Cluster/Detail/Tenant',
name:'集群下的租户'
},
{
path: '/cluster/:clusterId',
redirect: 'overview',
name: '概览页',
component: 'Layouts/BasicLayout',
name: '概览布局',
routes: [
{
path: 'cluster',
component: 'Cluster',
name: '集群页',
},
{
path: 'cluster/new',
component: 'Cluster/New',
name: '创建集群',
},
{
path: 'tenant',
component: 'Tenant',
name: '租户页',
},
{
path: 'tenant/new',
component: 'Tenant/New',
name: '创建租户',
},
{
path: 'overview',
component: 'Overview',
name: '系统概览页',
},
{
path: '/',
redirect: 'overview',
name: '系统概览页',
},
],
},
{
path: 'cluster/:clusterId',
component: 'Cluster/Detail',
name: '集群详情',
routes: [
{
path: 'overview',
component: 'Cluster/Detail/Overview',
name: '概览页',
},
{
path: 'topo',
component: 'Cluster/Detail/Topo',
name: '集群拓扑图',
},
{
path: 'monitor',
component: 'Cluster/Detail/Monitor',
name: '集群详情监控',
},
{
path: 'tenant',
component: 'Cluster/Detail/Tenant',
name: '集群下的租户',
},
{
path: '/cluster/:clusterId',
redirect: 'overview',
name: '概览页',
},
],
},
{
path: 'tenant/:tenantId',
component: 'Tenant/Detail',
name: '租户详情',
routes: [
{
path: 'overview',
component: 'Tenant/Detail/Overview',
name: '概览页',
},
{
path: 'topo',
component: 'Tenant/Detail/Topo',
name: '租户拓扑图',
},
{
path: 'backup',
component: 'Tenant/Detail/Backup',
name: '租户备份',
},
{
path: 'backup/new',
component: 'Tenant/Detail/NewBackup',
name: '新建租户备份',
},
{
path: 'monitor',
component: 'Tenant/Detail/Monitor',
name: '租户详情监控',
},
{
path: '/tenant/:tenantId',
redirect: 'overview',
name: '概览页',
},
],
},
],
},
{
path:'tenant/:tenantId',
component:'Tenant/Detail',
name:'租户详情',
routes:[
{
path: 'overview',
component: 'Tenant/Detail/Overview',
name: '概览页',
},
{
path: 'topo',
component: 'Tenant/Detail/Topo',
name: '租户拓扑图',
},
{
path: 'backup',
component: 'Tenant/Detail/Backup',
name: '租户备份',
},
{
path: 'backup/new',
component: 'Tenant/Detail/NewBackup',
name: '新建租户备份',
},
{
path:'monitor',
component:'Tenant/Detail/Monitor',
name:'租户详情监控'
},
{
path: '/tenant/:tenantId',
redirect: 'overview',
name: '概览页',
},
]
},
{
path: '/login',
component: 'Login',
Expand Down
4 changes: 1 addition & 3 deletions ui/src/components/TopoComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export default function TopoComponent({
refreshTenant,
defaultUnitCount,
}: TopoProps) {
const { appInfo } = useModel('global');
const clusterOperateList = tenantReplicas
? clusterOperateOfTenant
: clusterOperate;
Expand Down Expand Up @@ -124,7 +123,7 @@ export default function TopoComponent({
};
//delete cluster
const clusterDelete = async () => {
const res = await deleteClusterReportWrap({ ns, name, version: appInfo.version });
const res = await deleteClusterReportWrap({ ns, name });
if (res.successful) {
message.success(res.message);
getTopoData({ ns, name, useFor: 'topo', tenantReplicas });
Expand All @@ -136,7 +135,6 @@ export default function TopoComponent({
ns,
name,
zoneName: chooseZoneName.current,
version: appInfo.version
});
if (res.successful) {
message.success(
Expand Down
4 changes: 1 addition & 3 deletions ui/src/components/customModal/AddZoneModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { RULER_ZONE } from '@/constants/rules';
import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
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 @@ -20,7 +19,6 @@ export default function AddZoneModal({
successCallback,
}: CommonModalType) {
const [form] = Form.useForm();
const { appInfo } = useModel('global');
const handleSubmit = async () => {
try {
await form.validateFields();
Expand All @@ -34,7 +32,7 @@ export default function AddZoneModal({
}
const onFinish = async (values: any) => {
const [namespace, name] = getNSName();
const res = await addObzoneReportWrap({ namespace, name, ...values, version: appInfo.version });
const res = await addObzoneReportWrap({ namespace, name, ...values});
if (res.successful) {
message.success(res.message);
if(successCallback) successCallback();
Expand Down
3 changes: 0 additions & 3 deletions ui/src/components/customModal/ModifyUnitDetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ 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 @@ -84,7 +83,6 @@ 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 Down Expand Up @@ -123,7 +121,6 @@ export default function ModifyUnitDetailModal({
ns,
name,
zoneName,
version:appInfo.version,
...reqData,
});
if (res.successful) {
Expand Down
3 changes: 0 additions & 3 deletions ui/src/components/customModal/ModifyUnitModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getNSName } from '@/pages/Cluster/Detail/Overview/helper';
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 @@ -19,7 +18,6 @@ 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 @@ -36,7 +34,6 @@ export default function ModifyUnitModal({
ns: namespace,
name,
...values,
version: appInfo.version
});
if (res.successful) {
message.success(
Expand Down
3 changes: 0 additions & 3 deletions ui/src/components/customModal/ScaleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import CustomModal from '.';

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

Expand All @@ -21,7 +20,6 @@ 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 @@ -39,7 +37,6 @@ export default function ScaleModal({
name,
zoneName,
replicas: val.replicas,
version: appInfo.version
});
if (res.successful) {
message.success(res.message);
Expand Down
4 changes: 1 addition & 3 deletions ui/src/components/customModal/UpgradeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Form, Input, message } from 'antd';

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

Expand All @@ -16,7 +15,6 @@ export default function UpgradeModal({
successCallback,
}: CommonModalType) {
const [form] = Form.useForm();
const { appInfo } = useModel('global');
const handleSubmit = async () => {
try {
await form.validateFields();
Expand All @@ -27,7 +25,7 @@ export default function UpgradeModal({
const handleCancel = () => setVisible(false);
const onFinish = async ({ image }: any) => {
const [ns, name] = getNSName();
const res = await upgradeClusterReportWrap({ ns, name, image, version: appInfo.version });
const res = await upgradeClusterReportWrap({ ns, name, image });
if (res.successful) {
message.success(res.message);
if(successCallback) successCallback();
Expand Down
8 changes: 8 additions & 0 deletions ui/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ const REFRESH_FREQUENCY = 15;
// Number of monitoring points
const POINT_NUMBER = 15;

// two minutes
const CHECK_STORAGE_INTERVAL = 1000 * 120;

// three hours
const STATISTICS_INTERVAL = 1000 * 60 * 60 * 3;

const SUFFIX_UNIT = 'GB';

const MINIMAL_CONFIG = {
Expand Down Expand Up @@ -150,6 +156,7 @@ const MODE_MAP = new Map([
export {
BACKUP_RESULT_STATUS,
BADGE_IMG_MAP,
CHECK_STORAGE_INTERVAL,
CLUSTER_IMG_MAP,
CLUSTER_INFO_CONFIG,
COLOR_MAP,
Expand All @@ -163,6 +170,7 @@ export {
RESOURCE_NAME_REG,
RESULT_STATUS,
SERVER_IMG_MAP,
STATISTICS_INTERVAL,
STATUS,
SUFFIX_UNIT,
TOPO_INFO_CONFIG,
Expand Down
Loading

0 comments on commit b42863c

Please sign in to comment.