Skip to content

Commit

Permalink
Change DisplayInfo.js view.
Browse files Browse the repository at this point in the history
  • Loading branch information
drudilorenzo committed Nov 26, 2022
1 parent d05ae30 commit 8133d42
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions frontend/src/components/DisplayInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,28 @@ import { useEffect, useState } from "react";

const DisplayInfo = () => {

const columns = [{
src: 'Src',
data: 'Data',
desc: 'Description',
// angle: 'Smart Light'
}];
const bridge_states = {
'0': 'BEGIN',
'1': 'NORMAL',
'2': 'PREALARM',
'3': 'ALARM',
};

const [data, setData] = useState([]);
const [state, setState] = useState('');

const url_info = "http://localhost:5000/get_logs";

useEffect(() => {
var new_data = []
var new_state = state;
const fetchData = async () =>{
try {
await axios.get(url_info)
.then((response) => {
for (const res of response.data) {
new_data.push({
src: res.src,
data: res.data,
desc: res.desc
});
if (res.desc === "new state") {
new_state = bridge_states[res.data];
console.log(new_state);
}
}
})
.catch((e) => console.log(e));
Expand All @@ -36,15 +35,15 @@ const DisplayInfo = () => {
}
fetchData()
.then(() => {
setData(new_data);
setState(new_state);
})
.catch((e) => console.log(e));
}, []);

return (
<div className='mx-10 w-full'>
<h1 className='w-full h-full centered mb-4 font-bold'>System Info</h1>
<table className='w-full h-full bg-white shadow-lg'>
<h1 className='w-full h-full centered mb-4 font-bold'>{state}</h1>
{/* <table className='w-full h-full bg-white shadow-lg'>
<thead>
{
columns.map((value, key) => {
Expand Down Expand Up @@ -85,7 +84,7 @@ const DisplayInfo = () => {
})
}
</tbody>
</table>
</table> */}
</div>
)
}
Expand Down

0 comments on commit 8133d42

Please sign in to comment.