Showing
4 changed files
with
145 additions
and
0 deletions
apps/web/actions/keywords.js
0 → 100644
1 | +/** | ||
2 | + * | ||
3 | + * @author: jiangfeng<jeff.jiang@yoho.cn> | ||
4 | + * @date: 16/8/22 | ||
5 | + */ | ||
6 | + | ||
7 | +'use strict'; | ||
8 | + | ||
9 | +const Router = require('koa-router'); | ||
10 | +const moment = require('moment'); | ||
11 | + | ||
12 | +const { | ||
13 | + OperationLogger | ||
14 | +} = require('../../models'); | ||
15 | + | ||
16 | +const r = new Router(); | ||
17 | + | ||
18 | +r.get('/', async(ctx) => { | ||
19 | + await ctx.render('action/keywords'); | ||
20 | +}); | ||
21 | + | ||
22 | +// r.post('/log/query', async(ctx) => { | ||
23 | + | ||
24 | +// let q = ctx.request.body; | ||
25 | + | ||
26 | +// let start = parseInt(q.start || 0, 10); | ||
27 | +// let length = parseInt(q.length || 10, 10); | ||
28 | +// let draw = parseInt(q.draw, 10); | ||
29 | + | ||
30 | +// let sort = {time: -1}; | ||
31 | +// if (q.order && q.order.length > 0) { | ||
32 | +// let col = q.order[0].column; | ||
33 | +// let dir = q.order[0].dir === 'desc' ? -1 : 1; | ||
34 | + | ||
35 | +// col = parseInt(col, 10); | ||
36 | +// if (q.columns && q.columns.length > col) { | ||
37 | +// sort = {}; | ||
38 | +// sort[q.columns[col].data] = dir; | ||
39 | +// } | ||
40 | +// } | ||
41 | + | ||
42 | +// let logs = await OperationLogger.cfind({}).sort(sort).skip(start).limit(length).exec(); | ||
43 | +// let total = await OperationLogger.count(); | ||
44 | + | ||
45 | +// logs.forEach(l => { | ||
46 | +// l.username = l.user.username; | ||
47 | +// l.time = moment(l.time).format('YYYY-MM-DD HH:mm:ss.sss'); | ||
48 | +// l.meta = JSON.stringify(l.meta || {}); | ||
49 | +// }); | ||
50 | + | ||
51 | +// ctx.body = { | ||
52 | +// draw: draw, | ||
53 | +// recordsTotal: total, | ||
54 | +// recordsFiltered: total, | ||
55 | +// data: logs | ||
56 | +// }; | ||
57 | + | ||
58 | +// }); | ||
59 | + | ||
60 | +module.exports = r; |
@@ -16,6 +16,7 @@ const productCache = require('./actions/product_cache'); | @@ -16,6 +16,7 @@ const productCache = require('./actions/product_cache'); | ||
16 | const apiCache = require('./actions/api_cache'); | 16 | const apiCache = require('./actions/api_cache'); |
17 | const degrade = require('./actions/degrade'); | 17 | const degrade = require('./actions/degrade'); |
18 | const deploy = require('./actions/deploy'); | 18 | const deploy = require('./actions/deploy'); |
19 | +const keywords = require('./actions/keywords'); | ||
19 | const api = require('./actions/api'); | 20 | const api = require('./actions/api'); |
20 | const abuseProtection = require('./actions/abuse_protection'); | 21 | const abuseProtection = require('./actions/abuse_protection'); |
21 | const crawler = require('./actions/crawler'); | 22 | const crawler = require('./actions/crawler'); |
@@ -52,6 +53,7 @@ module.exports = function(app) { | @@ -52,6 +53,7 @@ module.exports = function(app) { | ||
52 | base.use('/api_cache', apiCache.routes(), apiCache.allowedMethods()); | 53 | base.use('/api_cache', apiCache.routes(), apiCache.allowedMethods()); |
53 | base.use('/degrade', degrade.routes(), degrade.allowedMethods()); | 54 | base.use('/degrade', degrade.routes(), degrade.allowedMethods()); |
54 | base.use('/deploys', deploy.routes(), deploy.allowedMethods()); | 55 | base.use('/deploys', deploy.routes(), deploy.allowedMethods()); |
56 | + base.use('/keywords', keywords.routes(), keywords.allowedMethods()); | ||
55 | 57 | ||
56 | const white = crawler('/crawler/ip_whitelists', '/crawler/ua_whitelists', '白名单', false); | 58 | const white = crawler('/crawler/ip_whitelists', '/crawler/ua_whitelists', '白名单', false); |
57 | const black = crawler('/crawler/ip_blacklists', '/crawler/ua_blacklists', '黑名单', true); | 59 | const black = crawler('/crawler/ip_blacklists', '/crawler/ua_blacklists', '黑名单', true); |
apps/web/views/action/keywords.hbs
0 → 100644
1 | +<div class="pageheader"> | ||
2 | + <div class="media"> | ||
3 | + <div class="pageicon pull-left"> | ||
4 | + <i class="fa fa-th-list"></i> | ||
5 | + </div> | ||
6 | + <div class="media-body"> | ||
7 | + <ul class="breadcrumb"> | ||
8 | + <li><a href="/"><i class="glyphicon glyphicon-home"></i></a></li> | ||
9 | + <li><a href="/keywords">关键词管理</a></li> | ||
10 | + </ul> | ||
11 | + <h4>关键词管理</h4> | ||
12 | + </div> | ||
13 | + </div> | ||
14 | + <!-- media --> | ||
15 | +</div> | ||
16 | + | ||
17 | +<div class="contentpanel project-index-page"> | ||
18 | + <div class="panel panel-default"> | ||
19 | + <div class="panel-body"> | ||
20 | + <table id="table-oper-log" class="table table-striped table-bordered building-table"> | ||
21 | + <thead> | ||
22 | + <tr> | ||
23 | + <th>操作用户</th> | ||
24 | + <th>时间</th> | ||
25 | + <th>动作</th> | ||
26 | + <th>描述</th> | ||
27 | + <th>数据</th> | ||
28 | + </tr> | ||
29 | + </thead> | ||
30 | + </table> | ||
31 | + </div> | ||
32 | + </div> | ||
33 | +</div> | ||
34 | + | ||
35 | +<div class="contentpanel project-index-page"> | ||
36 | + <div class="panel panel-default"> | ||
37 | + <div class="panel-heading"> | ||
38 | + <div class="pull-right"> | ||
39 | + <a href="" class="tooltips panel-minimize"><i class="fa fa-minus"></i></a> | ||
40 | + </div> | ||
41 | + <h4 class="panel-title">操作日志</h4> | ||
42 | + </div> | ||
43 | + <div class="panel-body"> | ||
44 | + <table id="table-oper-log" class="table table-striped table-bordered building-table"> | ||
45 | + <thead> | ||
46 | + <tr> | ||
47 | + <th>操作用户</th> | ||
48 | + <th>时间</th> | ||
49 | + <th>动作</th> | ||
50 | + <th>描述</th> | ||
51 | + <th>数据</th> | ||
52 | + </tr> | ||
53 | + </thead> | ||
54 | + </table> | ||
55 | + </div> | ||
56 | + </div> | ||
57 | +</div> | ||
58 | + | ||
59 | +<script> | ||
60 | + | ||
61 | + $(document).on('ready pjax:success', function() { | ||
62 | + $("#table-oper-log").DataTable({ | ||
63 | + pageLength: 25, | ||
64 | + retrieve: true, | ||
65 | + responsive: true, | ||
66 | + processing: true, | ||
67 | + serverSide: true, | ||
68 | + ajax: { | ||
69 | + url: '/operation/log/query', | ||
70 | + type: "POST" | ||
71 | + }, | ||
72 | + columns: [ | ||
73 | + {data: "username"}, | ||
74 | + {data: "time"}, | ||
75 | + {data: "action"}, | ||
76 | + {data: "description"}, | ||
77 | + {data: "meta"} | ||
78 | + ], | ||
79 | + order: [[1, 'desc']] | ||
80 | + }); | ||
81 | + }); | ||
82 | +</script> |
-
Please register or login to post a comment