Authored by shijian

关键词管理

/**
*
* @author: jiangfeng<jeff.jiang@yoho.cn>
* @date: 16/8/22
*/
'use strict';
const Router = require('koa-router');
const moment = require('moment');
const {
OperationLogger
} = require('../../models');
const r = new Router();
r.get('/', async(ctx) => {
await ctx.render('action/keywords');
});
// r.post('/log/query', async(ctx) => {
// let q = ctx.request.body;
// let start = parseInt(q.start || 0, 10);
// let length = parseInt(q.length || 10, 10);
// let draw = parseInt(q.draw, 10);
// let sort = {time: -1};
// if (q.order && q.order.length > 0) {
// let col = q.order[0].column;
// let dir = q.order[0].dir === 'desc' ? -1 : 1;
// col = parseInt(col, 10);
// if (q.columns && q.columns.length > col) {
// sort = {};
// sort[q.columns[col].data] = dir;
// }
// }
// let logs = await OperationLogger.cfind({}).sort(sort).skip(start).limit(length).exec();
// let total = await OperationLogger.count();
// logs.forEach(l => {
// l.username = l.user.username;
// l.time = moment(l.time).format('YYYY-MM-DD HH:mm:ss.sss');
// l.meta = JSON.stringify(l.meta || {});
// });
// ctx.body = {
// draw: draw,
// recordsTotal: total,
// recordsFiltered: total,
// data: logs
// };
// });
module.exports = r;
... ...
... ... @@ -16,6 +16,7 @@ const productCache = require('./actions/product_cache');
const apiCache = require('./actions/api_cache');
const degrade = require('./actions/degrade');
const deploy = require('./actions/deploy');
const keywords = require('./actions/keywords');
const api = require('./actions/api');
const abuseProtection = require('./actions/abuse_protection');
const crawler = require('./actions/crawler');
... ... @@ -52,6 +53,7 @@ module.exports = function(app) {
base.use('/api_cache', apiCache.routes(), apiCache.allowedMethods());
base.use('/degrade', degrade.routes(), degrade.allowedMethods());
base.use('/deploys', deploy.routes(), deploy.allowedMethods());
base.use('/keywords', keywords.routes(), keywords.allowedMethods());
const white = crawler('/crawler/ip_whitelists', '/crawler/ua_whitelists', '白名单', false);
const black = crawler('/crawler/ip_blacklists', '/crawler/ua_blacklists', '黑名单', true);
... ...
<div class="pageheader">
<div class="media">
<div class="pageicon pull-left">
<i class="fa fa-th-list"></i>
</div>
<div class="media-body">
<ul class="breadcrumb">
<li><a href="/"><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="/keywords">关键词管理</a></li>
</ul>
<h4>关键词管理</h4>
</div>
</div>
<!-- media -->
</div>
<div class="contentpanel project-index-page">
<div class="panel panel-default">
<div class="panel-body">
<table id="table-oper-log" class="table table-striped table-bordered building-table">
<thead>
<tr>
<th>操作用户</th>
<th>时间</th>
<th>动作</th>
<th>描述</th>
<th>数据</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
<div class="contentpanel project-index-page">
<div class="panel panel-default">
<div class="panel-heading">
<div class="pull-right">
<a href="" class="tooltips panel-minimize"><i class="fa fa-minus"></i></a>
</div>
<h4 class="panel-title">操作日志</h4>
</div>
<div class="panel-body">
<table id="table-oper-log" class="table table-striped table-bordered building-table">
<thead>
<tr>
<th>操作用户</th>
<th>时间</th>
<th>动作</th>
<th>描述</th>
<th>数据</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
<script>
$(document).on('ready pjax:success', function() {
$("#table-oper-log").DataTable({
pageLength: 25,
retrieve: true,
responsive: true,
processing: true,
serverSide: true,
ajax: {
url: '/operation/log/query',
type: "POST"
},
columns: [
{data: "username"},
{data: "time"},
{data: "action"},
{data: "description"},
{data: "meta"}
],
order: [[1, 'desc']]
});
});
</script>
\ No newline at end of file
... ...
... ... @@ -66,6 +66,7 @@
<li><a href="/check/list">代码检查</a></li>
</ul>
</li>
<li><a href="/keywords"><i class="fa fa-list"></i> <span>关键词管理</span></a></li>
{{/if}}
</ul>
... ...