|
|
@@ -1,70 +1,82 @@
|
|
|
import { PageContainer } from '@ant-design/pro-layout';
|
|
|
-import { InstanceModel } from '@/pages/device/Instance';
|
|
|
+import { InstanceModel, service } from '@/pages/device/Instance';
|
|
|
import { history } from 'umi';
|
|
|
-import { Button, Descriptions } from 'antd';
|
|
|
+import { Button } from 'antd';
|
|
|
import { useEffect, useState } from 'react';
|
|
|
import { statusMap } from '@/pages/device/Product';
|
|
|
+import { observer } from '@formily/react';
|
|
|
+import Config from '@/pages/device/Instance/Detail/Config';
|
|
|
+import Metadata from '@/pages/device/Instance/Detail/Metadata';
|
|
|
+import Log from '@/pages/device/Instance/Detail/Log';
|
|
|
+import Alarm from '@/pages/device/Instance/Detail/Alarm';
|
|
|
+import Info from '@/pages/device/Instance/Detail/Info';
|
|
|
+import Functions from '@/pages/device/Instance/Detail/Functions';
|
|
|
+import Running from '@/pages/device/Instance/Detail/Running';
|
|
|
|
|
|
-const InstanceDetail = () => {
|
|
|
+const list = [
|
|
|
+ {
|
|
|
+ key: 'detail',
|
|
|
+ tab: '实例信息',
|
|
|
+ component: <Config />,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'running',
|
|
|
+ tab: '运行状态',
|
|
|
+ component: <Running />,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'metadata',
|
|
|
+ tab: '物模型',
|
|
|
+ component: <Metadata />,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'functions',
|
|
|
+ tab: '设备功能',
|
|
|
+ component: <Functions />,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'log',
|
|
|
+ tab: '日志管理',
|
|
|
+ component: <Log />,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'alarm',
|
|
|
+ tab: '告警设置',
|
|
|
+ component: <Alarm />,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'visualization',
|
|
|
+ tab: '可视化',
|
|
|
+ component: null,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'shadow',
|
|
|
+ tab: '设备影子',
|
|
|
+ component: null,
|
|
|
+ },
|
|
|
+];
|
|
|
+const InstanceDetail = observer(() => {
|
|
|
const [tab, setTab] = useState<string>('detail');
|
|
|
+ const getDetail = (id: string) => {
|
|
|
+ service.detail(id).then((response) => {
|
|
|
+ InstanceModel.detail = response?.result;
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
- if (!InstanceModel.current) history.goBack();
|
|
|
+ if (!InstanceModel.current) {
|
|
|
+ history.goBack();
|
|
|
+ } else {
|
|
|
+ getDetail(InstanceModel.current?.id);
|
|
|
+ }
|
|
|
}, []);
|
|
|
+
|
|
|
return (
|
|
|
<PageContainer
|
|
|
onBack={() => history.goBack()}
|
|
|
onTabChange={setTab}
|
|
|
- tabList={[
|
|
|
- {
|
|
|
- key: 'detail',
|
|
|
- tab: '实例信息',
|
|
|
- },
|
|
|
- {
|
|
|
- key: 'metadata',
|
|
|
- tab: '物模型',
|
|
|
- },
|
|
|
- {
|
|
|
- key: 'log',
|
|
|
- tab: '日志管理',
|
|
|
- },
|
|
|
- {
|
|
|
- key: 'alarm',
|
|
|
- tab: '告警设置',
|
|
|
- },
|
|
|
- {
|
|
|
- key: 'visualization',
|
|
|
- tab: '可视化',
|
|
|
- },
|
|
|
- {
|
|
|
- key: 'shadow',
|
|
|
- tab: '设备影子',
|
|
|
- },
|
|
|
- ]}
|
|
|
- content={
|
|
|
- <Descriptions size="small" column={3}>
|
|
|
- <Descriptions.Item label="设备ID">{InstanceModel.current?.id}</Descriptions.Item>
|
|
|
- <Descriptions.Item label="产品名称">{InstanceModel.current?.name}</Descriptions.Item>
|
|
|
- <Descriptions.Item label="设备类型">
|
|
|
- {InstanceModel.current?.deviceType?.text}
|
|
|
- </Descriptions.Item>
|
|
|
- <Descriptions.Item label="链接协议">
|
|
|
- {InstanceModel.current?.protocolName}
|
|
|
- </Descriptions.Item>
|
|
|
- <Descriptions.Item label="消息协议">
|
|
|
- {InstanceModel.current?.transportProtocol}
|
|
|
- </Descriptions.Item>
|
|
|
- <Descriptions.Item label="创建时间">
|
|
|
- {InstanceModel.current?.createTime}
|
|
|
- </Descriptions.Item>
|
|
|
- <Descriptions.Item label="注册时间">
|
|
|
- {InstanceModel.current?.createTime}
|
|
|
- </Descriptions.Item>
|
|
|
- <Descriptions.Item label="最后上线时间">
|
|
|
- {InstanceModel.current?.createTime}
|
|
|
- </Descriptions.Item>
|
|
|
- <Descriptions.Item label="说明">{InstanceModel.current?.createTime}</Descriptions.Item>
|
|
|
- </Descriptions>
|
|
|
- }
|
|
|
+ tabList={list}
|
|
|
+ content={<Info />}
|
|
|
extra={[
|
|
|
statusMap[0],
|
|
|
<Button key="2">停用</Button>,
|
|
|
@@ -73,9 +85,8 @@ const InstanceDetail = () => {
|
|
|
</Button>,
|
|
|
]}
|
|
|
>
|
|
|
- 设备实例{tab}
|
|
|
- {JSON.stringify(InstanceModel.current)}
|
|
|
+ {list.find((k) => k.key === tab)?.component}
|
|
|
</PageContainer>
|
|
|
);
|
|
|
-};
|
|
|
+});
|
|
|
export default InstanceDetail;
|