Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
kouling-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
刘松
kouling-admin
Commits
ac97648b
Commit
ac97648b
authored
Dec 07, 2017
by
刘松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix page
parent
50c5f4dd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
34 deletions
+79
-34
app.js
app.js
+5
-3
app.bundle.js
app/built/app.bundle.js
+0
-0
dashboard.jsx
app/jsx/statistics/dashboard.jsx
+42
-9
gather.jsx
app/jsx/statistics/gather.jsx
+18
-12
controller.js
lib/controller.js
+14
-10
No files found.
app.js
View file @
ac97648b
...
...
@@ -50,7 +50,9 @@ app.get('/manage/*', function (req, res){
app
.
use
(
routes
);
app
.
listen
(
config
.
port
);
console
.
log
(
'server started on port '
+
config
.
port
);
console
.
log
(
process
.
env
.
NODE_ENV
+
'server started on port '
+
config
.
port
);
if
(
process
.
env
.
NODE_ENV
===
'production'
){
cron
.
start
();
cron_gather
.
start
();
}
cron
.
start
();
cron_gather
.
start
();
app/built/app.bundle.js
View file @
ac97648b
This source diff could not be displayed because it is too large. You can
view the blob
instead.
app/jsx/statistics/dashboard.jsx
View file @
ac97648b
...
...
@@ -6,7 +6,8 @@ const api = require('../../js/api');
import
json2xlsx
from
'../../js/json2xlsx'
;
import
{
Table
,
Icon
,
DatePicker
,
Alert
,
Row
,
Col
,
Spin
,
Button
}
from
'antd'
;
import
{
Table
,
Icon
,
DatePicker
,
Alert
,
Row
,
Col
,
Spin
,
Button
,
Select
,
Radio
}
from
'antd'
;
const
Option
=
Select
.
Option
;
const
{
RangePicker
}
=
DatePicker
;
class
DashBoard
extends
React
.
Component
{
...
...
@@ -14,7 +15,7 @@ class DashBoard extends React.Component{
constructor
(
props
){
super
(
props
);
this
.
range
=
[
moment
().
subtract
(
6
,
'days'
).
format
(
'YYYYMMDD'
),
moment
().
format
(
'YYYYMMDD'
)];
this
.
state
=
{
logs
:[],
status
:
'pending'
,
pagination
:{
current
:
1
,
pageSize
:
100
,
total
:
1
}
};
this
.
state
=
{
logs
:[],
status
:
'pending'
,
pagination
:{
current
:
1
,
pageSize
:
100
,
total
:
1
}
,
sort
:
'updatedAt'
};
}
componentDidMount
(){
if
(
document
.
cookie
.
match
(
'username=[a-zA-Z0-9]+'
)[
0
]
&&
document
.
cookie
.
match
(
'username=[a-zA-Z0-9]+'
)[
0
].
split
(
'='
)[
1
]){
...
...
@@ -22,23 +23,21 @@ class DashBoard extends React.Component{
}
let
pagination
=
this
.
state
.
pagination
;
let
data
=
{
start
:
moment
().
add
(
-
6
,
'days'
).
format
(
'YYYYMMDD'
),
end
:
moment
().
format
(
'YYYYMMDD'
)};
api
(
'GET'
,
'logs?'
+
'skip=0&limit='
+
pagination
.
pageSize
).
then
((
res
)
=>
{
api
(
'GET'
,
'logs?'
+
'skip=0&limit='
+
pagination
.
pageSize
+
'&sort=updatedAt'
).
then
((
res
)
=>
{
this
.
setState
({
logs
:
res
.
result
,
status
:
'ready'
,
pagination
:{
current
:
res
.
pagination
.
skip
,
pageSize
:
res
.
pagination
.
limit
,
total
:
res
.
pagination
.
total
}})
console
.
dir
(
res
.
result
);
});
}
getlogs
(
pagination
){
getlogs
(
pagination
,
sort
){
this
.
setState
({
status
:
'pending'
});
api
(
'GET'
,
'logs?'
+
'skip='
+
(
pagination
.
current
-
1
)
+
'&limit='
+
pagination
.
pageSize
).
then
((
res
)
=>
{
api
(
'GET'
,
'logs?'
+
'skip='
+
(
pagination
.
current
-
1
)
+
'&limit='
+
pagination
.
pageSize
+
'&sort='
+
sort
).
then
((
res
)
=>
{
this
.
setState
({
logs
:
res
.
result
,
status
:
'ready'
,
pagination
:{
current
:
res
.
pagination
.
skip
,
pageSize
:
res
.
pagination
.
limit
,
total
:
res
.
pagination
.
total
}})
console
.
dir
(
res
.
result
);
});
}
onChange
(
pagination
)
{
//let data = { start:dateString[0],end:dateString[1]};
this
.
getlogs
(
pagination
);
this
.
getlogs
(
pagination
,
this
.
state
.
sort
);
//this.props.dispatch(actions.getMainData(data));
}
onChangeRange
(
date
,
dateString
){
...
...
@@ -49,8 +48,22 @@ class DashBoard extends React.Component{
//json2xlsx(data,{sheetName:"基础数据", filename : '基础数据'+moment().format('YYYYMMDD')+'.xlsx'});
}
handleSort
(
e
){
this
.
setState
({
sort
:
e
.
target
.
value
});
this
.
getlogs
({
current
:
1
,
pageSize
:
this
.
state
.
pagination
.
pageSize
},
e
.
target
.
value
);
}
handleChange
(
value
){
var
pagination
=
this
.
state
.
pagination
;
console
.
dir
(
pagination
);
pagination
[
'current'
]
=
1
;
pagination
[
'pageSize'
]
=
parseInt
(
value
);
this
.
setState
({
pagination
:
pagination
});
this
.
getlogs
(
pagination
,
this
.
state
.
sort
);
}
render
(){
console
.
dir
(
this
.
state
.
pagination
);
const
columns
=
[
{
title
:
'日期'
,
...
...
@@ -84,6 +97,7 @@ class DashBoard extends React.Component{
dataIndex
:
'qd'
,
key
:
'qd'
,
width
:
100
,
// sorter: (a, b) => { a.qd - b.qd},
render
:
text
=>
<
span
href=
"#"
>
{
text
}
</
span
>,
},
{
...
...
@@ -111,7 +125,6 @@ class DashBoard extends React.Component{
let
count
=
0
;
let
logs
=
this
.
state
.
logs
;
for
(
let
i
=
0
;
i
<
logs
.
length
;
i
++
){
console
.
dir
(
logs
[
i
]);
data
.
push
({
key
:
i
,
date
:
logs
[
i
].
date
,
...
...
@@ -130,6 +143,26 @@ class DashBoard extends React.Component{
<
Button
type=
"primary"
icon=
"export"
onClick=
{
this
.
exportData
.
bind
(
this
)
}
style=
{
{
float
:
'right'
,
margin
:
'10px 0px'
}
}
>
导出数据
</
Button
>
<
Radio
.
Group
value
=
{
this
.
state
.
sort
}
onChange=
{
this
.
handleSort
.
bind
(
this
)
}
style=
{
{
float
:
'right'
,
"margin"
:
'10px'
}
}
>
<
Radio
.
Button
value=
"updatedAt"
>
按更新
</
Radio
.
Button
>
<
Radio
.
Button
value=
"status"
>
按状态
</
Radio
.
Button
>
<
Radio
.
Button
value=
"schedule"
>
按计划
</
Radio
.
Button
>
<
Radio
.
Button
value=
"date"
>
按日期
</
Radio
.
Button
>
</
Radio
.
Group
>
<
Select
size
="
default
"
defaultValue=
"100"
value
=
{
this
.
state
.
pagination
.
pageSize
}
onChange=
{
this
.
handleChange
.
bind
(
this
)
}
style=
{
{
width
:
100
,
float
:
'right'
,
"margin"
:
'10px'
}
}
>
<
Option
key=
'10'
>
10
</
Option
>
<
Option
key=
'20'
>
20
</
Option
>
<
Option
key=
'50'
>
50
</
Option
>
<
Option
key=
'100'
>
100
</
Option
>
<
Option
key=
'200'
>
200
</
Option
>
<
Option
key=
'500'
>
500
</
Option
>
</
Select
>
<
Spin
spinning=
{
this
.
state
.
status
==
'pending'
}
>
<
Table
columns=
{
columns
}
dataSource
=
{
data
}
size=
"middle"
pagination=
{
this
.
state
.
pagination
}
onChange
=
{
this
.
onChange
.
bind
(
this
)}
bordered
/>
</
Spin
>
...
...
app/jsx/statistics/gather.jsx
View file @
ac97648b
...
...
@@ -14,15 +14,15 @@ class Gather extends React.Component{
constructor
(
props
){
super
(
props
);
this
.
range
=
[
moment
().
subtract
(
6
,
'days'
).
format
(
'YYYYMMDD'
),
moment
().
format
(
'YYYYMMDD'
)];
this
.
state
=
{
qdgathers
:[],
status
:
'pending'
,
pagination
:{
current
:
1
,
pageSize
:
1
0
,
total
:
100
},
username
:
'channel'
,
tody
:{
tkl_count
:
0
,
count
:
0
,
schedule_count
:
0
}
,
none_tkls
:[],
list
:[]};
this
.
state
=
{
qdgathers
:[],
status
:
'pending'
,
pagination
:{
current
:
1
,
pageSize
:
2
0
,
total
:
100
},
username
:
'channel'
,
tody
:{
tkl_count
:
0
,
count
:
0
,
schedule_count
:
0
}
,
none_tkls
:[],
list
:[]};
}
componentDidMount
(){
let
data
=
{
start
:
moment
().
add
(
-
6
,
'days'
).
format
(
'YYYYMMDD'
),
end
:
moment
().
format
(
'YYYYMMDD'
)};
if
(
document
.
cookie
.
match
(
'username=[a-zA-Z0-9]+'
)[
0
]
&&
document
.
cookie
.
match
(
'username=[a-zA-Z0-9]+'
)[
0
].
split
(
'='
)[
1
]){
this
.
setState
({
username
:
document
.
cookie
.
match
(
'username=[a-zA-Z0-9]+'
)[
0
].
split
(
'='
)[
1
]});
}
api
(
'GET'
,
'gathers/qd'
).
then
((
res
)
=>
{
this
.
setState
({
qdgathers
:
res
.
result
,
status
:
'ready'
,
none_tkls
:
res
.
none_tkls
,
list
:
res
.
list
});
api
(
'GET'
,
'gathers/qd
?skip=0&limit=20
'
).
then
((
res
)
=>
{
this
.
setState
({
qdgathers
:
res
.
result
,
status
:
'ready'
,
none_tkls
:
res
.
none_tkls
,
list
:
res
.
list
,
pagination
:{
current
:
res
.
pagination
.
skip
,
pageSize
:
res
.
pagination
.
limit
,
total
:
res
.
pagination
.
total
}
});
this
.
handle
(
res
.
list
,
res
.
tkl_count
)
});
}
...
...
@@ -36,7 +36,7 @@ class Gather extends React.Component{
}
getQdGathers
s
(
pagination
){
getQdGathers
(
pagination
){
this
.
setState
({
status
:
'pending'
})
api
(
'GET'
,
'gathers/qd?'
+
'skip='
+
(
pagination
.
current
-
1
)
+
'&limit='
+
pagination
.
pageSize
).
then
((
res
)
=>
{
this
.
setState
({
qdgathers
:
res
.
result
,
status
:
'ready'
,
pagination
:{
current
:
res
.
pagination
.
skip
,
pageSize
:
res
.
pagination
.
limit
,
total
:
res
.
pagination
.
total
},
none_tkls
:
res
.
none_tkls
,
list
:
res
.
list
});
...
...
@@ -44,9 +44,14 @@ class Gather extends React.Component{
});
}
onChange
(
date
,
dateString
)
{
let
data
=
{
start
:
dateString
[
0
],
end
:
dateString
[
1
]};
onChange
(
pagination
)
{
//
let data = { start:dateString[0],end:dateString[1]};
//this.props.dispatch(actions.getMainData(data));
this
.
getQdGathers
(
pagination
);
}
onChangeDate
(){
}
exportData
(){
...
...
@@ -55,12 +60,13 @@ class Gather extends React.Component{
}
render
(){
console
.
dir
(
this
.
state
.
pagination
);
const
columns
=
[
{
title
:
'日期'
,
dataIndex
:
'date'
,
key
:
'date'
,
width
:
10
0
,
width
:
8
0
,
render
:
text
=>
<
span
href=
"#"
>
{
text
}
</
span
>,
},
{
...
...
@@ -74,21 +80,21 @@ class Gather extends React.Component{
title
:
'请求数'
,
dataIndex
:
'times'
,
key
:
'times'
,
width
:
10
0
,
width
:
5
0
,
render
:
text
=>
<
span
href=
"#"
>
{
text
}
</
span
>,
},
{
title
:
'导出数'
,
dataIndex
:
'dc_times'
,
key
:
'dc_times'
,
width
:
10
0
,
width
:
5
0
,
render
:
text
=>
<
span
href=
"#"
>
{
text
}
</
span
>,
},
{
title
:
'导出率(%)'
,
dataIndex
:
'rate'
,
key
:
'rate'
,
width
:
10
0
,
width
:
5
0
,
render
:
text
=>
<
span
href=
"#"
>
{
text
}
</
span
>,
}
];
...
...
@@ -184,12 +190,12 @@ class Gather extends React.Component{
</
Col
>
</
Row
>
</
div
>
<
RangePicker
onChange=
{
this
.
onChange
.
bind
(
this
)
}
value=
{
ranges
}
format=
{
'YYYYMMDD'
}
style=
{
{
margin
:
'10px 0px'
}
}
/>
{
<
RangePicker
onChange=
{
this
.
onChangeDate
.
bind
(
this
)
}
value=
{
ranges
}
format=
{
'YYYYMMDD'
}
style=
{
{
margin
:
'10px 0px'
}
}
/>
}
<
Button
type=
"primary"
icon=
"export"
onClick=
{
this
.
exportData
.
bind
(
this
)
}
style=
{
{
float
:
'right'
,
margin
:
'10px 0px'
}
}
>
导出数据
</
Button
>
<
Spin
spinning=
{
this
.
state
.
status
==
'pending'
}
>
<
Table
columns=
{
columns
}
dataSource
=
{
data
}
size=
"middle"
bordered
/>
<
Table
columns=
{
columns
}
dataSource
=
{
data
}
pagination=
{
this
.
state
.
pagination
}
onChange
=
{
this
.
onChange
.
bind
(
this
)}
size=
"middle"
bordered
/>
</
Spin
>
</
div
>
)
...
...
lib/controller.js
View file @
ac97648b
...
...
@@ -63,12 +63,15 @@ exports.putTbkl = async (req, res, next) => {
};
exports
.
logs
=
async
(
req
,
res
,
next
)
=>
{
let
{
start
,
end
}
=
req
.
body
;
//const condition = {'$and': [{'createdAt': {'$gte': moment(start, 'YYYYMMDD').startOf('day').toDate()}}, {'createdAt': {'$lt': moment(end, 'YYYYMMDD').endOf('day').toDate()}}]};
let
sess
=
req
.
cookies
[
'sess'
];
if
(
sess
){
let
{
limit
=
100
,
skip
=
0
,
sort
=
{
'updatedAt'
:
-
1
}}
=
req
.
query
;
let
options
=
{
limit
:
parseInt
(
limit
),
skip
:
parseInt
(
skip
)
*
limit
,
sort
};
let
{
limit
=
100
,
skip
=
0
,
sort
=
'updatedAt'
}
=
req
.
query
;
var
sort_body
=
{};
if
(
sort
)
sort_body
[
sort
]
=
-
1
;
sort_body
[
'updatedAt'
]
=
-
1
;
console
.
dir
(
sort_body
);
let
options
=
{
limit
:
parseInt
(
limit
),
skip
:
parseInt
(
skip
)
*
limit
,
sort
:
sort_body
};
var
session_body
=
await
Session
.
findById
(
sess
);
var
logs
=
[];
var
total
=
0
;
...
...
@@ -89,7 +92,7 @@ exports.logs = async (req, res, next) => {
total
=
await
Log
.
count
(
qs
,
null
);
}
logs
=
logs
.
map
(
x
=>
{
var
d
=
x
.
toJSON
();
d
[
'updatedAt'
]
=
dateFormat
(
d
[
'updatedAt'
]);
return
d
;});
res
.
send
({
status
:
'ok'
,
result
:
logs
,
pagination
:{
total
:
total
,
skip
:
skip
,
limit
:
limit
}});
res
.
send
({
status
:
'ok'
,
result
:
logs
,
pagination
:{
total
:
total
,
skip
:
parseInt
(
skip
)
+
1
,
limit
:
limit
}});
}
else
{
res
.
status
(
400
).
send
(
not_login
);
...
...
@@ -156,11 +159,12 @@ exports.getQdGatherData = async (req, res, next) => {
});
none_tkls
=
await
Nonetkl
.
find
({
date
:
match_qs
[
'date'
]}).
populate
(
'qd'
,
'user'
).
limit
(
1000
);
}
console
.
dir
(
options
);
var
gatherDatas
=
await
GatherData
.
find
(
qs
,
null
,
options
).
populate
(
'qd'
,
'user'
);
let
total
=
await
GatherData
.
count
(
{}
,
null
);
let
total
=
await
GatherData
.
count
(
qs
,
null
);
let
tkl_count
=
await
Kouling
.
count
(
kl_qs
,
null
);
gatherDatas
=
gatherDatas
.
map
(
x
=>
{
var
d
=
x
.
toJSON
();
d
[
'date'
]
=
dateFormat
(
d
[
'date'
],
'YYYYMMDD'
);
return
d
;});
res
.
send
({
status
:
'ok'
,
result
:
gatherDatas
,
list
:
list
,
none_tkls
:
none_tkls
,
tkl_count
:
tkl_count
,
pagination
:{
total
:
total
,
skip
:
skip
,
limit
:
limit
}});
res
.
send
({
status
:
'ok'
,
result
:
gatherDatas
,
list
:
list
,
none_tkls
:
none_tkls
,
tkl_count
:
tkl_count
,
pagination
:{
total
:
total
,
skip
:
parseInt
(
skip
)
+
1
,
limit
:
limit
}});
}
else
{
res
.
status
(
400
).
send
(
not_login
);
...
...
@@ -178,7 +182,7 @@ exports.getTbkls = async (req, res, next) => {
let
tbkls
=
await
Kouling
.
find
({},
null
,
options
).
populate
(
'link'
,
'title target'
);
tbkls
=
tbkls
.
map
(
x
=>
{
var
d
=
x
.
toJSON
();
d
[
'createdAt'
]
=
dateFormat
(
d
[
'createdAt'
]);
return
d
;});
let
total
=
await
Kouling
.
count
({},
null
);
res
.
send
({
status
:
'ok'
,
result
:
tbkls
,
pagination
:{
total
:
total
,
skip
:
skip
,
limit
:
limit
}});
res
.
send
({
status
:
'ok'
,
result
:
tbkls
,
pagination
:{
total
:
total
,
skip
:
parseInt
(
skip
)
+
1
,
limit
:
limit
}});
}
exports
.
getLinks
=
async
(
req
,
res
,
next
)
=>
{
...
...
@@ -203,7 +207,7 @@ exports.getLinks = async (req, res, next) => {
});
}
});
res
.
send
({
status
:
'ok'
,
result
:
links
,
pagination
:{
total
:
total
,
skip
:
skip
,
limit
:
limit
}});
res
.
send
({
status
:
'ok'
,
result
:
links
,
pagination
:{
total
:
total
,
skip
:
parseInt
(
skip
)
+
1
,
limit
:
limit
}});
}
exports
.
createLink
=
async
(
req
,
res
,
next
)
=>
{
...
...
@@ -248,7 +252,7 @@ exports.getSchedules = async (req, res, next) => {
Promise
.
all
(
tasks
).
then
(
async
function
(
arr
){
let
total
=
await
Schedule
.
count
({},
null
);
schedules
=
schedules
.
map
(
(
x
,
i
)
=>
{
var
a
=
x
.
toJSON
();
a
[
'createdAt'
]
=
dateFormat
(
a
[
'createdAt'
]);
a
[
'count'
]
=
arr
[
i
];
return
a
});
res
.
send
({
status
:
'ok'
,
result
:
schedules
,
pagination
:{
total
:
total
,
skip
:
skip
,
limit
:
limit
}});
res
.
send
({
status
:
'ok'
,
result
:
schedules
,
pagination
:{
total
:
total
,
skip
:
parseInt
(
skip
)
+
1
,
limit
:
limit
}});
});
}
...
...
@@ -272,7 +276,7 @@ exports.getQds = async (req, res, next) => {
return
x
;
});
//console.dir(_arrs);
res
.
send
({
status
:
'ok'
,
result
:
qds
,
pagination
:{
total
:
total
,
skip
:
skip
,
limit
:
limit
}});
res
.
send
({
status
:
'ok'
,
result
:
qds
,
pagination
:{
total
:
total
,
skip
:
parseInt
(
skip
)
+
1
,
limit
:
limit
}});
}
exports
.
createQd
=
async
(
req
,
res
,
next
)
=>
{
...
...
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