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
27da13f1
Commit
27da13f1
authored
Nov 27, 2019
by
Chaiwith Santaweesuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix feed
parent
9a3a094c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
97 additions
and
74 deletions
+97
-74
src/Pages/Home.js
+0
-0
src/components/DataCard.js
+36
-15
src/components/GetDataSelection.js
+8
-8
src/components/Mapbox.js
+4
-4
src/components/PrivateRoute.js
+1
-1
src/index.js
+1
-1
src/redux/actions/allDevicesInfoAction.js
+13
-13
src/redux/actions/feedDataAction.js
+24
-22
src/serviceWorker.js
+10
-10
No files found.
src/Pages/Home.js
View file @
27da13f1
This diff is collapsed.
Click to expand it.
src/components/DataCard.js
View file @
27da13f1
...
...
@@ -14,11 +14,11 @@ export const SmCard = props => {
<
h6
>
{
smdata
.
smtitle
}
<
/h6
>
<
Row
style
=
{{
alignItems
:
'center'
}}
>
<
Col
>
{
smdata
.
iconType
==
=
'max'
?
(
{
smdata
.
iconType
==
'max'
?
(
<
FaArrowUp
{...
iconStyle
}
/
>
)
:
smdata
.
iconType
==
=
'min'
?
(
)
:
smdata
.
iconType
==
'min'
?
(
<
FaArrowDown
{...
iconStyle
}
/
>
)
:
smdata
.
iconType
==
=
'money'
?
(
)
:
smdata
.
iconType
==
'money'
?
(
<
FaMoneyBillAlt
{...
iconStyle
}
/
>
)
:
(
<
FaUserFriends
{...
iconStyle
}
/
>
...
...
@@ -49,20 +49,41 @@ const DataCard = props => {
// if (Object.keys(mapValues).includes(key)) {
// mapValues[key] += allValues[index][1];
let
key
=
allValues
[
index
][
0
];
if
(
breakdown
==
"minutes"
){
// if (breakdown=="minutes") {
// key = moment(parseInt(allValues[index][0])).minutes(Math.round(moment(parseInt(allValues[index][0])).minutes() / 5) * 5);
// }
// else if (breakdown=="hours") {
// 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])).hours(0).minutes(0);
// }
// else if (breakdown=="weeks") {
// key = moment(parseInt(allValues[index][0])).startOf('week').hours(0).minutes(0);
// }
// else if (breakdown=="months") {
// key = moment(parseInt(allValues[index][0])).startOf('month').hours(0).minutes(0);
// }
if
(
breakdown
==
"minutes"
)
{
key
=
moment
(
parseInt
(
allValues
[
index
][
0
])).
minutes
(
Math
.
round
(
moment
(
parseInt
(
allValues
[
index
][
0
])).
minutes
()
/
5
)
*
5
);
// timestamp = key.valueOf().toString().substring(0, 8) + "00000";
}
else
if
(
breakdown
==
"hours"
)
{
key
=
moment
(
parseInt
(
allValues
[
index
][
0
])).
minutes
(
0
);
// timestamp = key.valueOf().toString().substring(0, 8) + "00000";
}
else
if
(
breakdown
==
"hours"
){
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
])).
hours
(
1
).
minutes
(
0
);
// timestamp = key.valueOf().toString().substring(0, 8) + "00000";
}
else
if
(
breakdown
==
"days"
){
key
=
moment
(
parseInt
(
allValues
[
index
][
0
])).
hours
(
0
).
minutes
(
0
);
}
else
if
(
breakdown
==
"weeks"
){
key
=
moment
(
parseInt
(
allValues
[
index
][
0
])).
startOf
(
'week'
).
hours
(
0
).
minutes
(
0
);
else
if
(
breakdown
==
"weeks"
)
{
key
=
moment
(
parseInt
(
allValues
[
index
][
0
])).
startOf
(
'week'
).
hours
(
1
).
minutes
(
0
);
// timestamp = key.valueOf().toString().substring(0, 8) + "00000";
}
else
if
(
breakdown
==
"months"
){
key
=
moment
(
parseInt
(
allValues
[
index
][
0
])).
startOf
(
'month'
).
hours
(
0
).
minutes
(
0
);
else
if
(
breakdown
==
"months"
)
{
key
=
moment
(
parseInt
(
allValues
[
index
][
0
])).
startOf
(
'month'
).
hours
(
1
).
minutes
(
0
);
// timestamp = key.valueOf().toString().substring(0, 8) + "00000";
}
const
timestamp
=
key
.
valueOf
().
toString
().
substring
(
0
,
8
)
+
"00000"
;
if
(
Object
.
keys
(
mapValues
).
includes
(
timestamp
))
{
...
...
@@ -122,7 +143,7 @@ const DataCard = props => {
<
/Card
>
<
Row
>
{
data
.
detail
.
map
((
item
,
index
)
=>
data
.
detail
.
length
==
=
1
?
(
data
.
detail
.
length
==
1
?
(
<
Col
key
=
{
index
}
md
=
{
12
}
style
=
{{
marginTop
:
'.7em'
}}
>
<
SmCard
backgroundColor
=
{
data
.
backgroundColor
}
...
...
@@ -136,7 +157,7 @@ const DataCard = props => {
md
=
{
6
}
style
=
{{
marginTop
:
'.7em'
,
paddingLeft
:
!
props
.
isMobileSized
?
(
index
%
2
==
=
0
?
'15px'
:
'7.5px'
)
:
'15px'
,
paddingLeft
:
!
props
.
isMobileSized
?
(
index
%
2
==
0
?
'15px'
:
'7.5px'
)
:
'15px'
,
paddingRight
:
!
props
.
isMobileSized
?
(
index
%
2
!==
0
?
'15px'
:
'7.5px'
)
:
'15px'
,
}}
>
...
...
src/components/GetDataSelection.js
View file @
27da13f1
...
...
@@ -38,8 +38,8 @@ class GetDataSelection extends Component {
const
{
allLocationInfo
}
=
this
.
props
;
const
startDateTimeStamp
=
moment
(
startDate
).
valueOf
();
const
endDateTimeStamp
=
moment
(
endDate
).
valueOf
();
const
devices
=
allLocationInfo
.
find
(
element
=>
element
.
locationid
==
=
location
).
devicesId
;
const
type
=
allLocationInfo
.
find
(
element
=>
element
.
locationid
==
=
location
).
type
;
const
devices
=
allLocationInfo
.
find
(
element
=>
element
.
locationid
==
location
).
devicesId
;
const
type
=
allLocationInfo
.
find
(
element
=>
element
.
locationid
==
location
).
type
;
this
.
props
.
getSelectedFeed
(
devices
,
location
,
...
...
@@ -64,8 +64,8 @@ class GetDataSelection extends Component {
};
componentDidUpdate
=
(
prevProps
,
prevState
)
=>
{
if
(
prevProps
.
selectedFeed
!=
this
.
props
.
selectedFeed
)
{
this
.
setState
({
location
:
this
.
props
.
selectedFeed
.
location
})
if
(
prevProps
.
selectedFeed
!=
this
.
props
.
selectedFeed
)
{
this
.
setState
({
location
:
this
.
props
.
selectedFeed
.
location
})
}
};
...
...
@@ -74,10 +74,10 @@ class GetDataSelection extends Component {
let
start
=
this
.
state
.
startDate
.
format
(
'DD MMM YY'
);
let
end
=
this
.
state
.
endDate
.
format
(
'DD MMM YY'
);
let
label
=
start
+
' - '
+
end
;
if
(
start
==
=
end
)
{
if
(
start
==
end
)
{
label
=
start
;
}
return
(
<
Col
>
<
Form
.
Label
>
Get
data
from
<
/Form.Label
>
...
...
@@ -100,8 +100,8 @@ class GetDataSelection extends Component {
);
})
)
:
(
<
option
value
=
""
>
Loading
...
<
/option
>
)}
<
option
value
=
""
>
Loading
...
<
/option
>
)}
<
/Form.Control
>
<
/Col
>
<
Col
md
>
...
...
src/components/Mapbox.js
View file @
27da13f1
...
...
@@ -19,9 +19,9 @@ export default class Mapbox extends Component {
// if (this.props.allLocationInfo) {
// if (prevProps.selectedFeed !== this.props.selectedFeed) {
// if(this.props.selectedFeed.type=="door"){
// const data1 = this.props.allLocationInfo.filter(location => location.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);
// const currentIndex = data1.findIndex(element => element.locationid == location);
// this.setState({
// data: data1,
// center: data1[currentIndex].position,
...
...
@@ -40,7 +40,7 @@ export default class Mapbox extends Component {
// };
componentDidUpdate
=
(
prevProps
,
prevState
)
=>
{
if
(
prevProps
.
active
!=
this
.
props
.
active
)
{
if
(
prevProps
.
active
!=
this
.
props
.
active
)
{
this
.
setState
({
data
:
this
.
props
.
data
,
center
:
this
.
props
.
center
,
...
...
@@ -119,7 +119,7 @@ export default class Mapbox extends Component {
<
/Map
>
<
/Col
>
);
}
}
...
...
src/components/PrivateRoute.js
View file @
27da13f1
...
...
@@ -5,7 +5,7 @@ export default function PrivateRoute({ component: Component, authenticated, ...r
return
(
<
Route
{...
rest
}
render
=
{
props
=>
(
authenticated
==
=
true
?
<
Component
{...
props
}
{...
rest
}
/> : <Redirect to="/
login
" />)}
render
=
{
props
=>
(
authenticated
==
true
?
<
Component
{...
props
}
{...
rest
}
/> : <Redirect to="/
login
" />)}
/>
);
}
src/index.js
View file @
27da13f1
...
...
@@ -8,7 +8,7 @@ import logger from 'redux-logger';
import
App
from
'./App'
;
import
'./styles.scss'
;
let
middleware
=
process
.
env
.
NODE_ENV
==
=
`development`
?
applyMiddleware
(
thunk
,
logger
)
:
applyMiddleware
(
thunk
);
let
middleware
=
process
.
env
.
NODE_ENV
==
`development`
?
applyMiddleware
(
thunk
,
logger
)
:
applyMiddleware
(
thunk
);
const
store
=
createStore
(
rootReducer
,
middleware
);
...
...
src/redux/actions/allDevicesInfoAction.js
View file @
27da13f1
...
...
@@ -15,18 +15,18 @@ export const getAllDevicesInfo = () => async (dispatch, getState) => {
const
currentUid
=
fireStoreReducer
.
fireStoreCurrentUser
.
uid
;
const
locationId
=
await
db
.
collection
(
'membership'
)
.
doc
(
currentUid
)
.
get
();
.
collection
(
'membership'
)
.
doc
(
currentUid
)
.
get
();
let
allLocationId
=
Object
.
keys
(
locationId
.
data
());
let
allLocationInfo
=
[];
let
allDeviceInfo
=
[];
let
allDeviceId
=
[];
for
(
let
i
=
0
,
len
=
allLocationId
.
length
;
i
<
len
;
i
++
)
{
const
locationInfo
=
await
db
.
collection
(
'location'
)
.
doc
(
allLocationId
[
i
])
.
get
();
.
collection
(
'location'
)
.
doc
(
allLocationId
[
i
])
.
get
();
let
info
=
locationInfo
.
data
();
let
locationData
=
{};
locationData
.
locationid
=
allLocationId
[
i
];
...
...
@@ -38,16 +38,16 @@ export const getAllDevicesInfo = () => async (dispatch, getState) => {
let
devicesId
=
Object
.
keys
(
info
.
devices
);
devicesId
.
forEach
(
async
device
=>
{
const
deviceInfo
=
await
db
.
collection
(
'device'
)
.
doc
(
device
)
.
get
();
.
collection
(
'device'
)
.
doc
(
device
)
.
get
();
allDeviceId
.
push
(
device
);
allDeviceInfo
.
push
({
location
:
allLocationId
[
i
],
deviceid
:
device
,
name
:
deviceInfo
.
data
().
name
});
allDeviceInfo
.
push
({
location
:
allLocationId
[
i
],
deviceid
:
device
,
name
:
deviceInfo
.
data
().
name
});
locationData
.
devicesId
.
push
(
device
);
});
allLocationInfo
.
push
(
locationData
);
if
(
i
==
=
allLocationId
.
length
-
1
)
{
if
(
i
==
allLocationId
.
length
-
1
)
{
dispatch
(
getAllDevicesInfoAction
(
allLocationInfo
.
sort
((
a
,
b
)
=>
a
.
name
.
localeCompare
(
b
.
name
)),
allLocationId
,
allDeviceInfo
,
allDeviceId
));
}
}
...
...
@@ -69,7 +69,7 @@ export const getAllDevicesInfo = () => async (dispatch, getState) => {
// devicedata.position = [devicedata.location._long, devicedata.location._lat];
// console.log(devicedata);
// allDeviceInfo.push(devicedata);
// if (i ==
=
allDeviceId.length - 1) {
// if (i == allDeviceId.length - 1) {
// console.log(allDeviceInfo);
// console.log(allDeviceId);
// dispatch(getAllDevicesInfoAction(allDeviceInfo, allDeviceId));
...
...
src/redux/actions/feedDataAction.js
View file @
27da13f1
...
...
@@ -24,13 +24,13 @@ export const getFeedData = () => async (dispatch, getState) => {
const
{
devices
,
range
,
breakdown
}
=
selectedFeedReducer
.
selectedFeed
;
const
attrList
=
[
{
tag
:
"['Current Cash']"
,
aggregator
:
'last'
},
{
tag
:
'Revenue'
,
aggregator
:
'sum'
},
{
tag
:
'Remote'
,
aggregator
:
'sum'
},
{
tag
:
'People'
,
aggregator
:
'sum'
},
{
tag
:
'Fingerprint'
,
aggregator
:
'sum'
},
{
tag
:
'Keycard'
,
aggregator
:
'sum'
}
];
{
tag
:
"['Current Cash']"
,
aggregator
:
'last'
},
{
tag
:
'Revenue'
,
aggregator
:
'sum'
},
{
tag
:
'Remote'
,
aggregator
:
'sum'
},
{
tag
:
'People'
,
aggregator
:
'sum'
},
{
tag
:
'Fingerprint'
,
aggregator
:
'sum'
},
{
tag
:
'Keycard'
,
aggregator
:
'sum'
}
];
let
metrics
=
[];
devices
.
forEach
(
device
=>
{
attrList
.
forEach
(
element
=>
{
...
...
@@ -61,8 +61,8 @@ export const getFeedData = () => async (dispatch, getState) => {
const
q_data
=
{
start_absolute
:
range
.
startDate
,
end_absolute
:
range
.
endDate
,
metrics
:
metrics
metrics
:
metrics
};
try
{
...
...
@@ -82,26 +82,28 @@ export const getFeedData = () => async (dispatch, getState) => {
let
fingerPrintFeedList
=
[];
let
keycardFeedList
=
[];
response
.
data
.
queries
.
forEach
(
query
=>
{
if
(
query
.
results
[
0
].
tags
.
attr
==
"['Current Cash']"
)
{
currentFeedList
.
push
({
deviceId
:
query
.
results
[
0
].
name
,
value
:
query
.
results
[
0
].
values
});
if
(
query
.
results
[
0
].
tags
.
attr
==
"['Current Cash']"
)
{
currentFeedList
.
push
({
deviceId
:
query
.
results
[
0
].
name
,
value
:
query
.
results
[
0
].
values
});
}
else
if
(
query
.
results
[
0
].
tags
.
attr
==
"Revenue"
)
{
revenueFeedList
.
push
({
deviceId
:
query
.
results
[
0
].
name
,
value
:
query
.
results
[
0
].
values
});
else
if
(
query
.
results
[
0
].
tags
.
attr
==
"Revenue"
)
{
revenueFeedList
.
push
({
deviceId
:
query
.
results
[
0
].
name
,
value
:
query
.
results
[
0
].
values
});
}
else
if
(
query
.
results
[
0
].
tags
.
attr
==
"Remote"
)
{
remoteFeedList
.
push
({
deviceId
:
query
.
results
[
0
].
name
,
value
:
query
.
results
[
0
].
values
});
else
if
(
query
.
results
[
0
].
tags
.
attr
==
"Remote"
)
{
remoteFeedList
.
push
({
deviceId
:
query
.
results
[
0
].
name
,
value
:
query
.
results
[
0
].
values
});
}
else
if
(
query
.
results
[
0
].
tags
.
attr
==
"People"
)
{
peopleFeedList
.
push
({
deviceId
:
query
.
results
[
0
].
name
,
value
:
query
.
results
[
0
].
values
});
else
if
(
query
.
results
[
0
].
tags
.
attr
==
"People"
)
{
peopleFeedList
.
push
({
deviceId
:
query
.
results
[
0
].
name
,
value
:
query
.
results
[
0
].
values
});
}
else
if
(
query
.
results
[
0
].
tags
.
attr
==
"Fingerprint"
)
{
fingerPrintFeedList
.
push
({
deviceId
:
query
.
results
[
0
].
name
,
value
:
query
.
results
[
0
].
values
});
else
if
(
query
.
results
[
0
].
tags
.
attr
==
"Fingerprint"
)
{
fingerPrintFeedList
.
push
({
deviceId
:
query
.
results
[
0
].
name
,
value
:
query
.
results
[
0
].
values
});
}
else
if
(
query
.
results
[
0
].
tags
.
attr
==
"Keycard"
)
{
keycardFeedList
.
push
({
deviceId
:
query
.
results
[
0
].
name
,
value
:
query
.
results
[
0
].
values
});
else
if
(
query
.
results
[
0
].
tags
.
attr
==
"Keycard"
)
{
keycardFeedList
.
push
({
deviceId
:
query
.
results
[
0
].
name
,
value
:
query
.
results
[
0
].
values
});
}
});
// console.log(peopleFeedList)
// console.log(revenueFeedList)
// console.log(currentFeedList)
dispatch
(
getFeedDataAction
({
currentFeed
:
currentFeedList
||
[],
...
...
src/serviceWorker.js
View file @
27da13f1
...
...
@@ -11,15 +11,15 @@
// opt-in, read https://bit.ly/CRA-PWA
const
isLocalhost
=
Boolean
(
window
.
location
.
hostname
==
=
'localhost'
||
// [::1] is the IPv6 localhost address.
window
.
location
.
hostname
=
==
'[::1]'
||
// 127.0.0.1/8 is considered localhost for IPv4.
window
.
location
.
hostname
.
match
(
/^127
(?:\.(?:
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
01
]?[
0-9
][
0-9
]?)){3}
$/
)
window
.
location
.
hostname
==
'localhost'
||
// [::1] is the IPv6 localhost address.
window
.
location
.
hostname
==
'[::1]'
||
// 127.0.0.1/8 is considered localhost for IPv4.
window
.
location
.
hostname
.
match
(
/^127
(?:\.(?:
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
01
]?[
0-9
][
0-9
]?)){3}
$/
)
);
export
function
register
(
config
)
{
if
(
process
.
env
.
NODE_ENV
==
=
'production'
&&
'serviceWorker'
in
navigator
)
{
if
(
process
.
env
.
NODE_ENV
==
'production'
&&
'serviceWorker'
in
navigator
)
{
// The URL constructor is available in all browsers that support SW.
const
publicUrl
=
new
URL
(
process
.
env
.
PUBLIC_URL
,
window
.
location
.
href
);
if
(
publicUrl
.
origin
!==
window
.
location
.
origin
)
{
...
...
@@ -41,7 +41,7 @@ export function register(config) {
navigator
.
serviceWorker
.
ready
.
then
(()
=>
{
console
.
log
(
'This web app is being served cache-first by a service '
+
'worker. To learn more, visit https://bit.ly/CRA-PWA'
'worker. To learn more, visit https://bit.ly/CRA-PWA'
);
});
}
else
{
...
...
@@ -62,14 +62,14 @@ function registerValidSW(swUrl, config) {
return
;
}
installingWorker
.
onstatechange
=
()
=>
{
if
(
installingWorker
.
state
==
=
'installed'
)
{
if
(
installingWorker
.
state
==
'installed'
)
{
if
(
navigator
.
serviceWorker
.
controller
)
{
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console
.
log
(
'New content is available and will be used when all '
+
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
);
// Execute callback
...
...
@@ -102,7 +102,7 @@ function checkValidServiceWorker(swUrl, config) {
.
then
(
response
=>
{
// Ensure service worker exists, and that we really are getting a JS file.
const
contentType
=
response
.
headers
.
get
(
'content-type'
);
if
(
response
.
status
==
=
404
||
(
contentType
!=
null
&&
contentType
.
indexOf
(
'javascript'
)
=
==
-
1
))
{
if
(
response
.
status
==
404
||
(
contentType
!==
null
&&
contentType
.
indexOf
(
'javascript'
)
==
-
1
))
{
// No service worker found. Probably a different app. Reload the page.
navigator
.
serviceWorker
.
ready
.
then
(
registration
=>
{
registration
.
unregister
().
then
(()
=>
{
...
...
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