Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
toiletcoin
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
atichat
toiletcoin
Commits
9446ef77
Commit
9446ef77
authored
Aug 07, 2019
by
OuiAtichat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disable go button
parent
09cfccca
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
62 deletions
+40
-62
src/Pages/Home.js
+32
-34
src/components/GetDataSelection/GetDataSelection.js
+8
-28
No files found.
src/Pages/Home.js
View file @
9446ef77
...
...
@@ -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
}
...
...
src/components/GetDataSelection/GetDataSelection.js
View file @
9446ef77
...
...
@@ -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
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment