Commit e626689e by Chaiwith Santaweesuk

update

parent b32b83bb
...@@ -115,7 +115,7 @@ class Home extends Component { ...@@ -115,7 +115,7 @@ class Home extends Component {
keycardAvg: null, keycardAvg: null,
table: null, table: null,
}; };
looper;
componentDidMount = async () => { componentDidMount = async () => {
await this.getConfig(); await this.getConfig();
await this.getCurrentUser(); await this.getCurrentUser();
...@@ -124,7 +124,8 @@ class Home extends Component { ...@@ -124,7 +124,8 @@ class Home extends Component {
componentDidUpdate = async (prevProps, prevState) => { componentDidUpdate = async (prevProps, prevState) => {
if (prevState.allDevicesId !== this.state.allDevicesId) { if (prevState.allDevicesId !== this.state.allDevicesId) {
await this.getFeedData(); // await this.getFeedData();
await this.loopFeedData();
} }
}; };
...@@ -173,6 +174,13 @@ class Home extends Component { ...@@ -173,6 +174,13 @@ class Home extends Component {
this.setState({ allDevicesId }); this.setState({ allDevicesId });
}; };
loopFeedData = async (deviceId,selectedRange,breakdown) => {
console.log("loopFeedData")
clearInterval(this.looper)
await this.getFeedData(deviceId,selectedRange,breakdown);
this.looper = setInterval(await this.getFeedData(deviceId,selectedRange,breakdown) , 60000)
}
getFeedData = async ( getFeedData = async (
deviceId, deviceId,
selectedRange = { selectedRange = {
...@@ -215,6 +223,7 @@ class Home extends Component { ...@@ -215,6 +223,7 @@ class Home extends Component {
}; };
try { try {
console.log("getFeedData")
axios.defaults.headers.common['Authorization'] = `Bearer ${userToken}`; axios.defaults.headers.common['Authorization'] = `Bearer ${userToken}`;
const response = await axios.post(kairosUrl, q_data); const response = await axios.post(kairosUrl, q_data);
this.setState({ this.setState({
...@@ -266,7 +275,8 @@ class Home extends Component { ...@@ -266,7 +275,8 @@ class Home extends Component {
}; };
getSelectedFeed = ({ device, range, breakdown }) => { getSelectedFeed = ({ device, range, breakdown }) => {
this.getFeedData(device, range, breakdown); this.loopFeedData(device, range, breakdown);
// this.getFeedData(device, range, breakdown);
}; };
getMax = data => { getMax = data => {
......
...@@ -18,7 +18,7 @@ export default class Mapbox extends React.PureComponent { ...@@ -18,7 +18,7 @@ export default class Mapbox extends React.PureComponent {
state = { state = {
center: undefined, center: undefined,
active: undefined, active: undefined,
zoom: [15], zoom: [10],
data:[] data:[]
}; };
...@@ -71,7 +71,7 @@ export default class Mapbox extends React.PureComponent { ...@@ -71,7 +71,7 @@ export default class Mapbox extends React.PureComponent {
onClick={() => onClick={() =>
this.setState({ this.setState({
center: this.state.data[item].position, center: this.state.data[item].position,
zoom: [15], zoom: [10],
active: this.state.data[item], active: this.state.data[item],
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment