|
@@ -1,14 +1,12 @@
|
|
|
import { PageContainer } from '@ant-design/pro-layout';
|
|
import { PageContainer } from '@ant-design/pro-layout';
|
|
|
import type { ProtocolItem } from '@/pages/link/Protocol/typings';
|
|
import type { ProtocolItem } from '@/pages/link/Protocol/typings';
|
|
|
-import { useRef, useState } from 'react';
|
|
|
|
|
|
|
+import { useRef } from 'react';
|
|
|
import type { ActionType, ProColumns } from '@jetlinks/pro-table';
|
|
import type { ActionType, ProColumns } from '@jetlinks/pro-table';
|
|
|
import { message, Popconfirm, Tag, Tooltip } from 'antd';
|
|
import { message, Popconfirm, Tag, Tooltip } from 'antd';
|
|
|
import {
|
|
import {
|
|
|
- BugOutlined,
|
|
|
|
|
- CloseOutlined,
|
|
|
|
|
CloudSyncOutlined,
|
|
CloudSyncOutlined,
|
|
|
|
|
+ DeleteOutlined,
|
|
|
EditOutlined,
|
|
EditOutlined,
|
|
|
- MinusOutlined,
|
|
|
|
|
PlayCircleOutlined,
|
|
PlayCircleOutlined,
|
|
|
} from '@ant-design/icons';
|
|
} from '@ant-design/icons';
|
|
|
import BaseCrud from '@/components/BaseCrud';
|
|
import BaseCrud from '@/components/BaseCrud';
|
|
@@ -16,14 +14,11 @@ import { useIntl } from '@@/plugin-locale/localeExports';
|
|
|
import type { ISchema } from '@formily/json-schema';
|
|
import type { ISchema } from '@formily/json-schema';
|
|
|
import { CurdModel } from '@/components/BaseCrud/model';
|
|
import { CurdModel } from '@/components/BaseCrud/model';
|
|
|
import Service from '@/pages/link/Protocol/service';
|
|
import Service from '@/pages/link/Protocol/service';
|
|
|
-import Debug from '@/pages/link/Protocol/Debug';
|
|
|
|
|
|
|
|
|
|
export const service = new Service('protocol');
|
|
export const service = new Service('protocol');
|
|
|
const Protocol = () => {
|
|
const Protocol = () => {
|
|
|
const intl = useIntl();
|
|
const intl = useIntl();
|
|
|
const actionRef = useRef<ActionType>();
|
|
const actionRef = useRef<ActionType>();
|
|
|
- const [visible, setVisible] = useState<boolean>(false);
|
|
|
|
|
- const [current, setCurrent] = useState<Partial<ProtocolItem>>({});
|
|
|
|
|
|
|
|
|
|
const modifyState = async (id: string, type: 'deploy' | 'un-deploy') => {
|
|
const modifyState = async (id: string, type: 'deploy' | 'un-deploy') => {
|
|
|
const resp = await service.modifyState(id, type);
|
|
const resp = await service.modifyState(id, type);
|
|
@@ -55,21 +50,18 @@ const Protocol = () => {
|
|
|
}),
|
|
}),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
|
|
+ dataIndex: 'type',
|
|
|
|
|
+ title: '类型',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
dataIndex: 'state',
|
|
dataIndex: 'state',
|
|
|
title: '状态',
|
|
title: '状态',
|
|
|
renderText: (text) =>
|
|
renderText: (text) =>
|
|
|
text === 1 ? <Tag color="#108ee9">正常</Tag> : <Tag color="#F50">禁用</Tag>,
|
|
text === 1 ? <Tag color="#108ee9">正常</Tag> : <Tag color="#F50">禁用</Tag>,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- dataIndex: 'type',
|
|
|
|
|
- title: '类型',
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- dataIndex: 'provider',
|
|
|
|
|
- title: intl.formatMessage({
|
|
|
|
|
- id: 'pages.table.provider',
|
|
|
|
|
- defaultMessage: '服务商',
|
|
|
|
|
- }),
|
|
|
|
|
|
|
+ dataIndex: 'description',
|
|
|
|
|
+ title: '说明',
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
title: intl.formatMessage({
|
|
title: intl.formatMessage({
|
|
@@ -114,31 +106,6 @@ const Protocol = () => {
|
|
|
</Popconfirm>
|
|
</Popconfirm>
|
|
|
</a>
|
|
</a>
|
|
|
),
|
|
),
|
|
|
- record.state === 1 && (
|
|
|
|
|
- <a key="unDeploy">
|
|
|
|
|
- <Popconfirm onConfirm={() => modifyState(record.id, 'un-deploy')} title="发布?">
|
|
|
|
|
- <Tooltip title="取消发布">
|
|
|
|
|
- <CloseOutlined />
|
|
|
|
|
- </Tooltip>
|
|
|
|
|
- </Popconfirm>
|
|
|
|
|
- </a>
|
|
|
|
|
- ),
|
|
|
|
|
- <a
|
|
|
|
|
- key="debug"
|
|
|
|
|
- onClick={() => {
|
|
|
|
|
- setVisible(true);
|
|
|
|
|
- setCurrent(record);
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
- <Tooltip
|
|
|
|
|
- title={intl.formatMessage({
|
|
|
|
|
- id: 'pages.notice.option.debug',
|
|
|
|
|
- defaultMessage: '调试',
|
|
|
|
|
- })}
|
|
|
|
|
- >
|
|
|
|
|
- <BugOutlined />
|
|
|
|
|
- </Tooltip>
|
|
|
|
|
- </a>,
|
|
|
|
|
record.state !== 1 && (
|
|
record.state !== 1 && (
|
|
|
<a key="delete">
|
|
<a key="delete">
|
|
|
<Popconfirm
|
|
<Popconfirm
|
|
@@ -163,7 +130,7 @@ const Protocol = () => {
|
|
|
defaultMessage: '删除',
|
|
defaultMessage: '删除',
|
|
|
})}
|
|
})}
|
|
|
>
|
|
>
|
|
|
- <MinusOutlined />
|
|
|
|
|
|
|
+ <DeleteOutlined />
|
|
|
</Tooltip>
|
|
</Tooltip>
|
|
|
</Popconfirm>
|
|
</Popconfirm>
|
|
|
</a>
|
|
</a>
|
|
@@ -179,141 +146,126 @@ const Protocol = () => {
|
|
|
type: 'void',
|
|
type: 'void',
|
|
|
'x-component': 'FormGrid',
|
|
'x-component': 'FormGrid',
|
|
|
'x-component-props': {
|
|
'x-component-props': {
|
|
|
- maxColumns: 2,
|
|
|
|
|
- minColumns: 2,
|
|
|
|
|
|
|
+ maxColumns: 1,
|
|
|
|
|
+ minColumns: 1,
|
|
|
},
|
|
},
|
|
|
properties: {
|
|
properties: {
|
|
|
id: {
|
|
id: {
|
|
|
title: 'ID',
|
|
title: 'ID',
|
|
|
'x-component': 'Input',
|
|
'x-component': 'Input',
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
- required: true,
|
|
|
|
|
'x-decorator-props': {
|
|
'x-decorator-props': {
|
|
|
gridSpan: 1,
|
|
gridSpan: 1,
|
|
|
},
|
|
},
|
|
|
|
|
+ 'x-validator': [
|
|
|
|
|
+ {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ message: '请输入ID',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ max: 64,
|
|
|
|
|
+ message: '最多可输入64个字符',
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
},
|
|
},
|
|
|
name: {
|
|
name: {
|
|
|
title: '名称',
|
|
title: '名称',
|
|
|
- required: true,
|
|
|
|
|
'x-component': 'Input',
|
|
'x-component': 'Input',
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
'x-decorator-props': {
|
|
'x-decorator-props': {
|
|
|
gridSpan: 1,
|
|
gridSpan: 1,
|
|
|
},
|
|
},
|
|
|
|
|
+ 'x-validator': [
|
|
|
|
|
+ {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ message: '请输入名称',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ max: 64,
|
|
|
|
|
+ message: '最多可输入64个字符',
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
},
|
|
},
|
|
|
type: {
|
|
type: {
|
|
|
title: '类型',
|
|
title: '类型',
|
|
|
'x-component': 'Select',
|
|
'x-component': 'Select',
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
- required: true,
|
|
|
|
|
|
|
+ 'x-decorator-props': {
|
|
|
|
|
+ tooltip: <div>jar:上传协议jar包,文件格式支持.jar或.zip</div>,
|
|
|
|
|
+ },
|
|
|
|
|
+ 'x-validator': [
|
|
|
|
|
+ {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ message: '请选择类型',
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
enum: [
|
|
enum: [
|
|
|
{ label: 'jar', value: 'jar' },
|
|
{ label: 'jar', value: 'jar' },
|
|
|
{ label: 'local', value: 'local' },
|
|
{ label: 'local', value: 'local' },
|
|
|
- { label: 'script', value: 'script' },
|
|
|
|
|
|
|
+ // { label: 'script', value: 'script' },
|
|
|
],
|
|
],
|
|
|
},
|
|
},
|
|
|
configuration: {
|
|
configuration: {
|
|
|
type: 'object',
|
|
type: 'object',
|
|
|
properties: {
|
|
properties: {
|
|
|
- provider: {
|
|
|
|
|
- title: '类名',
|
|
|
|
|
- 'x-component': 'Input',
|
|
|
|
|
- 'x-decorator': 'FormItem',
|
|
|
|
|
- 'x-visible': false,
|
|
|
|
|
- 'x-reactions': {
|
|
|
|
|
- dependencies: ['..type'],
|
|
|
|
|
- fulfill: {
|
|
|
|
|
- state: {
|
|
|
|
|
- visible: '{{["jar","local"].includes($deps[0])}}',
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- '{url:location}': {
|
|
|
|
|
|
|
+ location: {
|
|
|
title: '文件地址',
|
|
title: '文件地址',
|
|
|
- 'x-component': 'FUpload',
|
|
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
- 'x-component-props': {
|
|
|
|
|
- type: 'file',
|
|
|
|
|
- },
|
|
|
|
|
'x-visible': false,
|
|
'x-visible': false,
|
|
|
- 'x-reactions': {
|
|
|
|
|
- dependencies: ['..type'],
|
|
|
|
|
- when: '{{$deps[0]==="script"}}',
|
|
|
|
|
- fulfill: {
|
|
|
|
|
- state: {
|
|
|
|
|
- visible: false,
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- otherwise: {
|
|
|
|
|
- state: {
|
|
|
|
|
- visible: '{{["jar","local"].includes($deps[0])}}',
|
|
|
|
|
- componentType: '{{$deps[0]==="jar"?"FUpload":"Input"}}',
|
|
|
|
|
- componentProps: '{{$deps[0]==="jar"?{type:"file"}:{}}}',
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- protocol: {
|
|
|
|
|
- title: '协议标识',
|
|
|
|
|
- 'x-component': 'Input',
|
|
|
|
|
- 'x-decorator': 'FormItem',
|
|
|
|
|
- },
|
|
|
|
|
- transport: {
|
|
|
|
|
- title: '链接协议',
|
|
|
|
|
- 'x-component': 'Select',
|
|
|
|
|
- 'x-decorator': 'FormItem',
|
|
|
|
|
- enum: [
|
|
|
|
|
- { label: 'MQTT', value: 'MQTT' },
|
|
|
|
|
- { label: 'UDP', value: 'UDP' },
|
|
|
|
|
- { label: 'CoAP', value: 'CoAP' },
|
|
|
|
|
- { label: 'TCP', value: 'TCP' },
|
|
|
|
|
- { label: 'HTTP', value: 'HTTP' },
|
|
|
|
|
- { label: 'HTTPS', value: 'HTTPS' },
|
|
|
|
|
- ],
|
|
|
|
|
- },
|
|
|
|
|
- script: {
|
|
|
|
|
- title: '脚本',
|
|
|
|
|
- 'x-component': 'FMonacoEditor',
|
|
|
|
|
- 'x-decorator': 'FormItem',
|
|
|
|
|
'x-decorator-props': {
|
|
'x-decorator-props': {
|
|
|
- gridSpan: 2,
|
|
|
|
|
- labelCol: 2,
|
|
|
|
|
- wrapperCol: 22,
|
|
|
|
|
|
|
+ tooltip: (
|
|
|
|
|
+ <div>
|
|
|
|
|
+ local:填写本地协议编译目录绝对地址,如:d:/workspace/protocol/target/classes
|
|
|
|
|
+ </div>
|
|
|
|
|
+ ),
|
|
|
},
|
|
},
|
|
|
- default: `//解码,收到设备上行消息时
|
|
|
|
|
-codec.decoder(function (context) {
|
|
|
|
|
- var message = context.getMessage();
|
|
|
|
|
- return {
|
|
|
|
|
- messageType:"REPORT_PROPERTY"//消息类型
|
|
|
|
|
- };
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
-//编码读取设备属性消息
|
|
|
|
|
-codec.encoder("READ_PROPERTY",function(context){
|
|
|
|
|
- var message = context.getMessage();
|
|
|
|
|
- var properties = message.properties;
|
|
|
|
|
-})`,
|
|
|
|
|
- 'x-component-props': {
|
|
|
|
|
- height: 200,
|
|
|
|
|
- theme: 'dark',
|
|
|
|
|
- language: 'javascript',
|
|
|
|
|
- editorDidMount: (editor1: any) => {
|
|
|
|
|
- editor1.onDidContentSizeChange?.(() => {
|
|
|
|
|
- editor1.getAction('editor.action.formatDocument').run();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ 'x-validator': [
|
|
|
|
|
+ {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ message: '请输入文件地址',
|
|
|
},
|
|
},
|
|
|
- },
|
|
|
|
|
- 'x-visible': false,
|
|
|
|
|
|
|
+ ],
|
|
|
'x-reactions': {
|
|
'x-reactions': {
|
|
|
dependencies: ['..type'],
|
|
dependencies: ['..type'],
|
|
|
fulfill: {
|
|
fulfill: {
|
|
|
state: {
|
|
state: {
|
|
|
- visible: '{{$deps[0]==="script"}}',
|
|
|
|
|
|
|
+ visible: '{{["jar","local"].includes($deps[0])}}',
|
|
|
|
|
+ componentType: '{{$deps[0]==="jar"?"FileUpload":"Input"}}',
|
|
|
|
|
+ componentProps: '{{$deps[0]==="jar"?{type:"file", accept: ".jar, .zip"}:{}}}',
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
|
|
+ // provider: {
|
|
|
|
|
+ // title: '类名',
|
|
|
|
|
+ // 'x-component': 'Input',
|
|
|
|
|
+ // 'x-decorator': 'FormItem',
|
|
|
|
|
+ // 'x-visible': false,
|
|
|
|
|
+ // 'x-validator': [
|
|
|
|
|
+ // {
|
|
|
|
|
+ // required: true,
|
|
|
|
|
+ // message: '请选择类名',
|
|
|
|
|
+ // },
|
|
|
|
|
+ // ],
|
|
|
|
|
+ // 'x-reactions': {
|
|
|
|
|
+ // dependencies: ['..type'],
|
|
|
|
|
+ // fulfill: {
|
|
|
|
|
+ // state: {
|
|
|
|
|
+ // visible: '{{["jar","local"].includes($deps[0])}}',
|
|
|
|
|
+ // },
|
|
|
|
|
+ // },
|
|
|
|
|
+ // },
|
|
|
|
|
+ // },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ description: {
|
|
|
|
|
+ title: '说明',
|
|
|
|
|
+ 'x-component': 'Input.TextArea',
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component-props': {
|
|
|
|
|
+ rows: 3,
|
|
|
|
|
+ showCount: true,
|
|
|
|
|
+ maxLength: 200,
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -326,15 +278,13 @@ codec.encoder("READ_PROPERTY",function(context){
|
|
|
<BaseCrud
|
|
<BaseCrud
|
|
|
columns={columns}
|
|
columns={columns}
|
|
|
service={service}
|
|
service={service}
|
|
|
- title={intl.formatMessage({
|
|
|
|
|
- id: 'pages.link.protocol',
|
|
|
|
|
- defaultMessage: '协议管理',
|
|
|
|
|
- })}
|
|
|
|
|
- modelConfig={{ width: '50vw' }}
|
|
|
|
|
|
|
+ title={'插件管理'}
|
|
|
|
|
+ search={false}
|
|
|
|
|
+ modelConfig={{ width: '550px' }}
|
|
|
schema={schema}
|
|
schema={schema}
|
|
|
actionRef={actionRef}
|
|
actionRef={actionRef}
|
|
|
/>
|
|
/>
|
|
|
- {visible && <Debug data={current} close={() => setVisible(!visible)} />}
|
|
|
|
|
|
|
+ {/* {visible && <Debug data={current} close={() => setVisible(!visible)} />} */}
|
|
|
</PageContainer>
|
|
</PageContainer>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|