增加功能:操作日志覆盖个人中心与网站设置 closed #ITBOY

https://gitee.com/LongbowEnterprise/dashboard/issues?id=ITBOY
This commit is contained in:
Argo Zhang 2019-03-09 19:09:42 +08:00
parent 3931656166
commit 89041a1721
6 changed files with 132 additions and 3 deletions

View File

@ -77,4 +77,31 @@
<div class="card-body">
<table></table>
</div>
</div>
</div>
@section modal {
<div class="modal fade" id="dialogRequestData" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="myModalLabel">请求数据明细窗口</h5>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-body">
<form class="form-inline">
<div class="form-row">
<div class="form-group col-12">
<pre id="requestData"></pre>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">
<i class="fa fa-times"></i>
<span>关闭</span>
</button>
</div>
</div>
</div>
</div>
}

View File

@ -569,3 +569,31 @@ li[data-category="1"] .dd3-content .menuType {
.bootstrap-table .badge {
padding: 4px 6px;
}
pre {
padding: 5px;
margin: 5px;
width: 100%;
border-radius: 4px;
border: solid 1px #ccc;
}
.string {
color: green;
}
.number {
color: darkorange;
}
.boolean {
color: blue;
}
.null {
color: magenta;
}
.key {
color: red;
}

View File

@ -33,6 +33,33 @@
},
'#btnReset': function () {
this.log({ crud: '重置密码' });
},
'#btnSaveDisplayName': function () {
this.log({ crud: '设置显示名称' });
},
'#btnSavePassword': function () {
this.log({ crud: '修改密码' });
},
'#btnSaveApp': function () {
this.log({ crud: '设置默认应用' });
},
'#btnSaveCss': function () {
this.log({ crud: '设置个人样式' });
},
'a.btn.fileinput-upload-button': function () {
this.log({ crud: '设置头像' });
},
'button.kv-file-remove': function () {
this.log({ crud: '删除头像' });
},
'button[data-method="title"]': function () {
this.log({ crud: '保存网站标题'});
},
'button[data-method="footer"]': function () {
this.log({ crud: '保存网站页脚' });
},
'button[data-method="css"]': function () {
this.log({ crud: '设置网站样式' });
}
}
};
@ -40,6 +67,8 @@
logPlugin.prototype = {
constructor: logPlugin,
log: function (data) {
var bcData = $.logData.shift();
if (bcData !== undefined) $.extend(data, { requestData: JSON.stringify(bcData) });
$.extend(data, { requestUrl: window.location.pathname });
$.post({
url: $.formatUrl(this.options.url),
@ -51,6 +80,7 @@
};
$.extend({ logPlugin: function (options) { return new logPlugin(options); } });
$.logData = [];
})(jQuery);
$(function () {

View File

@ -1,5 +1,7 @@
$(function () {
var url = 'api/Logs';
var $data = $('#requestData');
var $dialog = $('#dialogRequestData');
$('.card-body table').smartTable({
url: url,
@ -14,10 +16,22 @@
{ title: "操作地点", field: "City", sortable: true },
{ title: "浏览器", field: "Browser", sortable: true },
{ title: "操作系统", field: "OS", sortable: true },
{ title: "Url", field: "RequestUrl", sortable: true }
{ title: "操作页面", field: "RequestUrl", sortable: true },
{
title: "请求数据", field: "RequestData", sortable: true, formatter: function (value, row, index) {
return '<button class="detail btn btn-info"><i class="fa fa-info"></i><span>明细</span></button>';
},
events: {
'click .detail': function (e, value, row, index) {
$data.html($.syntaxHighlight(row.RequestData));
$dialog.modal('show');
}
}
}
],
exportOptions: {
fileName: "操作日志数据"
fileName: "操作日志数据",
ignoreColumn: [8]
}
});
});

View File

@ -208,6 +208,7 @@
xhrFields: { withCredentials: true },
crossDomain: true
});
if ($.isArray($.logData) && !$.isEmptyObject(options.data)) $.logData.push({ url: url, data: options.data });
$.ajax(ajaxSettings);
},
lgbSwal: function (options) {
@ -231,6 +232,30 @@
if (url.substr(0, 4) === "http") return url;
var base = $('#pathBase').attr('href');
return base + url;
},
syntaxHighlight: function (json) {
if (typeof (json) === 'string') {
json = JSON.parse(json);
}
json = JSON.stringify(json, undefined, 2);
json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,
function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
}
);
}
});

View File

@ -53,6 +53,11 @@ namespace Bootstrap.DataAccess
/// </summary>
public string RequestUrl { get; set; }
/// <summary>
/// 获得/设置 请求数据
/// </summary>
public string RequestData { get; set; }
/// <summary>
/// 查询所有日志信息
/// </summary>