feat: 监视端开发

master
JINGYJ 12 months ago
parent 60d8ac2afc
commit 19fa6ce2f0

@ -76,21 +76,21 @@ export default [
path: '/offline/alarm-list',
component: './Offline/OfflineAlarmList',
},
{
name: 'offline-alarm-rules',
path: '/offline/alarm-rules',
component: './Offline/OfflineAlarmRules',
},
{
name: 'offline-device-list',
path: '/offline/device-list',
component: './Offline/OfflineDeviceList',
},
{
name: 'offline-video-file',
path: '/offline/video-file',
component: './Offline/VideoFile',
},
// {
// name: 'offline-alarm-rules',
// path: '/offline/alarm-rules',
// component: './Offline/OfflineAlarmRules',
// },
// {
// name: 'offline-device-list',
// path: '/offline/device-list',
// component: './Offline/OfflineDeviceList',
// },
// {
// name: 'offline-video-file',
// path: '/offline/video-file',
// component: './Offline/VideoFile',
// },
],
},
{

@ -48,15 +48,15 @@ export const mockGetMenuData = {
routes: [],
title: '告警列表',
},
{
component: 'RealTime/AlarmRules',
icon: '',
key: '103',
name: 'realTime-alarm-rules',
path: '/realTime/alarm-rules',
routes: [],
title: '告警规则',
},
// {
// component: 'RealTime/AlarmRules',
// icon: '',
// key: '103',
// name: 'realTime-alarm-rules',
// path: '/realTime/alarm-rules',
// routes: [],
// title: '告警规则',
// },
{
component: 'RealTime/DeviceList',
icon: '',
@ -64,7 +64,7 @@ export const mockGetMenuData = {
name: 'realTime-device-list',
path: '/realTime/device-list',
routes: [],
title: '设备管理',
title: '设备状态',
},
],
},
@ -94,33 +94,33 @@ export const mockGetMenuData = {
routes: [],
title: '告警列表',
},
{
component: 'Offline/OfflineAlarmRules',
icon: '',
key: '203',
name: 'offline-alarm-rules',
path: '/offline/alarm-rules',
routes: [],
title: '告警规则',
},
{
component: 'Offline/OfflineDeviceList',
icon: '',
key: '204',
name: 'offline-device-list',
path: '/offline/device-list',
routes: [],
title: '设备管理',
},
{
component: 'Offline/VideoFile',
icon: '',
key: '205',
name: 'offline-video-file',
path: '/offline/video-file',
routes: [],
title: '视频文件',
},
// {
// component: 'Offline/OfflineAlarmRules',
// icon: '',
// key: '203',
// name: 'offline-alarm-rules',
// path: '/offline/alarm-rules',
// routes: [],
// title: '告警规则',
// },
// {
// component: 'Offline/OfflineDeviceList',
// icon: '',
// key: '204',
// name: 'offline-device-list',
// path: '/offline/device-list',
// routes: [],
// title: '设备管理',
// },
// {
// component: 'Offline/VideoFile',
// icon: '',
// key: '205',
// name: 'offline-video-file',
// path: '/offline/video-file',
// routes: [],
// title: '视频文件',
// },
],
},
],

@ -46,3 +46,6 @@
padding-block: 0;
padding-inline: 0;
}
.ant-pro-setting-drawer-handle {
z-index: 10;
}

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-03-27 16:03:20
@ -12,11 +13,11 @@ import type { MenuProps } from 'antd';
import { Menu } from 'antd';
import React, { useEffect, useState } from 'react';
import { postWarningStatistics } from '../../../src/services/realTime/alarmlist';
import './index.less';
import menuFooter from '/public/menuFooter.svg';
import menuLogo from '/public/menuLogo.svg';
import './index.less';
export type MenuBarProps = {
menuData: any[];
};
@ -76,6 +77,27 @@ const MenuBar: React.FC<MenuBarProps> = ({ menuData }) => {
}
return null;
};
// 轮询告警信息
const [isHaveWarning, setIsHaveWarning] = useState(false);
const [totalResults, setTotalResults] = useState([]);
const pollServer = () => {
postWarningStatistics({})
.then((res) => {
let have_warning = res.data.have_warning;
console.log(res.data.have_warning, 'pollServer');
let totalResults = res.data.total_results;
setTotalResults(totalResults);
setIsHaveWarning(() => have_warning);
// setTimeout(pollServer, 5000);
})
.catch(() => {});
};
useEffect(() => {
pollServer();
}, []);
// useEffect(() => {
// console.log(isHaveWarning,'isHaveWarning');
// },[isHaveWarning])
// 当路由变化时更新当前选中菜单项
useEffect(() => {
const pathname = history.location.pathname;
@ -91,6 +113,9 @@ const MenuBar: React.FC<MenuBarProps> = ({ menuData }) => {
// Check if menuItem has route defined
if (menuItem && menuItem.path) {
history.push(menuItem.path);
// history.push(
// menuItem.path,
// {totalResults});
}
// console.log('menuClick ', e.item.props.path);
// const currRouteItem = e.item.props;
@ -193,6 +218,17 @@ const MenuBar: React.FC<MenuBarProps> = ({ menuData }) => {
onClick={() => menuClick(childItem)}
>
{childItem.title}
{childItem.key === '102' && isHaveWarning && (
<span
style={{
display: 'inline-block',
width: 10,
height: 10,
background: '#E80D0D',
borderRadius: '50%',
}}
></span>
)}
</Menu.Item>
))}
</Menu.SubMenu>

@ -73,6 +73,9 @@ export const device_relation: { [key: string]: string } = {
export const interface_manage: { [key: string]: string } = {
'device.interface_manage.table.list.id': 'ID',
'device.interface_manage.table.list.name': '接口名称',
'device.interface_manage.table.list.platform_name': '设备名称',
'device.interface_manage.table.list.statusUpdate': '最近一次状态查询',
'device.interface_manage.table.list.rename': '重命名',
'device.interface_manage.table.list.address': '接口地址',
'device.interface_manage.table.list.ip': 'IP地址',
'device.interface_manage.table.list.createTime': '创建时间',

@ -283,7 +283,13 @@ const OfflineAlarmList: React.FC = () => {
</div>
<div style={{ padding: '16px 0' }}>
<DatePicker locale={locale} value={importDate} onChange={onChange} allowClear />
<DatePicker
style={{ width: 280, borderRadius: 4 }}
locale={locale}
value={importDate}
onChange={onChange}
allowClear
/>
<Button
type="primary"
style={{ margin: '0 16px' }}

@ -91,3 +91,8 @@
background: none;
}
}
.select_Bg {
.ant-select-selector {
border-radius: 4px;
}
}

@ -2,7 +2,7 @@ import { postIgnoringvents } from '@/services/realTime/alarmlist';
import { postRecognition } from '@/services/realTime/involved';
import { ModalForm } from '@ant-design/pro-components';
import { useIntl } from '@umijs/max';
import { Button, Form, message } from 'antd';
import { Form, message } from 'antd';
import React, { useEffect, useState } from 'react';
// Import Swiper React components
// import { Swiper, SwiperSlide } from 'swiper/react';
@ -109,55 +109,48 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
cancelText: intl.formatMessage({ id: 'common.no', defaultMessage: '取消' }),
className: 'alarmModalForm',
}}
submitter={{
// resetButtonProps: {
// style: {
// display: 'none',
// },
// },
// searchConfig: {
// submitText: '忽略此事件',
// },
render: (prop) => {
return [
<Button
key="ok"
style={{ backgroundColor: '#E80D0D', color: '#FFF', borderBlockColor: '#E80D0D' }}
onClick={() => {
prop.submit();
}}
>
</Button>,
props.values?.person_list ? null : (
<Button
key="involved"
style={{ backgroundColor: '#FAAD14', color: '#FFF', borderBlockColor: '#FAAD14' }}
onClick={() => {
// console.log(props.updateModalOpen);
setInvolved(1);
handlePostRecognition(props.values?.person_id, 1);
}}
>
</Button>
),
props.values?.person_list ? null : (
<Button
key="noInvolved"
style={{ background: '#FFF', color: '#E80D0D', borderColor: '#E80D0D' }}
onClick={() => {
// console.log(props.updateModalOpen);
setInvolved(0);
handlePostRecognition(props.values?.person_id, 0);
}}
>
</Button>
),
];
},
}}
// submitter={{
// render: (prop) => {
// return [
// <Button
// key="ok"
// style={{ backgroundColor: '#E80D0D', color: '#FFF', borderBlockColor: '#E80D0D' }}
// onClick={() => {
// prop.submit();
// }}
// >
// 忽略此事件
// </Button>,
// props.values?.person_list ? null : (
// <Button
// key="involved"
// style={{ backgroundColor: '#FAAD14', color: '#FFF', borderBlockColor: '#FAAD14' }}
// onClick={() => {
// // console.log(props.updateModalOpen);
// setInvolved(1);
// handlePostRecognition(props.values?.person_id, 1);
// }}
// >
// 加入重点关注
// </Button>
// ),
// props.values?.person_list ? null : (
// <Button
// key="noInvolved"
// style={{ background: '#FFF', color: '#E80D0D', borderColor: '#E80D0D' }}
// onClick={() => {
// // console.log(props.updateModalOpen);
// setInvolved(0);
// handlePostRecognition(props.values?.person_id, 0);
// }}
// >
// 移除重点关注
// </Button>
// ),
// ];
// },
// }}
submitter={false}
submitTimeout={2000}
onFinish={async (values) => {
values.is_ignore = true;

@ -1,15 +1,17 @@
import { alarmRulesEnums } from '@/enums/status';
import { PageContainer, ProCard, ProList } from '@ant-design/pro-components';
import { Button, Image } from 'antd';
import { Button, Image, Select } from 'antd';
import React, { useEffect, useState } from 'react';
import { proTablePaginationOptions } from '../../../../config/defaultTable';
// import DeviceStatusCard from './components/DeviceStatusCard';
// import CreateForm from './components/CreateForm';
import { useMoment } from '@/hooks/useMoment';
import { postAlarmList } from '@/services/realTime/alarmlist';
import { postAlarmList, postWarningStatistics } from '@/services/realTime/alarmlist';
import Alarm_list_bg from '../../../../public/Alarm_list_bg.png';
import { ReactComponent as NoData } from '../../../../public/images/no_data.svg';
import AlarmDetails from './components/AlarmDetails';
// import { useLocation } from '@umijs/max';
import './components/AlarmDetails.less';
/**
* @
@ -66,6 +68,46 @@ const AlarmList: React.FC = () => {
const [dataTestList, setdataTestList] = useState<any>([]);
const [tab, setTab] = useState<string>(alarmRulesEnums[0].key);
// const location = useLocation();
// const { state } = location;
const [selectOptions, setSelectOptions] = useState<any>([]);
const [selectValue, setSelectValue] = useState<number>();
const pollServer = () => {
postWarningStatistics({})
.then((res) => {
if (res && res.data.total_results) {
// 使用 state.totalResults 来设置 selectOptions
const newOptions = res.data.total_results.map((record: any) => ({
value: record.id,
label: (
<span>
{record.platform_name}
{record.have_warning && (
<span
style={{
display: 'inline-block',
width: '10px',
height: '10px',
background: '#E80D0D',
borderRadius: '50%',
}}
/>
)}
</span>
),
}));
setSelectValue(res.data.total_results[0].id);
setSelectOptions(newOptions);
}
console.log(selectValue, 'selectValue');
// setTimeout(pollServer, 5000);
})
.catch(() => {});
};
useEffect(() => {
pollServer();
console.log(selectOptions);
}, []);
// const [tabs, setTabs] = useState<any>([]);
const changeProjectTab = (key: string) => {
setTab(key);
@ -73,23 +115,6 @@ const AlarmList: React.FC = () => {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
initList(key);
};
// const getTabs = () => {
// // if (alarmRulesEnums.length) {
// // setTab(alarmRulesEnums[0].key);
// // }
// setTabs(alarmRulesEnums);
// };
// useEffect(() => {
// getTabs();
// }, []);
// const handleCreateModal = () => {
// if (createModalOpen) {
// setCreateModalOpen(false);
// setCurrentRow(undefined);
// } else {
// setCreateModalOpen(true);
// }
// };
const handleUpdateModal = () => {
if (updateModalOpen) {
@ -100,41 +125,6 @@ const AlarmList: React.FC = () => {
}
};
// const handleDestroy = async () => {
// if (modalOpen) {
// setModalOpen(false);
// setCurrentRow(undefined);
// } else {
// setModalOpen(true);
// }
// // deleteBusinessImageDeleteBusinessImage({ id: selectedRow.id })
// // .then(() => {
// // message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' }));
// // actionRef.current?.reload();
// // })
// // .catch(() => {
// // message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' }));
// // });
// };
// const { confirm } = Modal;
// const showConfirm = (record: any) => {
// confirm({
// title: `确定删除${record.name}吗`,
// icon: <QuestionCircleFilled />,
// content: '确定删除服务器1吗删除后将找不到此服务器请谨慎操作.',
// okText: '确认',
// cancelText: '取消',
// width: 560,
// onOk() {
// console.log('OK');
// },
// onCancel() {
// console.log('Cancel');
// },
// });
// };
// 处理初始值
function initDataTestList(dataList: Record<string, any>[]) {
console.log(dataList, 'initDataTestList');
@ -228,13 +218,17 @@ const AlarmList: React.FC = () => {
setdataTestList(() => [...finalList]);
}
const handleChange = (value: any) => {
console.log(`selected ${value}`);
setSelectValue(value);
};
// 初始化加载
async function initList(tabId: string = tab) {
async function initList(tabId: string = tab, selectValues: any = selectValue) {
const reqParams = {
page: currentPage,
pageSize: currentPageSize,
// desc: false,
platform_id: selectValues,
warning_type: tabId,
// ...rest,
};
@ -313,6 +307,39 @@ const AlarmList: React.FC = () => {
changeProjectTab(key);
}}
></Tabs> */}
<div style={{ marginBottom: 16 }}>
<Select
defaultValue={1}
className="select_Bg"
style={{ width: 280, borderRadius: 4 }}
onChange={handleChange}
options={selectOptions}
/>
<Button
type="primary"
style={{ margin: '0 12px', borderRadius: 4 }}
onClick={() => {
// setCreateModalOpen(true);
initList();
}}
>
</Button>
<Button
type="primary"
style={{ borderRadius: 4 }}
onClick={() => {
// setCreateModalOpen(true);
// setImportDate(null);
// setInnerDate(null);
setTab(alarmRulesEnums[0].key);
setSelectValue(1);
initList(alarmRulesEnums[0].key, 1);
}}
>
</Button>
</div>
<div style={{ marginBottom: 12 }}>
<Button
style={{ height: 32, borderRadius: 20 }}

@ -1,4 +1,4 @@
import { postTestDevice } from '@/services/realTime/interfaces';
import { postTestDevice, postTestlPatform } from '@/services/realTime/interfaces';
import { useIntl } from '@umijs/max';
import { Button, Tag, message } from 'antd';
import moment from 'moment';
@ -15,21 +15,39 @@ const CaptureButton: React.FC<ImageSinglePopoverProps> = (props) => {
const [loading, setLoading] = useState<boolean>(false);
const connection = () => {
setLoading(true);
postTestDevice({
device_ip: props.values.device_ip,
id: props.values.id,
})
.then((res) => {
if (res.success) {
message.success(res.msg);
}
props.reload();
setLoading(false);
if (props.values.device_ip) {
postTestDevice({
device_ip: props.values.device_ip,
id: props.values.id,
})
.then((res) => {
if (res.success) {
message.success(res.msg);
}
props.reload();
setLoading(false);
})
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
setLoading(false);
});
} else {
postTestlPatform({
// device_ip: props.values.device_ip,
id: props.values.id,
})
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
setLoading(false);
});
.then((res) => {
if (res.success) {
message.success(res.msg);
}
props.reload();
setLoading(false);
})
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
setLoading(false);
});
}
};
return (

@ -37,6 +37,12 @@
border-start-end-radius: 0;
}
}
.table_body_bg {
.ant-spin-container {
padding-left: 24px;
background: #fff;
}
}
.DeviceList {
.ant-modal-content {
background: linear-gradient(180deg, #e3ebfc 0%, #ffffff 23%);

@ -6,11 +6,11 @@
* @FilePath: \general-ai-platform-web\src\pages\Device\DeviceCategoryList\components\UpdateForm.tsx
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { postInterfaces, postTestDevice } from '@/services/realTime/interfaces';
import { ModalForm, ProForm, ProFormText, ProFormTextArea } from '@ant-design/pro-components';
import { postPlatform } from '@/services/realTime/interfaces';
import { ModalForm, ProForm, ProFormText } from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import { Button, Form, message } from 'antd';
import React, { useState } from 'react';
import { Form, message } from 'antd';
// import React, { useState } from 'react';
import {
proFormSmallItemStyleProps,
proFormSmallModelWidth,
@ -33,28 +33,28 @@ export type UpdateFormProps = {
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
const intl = useIntl();
const [form] = Form.useForm<API.UpdateInterfacesParams>();
const [loading, setLoading] = useState<boolean>(false);
const connection = () => {
setLoading(true);
console.log(props.values);
postTestDevice({
device_ip: form.getFieldsValue().device_ip,
id: props.values.id,
})
.then((res) => {
// message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
// props.reload();
console.log(res);
if (res.success) {
message.success(res.msg);
}
setLoading(false);
})
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
setLoading(false);
});
};
// const [loading, setLoading] = useState<boolean>(false);
// const connection = () => {
// setLoading(true);
// console.log(props.values);
// postTestDevice({
// device_ip: form.getFieldsValue().device_ip,
// id: props.values.id,
// })
// .then((res) => {
// // message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
// // props.reload();
// console.log(res);
// if (res.success) {
// message.success(res.msg);
// }
// setLoading(false);
// })
// .catch(() => {
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
// setLoading(false);
// });
// };
return (
<ModalForm<any>
@ -69,7 +69,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
modalProps={{
destroyOnClose: true,
onCancel: () => {
setLoading(false);
// setLoading(false);
props.handleModal();
},
okText: intl.formatMessage({ id: 'common.okText', defaultMessage: '确认' }),
@ -80,7 +80,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
onFinish={async (values) => {
console.log(values);
values.id = props.values.id;
postInterfaces(values)
postPlatform(values)
.then(() => {
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
props.reload();
@ -96,7 +96,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_name"
name="platform_name"
label={
<span style={{ fontWeight: 'bold' }}>
<FormattedMessage
@ -113,7 +113,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
defaultMessage: '接口名称',
})}`}
required={true}
initialValue={props.values.device_name}
initialValue={props.values.platform_name}
rules={[
{
required: true,
@ -126,7 +126,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
},
]}
/>
<ProFormText
{/* <ProFormText
width={proFormSmallItemStyleProps.width}
name="device_address"
label={
@ -259,7 +259,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
})}`}
initialValue={props.values.note}
required={false}
/>
/> */}
</ProForm.Group>
</ModalForm>
);

@ -1,10 +1,9 @@
import TableActionCard from '@/components/TableActionCard';
import IsDelete from '@/components/TableActionCard/isDelete';
import { getInterfaces, postInterfaces } from '@/services/realTime/interfaces';
import { getPlatform } from '@/services/realTime/interfaces';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { PageContainer, ProCard, ProTable } from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import { Button, message } from 'antd';
import { FormattedMessage } from '@umijs/max';
import { Button } from 'antd';
import React, { useRef, useState } from 'react';
import { proTablePaginationOptions } from '../../../../config/defaultTable';
import CaptureButton from './components/CaptureButton';
@ -13,29 +12,30 @@ import './components/CaptureForm.less';
import CreateForm from './components/CreateForm';
import UpdateForm from './components/UpdateForm';
// svg 转组件
import { ReactComponent as Details } from '../../../../public/images/icons/details.svg';
// import { ReactComponent as Details } from '../../../../public/images/icons/details.svg';
// import { ReactComponent as Delete } from '../../../../public/images/icons/delete.svg';
import { EditOutlined } from '@ant-design/icons';
import { ReactComponent as Capture } from '../../../../public/images/icons/capture.svg';
const DeviceList: React.FC = () => {
/**
* @en-US International configuration
* @zh-CN
* */
const intl = useIntl();
// const intl = useIntl();
const actionRef = useRef<ActionType>();
// 动态设置每页数量
const [currentPageSize, setCurrentPageSize] = useState<number>(10);
const handleDestroy = async (selectedRow: API.UpdateInterfacesParams) => {
postInterfaces({ id: selectedRow.id, device_status: '3' })
.then(() => {
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
actionRef.current?.reload();
})
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
});
};
// const handleDestroy = async (selectedRow: API.UpdateInterfacesParams) => {
// postInterfaces({ id: selectedRow.id, device_status: '3' })
// .then(() => {
// message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
// actionRef.current?.reload();
// })
// .catch(() => {
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
// });
// };
const [currentRow, setCurrentRow] = useState<API.UpdateInterfacesParams>();
/**
@ -75,34 +75,142 @@ const DeviceList: React.FC = () => {
setCaptureModalOpen(true);
}
};
const expandedRowRender = (record: any) => {
console.log(record, 'record');
const data = record.devices;
return (
<ProTable
className="table_body_bg"
cardProps={{
bodyStyle: {
margin: 0,
padding: 0,
},
}}
rowKey={(record) => record.id}
columns={[
{
title: (
<FormattedMessage
id="device.interface_manage.table.list.name"
defaultMessage="接口名称"
/>
),
dataIndex: 'device_name',
hideInSearch: true,
// width: 150,
},
{
title: <FormattedMessage id="alarm_rules.page.status" defaultMessage="设备状态" />,
dataIndex: 'test_result',
hideInSearch: true,
// width: 280,
render: (dom, entity) => {
return <CaptureButton values={entity || {}} reload={actionRef.current?.reload} />;
},
},
{
title: (
<FormattedMessage
id="device.interface_manage.table.list.createTime"
defaultMessage="创建时间"
/>
),
// width: 200,
dataIndex: 'create_time',
sorter: true,
hideInSearch: true,
valueType: 'dateTime',
},
{
title: <FormattedMessage id="pages.searchTable.titleOption" defaultMessage="操作" />,
dataIndex: 'option',
valueType: 'option',
// width: 100,
fixed: 'right',
render: (_, record) => [
<TableActionCard
key="TableActionCardRef"
renderActions={[
{
key: 'capture',
renderDom: (
<Button
key="capture"
type="link"
size="small"
style={{
color: '#004FB2',
}}
icon={
<Capture
style={{
marginRight: 3,
display: 'inline-flex',
alignItems: 'center',
color: 'inherit',
fontStyle: 'normal',
lineHeight: 0,
textAlign: 'center',
textTransform: 'none',
verticalAlign: '-0.2em',
textRendering: 'optimizeLegibility',
}}
/>
}
onClick={() => {
console.log('11');
setCaptureModalOpen(true);
setCurrentRow(record);
}}
>
{/* 最近拍摄 */}
<FormattedMessage
id="device.interface_manage.table.list.capture"
defaultMessage="最近拍摄"
/>
</Button>
),
},
]}
></TableActionCard>,
],
},
]}
headerTitle={false}
search={false}
options={false}
dataSource={data}
pagination={false}
showHeader={false}
/>
);
};
const columns: ProColumns<API.UpdateInterfacesParams>[] = [
{
title: (
<FormattedMessage id="device.interface_manage.table.list.name" defaultMessage="接口名称" />
<FormattedMessage
id="device.interface_manage.table.list.platform_name"
defaultMessage="设备名称"
/>
),
dataIndex: 'device_name',
dataIndex: 'platform_name',
hideInSearch: true,
},
{
title: <FormattedMessage id="alarm_rules.page.status" defaultMessage="设备状态" />,
title: (
<FormattedMessage
id="device.interface_manage.table.list.statusUpdate"
defaultMessage="最近一次状态查询"
/>
),
dataIndex: 'test_result',
hideInSearch: true,
render: (dom, entity) => {
return <CaptureButton values={entity || {}} reload={actionRef.current?.reload} />;
},
},
// {
// title: <FormattedMessage id="device.interface_manage.table.list.address" defaultMessage="接口地址" />,
// dataIndex: 'device_api',
// hideInSearch: true,
// },
// {
// title: <FormattedMessage id="device.interface_manage.table.list.testTime" defaultMessage="状态查询时间" />,
// dataIndex: 'test_time',
// sorter: true,
// hideInSearch: true,
// valueType: 'dateTime',
// },
{
title: (
<FormattedMessage
@ -120,7 +228,7 @@ const DeviceList: React.FC = () => {
title: <FormattedMessage id="pages.searchTable.titleOption" defaultMessage="操作" />,
dataIndex: 'option',
valueType: 'option',
width: '260px',
width: '300px',
fixed: 'right',
render: (_, record) => [
<TableActionCard
@ -129,68 +237,52 @@ const DeviceList: React.FC = () => {
{
key: 'capture',
renderDom: (
<Button
key="capture"
type="link"
size="small"
style={{
color: '#004FB2',
}}
icon={
<Capture
style={{
marginRight: 3,
display: 'inline-flex',
alignItems: 'center',
color: 'inherit',
fontStyle: 'normal',
lineHeight: 0,
textAlign: 'center',
textTransform: 'none',
verticalAlign: '-0.2em',
textRendering: 'optimizeLegibility',
}}
/>
}
onClick={() => {
console.log('11');
setCaptureModalOpen(true);
setCurrentRow(record);
}}
>
{/* 最近拍摄 */}
<FormattedMessage
id="device.interface_manage.table.list.capture"
defaultMessage="最近拍摄"
/>
</Button>
),
},
{
key: 'update',
renderDom: (
// <Button
// key="capture"
// type="link"
// size="small"
// style={{
// color: '#004FB2',
// }}
// icon={
// <Capture
// style={{
// marginRight: 3,
// display: 'inline-flex',
// alignItems: 'center',
// color: 'inherit',
// fontStyle: 'normal',
// lineHeight: 0,
// textAlign: 'center',
// textTransform: 'none',
// verticalAlign: '-0.2em',
// textRendering: 'optimizeLegibility',
// }}
// />
// }
// onClick={() => {
// console.log('11');
// setCaptureModalOpen(true);
// setCurrentRow(record);
// }}
// >
// {/* 最近拍摄 */}
// <FormattedMessage
// id="device.interface_manage.table.list.capture"
// defaultMessage="最近拍摄"
// />
// </Button>
<Button
key="update"
type="link"
size="small"
style={{
color: '#004FB2',
// display: 'flex',
alignItems: 'center',
}}
icon={
<Details
<EditOutlined
style={{
marginRight: 3,
display: 'inline-flex',
alignItems: 'center',
color: 'inherit',
fontStyle: 'normal',
lineHeight: 0,
textAlign: 'center',
textTransform: 'none',
verticalAlign: '-0.2em',
textRendering: 'optimizeLegibility',
}}
/>
}
@ -199,20 +291,13 @@ const DeviceList: React.FC = () => {
setCurrentRow(record);
}}
>
<FormattedMessage id="common.details" defaultMessage="详情" />
<FormattedMessage
id="device.interface_manage.table.list.rename"
defaultMessage="重命名"
/>
</Button>
),
},
{
key: 'destroy',
renderDom: (
<IsDelete
deleteApi={() => {
handleDestroy(record).then(() => {});
}}
></IsDelete>
),
},
]}
></TableActionCard>,
],
@ -301,23 +386,23 @@ const DeviceList: React.FC = () => {
style={{ margin: 0, padding: 0, boxShadow: '0px 4px 8px 0px rgba(0,79,178,0.15)' }}
bodyStyle={{ margin: 0, padding: 0 }}
headerBordered
title="设备列表"
extra={
<Button
type="primary"
style={{
boxShadow: 'none',
}}
onClick={() => {
setCreateModalOpen(true);
}}
>
<FormattedMessage
id="device.interface_manage.table.list.add"
defaultMessage="新建设备/输入源"
/>
</Button>
}
title="设备状态"
// extra={
// <Button
// type="primary"
// style={{
// boxShadow: 'none',
// }}
// onClick={() => {
// setCreateModalOpen(true);
// }}
// >
// <FormattedMessage
// id="device.interface_manage.table.list.add"
// defaultMessage="新建设备/输入源"
// />
// </Button>
// }
>
<ProTable<API.DeviceCategory>
cardProps={{
@ -353,7 +438,7 @@ const DeviceList: React.FC = () => {
let sort_select = sort[reqParams.orderKey];
reqParams.desc = sort_select === 'descend';
}
let resp = await getInterfaces({ ...reqParams });
let resp = await getPlatform({ ...reqParams });
return {
data: resp.data.results.map((v: API.DeviceCategory) => {
return { ...v, key: v.id };
@ -365,6 +450,7 @@ const DeviceList: React.FC = () => {
};
}}
columns={columns}
expandable={{ expandedRowRender }}
/>
</ProCard>
<CreateForm

@ -67,7 +67,7 @@ const ImageWithPopover: React.FC<ImageWithPopoverProps> = ({
preview={false}
src={src}
/>
{classify === 1 && (
{classify === 0 && (
<Popover
placement="right"
content={content}

@ -59,3 +59,8 @@
padding-block-start: 0;
}
}
.select_Bg {
.ant-select-selector {
border-radius: 4px;
}
}

@ -1,10 +1,11 @@
// import { alarmRulesEnums } from '@/enums/status';
import { PageContainer, ProCard, ProList } from '@ant-design/pro-components';
import { Button, Checkbox, DatePicker } from 'antd';
import { Button, Checkbox, DatePicker, Select } from 'antd';
import React, { useEffect, useState } from 'react';
import { proTablePaginationOptions } from '../../../../config/defaultTable';
// import DeviceStatusCard from './components/DeviceStatusCard';
// import CreateForm from './components/CreateForm';
import { postWarningStatistics } from '@/services/realTime/alarmlist';
import { getInvolvedList } from '@/services/realTime/involved';
import locale from 'antd/es/date-picker/locale/zh_CN';
import { CheckboxProps } from 'antd/lib/checkbox';
@ -75,29 +76,44 @@ const InvolvedList: React.FC = () => {
const [importDate, setImportDate] = useState<any>(null);
const [innerDate, setInnerDate] = useState<any>(null);
const [classify, setClassify] = useState<string>('all');
// const changeProjectTab = (key: string) => {
// setTab(key);
// console.log(key);
// // eslint-disable-next-line @typescript-eslint/no-use-before-define
// initList(key)
// };
// const getTabs = () => {
// // if (alarmRulesEnums.length) {
// // setTab(alarmRulesEnums[0].key);
// // }
// setTabs(alarmRulesEnums);
// };
// useEffect(() => {
// getTabs();
// }, []);
// const handleCreateModal = () => {
// if (createModalOpen) {
// setCreateModalOpen(false);
// setCurrentRow(undefined);
// } else {
// setCreateModalOpen(true);
// }
// };
const [selectOptions, setSelectOptions] = useState<any>([]);
const [selectValue, setSelectValue] = useState<number>();
const pollServer = () => {
postWarningStatistics({})
.then((res) => {
if (res && res.data.total_results) {
// 使用 state.totalResults 来设置 selectOptions
const newOptions = res.data.total_results.map((record: any) => ({
value: record.id,
label: (
<span>
{record.platform_name}
{record.have_warning && (
<span
style={{
display: 'inline-block',
width: '10px',
height: '10px',
background: '#E80D0D',
borderRadius: '50%',
}}
/>
)}
</span>
),
}));
setSelectValue(res.data.total_results[0].id);
setSelectOptions(newOptions);
}
// setTimeout(pollServer, 5000);
})
.catch(() => {});
};
useEffect(() => {
pollServer();
console.log(selectValue, 'selectValue');
}, []);
const handleUpdateModal = () => {
if (updateModalOpen) {
@ -270,13 +286,18 @@ const InvolvedList: React.FC = () => {
}
// 初始化加载
async function initList(tabId: string = 'all', date: any = null) {
async function initList(
tabId: string = 'all',
date: any = null,
selectValues: any = selectValue,
) {
const reqParams = {
page: currentPage,
pageSize: currentPageSize,
// desc: false,
classify: tabId,
analyse_time: date,
platform_id: selectValues,
// ...rest,
};
const resp = await getInvolvedList({ ...reqParams });
@ -328,6 +349,10 @@ const InvolvedList: React.FC = () => {
initList('all', innerDate);
}
};
const handleChange = (value: any) => {
console.log(`selected ${value}`);
setSelectValue(value);
};
// useEffect(() => {
// // getTabs();
// // initList();
@ -373,6 +398,13 @@ const InvolvedList: React.FC = () => {
}}
>
<div style={{ paddingBottom: 16 }}>
<Select
defaultValue={1}
className="select_Bg"
style={{ width: 280, borderRadius: 4, marginRight: 12 }}
onChange={handleChange}
options={selectOptions}
/>
<DatePicker
style={{ width: 280, borderRadius: 4 }}
locale={locale}

@ -70,3 +70,18 @@ export async function postUploadIgnoringvents(
},
);
}
/**轮询告警信息 */
export async function postWarningStatistics(body: any, options?: { [key: string]: any }) {
return request<API.Response & { data?: API.PageResult; msg?: string }>(
`/api/poll_warning_statistics/`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
},
);
}

@ -122,3 +122,50 @@ export async function postAlgorithm(body: any, options?: { [key: string]: any })
},
);
}
/** 获取平台信息及接口信息 */
export async function getPlatform(
params: API.SearchAlarmRulesParams | any,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.PageResult; msg?: string }>(`/api/platform/`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
params: {
...params,
},
...(options || {}),
});
}
/** 更新平台信息及接口信息 */
export async function postPlatform(
body: API.UpdateInterfacesParams | any,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.PageResult; msg?: string }>(`/api/platform/`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** 测试平台连通 */
export async function postTestlPatform(
body: API.UpdateInterfacesParams | any,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.PageResult; msg?: string }>(`/api/test_platform/`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}

@ -90,6 +90,7 @@ declare namespace API {
destination_directory?: string;
operate_mode?: string;
source_directory?: string;
platform_name?: string;
};
type UpdateVideoParams = {
create_time?: string; // 设备名称

@ -48,15 +48,15 @@ export const mockGetMenuData = {
routes: [],
title: '告警列表',
},
{
component: 'RealTime/AlarmRules',
icon: '',
key: '103',
name: 'realTime-alarm-rules',
path: '/realTime/alarm-rules',
routes: [],
title: '告警规则',
},
// {
// component: 'RealTime/AlarmRules',
// icon: '',
// key: '103',
// name: 'realTime-alarm-rules',
// path: '/realTime/alarm-rules',
// routes: [],
// title: '告警规则',
// },
{
component: 'RealTime/DeviceList',
icon: '',
@ -64,7 +64,7 @@ export const mockGetMenuData = {
name: 'realTime-device-list',
path: '/realTime/device-list',
routes: [],
title: '设备管理',
title: '设备状态',
},
],
},
@ -94,33 +94,33 @@ export const mockGetMenuData = {
routes: [],
title: '告警列表',
},
{
component: 'Offline/OfflineAlarmRules',
icon: '',
key: '203',
name: 'offline-alarm-rules',
path: '/offline/alarm-rules',
routes: [],
title: '告警规则',
},
{
component: 'Offline/OfflineDeviceList',
icon: '',
key: '204',
name: 'offline-device-list',
path: '/offline/device-list',
routes: [],
title: '设备管理',
},
{
component: 'Offline/VideoFile',
icon: '',
key: '205',
name: 'offline-video-file',
path: '/offline/video-file',
routes: [],
title: '视频文件',
},
// {
// component: 'Offline/OfflineAlarmRules',
// icon: '',
// key: '203',
// name: 'offline-alarm-rules',
// path: '/offline/alarm-rules',
// routes: [],
// title: '告警规则',
// },
// {
// component: 'Offline/OfflineDeviceList',
// icon: '',
// key: '204',
// name: 'offline-device-list',
// path: '/offline/device-list',
// routes: [],
// title: '设备管理',
// },
// {
// component: 'Offline/VideoFile',
// icon: '',
// key: '205',
// name: 'offline-video-file',
// path: '/offline/video-file',
// routes: [],
// title: '视频文件',
// },
],
},
],

Loading…
Cancel
Save