diff --git a/src/component/Test1.js b/src/component/Test1.js
index 8b9d1bb..ec9066d 100644
--- a/src/component/Test1.js
+++ b/src/component/Test1.js
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
-import { Avatar, Button, Input, Select, Table } from 'antd';
+import { Avatar, Button, Input, Select, Table, Pagination, message, Spin,Image } from 'antd';
import axios from 'axios';
import moment from 'moment';
import DatePicker from "react-datepicker";
@@ -7,16 +7,17 @@ import "react-datepicker/dist/react-datepicker.css";
import 'antd/dist/antd.css';
const columns = [
+
{
title: 'Avt Origin',
dataIndex: 'url_origin_img',
- render: (url_origin_img) => ,
+ render: (url_origin_img) => ,
width: '20%',
},
{
title: 'Avt Input',
dataIndex: 'url_input_img',
- render: (url_input_img) => ,
+ render: (url_input_img) => ,
width: '20%',
},
{
@@ -57,38 +58,81 @@ const Test = () => {
const [inputURL, setInputURL] = useState();
const [inputConfidence, setInputConfidence] = useState();
+ const [loading, setLoading] = useState(false);
+
+ const [dataCount, setDataCount] = useState(0)
+
const [itemPerPage, setItemPerPage] = useState(10)
- const onChange = page => {
+ const onChangePage = page => {
setCurrentPage(page);
};
+ const handleChangePageSize = (e) => {
+ setItemPerPage(e)
+ }
+
+ const onChangeSize = (current, size) => {
+ setCurrentPage(current)
+ setItemPerPage(size)
+ }
+
+ useEffect(() => {
+ fetchData()
+ }, [currentPage, itemPerPage])
const fetchData = () => {
-
if (inputCam) {
var splitCam = inputCam.split(',');
}
-
-
- fetch(`${inputURL}/api/statistic_histories`, {
- method: "POST",
- body: JSON.stringify({
- 'start_date': moment(startDate).format("YYYY-MM-DD 00:00:00"),
- 'end_date': moment(endDate).format("YYYY-MM-DD 00:00:00"),
- 'index': 1,
- 'item_per_page': itemPerPage,
- 'confidence': +inputConfidence,
- "ids_camera": splitCam
+ if (inputURL) {
+ setLoading(true)
+ fetch(`${inputURL}/api/statistic_histories`, {
+ method: "POST",
+ body: JSON.stringify({
+ 'start_date': moment(startDate).format("YYYY-MM-DD 00:00:00"),
+ 'end_date': moment(endDate).format("YYYY-MM-DD 00:00:00"),
+ 'index': currentPage,
+ 'item_per_page': itemPerPage,
+ 'confidence': +inputConfidence,
+ "ids_camera": splitCam
+ })
})
+ .then((response) => response.json())
+ .then((data) => {
+ if (data.status === 10000) {
+ setData(data.data.histories)
+ setDataCount(data.data.count)
+ setLoading(false)
+ }
+ else {
+ message.error({
+ content: "FETCH DATA ERROR",
+ className: 'custom-class',
+ style: {
+ textAlign: "left",
+ },
+ })
+ setLoading(false)
+ }
- })
- .then((response) => response.json())
- .then((data) => {
- setData(data.data)
+ })
+ .catch(error => {
+ message.error("FETCH DATA ERROR")
+ setLoading(false)
+ });
+ } else {
+ message.error({
+ content: "URL required",
+ duration: 1,
+ className: 'custom-class',
+ style: {
+ textAlign: "left",
+ },
})
+ }
}
const onChangeInput = (e) => {
@@ -103,26 +147,14 @@ const Test = () => {
setInputConfidence(e.target.value)
}
- const handleChangePageSize = (e) => {
- setItemPerPage(e)
- console.log(itemPerPage)
-
- }
useEffect(() => {
fetchData()
- }, [itemPerPage])
-
- console.log(itemPerPage)
-
- const indexOfLastData = currentPage * itemPerPage;
- const indexOfFirstData = indexOfLastData - itemPerPage;
- const currentData = data.slice(indexOfFirstData, indexOfLastData)
-
- const totalData = data.length;
+ }, [currentPage])
+
+
- console.log(currentData)
return (
@@ -146,7 +178,7 @@ const Test = () => {
@@ -194,18 +226,21 @@ const Test = () => {
)
})
} */}
+
+
+
-
-
*/}
{/*
@@ -213,11 +248,15 @@ const Test = () => {
*/}
- {/*
*/}
+ onChange={onChangePage}
+ defaultPageSize={itemPerPage}
+ total={dataCount}
+ pageSizeOptions={[20, 50, 100, 500]}
+ onShowSizeChange={onChangeSize}
+
+ />
{/*