Przeglądaj źródła

feat(link): add Protocol\Type\Certificate\Gateway module

Lind 4 lat temu
rodzic
commit
15d9839713

+ 11 - 3
src/pages/device/Alarm/index.tsx

@@ -21,7 +21,7 @@ const Alarm = () => {
     },
     {
       title: intl.formatMessage({
-        id: 'pages.device.alarm.deviceID',
+        id: 'pages.device.alarm.id',
         defaultMessage: '设备ID',
       }),
       dataIndex: 'deviceId',
@@ -81,7 +81,10 @@ const Alarm = () => {
             }
             Modal.confirm({
               width: '40VW',
-              title: '告警数据',
+              title: intl.formatMessage({
+                id: 'pages.device.alarm.option.data',
+                defaultMessage: '告警数据',
+              }),
               content: (
                 <pre>
                   {content}
@@ -114,7 +117,12 @@ const Alarm = () => {
         <>
           {record.state !== 'solve' && (
             <a onClick={() => {}}>
-              <Tooltip title={'处理'}>
+              <Tooltip
+                title={intl.formatMessage({
+                  id: 'pages.device.alarm.option.dispose',
+                  defaultMessage: '处理',
+                })}
+              >
                 <CheckOutlined />
               </Tooltip>
             </a>

+ 7 - 4
src/pages/link/Certificate/typings.d.ts

@@ -1,4 +1,7 @@
-type Item = {
-  id: string;
-  name: string;
-};
+import type { BaseItem } from '@/utils/typings';
+
+type CertificateItem = {
+  instance: string;
+  description: string;
+  configs?: Record<string, any>;
+} & BaseItem;

+ 10 - 4
src/pages/link/Gateway/typings.d.ts

@@ -1,4 +1,10 @@
-type Item = {
-  id: string;
-  name: string;
-};
+import type { BaseItem, State } from '@/utils/typings';
+
+type GatewayItem = {
+  networkId: string;
+  provider: string;
+  state: State;
+  createTime: number;
+  creatorId: string;
+  configuration: Record<string, any>;
+} & BaseItem;

+ 83 - 1
src/pages/link/Protocol/index.tsx

@@ -1,6 +1,88 @@
 import { PageContainer } from '@ant-design/pro-layout';
+import BaseService from '@/utils/BaseService';
+import type { ProtocolItem } from '@/pages/link/Protocol/typings';
+import { useRef } from 'react';
+import type { ActionType, ProColumns } from '@jetlinks/pro-table';
+import { Tooltip } from 'antd';
+import {
+  ArrowDownOutlined,
+  BarsOutlined,
+  BugOutlined,
+  EditOutlined,
+  MinusOutlined,
+} from '@ant-design/icons';
+import BaseCrud from '@/components/BaseCrud';
 
+export const service = new BaseService<ProtocolItem>('protocol');
 const Protocol = () => {
-  return <PageContainer>Protocol</PageContainer>;
+  const actionRef = useRef<ActionType>();
+
+  const columns: ProColumns<ProtocolItem>[] = [
+    {
+      dataIndex: 'index',
+      valueType: 'indexBorder',
+      width: 48,
+    },
+    {
+      dataIndex: 'name',
+      title: '名称',
+    },
+    {
+      dataIndex: 'type',
+      title: '通知类型',
+    },
+    {
+      dataIndex: 'provider',
+      title: '服务商',
+    },
+    {
+      title: '操作',
+      valueType: 'option',
+      align: 'center',
+      width: 200,
+      render: (text, record) => [
+        <a onClick={() => console.log(record)}>
+          <Tooltip title="编辑">
+            <EditOutlined />
+          </Tooltip>
+        </a>,
+        <a>
+          <Tooltip title="删除">
+            <MinusOutlined />
+          </Tooltip>
+        </a>,
+        <a>
+          <Tooltip title="下载配置">
+            <ArrowDownOutlined />
+          </Tooltip>
+        </a>,
+        <a>
+          <Tooltip title="调试">
+            <BugOutlined />
+          </Tooltip>
+        </a>,
+        <a>
+          <Tooltip title="通知记录">
+            <BarsOutlined />
+          </Tooltip>
+        </a>,
+      ],
+    },
+  ];
+
+  const schema = {};
+
+  return (
+    <PageContainer>
+      <BaseCrud
+        columns={columns}
+        service={service}
+        title="协议管理"
+        schema={schema}
+        actionRef={actionRef}
+      />
+    </PageContainer>
+  );
 };
+
 export default Protocol;

+ 7 - 4
src/pages/link/Protocol/typings.d.ts

@@ -1,4 +1,7 @@
-type Item = {
-  id: string;
-  name: string;
-};
+import type { BaseItem } from '@/utils/typings';
+
+type ProtocolItem = {
+  state: number;
+  type: string;
+  configuration: Record<string, any>;
+} & BaseItem;

+ 75 - 3
src/pages/link/Type/index.tsx

@@ -1,6 +1,78 @@
+import BaseService from '@/utils/BaseService';
+import { useRef } from 'react';
+import type { ActionType, ProColumns } from '@jetlinks/pro-table';
+import { Tooltip } from 'antd';
+import { BugOutlined, EditOutlined, MinusOutlined } from '@ant-design/icons';
 import { PageContainer } from '@ant-design/pro-layout';
+import BaseCrud from '@/components/BaseCrud';
+import type { NetworkItem } from '@/pages/link/Type/typings';
 
-const Type = () => {
-  return <PageContainer>Type</PageContainer>;
+export const service = new BaseService<NetworkItem>('network/config');
+
+const Network = () => {
+  const actionRef = useRef<ActionType>();
+
+  const columns: ProColumns<NetworkItem>[] = [
+    {
+      dataIndex: 'index',
+      valueType: 'indexBorder',
+      width: 48,
+    },
+    {
+      dataIndex: 'name',
+      title: '名称',
+    },
+    {
+      dataIndex: 'type',
+      title: '类型',
+    },
+    {
+      dataIndex: 'state',
+      title: '状态',
+      render: (text, record) => record.state.value,
+    },
+    {
+      dataIndex: 'provider',
+      title: '服务商',
+    },
+    {
+      title: '操作',
+      valueType: 'option',
+      align: 'center',
+      width: 200,
+      render: (text, record) => [
+        <a onClick={() => console.log(record)}>
+          <Tooltip title="编辑">
+            <EditOutlined />
+          </Tooltip>
+        </a>,
+        <a>
+          <Tooltip title="删除">
+            <MinusOutlined />
+          </Tooltip>
+        </a>,
+        <a>
+          <Tooltip title="调试">
+            <BugOutlined />
+          </Tooltip>
+        </a>,
+      ],
+    },
+  ];
+
+  const schema = {};
+
+  return (
+    <PageContainer>
+      <BaseCrud
+        columns={columns}
+        service={service}
+        title="网络组建"
+        schema={schema}
+        actionRef={actionRef}
+      />
+    </PageContainer>
+  );
 };
-export default Type;
+
+export default Network;

+ 15 - 4
src/pages/link/Type/typings.d.ts

@@ -1,4 +1,15 @@
-type Item = {
-  id: string;
-  name: string;
-};
+import type { BaseItem } from '@/utils/typings';
+
+type NetworkItem = {
+  shareCluster: boolean;
+  type: string;
+  typeObject: {
+    name: string;
+    text: string;
+    value: string;
+  };
+  state: State;
+  createTime: number;
+  creatorId: string;
+  configuration: Record<string, any>;
+} & BaseItem;