Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
fengchao-admin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tf-boys
fengchao-admin
Commits
0132de15
Commit
0132de15
authored
Aug 08, 2017
by
刘松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
cff93891
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
89 additions
and
47 deletions
+89
-47
app.bundle.js
app/built/app.bundle.js
+0
-0
main.css
app/css/main.css
+25
-0
index.js
app/js/actions/index.js
+0
-1
dataReducer.js
app/js/reducers/dataReducer.js
+4
-4
dashboard.jsx
app/jsx/statistics/dashboard.jsx
+27
-5
detail.jsx
app/jsx/statistics/detail.jsx
+22
-24
index.js
config/index.js
+0
-6
statistics.js
lib/statistics.js
+11
-7
No files found.
app/built/app.bundle.js
View file @
0132de15
This diff is collapsed.
Click to expand it.
app/css/main.css
View file @
0132de15
...
...
@@ -64,3 +64,27 @@ body{
margin
:
16px
24px
16px
0
;
float
:
left
;
}
.box
{
box-shadow
:
0
0
1px
#ddd
;
background
:
#f7f7f7
;
border-radius
:
4px
;
display
:
flex
;
justify-content
:
flex-start
;
align-items
:
center
;
overflow
:
hidden
;
margin
:
5px
10px
;
}
.box
h3
{
width
:
40%
;
height
:
100%
;
padding
:
10px
;
color
:
#fff
;
text-align
:
center
;
background
:
#5587b3
;
}
.box
span
{
font-size
:
20px
;
width
:
58%
;
padding
:
0
20px
;
text-align
:
center
;
}
\ No newline at end of file
app/js/actions/index.js
View file @
0132de15
...
...
@@ -40,7 +40,6 @@ exports.getCountData= () => {
exports
.
getDetailData
=
(
data
)
=>
{
return
(
dispatch
)
=>
{
api
(
'POST'
,
'detail'
,
data
).
then
((
res
)
=>
{
console
.
dir
(
res
.
data
);
dispatch
({
status
:
res
.
result
,
data
:
res
.
data
,
type
:
types
.
DETAILDATA
});
});
};
...
...
app/js/reducers/dataReducer.js
View file @
0132de15
...
...
@@ -9,23 +9,23 @@ const defaultData = {
upstreams
:[],
upCount
:
0
,
userCount
:
0
,
count
:{
user
:
0
,
upstream
:
0
},
count
:{
user
:
0
,
upstream
:
0
,
admin
:
0
},
detail
:{
pagination
:{
current
:
1
,
total
:
1
,
pageSize
:
3
},
pagination
:{
current
:
1
,
total
:
1
,
pageSize
:
3
},
users
:[],
upstreams
:[]
},
range
:[
moment
().
subtract
(
6
,
'days'
).
format
(
'YYYYMMDD'
),
moment
().
format
(
'YYYYMMDD'
)]
};
module
.
exports
=
function
login
(
state
=
defaultData
,
action
)
{
module
.
exports
=
function
data
(
state
=
defaultData
,
action
)
{
switch
(
action
.
type
)
{
case
types
.
MAINDATA
:
return
_
.
assign
({},
state
,
{
status
:
action
.
status
,
userCount
:
action
.
data
.
userCount
,
upCount
:
action
.
data
.
upCount
,
users
:
action
.
data
.
users
,
upstreams
:
action
.
data
.
upstreams
,
range
:
action
.
data
.
range
});
case
types
.
COUNTDATA
:
return
_
.
assign
({},
state
,
{
count
:
action
.
data
});
case
types
.
DETAILDATA
:
return
_
.
assign
({},
state
,
{
detail
:
action
.
data
});
return
_
.
assign
({},
state
,
{
status
:
action
.
status
,
detail
:
action
.
data
});
default
:
return
state
;
}
...
...
app/jsx/statistics/dashboard.jsx
View file @
0132de15
...
...
@@ -3,7 +3,7 @@ const connect = require('react-redux').connect;
const
actions
=
require
(
'../../js/actions'
);
const
moment
=
require
(
'moment'
);
import
{
Table
,
Icon
,
DatePicker
,
Alert
}
from
'antd'
;
import
{
Table
,
Icon
,
DatePicker
,
Alert
,
Row
,
Col
}
from
'antd'
;
const
{
RangePicker
}
=
DatePicker
;
class
DashBoard
extends
React
.
Component
{
...
...
@@ -130,10 +130,32 @@ class DashBoard extends React.Component{
return
(
<
div
>
<
Alert
message
=
{
"截止目前,注册用户数
"
+
this
.
props
.
data
.
count
.
user
+
'
,绑定账号数
'
+
this
.
props
.
data
.
count
.
upstream
}
type
=
"
info
"
/>
<
Row
>
<
Col
span=
"6"
>
<
div
className
=
"
box
"
style=
{
{
marginLeft
:
'0px'
}
}
>
<
h3
>
用户数
</
h3
>
<
span
>
{
this
.
props
.
data
.
count
.
user
}
</
span
>
</
div
>
</
Col
>
<
Col
span=
"6"
>
<
div
className
=
"
box
"
>
<
h3
>
账号数
</
h3
>
<
span
>
{
this
.
props
.
data
.
count
.
upstream
}
</
span
>
</
div
>
</
Col
>
<
Col
span=
"6"
>
<
div
className
=
"
box
"
style=
{
{
marginRight
:
'0px'
}
}
>
<
h3
>
内部用户
</
h3
>
<
span
>
{
this
.
props
.
data
.
count
.
admin
}
</
span
>
</
div
>
</
Col
>
<
Col
span=
"6"
>
<
div
className
=
"
box
"
>
<
h3
>
外部用户
</
h3
>
<
span
>
{
this
.
props
.
data
.
count
.
upstream
-
this
.
props
.
data
.
count
.
admin
}
</
span
>
</
div
>
</
Col
>
</
Row
>
<
RangePicker
onChange=
{
this
.
onChange
.
bind
(
this
)
}
value=
{
ranges
}
format=
{
'YYYYMMDD'
}
style=
{
{
margin
:
'10px 0px'
}
}
/>
<
Table
columns=
{
columns
}
dataSource
=
{
data
}
size=
"middle"
/>
</
div
>
...
...
app/jsx/statistics/detail.jsx
View file @
0132de15
...
...
@@ -4,7 +4,7 @@ const actions = require('../../js/actions');
const
types
=
require
(
'../../js/actions/actionTypes'
);
const
moment
=
require
(
'moment'
);
import
{
Table
}
from
'antd'
;
import
{
Table
,
Spin
}
from
'antd'
;
class
Detail
extends
React
.
Component
{
constructor
(
props
){
...
...
@@ -15,6 +15,7 @@ class Detail extends React.Component{
componentDidMount
(){
let
limit
=
30
;
let
skip
=
0
;
// await this.props.dispatch({status:'pending',type:types.DETAILDATA});
this
.
props
.
dispatch
(
actions
.
getDetailData
({
limit
,
skip
}));
}
...
...
@@ -29,29 +30,6 @@ class Detail extends React.Component{
}
render
(){
let
users
=
this
.
props
.
data
.
detail
.
users
;
let
upstreams
=
this
.
props
.
data
.
detail
.
upstreams
;
console
.
dir
(
users
);
console
.
dir
(
upstreams
);
let
upMap
=
{};
let
data
=
[];
for
(
let
i
=
0
;
i
<
upstreams
.
length
;
i
++
){
let
id
=
upstreams
[
i
][
'_id'
][
'creater'
];
upMap
[
id
]
=
upstreams
[
i
][
'count'
];
}
for
(
let
i
=
0
;
i
<
users
.
length
;
i
++
){
let
item
=
users
[
i
];
data
.
push
({
key
:
i
,
name
:
item
[
'username'
]
||
'-'
,
phone
:
item
[
'phone'
]
||
'-'
,
ups
:
upMap
[
item
[
'_id'
]
]
||
0
,
date
:
moment
(
item
[
'createdAt'
]).
format
(
'YYYY/MM/DD hh:mm:ss'
)
})
}
console
.
dir
(
data
);
let
columns
=
[
{
title
:
'用户'
,
...
...
@@ -82,6 +60,26 @@ class Detail extends React.Component{
render
:
text
=>
<
a
href=
"#"
>
{
text
}
</
a
>,
},
];
let
users
=
this
.
props
.
data
.
detail
?
this
.
props
.
data
.
detail
.
users
:
[];
let
upstreams
=
this
.
props
.
data
.
detail
?
this
.
props
.
data
.
detail
.
upstreams
:
[];
let
upMap
=
{};
let
data
=
[];
for
(
let
i
=
0
;
i
<
upstreams
.
length
;
i
++
){
let
id
=
upstreams
[
i
][
'_id'
][
'creater'
];
upMap
[
id
]
=
upstreams
[
i
][
'count'
];
}
for
(
let
i
=
0
;
i
<
users
.
length
;
i
++
){
let
item
=
users
[
i
];
data
.
push
({
key
:
i
,
name
:
item
[
'username'
]
||
'-'
,
phone
:
item
[
'phone'
]
||
'-'
,
ups
:
upMap
[
item
[
'_id'
]
]
||
0
,
date
:
moment
(
item
[
'createdAt'
]).
format
(
'YYYY/MM/DD hh:mm:ss'
)
})
}
return
(
<
Table
columns=
{
columns
}
dataSource
=
{
data
}
pagination=
{
this
.
props
.
data
.
detail
.
pagination
}
size=
"middle"
onChange
=
{
this
.
handleTableChange
.
bind
(
this
)
}
/>
)
...
...
config/index.js
View file @
0132de15
try
{
module
.
exports
=
require
(
'./config_current.js'
);
}
catch
(
err
)
{
module
.
exports
=
require
(
'./config.default.js'
);
\ No newline at end of file
}
\ No newline at end of file
lib/statistics.js
View file @
0132de15
...
...
@@ -2,10 +2,11 @@ const express = require('request-promise');
const
user
=
require
(
'../db/mongo/user'
);
const
upstream
=
require
(
'../db/mongo/upstream'
);
const
moment
=
require
(
'moment'
);
const
mongoose
=
require
(
'mongoose'
);
exports
.
data
=
async
(
req
,
res
,
next
)
=>
{
let
{
start
,
end
}
=
req
.
body
;
const
condition
=
{
'$and'
:
[{
'createdAt'
:
{
'$gte'
:
moment
(
start
,
'YYYYMMDD'
).
startOf
(
'day'
).
toDate
()}},
{
'createdAt'
:
{
'$lt
e
'
:
moment
(
end
,
'YYYYMMDD'
).
endOf
(
'day'
).
toDate
()}}]};
const
condition
=
{
'$and'
:
[{
'createdAt'
:
{
'$gte'
:
moment
(
start
,
'YYYYMMDD'
).
startOf
(
'day'
).
toDate
()}},
{
'createdAt'
:
{
'$lt'
:
moment
(
end
,
'YYYYMMDD'
).
endOf
(
'day'
).
toDate
()}}]};
const
basicCondition
=
{
'createdAt'
:
{
'$lt'
:
moment
(
start
,
'YYYYMMDD'
).
startOf
(
'day'
).
toDate
()}};
console
.
dir
(
condition
[
'$and'
]);
console
.
dir
(
basicCondition
);
...
...
@@ -29,7 +30,7 @@ exports.data = async (req,res,next) => {
const
userPromise
=
await
user
.
aggregate
(
pipeline
);
const
basicUserPromise
=
await
user
.
count
(
basicCondition
);
const
upstreamPromise
=
await
upstream
.
aggregate
(
pipeline
);
const
basicUpstreamPromise
=
await
u
ser
.
count
(
basicCondition
);
const
basicUpstreamPromise
=
await
u
pstream
.
count
(
basicCondition
);
let
userResult
=
[];
let
upstreamsResult
=
[];
...
...
@@ -48,22 +49,25 @@ exports.count = async(req,res,next) => {
const
userPromise
=
await
user
.
count
({});
const
upstreamPromise
=
await
upstream
.
count
({});
const
adminPromise
=
await
upstream
.
count
({
creater
:
mongoose
.
Types
.
ObjectId
(
'58afdd80aa96916a41598698'
)
});
let
userCount
=
0
;
let
upstreamCount
=
0
;
await
Promise
.
all
([
userPromise
,
upstreamPromise
]).
then
(
([
users
,
upstreams
])
=>
{
let
adminCount
=
0
;
await
Promise
.
all
([
userPromise
,
upstreamPromise
,
adminPromise
]).
then
(
([
users
,
upstreams
,
admin
])
=>
{
userCount
=
users
;
upstreamCount
=
upstreams
;
adminCount
=
admin
;
});
res
.
send
({
result
:
'ok'
,
data
:
{
user
:
userCount
,
upstream
:
upstreamCount
}})
res
.
send
({
result
:
'ok'
,
data
:
{
user
:
userCount
,
upstream
:
upstreamCount
,
admin
:
adminCount
}})
}
exports
.
detail
=
async
(
req
,
res
,
next
)
=>
{
let
{
limit
=
3
,
skip
=
0
}
=
req
.
body
;
let
{
limit
=
3
0
,
skip
=
0
}
=
req
.
body
;
try
{
const
users
=
await
user
.
find
({},
null
,{
limit
:
limit
,
skip
:
skip
});
const
users
=
await
user
.
find
({},
null
,{
limit
:
parseInt
(
limit
),
skip
:
parseInt
(
skip
)
*
30
}).
sort
({
createdAt
:
-
1
});
const
total
=
await
user
.
count
({},
null
);
let
creaters
=
[];
users
.
forEach
(
item
=>
{
...
...
@@ -79,7 +83,7 @@ exports.detail = async(req,res,next) => {
}
];
const
upstreams
=
await
upstream
.
aggregate
(
pipeline
);
res
.
send
({
result
:
'ok'
,
data
:
{
users
:
users
.
map
(
x
=>
x
.
toJSON
()),
upstreams
:
upstreams
,
pagination
:{
current
:
skip
,
total
:
total
,
pageSize
:
limit
}}})
res
.
send
({
result
:
'ok'
,
data
:
{
users
:
users
.
map
(
x
=>
x
.
toJSON
()),
upstreams
:
upstreams
,
pagination
:{
current
:
parseInt
(
skip
),
total
:
total
,
pageSize
:
parseInt
(
limit
)
}}})
}
catch
(
err
)
{
console
.
dir
(
err
);
res
.
status
(
400
);
...
...
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