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
b1eeb28d
Commit
b1eeb28d
authored
Aug 07, 2019
by
OuiAtichat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update get interval
parent
96662896
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
39 deletions
+44
-39
src/Pages/Home.js
+34
-26
src/components/Mapbox.js
+10
-10
src/index.js
+0
-3
yarn.lock
+0
-0
No files found.
src/Pages/Home.js
View file @
b1eeb28d
...
...
@@ -74,7 +74,7 @@ const Data = [
{
smtitle
:
'Max. Fingerprint'
,
smValue
:
0
,
iconType
:
'max'
},
{
smtitle
:
'Min. Fingerprint'
,
smValue
:
0
,
iconType
:
'min'
},
],
}
}
,
];
class
Home
extends
Component
{
...
...
@@ -115,7 +115,7 @@ class Home extends Component {
keycardAvg
:
null
,
table
:
null
,
};
looper
;
looper
=
null
;
componentDidMount
=
async
()
=>
{
await
this
.
getConfig
();
await
this
.
getCurrentUser
();
...
...
@@ -125,7 +125,7 @@ class Home extends Component {
componentDidUpdate
=
async
(
prevProps
,
prevState
)
=>
{
if
(
prevState
.
allDevicesId
!==
this
.
state
.
allDevicesId
)
{
// await this.getFeedData();
await
this
.
loopFeedData
();
this
.
loopFeedData
();
}
};
...
...
@@ -164,8 +164,8 @@ class Home extends Component {
.
doc
(
allDevicesId
[
i
])
.
get
();
let
devicedata
=
deviceInfo
.
data
();
devicedata
.
deviceid
=
allDevicesId
[
i
]
devicedata
.
position
=
[
devicedata
.
location
.
_long
,
devicedata
.
location
.
_lat
]
devicedata
.
deviceid
=
allDevicesId
[
i
]
;
devicedata
.
position
=
[
devicedata
.
location
.
_long
,
devicedata
.
location
.
_lat
];
allDeviceInfo
.
push
(
devicedata
);
if
(
i
===
allDevicesId
.
length
-
1
)
{
this
.
setState
({
allDeviceInfo
});
...
...
@@ -174,12 +174,12 @@ class Home extends Component {
this
.
setState
({
allDevicesId
});
};
loopFeedData
=
async
(
deviceId
,
selectedRange
,
breakdown
)
=>
{
console
.
log
(
"loopFeedData"
)
clearInterval
(
this
.
looper
)
await
this
.
getFeedData
(
deviceId
,
selectedRange
,
breakdown
);
this
.
looper
=
setInterval
(
a
wait
this
.
getFeedData
(
deviceId
,
selectedRange
,
breakdown
)
,
60000
)
}
loopFeedData
=
async
(
deviceId
,
selectedRange
,
breakdown
)
=>
{
console
.
log
(
'loopFeedData'
);
//
clearInterval(this.looper)
await
this
.
getFeedData
(
deviceId
,
selectedRange
,
breakdown
);
this
.
looper
=
setInterval
(
a
sync
()
=>
await
this
.
getFeedData
(
deviceId
,
selectedRange
,
breakdown
),
60000
);
}
;
getFeedData
=
async
(
deviceId
,
...
...
@@ -223,7 +223,7 @@ class Home extends Component {
};
try
{
console
.
log
(
"getFeedData"
)
console
.
log
(
'getFeedData'
);
axios
.
defaults
.
headers
.
common
[
'Authorization'
]
=
`Bearer
${
userToken
}
`
;
const
response
=
await
axios
.
post
(
kairosUrl
,
q_data
);
this
.
setState
({
...
...
@@ -236,7 +236,7 @@ class Home extends Component {
currentLast
:
Math
.
round
(
response
.
data
.
queries
[
0
].
results
[
5
].
values
[
response
.
data
.
queries
[
0
].
results
[
5
].
values
.
length
-
1
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
,
...
...
@@ -251,23 +251,29 @@ class Home extends Component {
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
(
response
.
data
.
queries
[
0
].
results
[
0
].
values
[
response
.
data
.
queries
[
0
].
results
[
0
].
values
.
length
-
1
][
1
]
*
100
)
/
100
,
fingerPrintTotal
:
Math
.
round
(
response
.
data
.
queries
[
0
].
results
[
0
].
values
[
response
.
data
.
queries
[
0
].
results
[
0
].
values
.
length
-
1
][
1
]
*
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
(
response
.
data
.
queries
[
0
].
results
[
3
].
values
[
response
.
data
.
queries
[
0
].
results
[
3
].
values
.
length
-
1
][
1
]
*
100
)
/
100
,
keycardTotal
:
Math
.
round
(
response
.
data
.
queries
[
0
].
results
[
3
].
values
[
response
.
data
.
queries
[
0
].
results
[
3
].
values
.
length
-
1
][
1
]
*
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
(
this
.
state
.
allDeviceInfo
[
this
.
state
.
allDevicesId
.
indexOf
(
deviceId
||
this
.
state
.
allDevicesId
[
0
])].
name
,
response
.
data
.
queries
[
0
].
results
),
table
:
this
.
getTable
(
this
.
state
.
allDeviceInfo
[
this
.
state
.
allDevicesId
.
indexOf
(
deviceId
||
this
.
state
.
allDevicesId
[
0
])]
.
name
,
response
.
data
.
queries
[
0
].
results
),
});
}
catch
(
error
)
{
console
.
error
(
error
);
...
...
@@ -315,19 +321,21 @@ class Home extends Component {
return
total
;
};
getTable
=
(
site
,
data
)
=>
{
getTable
=
(
site
,
data
)
=>
{
let
table
=
[];
for
(
let
i
=
0
,
len
=
data
[
1
].
values
.
length
;
i
<
len
;
i
++
)
{
let
v
=
{
site
:
site
,
site
:
site
,
people
:
data
[
1
].
values
[
i
][
1
],
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'
),
};
table
[
table
.
length
]
=
v
;
}
return
table
;
};
...
...
src/components/Mapbox.js
View file @
b1eeb28d
...
...
@@ -6,20 +6,20 @@ const Map = ReactMapboxGl({
accessToken
:
'pk.eyJ1IjoicHJhY2hwYXdlZSIsImEiOiJjanlxdndybXcwNDZtM2RxcDlzenRrdzhsIn0.gvfTBIUhhBKvY2ZWBjj3Zw'
,
});
const
Data
=
[
{
id
:
1
,
position
:
[
100.56721
,
13.748115
],
name
:
'nexpie'
},
{
id
:
2
,
position
:
[
100.56987
,
13.747821
],
name
:
'avani'
},
{
id
:
3
,
position
:
[
100.622749
,
13.962597
],
name
:
'zeer'
},
{
id
:
4
,
position
:
[
100.535007
,
13.746648
],
name
:
'siam paragon'
},
{
id
:
5
,
position
:
[
100.679211
,
13.826122
],
name
:
'Fashion Island'
},
];
//
const Data = [
//
{ id: 1, position: [100.56721, 13.748115], name: 'nexpie' },
//
{ id: 2, position: [100.56987, 13.747821], name: 'avani' },
//
{ id: 3, position: [100.622749, 13.962597], name: 'zeer' },
//
{ id: 4, position: [100.535007, 13.746648], name: 'siam paragon' },
//
{ id: 5, position: [100.679211, 13.826122], name: 'Fashion Island' },
//
];
export
default
class
Mapbox
extends
React
.
PureComponent
{
state
=
{
center
:
undefined
,
active
:
undefined
,
zoom
:
[
10
],
data
:
[]
data
:
[],
};
componentDidUpdate
=
()
=>
{
...
...
@@ -27,8 +27,8 @@ export default class Mapbox extends React.PureComponent {
let
data1
=
this
.
props
.
allDeviceInfo
;
this
.
setState
({
data
:
data1
,
center
:
data1
[
0
].
position
,
active
:
data1
[
0
]
center
:
data1
[
0
].
position
,
active
:
data1
[
0
],
});
}
};
...
...
src/index.js
View file @
b1eeb28d
import
React
from
'react'
;
import
ReactDOM
from
'react-dom'
;
import
App
from
'./App'
;
import
*
as
serviceWorker
from
'./serviceWorker'
;
import
'./styles.scss'
;
ReactDOM
.
render
(
<
App
/>
,
document
.
getElementById
(
'root'
));
// serviceWorker.register();
yarn.lock
View file @
b1eeb28d
This diff is collapsed.
Click to expand it.
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