Commit 9446ef77 by OuiAtichat

disable go button

parent 09cfccca
......@@ -110,7 +110,6 @@ class Home extends Component {
await this.getConfig();
await this.getCurrentUser();
this.getAllDevicesInfo();
// await this.getFeedData();
}
getConfig = async () => {
......@@ -134,8 +133,8 @@ class Home extends Component {
getAllDevicesInfo = async () => {
const { currentUid } = this.state;
console.log('currentUid');
console.log(currentUid);
// console.log('currentUid');
// console.log(currentUid);
const DevicesId = await db
.collection('membership')
.doc(currentUid)
......@@ -203,29 +202,31 @@ class Home extends Component {
keycardFeed: response.data.queries[0].results[3].values,
fingerPrintFeed: response.data.queries[0].results[0].values,
currentLast:
Math.round(response.data.queries[0].results[5].values[
Math.round(
response.data.queries[0].results[5].values[
response.data.queries[0].results[5].values.length - 1
][1]*100)/100,
revenueTotal: Math.round(this.getTotal(response.data.queries[0].results[4].values)*100)/100,
revenueMax: Math.round(this.getMax(response.data.queries[0].results[4].values)*100)/100,
revenueMin: Math.round(this.getMin(response.data.queries[0].results[4].values)*100)/100,
revenueAvg: Math.round(this.getAvg(response.data.queries[0].results[4].values)*100)/100,
peopleTotal: Math.round(this.getTotal(response.data.queries[0].results[1].values)*100)/100,
peopleMax: Math.round(this.getMax(response.data.queries[0].results[1].values)*100)/100,
peopleMin: Math.round(this.getMin(response.data.queries[0].results[1].values)*100)/100,
peopleAvg: Math.round(this.getAvg(response.data.queries[0].results[1].values)*100)/100,
remoteTotal: Math.round(this.getTotal(response.data.queries[0].results[2].values)*100)/100,
remoteMax: Math.round(this.getMax(response.data.queries[0].results[2].values)*100)/100,
remoteMin: Math.round(this.getMin(response.data.queries[0].results[2].values)*100)/100,
remoteAvg: Math.round(this.getAvg(response.data.queries[0].results[2].values)*100)/100,
fingerPrintTotal: Math.round(this.getTotal(response.data.queries[0].results[0].values)*100)/100,
fingerPrintMax: Math.round(this.getMax(response.data.queries[0].results[0].values)*100)/100,
fingerPrintMin: Math.round(this.getMin(response.data.queries[0].results[0].values)*100)/100,
fingerPrintAvg: Math.round(this.getAvg(response.data.queries[0].results[0].values)*100)/100,
keycardTotal: Math.round(this.getTotal(response.data.queries[0].results[3].values)*100)/100,
keycardMax: Math.round(this.getMax(response.data.queries[0].results[3].values)*100)/100,
keycardMin: Math.round(this.getMin(response.data.queries[0].results[3].values)*100)/100,
keycardAvg: Math.round(this.getAvg(response.data.queries[0].results[3].values)*100)/100,
][1] * 100
) / 100,
revenueTotal: Math.round(this.getTotal(response.data.queries[0].results[4].values) * 100) / 100,
revenueMax: Math.round(this.getMax(response.data.queries[0].results[4].values) * 100) / 100,
revenueMin: Math.round(this.getMin(response.data.queries[0].results[4].values) * 100) / 100,
revenueAvg: Math.round(this.getAvg(response.data.queries[0].results[4].values) * 100) / 100,
peopleTotal: Math.round(this.getTotal(response.data.queries[0].results[1].values) * 100) / 100,
peopleMax: Math.round(this.getMax(response.data.queries[0].results[1].values) * 100) / 100,
peopleMin: Math.round(this.getMin(response.data.queries[0].results[1].values) * 100) / 100,
peopleAvg: Math.round(this.getAvg(response.data.queries[0].results[1].values) * 100) / 100,
remoteTotal: Math.round(this.getTotal(response.data.queries[0].results[2].values) * 100) / 100,
remoteMax: Math.round(this.getMax(response.data.queries[0].results[2].values) * 100) / 100,
remoteMin: Math.round(this.getMin(response.data.queries[0].results[2].values) * 100) / 100,
remoteAvg: Math.round(this.getAvg(response.data.queries[0].results[2].values) * 100) / 100,
fingerPrintTotal: Math.round(this.getTotal(response.data.queries[0].results[0].values) * 100) / 100,
fingerPrintMax: Math.round(this.getMax(response.data.queries[0].results[0].values) * 100) / 100,
fingerPrintMin: Math.round(this.getMin(response.data.queries[0].results[0].values) * 100) / 100,
fingerPrintAvg: Math.round(this.getAvg(response.data.queries[0].results[0].values) * 100) / 100,
keycardTotal: Math.round(this.getTotal(response.data.queries[0].results[3].values) * 100) / 100,
keycardMax: Math.round(this.getMax(response.data.queries[0].results[3].values) * 100) / 100,
keycardMin: Math.round(this.getMin(response.data.queries[0].results[3].values) * 100) / 100,
keycardAvg: Math.round(this.getAvg(response.data.queries[0].results[3].values) * 100) / 100,
table: this.getTable(response.data.queries[0].results),
});
} catch (error) {
......@@ -256,25 +257,25 @@ class Home extends Component {
return min;
};
getAvg(data) {
getAvg = data => {
let avg = data[0][1];
for (let i = 1, len = data.length; i < len; i++) {
let v = data[i][1];
avg = avg + v;
}
return avg / data.length;
}
};
getTotal(data) {
getTotal = data => {
let total = data[0][1];
for (let i = 1, len = data.length; i < len; i++) {
let v = data[i][1];
total = total + v;
}
return total;
}
};
getTable(data) {
getTable = data => {
let table = [];
for (let i = 0, len = data[1].values.length; i < len; i++) {
let v = {
......@@ -288,7 +289,7 @@ class Home extends Component {
table[table.length] = v;
}
return table;
}
};
render() {
const {
......@@ -318,9 +319,6 @@ class Home extends Component {
<Mapbox />
</Row>
<Row>
{/* {Data.map((item, index) => (
<DataCard key={index} item={item} feedData={feedData} />
))} */}
<DataCard
item={Data[0]}
feedData={currentFeed}
......
......@@ -14,7 +14,6 @@ class GetDataSelection extends Component {
endDate: moment().valueOf(),
},
breakdown: 'minutes',
allDeviceInfo: null,
};
handleClickGo = e => {
......@@ -25,32 +24,10 @@ class GetDataSelection extends Component {
this.setState({ range: selectedRange });
};
getAllDevicesInfo = () => {
if (this.props.allDevicesId) {
const allDevicesId = this.props.allDevicesId;
let allDeviceInfo = [];
allDevicesId.map(async (deviceId, index) => {
const deviceInfo = await db
.collection('device')
.doc(deviceId)
.get();
allDeviceInfo.push(deviceInfo.data());
});
console.log('allDeviceInfo', allDeviceInfo);
this.setState({ allDeviceInfo });
}
};
componentDidMount = () => {
this.getAllDevicesInfo();
};
render() {
let { allDevicesId, allDeviceInfo } = this.props;
console.log('allDevicesId', allDevicesId);
console.log('allDeviceInfo', allDeviceInfo);
// console.log('allDevicesId', allDevicesId);
// console.log('allDeviceInfo', allDeviceInfo);
return (
<Col>
......@@ -65,14 +42,17 @@ class GetDataSelection extends Component {
this.setState({ device: e.target.value });
}}
>
{allDevicesId &&
{allDevicesId ? (
allDevicesId.map((deviceId, index) => {
return (
<option key={`option${index}`} value={deviceId}>
{allDeviceInfo[index].name}
</option>
);
})}
})
) : (
<option value="">Loading...</option>
)}
</Form.Control>
</Col>
<Col md>
......@@ -95,7 +75,7 @@ class GetDataSelection extends Component {
</Form.Control>
</Col>
<Col md={1}>
<Button block variant="success" onClick={this.handleClickGo}>
<Button block variant="success" onClick={this.handleClickGo} disabled={!!!allDevicesId}>
Go
</Button>
</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