Przeglądaj źródła

fix(rule-engine): fix lint error

Lind 4 lat temu
rodzic
commit
454daab74c

+ 92 - 57
config/routes.ts

@@ -154,18 +154,6 @@
         component: './link/Certificate',
       },
       {
-        path: '/link/gateway',
-        name: 'gateway',
-        icon: 'smile',
-        component: './link/Gateway',
-      },
-      {
-        path: '/link/opcua',
-        name: 'opcua',
-        icon: 'smile',
-        component: './link/Opcua',
-      },
-      {
         path: '/link/protocol',
         name: 'protocol',
         icon: 'smile',
@@ -177,6 +165,18 @@
         icon: 'smile',
         component: './link/Type',
       },
+      {
+        path: '/link/gateway',
+        name: 'gateway',
+        icon: 'smile',
+        component: './link/Gateway',
+      },
+      {
+        path: '/link/opcua',
+        name: 'opcua',
+        icon: 'smile',
+        component: './link/Opcua',
+      },
     ],
   },
   {
@@ -235,10 +235,10 @@
     path: '/visualization',
     name: 'visualization',
     icon: 'crown',
-    routes:[
+    routes: [
       {
         path: '/visualization',
-        redirect: '/visualization/category'
+        redirect: '/visualization/category',
       },
       {
         path: '/visualization/category',
@@ -258,24 +258,24 @@
         icon: 'smile',
         component: './visualization/configuration',
       },
-    ]
+    ],
   },
   {
     path: '/simulator',
     name: 'simulator',
     icon: 'crown',
-    routes:[
+    routes: [
       {
-        path:'/simulator',
+        path: '/simulator',
         redirect: '/simulator/device',
       },
       {
-        path:'/simulator/device',
-        name:'device',
-        icon:'smile',
-        component: './simulator/Device'
-      }
-    ]
+        path: '/simulator/device',
+        name: 'device',
+        icon: 'smile',
+        component: './simulator/Device',
+      },
+    ],
   },
   {
     path: '/log',
@@ -301,62 +301,97 @@
     ],
   },
   {
-    path:'/cloud',
-    name:'cloud',
-    icon:"crown",
+    path: '/cloud',
+    name: 'cloud',
+    icon: 'crown',
     routes: [
       {
-        path:'/cloud',
-        redirect: '/cloud/duer'
+        path: '/cloud',
+        redirect: '/cloud/duer',
       },
       {
-        path:'/cloud/duer',
-        name:'duerOS',
-        icon:'smile',
+        path: '/cloud/duer',
+        name: 'DuerOS',
+        icon: 'smile',
         component: './cloud/DuerOS',
       },
       {
-        path:'/cloud/aliyun',
-        name:'aliyun',
-        icon:'smile',
-        component: './cloud/Aliyun'
-      }
-    ]
+        path: '/cloud/aliyun',
+        name: 'aliyun',
+        icon: 'smile',
+        component: './cloud/Aliyun',
+      },
+      {
+        path: '/cloud/onenet',
+        name: 'onenet',
+        icon: 'smile',
+        component: './cloud/Onenet',
+      },
+      {
+        path: '/cloud/ctwing',
+        name: 'ctwing',
+        icon: 'smile',
+        component: './cloud/Ctwing',
+      },
+    ],
   },
   {
-    path:'/media',
-    name:'media',
-    icon:'crown',
-    routes:[
+    path: '/media',
+    name: 'media',
+    icon: 'crown',
+    routes: [
       {
-        path:'/media',
+        path: '/media',
         redirect: '/media/config',
       },
       {
-        path:'/media/config',
-        name:'config',
-        icon:'smile',
+        path: '/media/config',
+        name: 'config',
+        icon: 'smile',
         component: './media/Config',
       },
       {
-        path:'/media/device',
-        name:'device',
-        icon:'smile',
-        component: './media/device'
+        path: '/media/device',
+        name: 'device',
+        icon: 'smile',
+        component: './media/device',
       },
       {
-        path:'/media/reveal',
-        name:'reveal',
-        icon:'smile',
+        path: '/media/reveal',
+        name: 'reveal',
+        icon: 'smile',
         component: './media/reveal',
       },
       {
-        path:'/media/cascade',
-        name:'cascade',
-        icon:'smile',
+        path: '/media/cascade',
+        name: 'cascade',
+        icon: 'smile',
         component: './media/Cascade',
-      }
-      ]
+      },
+    ],
+  },
+  {
+    path: '/edge',
+    name: 'edge',
+    icon: 'crown',
+    routes: [
+      {
+        path: '/edge',
+        redirect: '/edge/product',
+      },
+      {
+        path: '/edge/product',
+        name: 'product',
+        icon: 'smile',
+        component: './edge/Product',
+      },
+      {
+        path: '/edge/device',
+        name: 'device',
+        icon: 'smile',
+        component: './edge/Device',
+      },
+    ],
   },
   {
     path: '/',

+ 84 - 1
src/pages/rule-engine/Instance/index.tsx

@@ -1,6 +1,89 @@
 import { PageContainer } from '@ant-design/pro-layout';
+import BaseService from '@/utils/BaseService';
+import type { InstanceItem } from '@/pages/rule-engine/Instance/typings';
+import { useRef } from 'react';
+import type { ActionType, ProColumns } from '@jetlinks/pro-table';
+import {
+  CaretRightOutlined,
+  EditOutlined,
+  EyeOutlined,
+  MinusOutlined,
+  ReloadOutlined,
+} from '@ant-design/icons';
+import { Tooltip } from 'antd';
+import BaseCrud from '@/components/BaseCrud';
 
+export const service = new BaseService<InstanceItem>('rule-engine/instance');
 const Instance = () => {
-  return <PageContainer>Instance</PageContainer>;
+  const actionRef = useRef<ActionType>();
+
+  const columns: ProColumns<InstanceItem>[] = [
+    {
+      dataIndex: 'index',
+      valueType: 'indexBorder',
+      width: 48,
+    },
+    {
+      dataIndex: 'name',
+      title: '名称',
+    },
+    {
+      dataIndex: 'modelType',
+      title: '类型',
+    },
+    {
+      dataIndex: 'state',
+      title: '状态',
+      render: (text, record) => record.state.value,
+    },
+    {
+      title: '操作',
+      valueType: 'option',
+      align: 'center',
+      width: 200,
+      render: (text, record) => [
+        <a>
+          <Tooltip title="查看">
+            <EyeOutlined />
+          </Tooltip>
+        </a>,
+        <a onClick={() => console.log(record)}>
+          <Tooltip title="编辑">
+            <EditOutlined />
+          </Tooltip>
+        </a>,
+        <a onClick={() => console.log(record)}>
+          <Tooltip title="启动">
+            <CaretRightOutlined />
+          </Tooltip>
+        </a>,
+        <a onClick={() => console.log(record)}>
+          <Tooltip title="重启">
+            <ReloadOutlined />
+          </Tooltip>
+        </a>,
+
+        <a>
+          <Tooltip title="删除">
+            <MinusOutlined />
+          </Tooltip>
+        </a>,
+      ],
+    },
+  ];
+
+  const schema = {};
+
+  return (
+    <PageContainer>
+      <BaseCrud
+        columns={columns}
+        service={service}
+        title="规则实例"
+        schema={schema}
+        actionRef={actionRef}
+      />
+    </PageContainer>
+  );
 };
 export default Instance;

+ 13 - 4
src/pages/rule-engine/Instance/typings.d.ts

@@ -1,4 +1,13 @@
-type Item = {
-  id: string;
-  name: string;
-};
+import type { BaseItem } from '@/utils/typings';
+
+type InstanceItem = {
+  createTime: number;
+  modelId: string;
+  modelMeta: string;
+  modelType: string;
+  modelVersion: number;
+  state: {
+    text: string;
+    value: string;
+  };
+} & BaseItem;

+ 92 - 1
src/pages/rule-engine/SQLRule/index.tsx

@@ -1,6 +1,97 @@
 import { PageContainer } from '@ant-design/pro-layout';
+import { useRef } from 'react';
+import type { ActionType, ProColumns } from '@jetlinks/pro-table';
+import type { SQLRuleItem } from '@/pages/rule-engine/SQLRule/typings';
+import { message, Tooltip } from 'antd';
+import {
+  CaretRightOutlined,
+  DownloadOutlined,
+  EditOutlined,
+  MinusOutlined,
+  ReloadOutlined,
+  StopOutlined,
+} from '@ant-design/icons';
+import BaseCrud from '@/components/BaseCrud';
+import { service } from '@/pages/rule-engine/Instance';
 
 const SQLRule = () => {
-  return <PageContainer>SQLRule</PageContainer>;
+  const actionRef = useRef<ActionType>();
+
+  const columns: ProColumns<SQLRuleItem>[] = [
+    {
+      dataIndex: 'index',
+      valueType: 'indexBorder',
+      width: 48,
+    },
+    {
+      dataIndex: 'name',
+      title: '名称',
+    },
+    {
+      dataIndex: 'createTime',
+      title: '创建时间',
+    },
+    {
+      dataIndex: 'state',
+      title: '状态',
+      render: (text, record) => record.state.value,
+    },
+    {
+      title: '操作',
+      valueType: 'option',
+      align: 'center',
+      width: 200,
+      render: (text, record) => [
+        <a onClick={() => console.log(record)}>
+          <Tooltip title="编辑">
+            <EditOutlined />
+          </Tooltip>
+        </a>,
+        <a onClick={() => console.log(record)}>
+          <Tooltip title="启动">
+            <CaretRightOutlined />
+          </Tooltip>
+        </a>,
+        <a onClick={() => console.log(record)}>
+          <Tooltip title="重启">
+            <ReloadOutlined />
+          </Tooltip>
+        </a>,
+        <a onClick={() => console.log(record)}>
+          <Tooltip title="停止">
+            <StopOutlined />
+          </Tooltip>
+        </a>,
+        <a>
+          <Tooltip title="删除">
+            <MinusOutlined />
+          </Tooltip>
+        </a>,
+        <a key="download">
+          <Tooltip title="下载配置">
+            <DownloadOutlined
+              onClick={() => {
+                message.success('下载');
+              }}
+            />
+          </Tooltip>
+        </a>,
+      ],
+    },
+  ];
+
+  const schema = {};
+  return (
+    <PageContainer>
+      <BaseCrud
+        columns={columns}
+        service={service}
+        title="数据转发"
+        schema={schema}
+        defaultParams={{ modelType: 'sql_rule' }}
+        actionRef={actionRef}
+      />
+    </PageContainer>
+  );
 };
 export default SQLRule;

+ 3 - 4
src/pages/rule-engine/SQLRule/typings.d.ts

@@ -1,4 +1,3 @@
-type Item = {
-  id: string;
-  name: string;
-};
+import type { InstanceItem } from '@/pages/rule-engine/Instance/typings';
+
+type SQLRuleItem = InstanceItem;

+ 91 - 1
src/pages/rule-engine/Scene/index.tsx

@@ -1,6 +1,96 @@
 import { PageContainer } from '@ant-design/pro-layout';
+import BaseService from '@/utils/BaseService';
+import { useRef } from 'react';
+import type { ActionType, ProColumns } from '@jetlinks/pro-table';
+import type { SceneItem } from '@/pages/rule-engine/Scene/typings';
+import { Tooltip } from 'antd';
+import {
+  CaretRightOutlined,
+  EditOutlined,
+  EyeOutlined,
+  MinusOutlined,
+  ReloadOutlined,
+  StopOutlined,
+} from '@ant-design/icons';
+import BaseCrud from '@/components/BaseCrud';
 
+export const service = new BaseService<SceneItem>('rule-engine/scene');
 const Scene = () => {
-  return <PageContainer>Scene</PageContainer>;
+  const actionRef = useRef<ActionType>();
+
+  const columns: ProColumns<SceneItem>[] = [
+    {
+      dataIndex: 'index',
+      valueType: 'indexBorder',
+      width: 48,
+    },
+    {
+      dataIndex: 'name',
+      title: '名称',
+    },
+    {
+      dataIndex: 'triggers',
+      title: '触发方式',
+      render: () => 'todo',
+    },
+    {
+      dataIndex: 'state',
+      title: '状态',
+      render: (text, record) => record.state.value,
+    },
+    {
+      title: '操作',
+      valueType: 'option',
+      align: 'center',
+      width: 200,
+      render: (text, record) => [
+        <a>
+          <Tooltip title="查看">
+            <EyeOutlined />
+          </Tooltip>
+        </a>,
+        <a onClick={() => console.log(record)}>
+          <Tooltip title="编辑">
+            <EditOutlined />
+          </Tooltip>
+        </a>,
+        <a onClick={() => console.log(record)}>
+          <Tooltip title="启动">
+            <CaretRightOutlined />
+          </Tooltip>
+        </a>,
+        <a onClick={() => console.log(record)}>
+          <Tooltip title="启动">
+            <StopOutlined />
+          </Tooltip>
+        </a>,
+        <a onClick={() => console.log(record)}>
+          <Tooltip title="执行">
+            <ReloadOutlined />
+          </Tooltip>
+        </a>,
+
+        <a>
+          <Tooltip title="删除">
+            <MinusOutlined />
+          </Tooltip>
+        </a>,
+      ],
+    },
+  ];
+
+  const schema = {};
+
+  return (
+    <PageContainer>
+      <BaseCrud
+        columns={columns}
+        service={service}
+        title="场景联动"
+        schema={schema}
+        actionRef={actionRef}
+      />
+    </PageContainer>
+  );
 };
 export default Scene;

+ 16 - 3
src/pages/rule-engine/Scene/typings.d.ts

@@ -1,4 +1,17 @@
-type Item = {
-  id: string;
-  name: string;
+import type { BaseItem, State } from '@/utils/typings';
+
+type Action = {
+  executor: string;
+  configuration: Record<string, unknown>;
 };
+
+type Trigger = {
+  trigger: string;
+  device: Record<string, unknown>;
+};
+type SceneItem = {
+  parallel: boolean;
+  state: State;
+  actions: Action[];
+  triggers: Trigger[];
+} & BaseItem;