integration api history alarm and event alarm
This commit is contained in:
21
src/api/history-value.jsx
Normal file
21
src/api/history-value.jsx
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { SendRequest } from '../components/Global/ApiRequest';
|
||||||
|
|
||||||
|
const getAllHistoryAlarm = async (queryParams) => {
|
||||||
|
const response = await SendRequest({
|
||||||
|
method: 'get',
|
||||||
|
prefix: `history/alarm?${queryParams.toString()}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getAllHistoryEvent = async (queryParams) => {
|
||||||
|
const response = await SendRequest({
|
||||||
|
method: 'get',
|
||||||
|
prefix: `history/event?${queryParams.toString()}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export { getAllHistoryAlarm, getAllHistoryEvent };
|
||||||
@@ -2,6 +2,7 @@ import React, { memo, useState, useEffect } from 'react';
|
|||||||
import { Button, Row, Col, Card, Input } from 'antd';
|
import { Button, Row, Col, Card, Input } from 'antd';
|
||||||
import { SearchOutlined } from '@ant-design/icons';
|
import { SearchOutlined } from '@ant-design/icons';
|
||||||
import TableList from '../../../../components/Global/TableList';
|
import TableList from '../../../../components/Global/TableList';
|
||||||
|
import { getAllHistoryAlarm } from '../../../../api/history-value';
|
||||||
|
|
||||||
const ListHistoryAlarm = memo(function ListHistoryAlarm(props) {
|
const ListHistoryAlarm = memo(function ListHistoryAlarm(props) {
|
||||||
const columns = [
|
const columns = [
|
||||||
@@ -16,7 +17,8 @@ const ListHistoryAlarm = memo(function ListHistoryAlarm(props) {
|
|||||||
title: 'Datetime',
|
title: 'Datetime',
|
||||||
dataIndex: 'datetime',
|
dataIndex: 'datetime',
|
||||||
key: 'datetime',
|
key: 'datetime',
|
||||||
width: '10%',
|
width: '15%',
|
||||||
|
// render: (_, record) => toAppDateTimezoneFormatter(record.datetime),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Tag Name',
|
title: 'Tag Name',
|
||||||
@@ -26,50 +28,78 @@ const ListHistoryAlarm = memo(function ListHistoryAlarm(props) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Value',
|
title: 'Value',
|
||||||
dataIndex: 'stat',
|
dataIndex: 'new_val',
|
||||||
key: 'stat',
|
key: 'new_val',
|
||||||
width: '10%',
|
width: '10%',
|
||||||
|
render: (_, record) => Number(record.new_val).toFixed(4),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Threshold',
|
title: 'Threshold',
|
||||||
dataIndex: 'threshold',
|
dataIndex: 'threshold',
|
||||||
key: 'threshold',
|
key: 'threshold',
|
||||||
width: '10%',
|
width: '10%',
|
||||||
|
render: (_, record) => {
|
||||||
|
switch (record.status) {
|
||||||
|
case 1:
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
{record.lim_low + 1} : {record.lim_high - 1}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
case 2:
|
||||||
|
return <span>{`< ${record.lim_low_crash}`}</span>;
|
||||||
|
case 3:
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
{record.lim_low_crash + 1} : {record.lim_low - 1}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
case 4:
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
{record.lim_high + 1} : {record.lim_high_crash - 1}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
case 5:
|
||||||
|
return <span>{`> ${record.lim_high_crash}`}</span>;
|
||||||
|
default:
|
||||||
|
return <span>Undefined</span>;
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Condition',
|
title: 'Condition',
|
||||||
dataIndex: 'condition',
|
dataIndex: 'condition',
|
||||||
key: 'condition',
|
key: 'condition',
|
||||||
width: '20%',
|
width: '20%',
|
||||||
|
render: (_, record) => (
|
||||||
|
<Button type="text" style={{ backgroundColor: record.status_color, width: '100%' }}>
|
||||||
|
{record.condition}
|
||||||
|
</Button>
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Stat',
|
title: 'Stat',
|
||||||
dataIndex: 'stat',
|
dataIndex: 'status',
|
||||||
key: 'stat',
|
key: 'status',
|
||||||
width: '5%',
|
width: '5%',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const [trigerFilter, setTrigerFilter] = useState(false);
|
const [trigerFilter, setTrigerFilter] = useState(false);
|
||||||
|
|
||||||
const defaultFilter = { search: '' };
|
const defaultFilter = { criteria: '' };
|
||||||
const [formDataFilter, setFormDataFilter] = useState(defaultFilter);
|
const [formDataFilter, setFormDataFilter] = useState(defaultFilter);
|
||||||
const [searchValue, setSearchValue] = useState('');
|
const [searchValue, setSearchValue] = useState('');
|
||||||
|
|
||||||
const getAllEventAlarm = async (params) => {
|
|
||||||
return {
|
|
||||||
data: [],
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSearch = () => {
|
const handleSearch = () => {
|
||||||
setFormDataFilter({ search: searchValue });
|
setFormDataFilter({ criteria: searchValue });
|
||||||
setTrigerFilter((prev) => !prev);
|
setTrigerFilter((prev) => !prev);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSearchClear = () => {
|
const handleSearchClear = () => {
|
||||||
setSearchValue('');
|
setSearchValue('');
|
||||||
setFormDataFilter({ search: '' });
|
setFormDataFilter({ criteria: '' });
|
||||||
setTrigerFilter((prev) => !prev);
|
setTrigerFilter((prev) => !prev);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -113,7 +143,7 @@ const ListHistoryAlarm = memo(function ListHistoryAlarm(props) {
|
|||||||
</Col>
|
</Col>
|
||||||
<Col xs={24} sm={24} md={24} lg={24} xl={24} style={{ marginTop: '16px' }}>
|
<Col xs={24} sm={24} md={24} lg={24} xl={24} style={{ marginTop: '16px' }}>
|
||||||
<TableList
|
<TableList
|
||||||
getData={getAllEventAlarm}
|
getData={getAllHistoryAlarm}
|
||||||
queryParams={formDataFilter}
|
queryParams={formDataFilter}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
triger={trigerFilter}
|
triger={trigerFilter}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { memo, useState, useEffect } from 'react';
|
|||||||
import { Button, Row, Col, Card, Input } from 'antd';
|
import { Button, Row, Col, Card, Input } from 'antd';
|
||||||
import { SearchOutlined } from '@ant-design/icons';
|
import { SearchOutlined } from '@ant-design/icons';
|
||||||
import TableList from '../../../../components/Global/TableList';
|
import TableList from '../../../../components/Global/TableList';
|
||||||
|
import { getAllHistoryEvent } from '../../../../api/history-value';
|
||||||
|
|
||||||
const ListHistoryEvent = memo(function ListHistoryEvent(props) {
|
const ListHistoryEvent = memo(function ListHistoryEvent(props) {
|
||||||
const columns = [
|
const columns = [
|
||||||
@@ -16,7 +17,8 @@ const ListHistoryEvent = memo(function ListHistoryEvent(props) {
|
|||||||
title: 'Datetime',
|
title: 'Datetime',
|
||||||
dataIndex: 'datetime',
|
dataIndex: 'datetime',
|
||||||
key: 'datetime',
|
key: 'datetime',
|
||||||
width: '10%',
|
width: '15%',
|
||||||
|
// render: (_, record) => toAppDateTimezoneFormatter(record.datetime),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Tag Name',
|
title: 'Tag Name',
|
||||||
@@ -25,39 +27,38 @@ const ListHistoryEvent = memo(function ListHistoryEvent(props) {
|
|||||||
width: '40%',
|
width: '40%',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Stat',
|
title: 'Description',
|
||||||
dataIndex: 'stat',
|
dataIndex: 'condition',
|
||||||
key: 'stat',
|
key: 'condition',
|
||||||
width: '5%',
|
width: '20%',
|
||||||
|
render: (_, record) => (
|
||||||
|
<Button type="text" style={{ backgroundColor: record.status_color, width: '100%' }}>
|
||||||
|
{record.condition}
|
||||||
|
</Button>
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Description',
|
title: 'Stat',
|
||||||
dataIndex: 'description',
|
dataIndex: 'status',
|
||||||
key: 'description',
|
key: 'status',
|
||||||
width: '15%',
|
width: '5%',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const [trigerFilter, setTrigerFilter] = useState(false);
|
const [trigerFilter, setTrigerFilter] = useState(false);
|
||||||
|
|
||||||
const defaultFilter = { search: '' };
|
const defaultFilter = { criteria: '' };
|
||||||
const [formDataFilter, setFormDataFilter] = useState(defaultFilter);
|
const [formDataFilter, setFormDataFilter] = useState(defaultFilter);
|
||||||
const [searchValue, setSearchValue] = useState('');
|
const [searchValue, setSearchValue] = useState('');
|
||||||
|
|
||||||
const getAllEventAlarm = async (params) => {
|
|
||||||
return {
|
|
||||||
data: [],
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSearch = () => {
|
const handleSearch = () => {
|
||||||
setFormDataFilter({ search: searchValue });
|
setFormDataFilter({ criteria: searchValue });
|
||||||
setTrigerFilter((prev) => !prev);
|
setTrigerFilter((prev) => !prev);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSearchClear = () => {
|
const handleSearchClear = () => {
|
||||||
setSearchValue('');
|
setSearchValue('');
|
||||||
setFormDataFilter({ search: '' });
|
setFormDataFilter({ criteria: '' });
|
||||||
setTrigerFilter((prev) => !prev);
|
setTrigerFilter((prev) => !prev);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -101,7 +102,7 @@ const ListHistoryEvent = memo(function ListHistoryEvent(props) {
|
|||||||
</Col>
|
</Col>
|
||||||
<Col xs={24} sm={24} md={24} lg={24} xl={24} style={{ marginTop: '16px' }}>
|
<Col xs={24} sm={24} md={24} lg={24} xl={24} style={{ marginTop: '16px' }}>
|
||||||
<TableList
|
<TableList
|
||||||
getData={getAllEventAlarm}
|
getData={getAllHistoryEvent}
|
||||||
queryParams={formDataFilter}
|
queryParams={formDataFilter}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
triger={trigerFilter}
|
triger={trigerFilter}
|
||||||
|
|||||||
Reference in New Issue
Block a user