Commit 33f9506b by littleploy

update week

parent f8f67b97
......@@ -165,7 +165,8 @@ class Home extends Component {
keycardFeed,
currentFeed,
]),
deviceList: selectDevice
deviceList: selectDevice,
coinExchangeTable: this.getCoinExchangeTable()
});
};
......@@ -258,7 +259,6 @@ class Home extends Component {
let table = [];
let feeds = [];
const breakdown = this.props.selectedFeed.breakdown;
console.log(data)
for (let data_index = 0; data_index < data.length; data_index++) {
var allValues = [];
for (let feed_index = 0; feed_index < data[data_index].length; feed_index++) {
......@@ -267,14 +267,19 @@ class Home extends Component {
var mapValues = [];
for (let index = 0; index < allValues.length; index++) {
let key = allValues[index][0];
let timestamp = allValues[index][0].toString().substring(0, 8) + "00000";
if(breakdown=="minutes"){
key = moment(parseInt(allValues[index][0])).minutes(Math.round(moment(parseInt(allValues[index][0])).minutes() / 5) * 5);
}else if(breakdown=="hours"){
key = moment(parseInt(allValues[index][0])).minutes(0);
timestamp = key.valueOf().toString().substring(0, 8) + "00000";
}
let timestamp = key.valueOf().toString().substring(0, 8) + "00000";
else {
key = moment(parseInt(allValues[index][0])).hours(1).minutes(0);
timestamp = key.valueOf().toString().substring(0, 8) + "00000";
}
console.log(timestamp)
mapValues[timestamp] = [];
......@@ -288,11 +293,16 @@ class Home extends Component {
isExist = data[data_index][i].value.find(element =>
(moment(element[0]).minutes(0).valueOf().toString().substring(0, 8)+"00000"===timestamp)
);
}else{
}else {
isExist = data[data_index][i].value.find(element =>
(element[0].toString().substring(0, 8)+"00000"===timestamp)
(moment(element[0]).hours(1).minutes(0).valueOf().toString().substring(0, 8)+"00000"===timestamp)
);
}
// else{
// isExist = data[data_index][i].value.find(element =>
// (element[0].toString().substring(0, 8)+"00000"===timestamp)
// );
// }
if(isExist){
mapValues[timestamp].push(isExist[1]);
}else{
......@@ -300,7 +310,7 @@ class Home extends Component {
}
}
}
// console.log(allValues);
console.log(allValues);
feeds.push(mapValues);
}
......@@ -336,15 +346,19 @@ class Home extends Component {
return table;
};
getCoinExchangeTable = () => {
return [];
}
getBox = () => {
const { currentFeed, revenueFeed, peopleFeed, remoteFeed, fingerPrintFeed, keycardFeed } = this.props.feedData;
if(this.props.selectedFeed && this.props.selectedFeed.type=="door"){
return (<div>
<Row>
{/* <Row>
<Mapbox />
</Row>
</Row> */}
<Row>
<DataCard
item={Data[0]}
......@@ -414,7 +428,7 @@ class Home extends Component {
}else if(this.props.selectedFeed && this.props.selectedFeed.type=="coinexchange"){
return (<div><Row>
<DataTable table={this.state.table} size={currentFeed ? currentFeed.length: 0} deviceList={this.state.deviceList} />
<DataTable table={this.state.coinExchangeTable} size={currentFeed ? currentFeed.length: 0} deviceList={this.state.deviceList} />
</Row></div>)
}
}
......@@ -431,6 +445,9 @@ class Home extends Component {
<Row>
<GetDataSelection loading={this.state.isLoading} />
</Row>
<Row>
<Mapbox />
</Row>
{/* <Row>
{this.props.selectedFeed && this.props.selectedFeed.type=="door" ? <Mapbox /> : <div style={{ display: 'none'}}><Mapbox /></div>}
</Row> */}
......
......@@ -53,10 +53,12 @@ const DataCard = props => {
key = moment(parseInt(allValues[index][0])).minutes(Math.round(moment(parseInt(allValues[index][0])).minutes() / 5) * 5);
}else if(breakdown=="hours"){
key = moment(parseInt(allValues[index][0])).minutes(Math.round(moment(parseInt(allValues[index][0])).minutes() / 60) * 60);
}else if(breakdown=="days"){
key = moment(parseInt(allValues[index][0])).minutes(Math.round(moment(parseInt(allValues[index][0])).minutes() / 1440) * 1440);
}
else {
key = moment(parseInt(allValues[index][0])).hours(1).minutes(0);
}
const timestamp = key.valueOf().toString().substring(0, 8) + "00000";
// console.log(timestamp);
if (Object.keys(mapValues).includes(timestamp)) {
mapValues[timestamp] += allValues[index][1];
} else {
......
......@@ -15,6 +15,19 @@ class Mapbox extends Component {
data: [],
};
// componentDidMount = () => {
// if(this.props.selectedFeed.type=="door"){
// const data1 = this.props.allLocationInfo.filter(location => location.type === "door");
// const { location } = this.props.selectedFeed;
// const currentIndex = data1.findIndex(element => element.locationid === location);
// this.setState({
// data: data1,
// center: data1[currentIndex].position,
// active: data1[currentIndex],
// });
// }
// }
componentDidUpdate = (prevProps, prevState) => {
if (this.props.allLocationInfo) {
if (prevProps.selectedFeed !== this.props.selectedFeed) {
......@@ -35,81 +48,87 @@ class Mapbox extends Component {
active: null,
});
}
}
}
}
};
render() {
const { center, active, zoom } = this.state;
console.log(this.state)
return (
<Col>
<Map
// eslint-disable-next-line
style="mapbox://styles/mapbox/streets-v11"
containerStyle={{
height: '50vh',
width: '100%',
marginTop: '.5em',
}}
center={center}
zoom={zoom}
onClick={() => this.setState({ active: undefined })}
movingMethod="jumpTo"
>
<Layer
style={{ cursor: 'pointer' }}
type="circle"
id="marker"
paint={{
'circle-color': 'red',
'circle-stroke-width': 1,
'circle-stroke-color': 'white',
'circle-stroke-opacity': 1,
if(this.props.selectedFeed && this.props.selectedFeed.type=="door"){
console.log('door');
return (
<Col>
<Map
// eslint-disable-next-line
style="mapbox://styles/mapbox/streets-v11"
containerStyle={{
height: '50vh',
width: '100%',
marginTop: '.5em',
}}
center={center}
zoom={zoom}
onClick={() => this.setState({ active: undefined })}
movingMethod="jumpTo"
>
{Object.keys(this.state.data).map((item, index) => (
<Feature
key={item}
style={{ cursor: 'pointer' }}
coordinates={this.state.data[item].position}
onMouseEnter={() =>
this.setState({
active: this.state.data[item],
})
}
onClick={() => {
this.setState({
center: this.state.data[item].position,
zoom: [10],
active: this.state.data[item],
});
}}
/>
))}
</Layer>
{active && (
<Popup
key={active.id}
coordinates={active.position}
// onClick={() => console.log('change to ' + active.name)}
<Layer
style={{ cursor: 'pointer' }}
type="circle"
id="marker"
paint={{
'circle-color': 'red',
'circle-stroke-width': 1,
'circle-stroke-color': 'white',
'circle-stroke-opacity': 1,
}}
>
<div
style={{
background: 'white',
color: '#3f618c',
fontWeight: 400,
borderRadius: 2,
}}
{Object.keys(this.state.data).map((item, index) => (
<Feature
key={item}
style={{ cursor: 'pointer' }}
coordinates={this.state.data[item].position}
onMouseEnter={() =>
this.setState({
active: this.state.data[item],
})
}
onClick={() => {
this.setState({
center: this.state.data[item].position,
zoom: [10],
active: this.state.data[item],
});
}}
/>
))}
</Layer>
{active && (
<Popup
key={active.id}
coordinates={active.position}
// onClick={() => console.log('change to ' + active.name)}
style={{ cursor: 'pointer' }}
>
{active.name.toUpperCase()}
</div>
</Popup>
)}
</Map>
</Col>
);
<div
style={{
background: 'white',
color: '#3f618c',
fontWeight: 400,
borderRadius: 2,
}}
>
{active.name.toUpperCase()}
</div>
</Popup>
)}
</Map>
</Col>
);
}else{
console.log('coin');
return (<Col></Col>);
}
}
}
......
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