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
0117ba85
Commit
0117ba85
authored
Aug 06, 2019
by
OuiAtichat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api update
parent
3454e080
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
53 deletions
+67
-53
src/Pages/Home.js
+63
-51
src/components/GetDataSelection/GetDataSelection.js
+4
-2
No files found.
src/Pages/Home.js
View file @
0117ba85
...
...
@@ -134,8 +134,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
)
...
...
@@ -151,11 +151,12 @@ class Home extends Component {
.
doc
(
allDevicesId
[
i
])
.
get
();
allDeviceInfo
.
push
(
deviceInfo
.
data
());
if
(
i
==
allDevicesId
.
length
-
1
)
{
console
.
log
(
allDeviceInfo
)
if
(
i
===
allDevicesId
.
length
-
1
)
{
this
.
setState
({
allDeviceInfo
});
}
}
// this.setState({ allDevicesId: Object.keys(DevicesId.data()) });
this
.
setState
({
allDevicesId
:
Object
.
keys
(
DevicesId
.
data
())
});
};
getFeedData
=
async
(
deviceId
,
selectedRange
,
breakdown
)
=>
{
...
...
@@ -201,7 +202,10 @@ class Home extends Component {
remoteFeed
:
response
.
data
.
queries
[
0
].
results
[
2
].
values
,
keycardFeed
:
response
.
data
.
queries
[
0
].
results
[
1
].
values
,
fingerPrintFeed
:
response
.
data
.
queries
[
0
].
results
[
0
].
values
,
currentLast
:
response
.
data
.
queries
[
0
].
results
[
5
].
values
[
response
.
data
.
queries
[
0
].
results
[
5
].
values
.
length
-
1
][
1
],
currentLast
:
response
.
data
.
queries
[
0
].
results
[
5
].
values
[
response
.
data
.
queries
[
0
].
results
[
5
].
values
.
length
-
1
][
1
],
revenueTotal
:
this
.
getTotal
(
response
.
data
.
queries
[
0
].
results
[
4
].
values
),
revenueMax
:
this
.
getMax
(
response
.
data
.
queries
[
0
].
results
[
4
].
values
),
revenueMin
:
this
.
getMin
(
response
.
data
.
queries
[
0
].
results
[
4
].
values
),
...
...
@@ -222,8 +226,7 @@ class Home extends Component {
keycardMax
:
this
.
getMax
(
response
.
data
.
queries
[
0
].
results
[
1
].
values
),
keycardMin
:
this
.
getMin
(
response
.
data
.
queries
[
0
].
results
[
1
].
values
),
keycardAvg
:
this
.
getAvg
(
response
.
data
.
queries
[
0
].
results
[
1
].
values
),
table
:
this
.
getTable
(
response
.
data
.
queries
[
0
].
results
)
table
:
this
.
getTable
(
response
.
data
.
queries
[
0
].
results
),
});
}
catch
(
error
)
{
console
.
error
(
error
);
...
...
@@ -235,23 +238,23 @@ class Home extends Component {
this
.
getFeedData
(
device
||
this
.
state
.
allDevicesId
[
0
],
range
,
breakdown
);
};
getMax
=
(
data
)
=>
{
let
max
=
data
[
0
][
1
]
getMax
=
data
=>
{
let
max
=
data
[
0
][
1
]
;
for
(
let
i
=
1
,
len
=
data
.
length
;
i
<
len
;
i
++
)
{
let
v
=
data
[
i
][
1
];
max
=
(
v
>
max
)
?
v
:
max
;
max
=
v
>
max
?
v
:
max
;
}
return
max
}
return
max
;
}
;
getMin
=
(
data
)
=>
{
let
min
=
data
[
0
][
1
]
getMin
=
data
=>
{
let
min
=
data
[
0
][
1
]
;
for
(
let
i
=
1
,
len
=
data
.
length
;
i
<
len
;
i
++
)
{
let
v
=
data
[
i
][
1
];
min
=
(
v
<
min
)
?
v
:
min
;
min
=
v
<
min
?
v
:
min
;
}
return
min
}
return
min
;
}
;
getAvg
(
data
)
{
let
avg
=
data
[
0
][
1
];
...
...
@@ -259,7 +262,7 @@ class Home extends Component {
let
v
=
data
[
i
][
1
];
avg
=
avg
+
v
;
}
return
avg
/
data
.
length
return
avg
/
data
.
length
;
}
getTotal
(
data
)
{
...
...
@@ -268,7 +271,7 @@ class Home extends Component {
let
v
=
data
[
i
][
1
];
total
=
total
+
v
;
}
return
total
return
total
;
}
getTable
(
data
)
{
...
...
@@ -280,11 +283,11 @@ class Home extends Component {
revenue
:
data
[
4
].
values
[
i
][
1
],
remote
:
data
[
2
].
values
[
i
][
1
],
current
:
data
[
5
].
values
[
i
][
1
],
timestamp
:
moment
(
data
[
1
].
values
[
i
][
0
]).
format
(
'D/M/YY h:mm:ss a'
)
timestamp
:
moment
(
data
[
1
].
values
[
i
][
0
]).
format
(
'D/M/YY h:mm:ss a'
)
,
};
table
[
table
.
length
]
=
v
table
[
table
.
length
]
=
v
;
}
return
table
return
table
;
}
render
()
{
...
...
@@ -307,7 +310,7 @@ class Home extends Component {
<
Row
>
<
GetDataSelection
allDevicesId
=
{
allDevicesId
}
//
allDeviceInfo={allDeviceInfo}
allDeviceInfo
=
{
allDeviceInfo
}
onConfirm
=
{
this
.
getSelectedFeed
}
/
>
<
/Row
>
...
...
@@ -318,55 +321,64 @@ class Home extends Component {
{
/* {Data.map((item, index) => (
<DataCard key={index} item={item} feedData={feedData} />
))} */
}
<
DataCard
item
=
{
Data
[
0
]}
feedData
=
{
currentFeed
}
datavalue
=
{[{
title
:
"last"
,
value
:
this
.
state
.
currentLast
}]}
/
>
<
DataCard
item
=
{
Data
[
0
]}
feedData
=
{
currentFeed
}
datavalue
=
{[{
title
:
'last'
,
value
:
this
.
state
.
currentLast
}]}
/
>
<
DataCard
item
=
{
Data
[
1
]}
feedData
=
{
revenueFeed
}
total
=
{
this
.
state
.
revenueTotal
}
max
=
{
this
.
state
.
revenueMax
}
min
=
{
this
.
state
.
revenueMin
}
avg
=
{
this
.
state
.
revenueAvg
}
datavalue
=
{[{
title
:
"total"
,
value
:
this
.
state
.
revenueTotal
},
{
title
:
"avg"
,
value
:
this
.
state
.
revenueAvg
},
{
title
:
"max"
,
value
:
this
.
state
.
revenueMax
},
{
title
:
"min"
,
value
:
this
.
state
.
revenueMin
}]}
datavalue
=
{[
{
title
:
'total'
,
value
:
this
.
state
.
revenueTotal
},
{
title
:
'avg'
,
value
:
this
.
state
.
revenueAvg
},
{
title
:
'max'
,
value
:
this
.
state
.
revenueMax
},
{
title
:
'min'
,
value
:
this
.
state
.
revenueMin
},
]}
/
>
<
DataCard
item
=
{
Data
[
2
]}
feedData
=
{
peopleFeed
}
total
=
{
this
.
state
.
peopleTotal
}
max
=
{
this
.
state
.
peopleMax
}
min
=
{
this
.
state
.
peopleMin
}
avg
=
{
this
.
state
.
peopleAvg
}
datavalue
=
{[{
title
:
"total"
,
value
:
this
.
state
.
peopleTotal
},
{
title
:
"avg"
,
value
:
this
.
state
.
peopleAvg
},
{
title
:
"max"
,
value
:
this
.
state
.
peopleMax
},
{
title
:
"min"
,
value
:
this
.
state
.
peopleMin
}]}
datavalue
=
{[
{
title
:
'total'
,
value
:
this
.
state
.
peopleTotal
},
{
title
:
'avg'
,
value
:
this
.
state
.
peopleAvg
},
{
title
:
'max'
,
value
:
this
.
state
.
peopleMax
},
{
title
:
'min'
,
value
:
this
.
state
.
peopleMin
},
]}
/
>
<
DataCard
item
=
{
Data
[
3
]}
feedData
=
{
remoteFeed
}
total
=
{
this
.
state
.
remoteTotal
}
max
=
{
this
.
state
.
remoteMax
}
min
=
{
this
.
state
.
remoteMin
}
avg
=
{
this
.
state
.
remoteAvg
}
datavalue
=
{[{
title
:
"total"
,
value
:
this
.
state
.
remoteTotal
},
{
title
:
"avg"
,
value
:
this
.
state
.
remoteAvg
},
{
title
:
"max"
,
value
:
this
.
state
.
remoteMax
},
{
title
:
"min"
,
value
:
this
.
state
.
remoteMin
}]}
datavalue
=
{[
{
title
:
'total'
,
value
:
this
.
state
.
remoteTotal
},
{
title
:
'avg'
,
value
:
this
.
state
.
remoteAvg
},
{
title
:
'max'
,
value
:
this
.
state
.
remoteMax
},
{
title
:
'min'
,
value
:
this
.
state
.
remoteMin
},
]}
/
>
<
DataCard
item
=
{
Data
[
5
]}
feedData
=
{
fingerPrintFeed
}
total
=
{
this
.
state
.
fingerPrintTotal
}
max
=
{
this
.
state
.
fingerPrintMax
}
min
=
{
this
.
state
.
fingerPrintMin
}
avg
=
{
this
.
state
.
fingerPrintAvg
}
datavalue
=
{[{
title
:
"total"
,
value
:
this
.
state
.
fingerPrintTotal
},
{
title
:
"avg"
,
value
:
this
.
state
.
fingerPrintAvg
},
{
title
:
"max"
,
value
:
this
.
state
.
fingerPrintMax
},
{
title
:
"min"
,
value
:
this
.
state
.
fingerPrintMin
}]}
datavalue
=
{[
{
title
:
'total'
,
value
:
this
.
state
.
fingerPrintTotal
},
{
title
:
'avg'
,
value
:
this
.
state
.
fingerPrintAvg
},
{
title
:
'max'
,
value
:
this
.
state
.
fingerPrintMax
},
{
title
:
'min'
,
value
:
this
.
state
.
fingerPrintMin
},
]}
/
>
<
DataCard
item
=
{
Data
[
4
]}
feedData
=
{
keycardFeed
}
total
=
{
this
.
state
.
keycardTotal
}
max
=
{
this
.
state
.
keycardMax
}
min
=
{
this
.
state
.
keycardMin
}
avg
=
{
this
.
state
.
keycardAvg
}
datavalue
=
{[{
title
:
"total"
,
value
:
this
.
state
.
keycardTotal
},
{
title
:
"avg"
,
value
:
this
.
state
.
keycardAvg
},
{
title
:
"max"
,
value
:
this
.
state
.
keycardMax
},
{
title
:
"min"
,
value
:
this
.
state
.
keycardMin
}]}
datavalue
=
{[
{
title
:
'total'
,
value
:
this
.
state
.
keycardTotal
},
{
title
:
'avg'
,
value
:
this
.
state
.
keycardAvg
},
{
title
:
'max'
,
value
:
this
.
state
.
keycardMax
},
{
title
:
'min'
,
value
:
this
.
state
.
keycardMin
},
]}
/
>
<
/Row
>
<
Row
>
<
DataTable
table
=
{
this
.
state
.
table
}
/
>
<
DataTable
table
=
{
this
.
state
.
table
}
/
>
<
/Row
>
<
/Container
>
<
/
>
...
...
src/components/GetDataSelection/GetDataSelection.js
View file @
0117ba85
...
...
@@ -48,8 +48,10 @@ class GetDataSelection extends Component {
};
render
()
{
let
{
allDevicesId
}
=
this
.
props
;
let
{
allDevicesId
,
allDeviceInfo
}
=
this
.
props
;
console
.
log
(
'allDevicesId'
,
allDevicesId
);
console
.
log
(
'allDeviceInfo'
,
allDeviceInfo
);
return
(
<
Col
>
<
Form
.
Label
>
Get
data
from
<
/Form.Label
>
...
...
@@ -67,7 +69,7 @@ class GetDataSelection extends Component {
allDevicesId
.
map
((
deviceId
,
index
)
=>
{
return
(
<
option
key
=
{
`option
${
index
}
`
}
value
=
{
deviceId
}
>
{
index
}
{
allDeviceInfo
[
index
].
name
}
<
/option
>
);
})}
...
...
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