hejq 7 жил өмнө
parent
commit
6508ba878f

+ 14 - 12
src/main/webapp/WEB-INF/views/normal/logs.html

@@ -56,13 +56,16 @@
         word-wrap: break-word;
         max-height: 450px;
         max-width: 600px;
-        overflow: scroll;
+        overflow: auto;
     }
-    /*#pa_detail pre {
-        max-height: 200px;
-        max-width: 600px;
-        overflow: scroll;
-    }*/
+    #pa_detail pre {
+        outline: 1px solid #ccc; padding: 5px; margin: 5px;
+    }
+    .string { color: red; }
+    .number { color: purple; }
+    .boolean { color: blue; }
+    .null { color: magenta; }
+    .key { color: green; }
 </style>
 <div id="loadingDiv">
 	<div id="loadingImg">
@@ -114,7 +117,7 @@
             <th class="text-center" width="100">访问路径</th>
 			<th class="text-center" width="100">错误原因</th>
             <th class="text-center" width="150">详情</th>
-            <th class="text-center" width="120">参数</th>
+            <th class="text-center" width="50">参数</th>
 		</thead>
         <tbody id="logList-body">
         </tbody>
@@ -127,12 +130,11 @@
 <!-- 参数详情 -->
 <div class="modal fade" id="paraDetail" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
     <div class="modal-dialog">
-        <div class="modal-content">
-            <div class="modal-header">
-                参数详情
+        <div class="modal-content" id="para-main">
+            <div class="modal-header" id="para-title">
             </div>
-            <div class="modal-body">
-                <p id="para-content" readonly placeholder="暂无详情"></p>
+            <div class="modal-body" id="para-content">
+                <!--<p id="para-content" readonly placeholder="暂无详情"></p>-->
             </div>
             <div class="modal-footer">
                 <a type="button" class="btn btn-default" data-dismiss="modal">

+ 3 - 2
src/main/webapp/resources/js/account/enterprise.js

@@ -16,6 +16,7 @@ var enterpriseList = [];
 function getEnterpriseList(count, page, keyword) {
     $('#loadingDiv').show();
     enterpriseList = [];
+    $("#enterprise-body").empty();
     $.get('enterprise/list', {
         count: count,
         page: page,
@@ -24,7 +25,7 @@ function getEnterpriseList(count, page, keyword) {
         $('#loadingDiv').hide();
         enterpriseList = data.content;
         var pageNumber = data.number;
-        var pageSzie = data.size;
+        var pageSize = data.size;
         var total = data.totalElements;
         var totalPage = data.totalPages;
         var tbody = document.getElementById("enterprise-body");
@@ -61,7 +62,7 @@ function getEnterpriseList(count, page, keyword) {
             pageCount: totalPage,
             totalData: total,
             current: pageNumber,
-            showData: pageSzie,
+            showData: pageSize,
             coping: true,
             homePage: '首页',
             endPage: '末页',

+ 35 - 7
src/main/webapp/resources/js/common/log.js

@@ -15,6 +15,7 @@ var logList = [];
  */
 function getLogList(count, page, keyword, fromDate, endDate) {
     $('#loadingDiv').show();
+    $("#logList-body").empty();
     logList = [];
     $.get('log/errPage', {
         count: count,
@@ -39,7 +40,7 @@ function getLogList(count, page, keyword, fromDate, endDate) {
                 tbody.appendChild(trow);
                 (function(i) {
                     $("#para_detail_" + logList[i].id ).click(function () {
-                        getPara(logList[i].id);
+                        getPara(logList[i].id, logList[i].enName, logList[i].url);
                         $('#loadingDiv').show();
                     });
                 })(i)
@@ -88,15 +89,40 @@ function getLogList(count, page, keyword, fromDate, endDate) {
  *
  * @param id 主表id
  */
-function getPara(id) {
+function getPara(id, name, url) {
     $.get('log/para', {id: id}, function (data) {
-        var content = document.getElementById('para-content');
-        content.innerText = data.content;
+        $('#para-content').empty();
+        $('#para-title').empty();
+        $("<p style='font-size: 16px; font-weight: bold'>").text(name).appendTo("#para-title");
+        var result = JSON.stringify(JSON.parse(data.content), null, 4);
+        $("<pre>").html(syntaxHighlight(result)).appendTo("#para-content");
         $('#loadingDiv').hide();
         $('#paraDetail').modal('show');
     });
 }
 
+function syntaxHighlight(json) {
+    if (typeof json != 'string') {
+        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>';
+    });
+}
+
 /**
  * 建立表格数据
  *
@@ -134,6 +160,8 @@ function getDataRow(log, i) {
 
     var msgCell = document.createElement('td'); //msg
     msgCell.setAttribute("class", "text-center");
+    msgCell.setAttribute("title", log.msg);
+    msgCell.setAttribute("style", "max-height: 400px; overflow-y: auto;");
     msgCell.innerHTML = log.msg; //填充数据
     row.appendChild(msgCell);
 
@@ -142,13 +170,13 @@ function getDataRow(log, i) {
     detailCell.setAttribute("title", log.detail);
     detailCell.setAttribute("id", "pa_detail");
     var result = JSON.stringify(JSON.parse(log.detail), null, 4);
-    $("<pre>").text(result).appendTo(detailCell);
+    $("<pre>").html(syntaxHighlight(result)).appendTo(detailCell);
     row.appendChild(detailCell);
 
     var paraCell = document.createElement('td'); //parameters
     paraCell.setAttribute("class", "text-center");
-    paraCell.setAttribute("title", "查看详情");
-    paraCell.innerHTML = "查看参数详情"; //填充数据
+    paraCell.setAttribute("title", "查看参数详情");
+    paraCell.innerHTML = "详情"; //填充数据
     paraCell.setAttribute("id", "para_detail_" + log.id)
     row.appendChild(paraCell);