Commit 33f9506b by littleploy

update week

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