ソースを参照

feat(link): bind User

Lind 4 年 前
コミット
06f86e8324

+ 44 - 10
src/components/Authorization/index.tsx

@@ -14,21 +14,50 @@ import DB from '@/db';
 
 const service = new Service();
 
-const permissionType = [
-  { label: '全部', value: 'all' },
-  { label: '默认', value: 'default' },
-  { label: '系统', value: 'system' },
-  { label: '业务功能', value: 'business' },
-  { label: 'OpenAPI', value: 'open-api' },
-  { label: '多租户', value: 'tenant' },
-];
-
 const tableName = 'permission';
 
 const Authorization = observer((props: AuthorizationProps) => {
   const [form] = Form.useForm();
   const { target, close } = props;
   const intl = useIntl();
+  const permissionType = [
+    {
+      label: intl.formatMessage({
+        id: 'pages.system.authorization.screen.all',
+        defaultMessage: '全部',
+      }),
+      value: 'all',
+    },
+    {
+      label: intl.formatMessage({
+        id: 'pages.system.authorization.screen.default',
+        defaultMessage: '默认',
+      }),
+      value: 'default',
+    },
+    {
+      label: intl.formatMessage({
+        id: 'pages.system.authorization.screen.system',
+        defaultMessage: '系统',
+      }),
+      value: 'system',
+    },
+    {
+      label: intl.formatMessage({
+        id: 'pages.system.authorization.screen.business',
+        defaultMessage: '业务功能',
+      }),
+      value: 'business',
+    },
+    { label: 'OpenAPI', value: 'open-api' },
+    {
+      label: intl.formatMessage({
+        id: 'pages.system.authorization.screen.tenant',
+        defaultMessage: '多租户',
+      }),
+      value: 'tenant',
+    },
+  ];
   const calculationSelectAll = useMemo(
     () => (permissionDB: PermissionItem[], data: Record<string, any>) => {
       // 计算是否全选
@@ -254,7 +283,12 @@ const Authorization = observer((props: AuthorizationProps) => {
         wrapperCol={{ span: 20 }}
         labelCol={{ span: 3 }}
       >
-        <Form.Item label="被授权主体">
+        <Form.Item
+          label={intl.formatMessage({
+            id: 'pages.system.authorization.subject',
+            defaultMessage: '被授权主体',
+          })}
+        >
           <Input value={target.name} disabled={true} />
         </Form.Item>
         <Form.Item

+ 37 - 6
src/components/BindUser/Bound.tsx

@@ -23,10 +23,20 @@ const Bound = observer(() => {
 
   const handleUnBindResult = {
     next: async () => {
-      message.success('解绑成功');
+      message.success(
+        intl.formatMessage({
+          id: 'pages.bindUser.theBoundUser.success',
+          defaultMessage: '解绑成功',
+        }),
+      );
     },
     error: async () => {
-      message.error('操作失败');
+      message.error(
+        intl.formatMessage({
+          id: 'pages.bindUser.theBoundUser.fail',
+          defaultMessage: '操作失败',
+        }),
+      );
     },
     complete: () => {
       // 通知右侧组建刷新
@@ -56,7 +66,12 @@ const Bound = observer(() => {
         handleOrgUnBind();
         break;
       default:
-        message.error('解绑类型数据错误');
+        message.error(
+          intl.formatMessage({
+            id: 'pages.bindUser.theBoundUser.typeError',
+            defaultMessage: '解绑类型数据错误',
+          }),
+        );
     }
   };
 
@@ -79,16 +94,32 @@ const Bound = observer(() => {
         tableAlertRender={({ selectedRowKeys, onCleanSelected }) => (
           <Space size={24}>
             <span>
-              已选 {selectedRowKeys.length} 项
+              {intl.formatMessage({
+                id: 'pages.bindUser.bindTheNewUser.selected',
+                defaultMessage: '已选',
+              })}{' '}
+              {selectedRowKeys.length}{' '}
+              {intl.formatMessage({
+                id: 'pages.bindUser.bindTheNewUser.item',
+                defaultMessage: '项',
+              })}
               <a style={{ marginLeft: 8 }} onClick={onCleanSelected}>
-                取消选择
+                {intl.formatMessage({
+                  id: 'pages.bindUser.bindTheNewUser.deselect',
+                  defaultMessage: '取消选择',
+                })}
               </a>
             </span>
           </Space>
         )}
         tableAlertOptionRender={() => (
           <Space size={16}>
-            <a onClick={handleUnbind}>批量解绑</a>
+            <a onClick={handleUnbind}>
+              {intl.formatMessage({
+                id: 'pages.bindUser.bindTheNewUser.untieInBulk',
+                defaultMessage: '批量解绑',
+              })}
+            </a>
           </Space>
         )}
         actionRef={actionRef}

+ 44 - 7
src/components/BindUser/Unbound.tsx

@@ -8,8 +8,10 @@ import SystemConst from '@/utils/const';
 import { useEffect, useRef } from 'react';
 import { BindModel } from '@/components/BindUser/model';
 import { columns, service } from '@/components/BindUser/index';
+import { useIntl } from '@@/plugin-locale/localeExports';
 
 const Unbound = observer(() => {
+  const intl = useIntl();
   const actionRef = useRef<ActionType>();
 
   useEffect(() => {
@@ -20,9 +22,20 @@ const Unbound = observer(() => {
   });
 
   const handleBindResult = {
-    next: () => message.success('绑定成功'),
+    next: () =>
+      message.success(
+        intl.formatMessage({
+          id: 'pages.bindUser.bindTheNewUser.success',
+          defaultMessage: '绑定成功',
+        }),
+      ),
     error: async () => {
-      message.success('绑定失败');
+      message.success(
+        intl.formatMessage({
+          id: 'pages.bindUser.bindTheNewUser.fail',
+          defaultMessage: '绑定失败',
+        }),
+      );
     },
     complete: () => {
       // 通知左侧组件刷新
@@ -64,13 +77,21 @@ const Unbound = observer(() => {
         handleOrgBind();
         break;
       default:
-        message.error('绑定类型数据错误');
+        message.error(
+          intl.formatMessage({
+            id: 'pages.bindUser.bindTheNewUser.typeError',
+            defaultMessage: '绑定类型数据错误',
+          }),
+        );
     }
   };
 
   return (
     <Card
-      title="绑定新用户"
+      title={intl.formatMessage({
+        id: 'pages.bindUser.bindTheNewUser',
+        defaultMessage: '绑定新用户',
+      })}
       extra={
         <CloseOutlined
           onClick={() => {
@@ -94,16 +115,32 @@ const Unbound = observer(() => {
         tableAlertRender={({ selectedRowKeys, onCleanSelected }) => (
           <Space size={24}>
             <span>
-              已选 {selectedRowKeys.length} 项
+              {intl.formatMessage({
+                id: 'pages.bindUser.bindTheNewUser.selected',
+                defaultMessage: '已选',
+              })}{' '}
+              {selectedRowKeys.length}{' '}
+              {intl.formatMessage({
+                id: 'pages.bindUser.bindTheNewUser.item',
+                defaultMessage: '项',
+              })}
               <a style={{ marginLeft: 8 }} onClick={onCleanSelected}>
-                取消选择
+                {intl.formatMessage({
+                  id: 'pages.bindUser.bindTheNewUser.deselect',
+                  defaultMessage: '取消选择',
+                })}
               </a>
             </span>
           </Space>
         )}
         tableAlertOptionRender={() => (
           <Space size={16}>
-            <a onClick={handleBind}>批量绑定</a>
+            <a onClick={handleBind}>
+              {intl.formatMessage({
+                id: 'pages.bindUser.bindTheNewUser.bulkBinds',
+                defaultMessage: '批量绑定',
+              })}
+            </a>
           </Space>
         )}
         size="small"

+ 14 - 2
src/locales/en-US/pages.ts

@@ -16,7 +16,7 @@ export default {
   'pages.data.option.remove.tips': 'Confirm to delete?',
   'pages.data.option.disabled': 'Disable',
   'pages.data.option.disabled.tips': 'Confirm to disable?',
-  'pages.data.option.enabled': 'enable',
+  'pages.data.option.enabled': 'Enable',
   'pages.data.option.enabled.tips': 'Confirm to enable?',
   'pages.data.option.add': 'Add',
   'pages.data.option.edit': 'Edit',
@@ -74,7 +74,7 @@ export default {
   'pages.system.authorization.screen.default': 'Default',
   'pages.system.authorization.screen.system': 'System',
   'pages.system.authorization.screen.business': 'Business Functions',
-  'pages.system.authorization.screen.multiTenant': 'Multi Tenant',
+  'pages.system.authorization.screen.tenant': 'Multi Tenant',
   'pages.system.authorization.screen.tip': 'Please enter the permission name',
   'pages.system.authorization.actions': 'Permission To Operate',
   'pages.system.authorization.selectAll': 'Select All',
@@ -86,6 +86,18 @@ export default {
   'pages.system.role.option.bindUser': 'Bind User',
   // 系统设置-角色管理-绑定用户
   'pages.bindUser.theBoundUser': 'The Bound User',
+  'pages.bindUser.theBoundUser.success': 'Unbundling success',
+  'pages.bindUser.theBoundUser.fail': 'Operation failure',
+  'pages.bindUser.theBoundUser.typeError': 'Unbind type data error',
+  'pages.bindUser.bindTheNewUser': 'Bind The New User',
+  'pages.bindUser.bindTheNewUser.selected': 'Selected',
+  'pages.bindUser.bindTheNewUser.item': 'item',
+  'pages.bindUser.bindTheNewUser.deselect': 'Deselect',
+  'pages.bindUser.bindTheNewUser.bulkBinds': 'Bulk Binds',
+  'pages.bindUser.bindTheNewUser.untieInBulk': 'Untie In Bulk',
+  'pages.bindUser.bindTheNewUser.success': 'Binding success',
+  'pages.bindUser.bindTheNewUser.fail': 'Binding failure',
+  'pages.bindUser.bindTheNewUser.typeError': 'Error binding type data',
   // 系统设置-权限管理
   'pages.system.permission': 'Permission',
   'pages.system.permission.id': 'ID',

+ 13 - 1
src/locales/zh-CN/pages.ts

@@ -74,7 +74,7 @@ export default {
   'pages.system.authorization.screen.default': '默认',
   'pages.system.authorization.screen.system': '系统',
   'pages.system.authorization.screen.business': '业务功能',
-  'pages.system.authorization.screen.multiTenant': '多租户',
+  'pages.system.authorization.screen.tenant': '多租户',
   'pages.system.authorization.screen.tip': '请输入权限名称',
   'pages.system.authorization.actions': '权限操作',
   'pages.system.authorization.selectAll': '全选',
@@ -86,6 +86,18 @@ export default {
   'pages.system.role.option.bindUser': '绑定用户',
   // 系统设置-角色管理-绑定用户
   'pages.bindUser.theBoundUser': '已绑定用户',
+  'pages.bindUser.theBoundUser.success': '解绑成功',
+  'pages.bindUser.theBoundUser.fail': '操作失败',
+  'pages.bindUser.theBoundUser.typeError': '解绑类型数据错误',
+  'pages.bindUser.bindTheNewUser': '绑定新用户',
+  'pages.bindUser.bindTheNewUser.selected': '已选',
+  'pages.bindUser.bindTheNewUser.item': '项',
+  'pages.bindUser.bindTheNewUser.deselect': '取消选择',
+  'pages.bindUser.bindTheNewUser.bulkBinds': '批量绑定',
+  'pages.bindUser.bindTheNewUser.untieInBulk': '批量解绑',
+  'pages.bindUser.bindTheNewUser.success': '绑定成功',
+  'pages.bindUser.bindTheNewUser.fail': '绑定失败',
+  'pages.bindUser.bindTheNewUser.typeError': '绑定类型数据错误',
   // 系统设置-权限管理
   'pages.system.permission': '权限管理',
   'pages.system.permission.id': '标识',

+ 2 - 2
src/pages/Analysis/MessageChart/index.tsx

@@ -1,4 +1,4 @@
-import { Column } from '@ant-design/charts';
+import { Column, ColumnConfig } from '@ant-design/charts';
 import moment from 'moment';
 import { useEffect } from 'react';
 import { service } from '@/pages/Analysis';
@@ -97,7 +97,7 @@ const MessageChart = () => {
 
   const paletteSemanticRed = '#F4664A';
   const brandColor = '#5B8FF9';
-  const config = {
+  const config: ColumnConfig = {
     data,
     xField: 'type',
     yField: 'value',

+ 60 - 1
src/pages/link/Certificate/index.tsx

@@ -7,6 +7,7 @@ import { Tooltip } from 'antd';
 import { EditOutlined, MinusOutlined } from '@ant-design/icons';
 import BaseCrud from '@/components/BaseCrud';
 import { useIntl } from '@@/plugin-locale/localeExports';
+import { ISchema } from '@formily/json-schema';
 
 export const service = new BaseService<CertificateItem>('network/certificate');
 const Certificate = () => {
@@ -73,7 +74,65 @@ const Certificate = () => {
     },
   ];
 
-  const schema = {};
+  // todo Upload 组件思考
+  const schema: ISchema = {
+    type: 'object',
+    properties: {
+      name: {
+        title: '名称',
+        'x-component': 'Input',
+        'x-decorator': 'FormItem',
+      },
+      instance: {
+        title: '类型',
+        'x-component': 'Select',
+        'x-decorator': 'FormItem',
+        default: 'PEM',
+        enum: [
+          { label: 'PFX', value: 'PFX' },
+          { label: 'JKS', value: 'JKS' },
+          { label: 'PEM', value: 'PEM' },
+        ],
+      },
+      'configs.keystoreBase64': {
+        title: '密钥库',
+        'x-component': 'Upload',
+        'x-decorator': 'FormItem',
+      },
+      'configs.keystorePwd': {
+        title: '密钥库密码',
+        'x-component': 'Password',
+        'x-decorator': 'FormItem',
+        'x-visible': false,
+        'x-component-props': {
+          style: {
+            width: '100%',
+          },
+        },
+      },
+      'configs.trustKeyStoreBase64': {
+        title: '信任库',
+        'x-component': 'Upload',
+        'x-decorator': 'FormItem',
+        'x-component-props': {
+          style: {
+            width: '100px',
+          },
+        },
+      },
+      'configs.trustKeyStorePwd': {
+        title: '信任库密码',
+        'x-visible': false,
+        'x-decorator': 'FormItem',
+        'x-component': 'Password',
+      },
+      description: {
+        title: '描述',
+        'x-component': 'Input.TextArea',
+        'x-decorator': 'FormItem',
+      },
+    },
+  };
 
   return (
     <PageContainer>

+ 30 - 4
src/pages/link/Gateway/index.tsx

@@ -1,7 +1,6 @@
 import { PageContainer } from '@ant-design/pro-layout';
-import BaseService from '@/utils/BaseService';
 import type { GatewayItem } from '@/pages/link/Gateway/typings';
-import { useRef } from 'react';
+import { useEffect, useRef } from 'react';
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import { Tooltip } from 'antd';
 import {
@@ -13,8 +12,13 @@ import {
 } from '@ant-design/icons';
 import BaseCrud from '@/components/BaseCrud';
 import { useIntl } from '@@/plugin-locale/localeExports';
+import { ISchema } from '@formily/json-schema';
+import Service from '@/pages/link/Gateway/service';
+import linkService from '@/pages/link/service';
+import GatewayModel from '@/pages/link/Gateway/model';
+
+export const service = new Service('network/config');
 
-export const service = new BaseService<GatewayItem>('network/config');
 const Gateway = () => {
   const intl = useIntl();
   const actionRef = useRef<ActionType>();
@@ -110,7 +114,29 @@ const Gateway = () => {
     },
   ];
 
-  const schema = {};
+  const getProviders = () => {
+    linkService.getProviders().subscribe((data) => {
+      GatewayModel.provider = data;
+    });
+  };
+
+  useEffect(() => {
+    getProviders();
+  }, []);
+
+  const schema: ISchema = {
+    type: 'object',
+    properties: {
+      name: {},
+      type: {
+        title: '类型',
+        'x-component': 'Select',
+        enum: GatewayModel.provider,
+      },
+      network: {},
+      description: {},
+    },
+  };
 
   return (
     <PageContainer>

+ 10 - 0
src/pages/link/Gateway/model.ts

@@ -0,0 +1,10 @@
+import { model } from '@formily/reactive';
+
+type GatewayModelType = {
+  provider: { label: string; value: string }[];
+};
+const GatewayModel = model<GatewayModelType>({
+  provider: [],
+});
+
+export default GatewayModel;

+ 6 - 0
src/pages/link/Gateway/service.ts

@@ -0,0 +1,6 @@
+import BaseService from '@/utils/BaseService';
+import { GatewayItem } from '@/pages/link/Gateway/typings';
+
+class Service extends BaseService<GatewayItem> {}
+
+export default Service;

+ 31 - 0
src/pages/link/service.ts

@@ -0,0 +1,31 @@
+import { request } from 'umi';
+import { defer, from } from 'rxjs';
+import SystemConst from '@/utils/const';
+import { filter, map } from 'rxjs/operators';
+
+class LinkService {
+  public getProviders = () =>
+    defer(() =>
+      from(
+        request(`${SystemConst.API_BASE}/gateway/device/providers`, {
+          method: 'GET',
+        }),
+      ),
+    ).pipe(
+      filter((item) => item.status === 200),
+      map((item) => item.result),
+    );
+
+  public getSupports = () => {
+    defer(() =>
+      from(
+        request(`${SystemConst.API_BASE}/protocol/supports`, {
+          method: 'GET',
+        }),
+      ),
+    );
+  };
+}
+
+const linkService = new LinkService();
+export default linkService;

+ 1 - 1
src/pages/system/User/index.tsx

@@ -169,7 +169,7 @@ const User = observer(() => {
         <a key="changeState">
           <Popconfirm
             title={intl.formatMessage({
-              id: `pages.data.option.${record.status ? 'disabled' : 'enabled'}`,
+              id: `pages.data.option.${record.status ? 'disabled' : 'enabled'}.tips`,
               defaultMessage: `确认${record.status ? '禁用' : '启用'}?`,
             })}
             onConfirm={async () => {