wzyyy 3 vuotta sitten
vanhempi
commit
6b85f9ba57

+ 12 - 2
src/pages/device/Category/Save/index.tsx

@@ -20,7 +20,6 @@ import * as ICONS from '@ant-design/icons';
 import { Modal } from 'antd';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import type { ISchema } from '@formily/json-schema';
-import type { CategoryItem } from '@/pages/visualization/Category/typings';
 import { service, state } from '@/pages/device/Category';
 import type { Response } from '@/utils/typings';
 import { onlyMessage } from '@/utils/util';
@@ -111,7 +110,16 @@ const Save = (props: Props) => {
         'x-component-props': {
           placeholder: '请输入名称',
         },
-        required: true,
+        'x-validator': [
+          {
+            required: true,
+            message: '请输入名称',
+          },
+          {
+            max: 64,
+            message: '最多可输入64个字符',
+          },
+        ],
         name: 'name',
       },
       sortIndex: {
@@ -138,6 +146,8 @@ const Save = (props: Props) => {
         'x-component-props': {
           rows: 3,
           placeholder: '请输入说明',
+          showCount: true,
+          maxLength: 200,
         },
         name: 'description',
       },

+ 11 - 7
src/pages/device/Category/index.tsx

@@ -27,7 +27,7 @@ export const state = model<{
 });
 
 export const getSortIndex = (data: CategoryItem[], pId?: string): number => {
-  let sortIndex = 0;
+  let sortIndex = 1;
   if (data.length) {
     if (!pId) {
       return data.sort((a, b) => b.sortIndex - a.sortIndex)[0].sortIndex + 1;
@@ -120,12 +120,16 @@ const Category = observer(() => {
           type="link"
           isPermission={permission.add}
           onClick={() => {
-            state.visible = true;
-            const sortIndex = getSortIndex(treeData, record.id);
-            state.parentId = record.id;
-            state.current = {
-              sortIndex,
-            };
+            if (record.level <= 5) {
+              state.visible = true;
+              const sortIndex = getSortIndex(treeData, record.id);
+              state.parentId = record.id;
+              state.current = {
+                sortIndex,
+              };
+            } else {
+              onlyMessage('最多可添加5层', 'error');
+            }
           }}
         >
           <PlusCircleOutlined />

+ 85 - 0
src/pages/home/components/BaseStatistics.tsx

@@ -0,0 +1,85 @@
+import Statistics from '../components/Statistics';
+import './index.less';
+import Pie from '@/pages/home/components/Pie';
+import { getMenuPathByCode, MENUS_CODE } from '@/utils/menu';
+import { message } from 'antd';
+import { useEffect, useState } from 'react';
+import useSendWebsocketMessage from '@/hooks/websocket/useSendWebsocketMessage';
+import { map } from 'rxjs';
+import useHistory from '@/hooks/route/useHistory';
+
+const BaseStatistics = () => {
+  const [subscribeTopic] = useSendWebsocketMessage();
+  const history = useHistory();
+  const [cpuValue, setCpuValue] = useState<number>(0);
+  const [jvmValue, setJvmValue] = useState<number>(0);
+  useEffect(() => {
+    const cpuRealTime = subscribeTopic!(
+      `operations-statistics-system-info-cpu-realTime`,
+      `/dashboard/systemMonitor/stats/info/realTime`,
+      {
+        type: 'cpu',
+        interval: '2s',
+        agg: 'avg',
+      },
+    )
+      ?.pipe(map((res) => res.payload))
+      .subscribe((payload: any) => {
+        setCpuValue(payload.value?.systemUsage || 0);
+      });
+
+    const jvmRealTime = subscribeTopic!(
+      `operations-statistics-system-info-memory-realTime`,
+      `/dashboard/systemMonitor/stats/info/realTime`,
+      {
+        type: 'memory',
+        interval: '2s',
+        agg: 'avg',
+      },
+    )
+      ?.pipe(map((res) => res.payload))
+      .subscribe((payload: any) => {
+        setJvmValue(payload.value?.jvmHeapUsage || 0);
+      });
+
+    return () => {
+      cpuRealTime?.unsubscribe();
+      jvmRealTime?.unsubscribe();
+    };
+  }, []);
+  return (
+    <Statistics
+      data={[
+        {
+          name: 'CPU使用率',
+          value: String(cpuValue) + '%',
+          children: <Pie value={cpuValue} />,
+        },
+        {
+          name: 'JVM内存',
+          value: String(jvmValue) + '%',
+          children: <Pie value={jvmValue} />,
+        },
+      ]}
+      title="基础统计"
+      extra={
+        <div style={{ fontSize: 14, fontWeight: 400 }}>
+          <a
+            onClick={() => {
+              const url = getMenuPathByCode(MENUS_CODE['link/DashBoard']);
+              if (!!url) {
+                history.push(`${url}`);
+              } else {
+                message.warning('暂无权限,请联系管理员');
+              }
+            }}
+          >
+            详情
+          </a>
+        </div>
+      }
+    />
+  );
+};
+
+export default BaseStatistics;

+ 3 - 74
src/pages/home/comprehensive/index.tsx

@@ -3,21 +3,17 @@ import useHistory from '@/hooks/route/useHistory';
 import { getMenuPathByCode, MENUS_CODE } from '@/utils/menu';
 import { Col, message, Row, Tooltip } from 'antd';
 import Body from '../components/Body';
-// import Guide from '../components/Guide';
-import Statistics from '../components/Statistics';
+import BaseStatistics from '../components/BaseStatistics';
 import Steps from '../components/Steps';
 import { service } from '..';
 import { useEffect, useState } from 'react';
-import useSendWebsocketMessage from '@/hooks/websocket/useSendWebsocketMessage';
-import { map } from 'rxjs';
-import Pie from '../components/Pie';
+import Statistics from '../components/Statistics';
 import { QuestionCircleOutlined } from '@ant-design/icons';
 import ProductChoose from '../components/ProductChoose';
 import DeviceChoose from '../components/DeviceChoose';
 import GuideHome from '../components/GuideHome';
 
 const Comprehensive = () => {
-  const [subscribeTopic] = useSendWebsocketMessage();
   const productPermission = PermissionButton.usePermission('device/Product').permission;
   const devicePermission = PermissionButton.usePermission('device/Instance').permission;
   const rulePermission = PermissionButton.usePermission('rule-engine/Instance').permission;
@@ -29,8 +25,6 @@ const Comprehensive = () => {
   const [productMessage, setProductMessage] = useState<string>();
   const [deviceCount, setDeviceCount] = useState<number>(0);
   const [deviceMessage, setDeviceMessage] = useState<string>();
-  const [cpuValue, setCpuValue] = useState<number>(0);
-  const [jvmValue, setJvmValue] = useState<number>(0);
   const [productVisible, setProductVisible] = useState<boolean>(false);
   const [deviceVisible, setDeviceVisible] = useState<boolean>(false);
   // const [StatisticsList] = useState([
@@ -71,41 +65,6 @@ const Comprehensive = () => {
     getDeviceCount();
   }, []);
 
-  useEffect(() => {
-    const cpuRealTime = subscribeTopic!(
-      `operations-statistics-system-info-cpu-realTime`,
-      `/dashboard/systemMonitor/stats/info/realTime`,
-      {
-        type: 'cpu',
-        interval: '2s',
-        agg: 'avg',
-      },
-    )
-      ?.pipe(map((res) => res.payload))
-      .subscribe((payload: any) => {
-        setCpuValue(payload.value?.systemUsage || 0);
-      });
-
-    const jvmRealTime = subscribeTopic!(
-      `operations-statistics-system-info-memory-realTime`,
-      `/dashboard/systemMonitor/stats/info/realTime`,
-      {
-        type: 'memory',
-        interval: '2s',
-        agg: 'avg',
-      },
-    )
-      ?.pipe(map((res) => res.payload))
-      .subscribe((payload: any) => {
-        setJvmValue(payload.value?.jvmHeapUsage || 0);
-      });
-
-    return () => {
-      cpuRealTime?.unsubscribe();
-      jvmRealTime?.unsubscribe();
-    };
-  }, []);
-
   const history = useHistory();
   // // 跳转
   const guideList = [
@@ -221,37 +180,7 @@ const Comprehensive = () => {
             />
           </Col>
           <Col span={12}>
-            <Statistics
-              data={[
-                {
-                  name: 'CPU使用率',
-                  value: String(cpuValue) + '%',
-                  children: <Pie value={cpuValue} />,
-                },
-                {
-                  name: 'JVM内存',
-                  value: String(jvmValue) + '%',
-                  children: <Pie value={jvmValue} />,
-                },
-              ]}
-              title="基础统计"
-              extra={
-                <div style={{ fontSize: 14, fontWeight: 400 }}>
-                  <a
-                    onClick={() => {
-                      const url = getMenuPathByCode(MENUS_CODE['link/DashBoard']);
-                      if (!!url) {
-                        history.push(`${url}`);
-                      } else {
-                        message.warning('暂无权限,请联系管理员');
-                      }
-                    }}
-                  >
-                    详情
-                  </a>
-                </div>
-              }
-            />
+            <BaseStatistics />
           </Col>
         </Row>
         <Row gutter={24}>

+ 44 - 73
src/pages/home/ops/index.tsx

@@ -1,60 +1,61 @@
 import { Col, message, Row, Tooltip } from 'antd';
 import Guide from '../components/Guide';
-import Statistics from '../components/Statistics';
-import Pie from '@/pages/home/components/Pie';
+// import Statistics from '../components/Statistics';
+// import Pie from '@/pages/home/components/Pie';
 import { getMenuPathByCode, MENUS_CODE } from '@/utils/menu';
-import { useEffect, useState } from 'react';
-import { map } from 'rxjs';
-import useSendWebsocketMessage from '@/hooks/websocket/useSendWebsocketMessage';
+// import { useEffect, useState } from 'react';
+// import { map } from 'rxjs';
+// import useSendWebsocketMessage from '@/hooks/websocket/useSendWebsocketMessage';
 import useHistory from '@/hooks/route/useHistory';
 import Body from '@/pages/home/components/Body';
 import Steps from '@/pages/home/components/Steps';
+import BaseStatistics from '../components/BaseStatistics';
 import { QuestionCircleOutlined } from '@ant-design/icons';
 
 const Ops = () => {
-  const [subscribeTopic] = useSendWebsocketMessage();
+  // const [subscribeTopic] = useSendWebsocketMessage();
   const history = useHistory();
 
   const accessPermission = getMenuPathByCode(MENUS_CODE['link/AccessConfig']);
   const logPermission = getMenuPathByCode(MENUS_CODE['Log']);
   const linkPermission = getMenuPathByCode(MENUS_CODE['link/DashBoard']);
-  const [cpuValue, setCpuValue] = useState<number>(0);
-  const [jvmValue, setJvmValue] = useState<number>(0);
+  // const [cpuValue, setCpuValue] = useState<number>(0);
+  // const [jvmValue, setJvmValue] = useState<number>(0);
 
-  useEffect(() => {
-    const cpuRealTime = subscribeTopic!(
-      `operations-statistics-system-info-cpu-realTime`,
-      `/dashboard/systemMonitor/stats/info/realTime`,
-      {
-        type: 'cpu',
-        interval: '2s',
-        agg: 'avg',
-      },
-    )
-      ?.pipe(map((res) => res.payload))
-      .subscribe((payload: any) => {
-        setCpuValue(payload.value?.systemUsage || 0);
-      });
-
-    const jvmRealTime = subscribeTopic!(
-      `operations-statistics-system-info-memory-realTime`,
-      `/dashboard/systemMonitor/stats/info/realTime`,
-      {
-        type: 'memory',
-        interval: '2s',
-        agg: 'avg',
-      },
-    )
-      ?.pipe(map((res) => res.payload))
-      .subscribe((payload: any) => {
-        setJvmValue(payload.value?.jvmHeapUsage || 0);
-      });
-
-    return () => {
-      cpuRealTime?.unsubscribe();
-      jvmRealTime?.unsubscribe();
-    };
-  }, []);
+  // useEffect(() => {
+  //   const cpuRealTime = subscribeTopic!(
+  //     `operations-statistics-system-info-cpu-realTime`,
+  //     `/dashboard/systemMonitor/stats/info/realTime`,
+  //     {
+  //       type: 'cpu',
+  //       interval: '2s',
+  //       agg: 'avg',
+  //     },
+  //   )
+  //     ?.pipe(map((res) => res.payload))
+  //     .subscribe((payload: any) => {
+  //       setCpuValue(payload.value?.systemUsage || 0);
+  //     });
+  //
+  //   const jvmRealTime = subscribeTopic!(
+  //     `operations-statistics-system-info-memory-realTime`,
+  //     `/dashboard/systemMonitor/stats/info/realTime`,
+  //     {
+  //       type: 'memory',
+  //       interval: '2s',
+  //       agg: 'avg',
+  //     },
+  //   )
+  //     ?.pipe(map((res) => res.payload))
+  //     .subscribe((payload: any) => {
+  //       setJvmValue(payload.value?.jvmHeapUsage || 0);
+  //     });
+  //
+  //   return () => {
+  //     cpuRealTime?.unsubscribe();
+  //     jvmRealTime?.unsubscribe();
+  //   };
+  // }, []);
 
   const guideOpsList: any[] = [
     {
@@ -91,37 +92,7 @@ const Ops = () => {
         <Guide title="运维引导" data={guideOpsList} />
       </Col>
       <Col span={10}>
-        <Statistics
-          data={[
-            {
-              name: 'CPU使用率',
-              value: String(cpuValue) + '%',
-              children: <Pie value={cpuValue} />,
-            },
-            {
-              name: 'JVM内存',
-              value: String(jvmValue) + '%',
-              children: <Pie value={jvmValue} />,
-            },
-          ]}
-          title="基础统计"
-          extra={
-            <div style={{ fontSize: 14, fontWeight: 400 }}>
-              <a
-                onClick={() => {
-                  const url = getMenuPathByCode(MENUS_CODE['device/DashBoard']);
-                  if (!!url) {
-                    history.push(`${url}`);
-                  } else {
-                    message.warning('暂无权限,请联系管理员');
-                  }
-                }}
-              >
-                详情
-              </a>
-            </div>
-          }
-        />
+        <BaseStatistics />
       </Col>
       <Col span={24}>
         <Body title={'平台架构图'} english={'PLATFORM ARCHITECTURE DIAGRAM'} />

+ 4 - 4
src/pages/media/DashBoard/index.tsx

@@ -84,7 +84,7 @@ export default () => {
 
   const getEcharts = async (params: any) => {
     let _time = '1h';
-    let format = 'HH';
+    // let format = 'HH';
     let limit = 12;
     const dt = params.time.end - params.time.start;
     const hour = 60 * 60 * 1000;
@@ -96,11 +96,11 @@ export default () => {
     } else if (dt > day && dt < year) {
       limit = Math.abs(Math.ceil(dt / day)) + 1;
       _time = '1d';
-      format = 'M月dd日';
+      // format = 'M月dd日';
     } else if (dt >= year) {
       limit = Math.abs(Math.floor(dt / month));
       _time = '1M';
-      format = 'yyyy年-M月';
+      // format = 'yyyy年-M月';
     }
     const resp = await service.getMulti([
       {
@@ -114,7 +114,7 @@ export default () => {
           from: moment(params.time.start).format('YYYY-MM-DD HH:mm:ss'),
           to: moment(params.time.end).format('YYYY-MM-DD HH:mm:ss'),
           limit: limit,
-          format: format,
+          // format: format,
         },
       },
     ]);

+ 16 - 16
src/pages/system/User/Save/index.tsx

@@ -215,14 +215,14 @@ const Save = (props: Props) => {
         ],
         name: 'password',
         'x-validator': [
-          // {
-          //   max: 128,
-          //   message: '密码最多可输入128位',
-          // },
-          // {
-          //   min: 8,
-          //   message: '密码不能少于8位',
-          // },
+          {
+            max: 64,
+            message: '密码最多可输入64位',
+          },
+          {
+            min: 8,
+            message: '密码不能少于8位',
+          },
           {
             required: model === 'add',
             message: '请输入密码',
@@ -243,14 +243,14 @@ const Save = (props: Props) => {
         },
         'x-visible': model === 'add',
         'x-validator': [
-          // {
-          //   max: 128,
-          //   message: '密码最多可输入128位',
-          // },
-          // {
-          //   min: 8,
-          //   message: '密码不能少于6位',
-          // },
+          {
+            max: 64,
+            message: '密码最多可输入64位',
+          },
+          {
+            min: 8,
+            message: '密码不能少于8位',
+          },
           {
             required: model === 'add',
             message: '请输入确认密码',

+ 3 - 1
src/utils/menu/router.ts

@@ -44,7 +44,9 @@ export enum MENUS_CODE {
   'link/Protocol' = 'link/Protocol',
   'link/Type' = 'link/Type',
   'link/AccessConfig' = 'link/AccessConfig',
-  'link/DashBoard' = 'link/DashBoard',
+  'link/DataCollect/Dashboard' = 'link/DataCollect/Dashboard',
+  'link/DataCollect/DataGathering' = 'link/DataCollect/DataGathering',
+  'link/DataCollect/IntegratedQuery' = 'link/DataCollect/IntegratedQuery',
   'Log' = 'Log',
   'media/Cascade' = 'media/Cascade',
   'media/Cascade/Save' = 'media/Cascade/Save',