更新log框架,使log全局监控按钮
This commit is contained in:
parent
3a2c89f289
commit
6419ca64e7
|
@ -1,22 +1,9 @@
|
||||||
(function ($) {
|
(function ($) {
|
||||||
LogPlugin = function (options) {
|
logPlugin = function (options) {
|
||||||
var that = this;
|
this.options = $.extend({}, logPlugin.settings, options);
|
||||||
this.options = $.extend({}, LogPlugin.settings, options);
|
|
||||||
|
|
||||||
// handler click event
|
|
||||||
for (name in this.options.click) {
|
|
||||||
var cId = this.options.click[name];
|
|
||||||
var source = $("#" + cId);
|
|
||||||
source.data('click', name);
|
|
||||||
source.click(function () {
|
|
||||||
var method = $(this).data('click');
|
|
||||||
LogPlugin.prototype[method].call(that, this);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPlugin.settings = {
|
logPlugin.settings = {
|
||||||
url: '../api/Logs',
|
url: '../api/Logs',
|
||||||
click: {
|
click: {
|
||||||
query: 'btn_query',
|
query: 'btn_query',
|
||||||
|
@ -25,14 +12,43 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPlugin.prototype = {
|
logPlugin.prototype = {
|
||||||
constructor: LogPlugin,
|
constructor: logPlugin,
|
||||||
|
init: function () {
|
||||||
|
var that = this;
|
||||||
|
// handler click event
|
||||||
|
for (name in this.options.click) {
|
||||||
|
var cId = this.options.click[name];
|
||||||
|
var source = $("#" + cId);
|
||||||
|
source.data('click', name);
|
||||||
|
source.click(function () {
|
||||||
|
var method = $(this).data('click');
|
||||||
|
logPlugin.prototype[method].call(that, this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
query: function (element) {
|
query: function (element) {
|
||||||
log(this.options.url, { crud: 'Query' });
|
//log(this.options.url, { crud: '查询' });
|
||||||
|
},
|
||||||
|
save: function () {
|
||||||
|
log(this.options.url, { crud: '保存' });
|
||||||
|
},
|
||||||
|
del: function () {
|
||||||
|
log(this.options.url, { crud: '删除' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logPlugin.init = function (options) {
|
||||||
|
var log = new logPlugin(options);
|
||||||
|
log.init();
|
||||||
|
}
|
||||||
|
|
||||||
var log = function (url, data) {
|
var log = function (url, data) {
|
||||||
|
$.extend(data, { requestUrl: window.location.pathname });
|
||||||
$.post(url, data);
|
$.post(url, data);
|
||||||
}
|
}
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
logPlugin.init();
|
||||||
|
});
|
|
@ -34,7 +34,6 @@ namespace Bootstrap.Admin.Controllers
|
||||||
{
|
{
|
||||||
var request = HttpContext.Current.Request;
|
var request = HttpContext.Current.Request;
|
||||||
value.ClientAgent = request.UserAgent;
|
value.ClientAgent = request.UserAgent;
|
||||||
value.RequestUrl = request.Url.AbsolutePath;
|
|
||||||
value.ClientIp = request.UserHostAddress;
|
value.ClientIp = request.UserHostAddress;
|
||||||
value.UserName = HttpContext.Current.User.Identity.Name;
|
value.UserName = HttpContext.Current.User.Identity.Name;
|
||||||
return LogHelper.SaveLog(value);
|
return LogHelper.SaveLog(value);
|
||||||
|
|
|
@ -17,5 +17,4 @@
|
||||||
{ title: "操作模块", field: "RequestUrl", sortable: false }
|
{ title: "操作模块", field: "RequestUrl", sortable: false }
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
var log = new LogPlugin();
|
|
||||||
});
|
});
|
|
@ -16,7 +16,6 @@
|
||||||
<script src="~/Content/js/jquery.scrollTo.js"></script>
|
<script src="~/Content/js/jquery.scrollTo.js"></script>
|
||||||
<script src="~/Content/js/jquery.nicescroll.min.js"></script>
|
<script src="~/Content/js/jquery.nicescroll.min.js"></script>
|
||||||
<script src="~/Content/js/common-scripts.js"></script>
|
<script src="~/Content/js/common-scripts.js"></script>
|
||||||
<script src="~/Content/js/jQuery.cookie.js"></script>
|
|
||||||
<script src="~/Content/js/log.js"></script>
|
<script src="~/Content/js/log.js"></script>
|
||||||
<script src="~/Content/js/framework.js"></script>
|
<script src="~/Content/js/framework.js"></script>
|
||||||
@RenderSection("Javascript", false)
|
@RenderSection("Javascript", false)
|
||||||
|
|
Loading…
Reference in New Issue