// 在WSHandler的onUserList之类的方法里使用。 // ----------------------------------------------- var loadAuditLog = function() { $('[data-toggle="tooltip"]').tooltip(); console.log("loadAuditLog!"); changePie1Time($("#pie1")[0].value); changePie2Time($("#pie2")[0].value); changeLine1Time($("#line1")[0].value); changeLine2Time($("#line2")[0].value); document.getElementById('manageLogInput').value="2"; changeManageLogTime(2); //默认查看近2天的日志 document.getElementById('CMLogInput').value="2"; changeCMLogTime(2); }; var changePie1Time = function(data){ var time = data.split("天")[0]; setTimeout(function() { var arg = {}; arg.action = "listManageLogPie"; arg.date = new Date().getTime() - 24 * 3600 * 1000 * time; global.wssocket.send(JSON.stringify(arg)); }, 300); }; var changePie2Time = function(data){ var time = data.split("天")[0]; setTimeout(function() { var arg = {}; arg.action = "listCMLogPie"; arg.date = new Date().getTime() - 24 * 3600 * 1000 * time; global.wssocket.send(JSON.stringify(arg)); }, 300); }; var changeLine1Time = function(data){ var time = data.split("天")[0]; global.ManageLineTime = time; setTimeout(function() { var arg = {}; arg.action = "listManageLogLine"; arg.date = new Date().getTime() - 24 * 3600 * 1000 * global.ManageLineTime; arg.start = getDateDaysBefore(global.ManageLineTime); global.wssocket.send(JSON.stringify(arg)); }, 300); }; var changeLine2Time = function(data){ var time = data.split("天")[0]; global.CMLineTime = time; setTimeout(function() { var arg = {}; arg.action = "listCMLogLine"; arg.date = new Date().getTime() - 24 * 3600 * 1000 * global.CMLineTime; arg.start = getDateDaysBefore(global.CMLineTime); global.wssocket.send(JSON.stringify(arg)); }, 300); }; var onListManageLogPie = function(data){ //console.log(data.data); drawLogPie("auditLogPieDiv", data.data, logActionToCategory); }; var onListCMLogPie = function(data){ //console.log(data.data); drawLogPie("auditCMLogPieDiv", data.data, cmActionToCategory); }; var onListManageLogLine = function(data){ //console.log(data.data); drawLogBar("auditLogBarDiv", data); }; var onListCMLogLine = function(data){ //console.log(data.data); drawLogBar("auditCMLogBarDiv", data); }; var customAlert = function(message, title) { if (!title) title = '提示'; if (!message) message = 'No Message to Display.'; $('
').html(message).dialog({ title : title, resizable : false, modal : true, buttons : { 'Ok' : function() { $(this).dialog('close'); } } }); }; var changeManageLogTime = function(){ var data = document.getElementById('manageLogInput').value; data = parseInt(data); // console.log(data); if(data > 30 || data < 1){ customAlert("超出时间范围!"); return; } global.manageLogTime = parseInt(data); setTimeout(function() { var arg = {}; arg.action = "queryActionLog"; arg.date = new Date().getTime() - 24 * 3600 * 1000 * global.manageLogTime; global.wssocket.send(JSON.stringify(arg)); }, 300); }; var changeCMLogTime = function(){ var data = document.getElementById('CMLogInput').value; data = parseInt(data); // console.log(data); if(data > 30 || data < 1){ customAlert("超出时间范围!"); return; } global.CMLogTime = parseInt(data); setTimeout(function() { var arg = {}; arg.date = new Date().getTime() - 24 * 3600 * 1000 * global.CMLogTime; arg.action = "queryCMLog"; arg.reverse = true; arg.filter = "syncPing"; global.wssocket.send(JSON.stringify(arg)); }, 300); }; var auditConf = { firstRowHeight : '200px' }; // ----------------------------------------------- var logActionToCategory = function(action) { switch (action) { case 'getSessionID': case 'login': case 'getRole': return "登录类"; case 'listAllUsers': case 'listApplyList': case 'applyRole': case 'accept': case 'delete': case 'authNodeManager': return "用户类"; case 'queryCMLog': case 'queryActionLog': case 'queryUserStat': case 'listManageLogPie': case 'listCMLogPie': case 'listManageLogLine': case 'listCMLogLine': return "日志类"; case 'listLicence': case 'updateLicence': case 'listNodes': case 'listTrustUnits': case 'getNodeTrustUnits': case 'distributeContract': case 'startContractTrustfully': case 'createTrustUnit': return "维护类"; default:{ // console.log(action); return "其他类"; } } }; var cmActionToCategory = function(action) { switch (action) { case "syncPing": return undefined; case "setNodeID": case "onGetUDPID": return "连接类"; case "listCMInfo": case "updateContract": return "状态更新类"; case "pubEvent": case "subEvent": case "executeContractOnOtherNodes": case "eonReceiveContractExecution": case "receiveProject": case "onReceiveProject": case 'onStartEachNode': return "合约执行类"; default:{ // console.log(action); return "其他类"; } } }; var drawLogPie = function(id, data, cateFun) { if(id == "auditLogPieDiv"){ $("#Pie1").html("管理操作分类统计(" + global.manageLogTime + "日)"); }else if(id == "auditCMLogPieDiv"){ $("#Pie2").html("合约操作分类统计(" + global.CMLogTime + "日)"); } if ($("#" + id).css("height") == "0px") { console.log("drawLogPie: ignore"); return; } $("#" + id).html( ""); var result = {}; for (var i = 0; i < data.length; i++) { var obj = JSON.parse(data[i]); var act = cateFun(obj.action) if (act == undefined) continue; if (result[act] == undefined) { result[act] = obj.times; } else result[act] += obj.times; } global.result = result; var dataList = []; var valDataList = []; for ( var key in result) { dataList.push(key); var l = {}; l.name = key l.value = result[key]; valDataList.push(l); } var myChart = echarts.init($("#" + id + "Canv")[0], 'walden'); var option222 = { toolbox : { show : true, feature : { restore : {}, saveAsImage : {} } }, tooltip : { trigger : 'item', formatter : '{a}序号 | 时间 | 操作 | 公钥 |
---|