Commit 604d20f214f6675dffb8a175b28c054cdf3650e3

Authored by DESKTOP-AO0VKC8\mahua
2 parents e676f892 67428a55

Merge remote-tracking branch 'origin/develop' into develop

src/main/resources/templates/monitor/apilog/apilog.html
... ... @@ -118,11 +118,15 @@
118 118 align: 'center',
119 119 formatter: function (value, row, index) {
120 120 var actions = [];
121   - actions.push('<a class="btn btn-success btn-xs " href="#" onclick="$.operate.detail(\'' + row.id + '\')">详情</a> ');
  121 + actions.push('<a class="btn btn-success btn-xs " href="#" onclick="$.operate.detail(' + row.id + ')">详情</a> ');
122 122 return actions.join('');
123 123 }
124 124 },
125 125 {
  126 + field: 'requestFrom',
  127 + title: 'from'
  128 + },
  129 + {
126 130 field: 'apiName',
127 131 title: 'API'
128 132 },
... ... @@ -132,10 +136,7 @@
132 136 title: 'IP'
133 137 },
134 138 **/
135   - {
136   - field: 'requestFrom',
137   - title: 'from'
138   - },
  139 +
139 140 {
140 141 field: 'responseBy',
141 142 title: 'to'
... ... @@ -212,7 +213,7 @@
212 213 var actions = [];
213 214 if(value == undefined)
214 215 value = " "
215   - actions.push('<pre style="white-space: pre-wrap; width:400px" ondblclick="parseJson(this)" title="双击格式化">'+value+ '</pre>')
  216 + actions.push('<pre style="white-space: pre-wrap; width:350px" ondblclick="copy(this)" title="双击复制">'+value+ '</pre>')
216 217 return actions.join(" ")
217 218 }
218 219 },
... ... @@ -229,7 +230,7 @@
229 230 var actions = [];
230 231 if(value == undefined)
231 232 value = " "
232   - actions.push('<pre style="white-space: pre-wrap; width:400px" ondblclick="parseJson(this)" title="双击格式化">'+value+ '</pre>')
  233 + actions.push('<pre style="white-space: pre-wrap; width:350px" ondblclick="copy(this)" title="双击复制">'+value+ '</pre>')
233 234 return actions.join(" ")
234 235 }
235 236 },
... ... @@ -250,15 +251,36 @@
250 251 $.table.init(options);
251 252 });
252 253  
  254 + /**
253 255 function parseJson(obj){
254 256 var str = obj.innerHTML
255 257 try {
256 258 str = JSON.parse(str);
257   - obj.outerHTML = '<pre style="white-space: pre-wrap; width:400px">' + JSON.stringify(str, null, 2) + '</pre>';
  259 + obj.outerHTML = '<pre style="white-space: pre-wrap; width:350px" ondblclick="unParse(this)">' + JSON.stringify(str, null, 2) + '</pre>';
258 260 }catch (e) {
259 261 str = str.split("&amp;").join("&#10;")
260   - obj.outerHTML = '<pre style="white-space: pre-wrap; width:400px">' + str + '</pre>';
  262 + obj.outerHTML = '<pre style="white-space: pre-wrap; width:350px" ondblclick="unParse(this)">' + str + '</pre>';
  263 + }
  264 + }
  265 +
  266 + function unParse(obj) {
  267 + var str = obj.innerHTML;
  268 +
  269 + obj.outerHTML = '<pre style="white-space: pre-wrap; width:350px" ondblclick="parseJson(this)" title="双击格式化">'+str.replaceAll("\n","")+ '</pre>'
  270 + }
  271 + **/
  272 +
  273 + function copy(obj) {
  274 + let transfer = document.createElement('textarea');
  275 + document.body.appendChild(transfer);
  276 + transfer.value = obj.innerHTML;
  277 + // transfer.focus();
  278 + transfer.select();
  279 + if (document.execCommand('copy')) {
  280 + document.execCommand('copy');
261 281 }
  282 + transfer.blur();
  283 + document.body.removeChild(transfer);
262 284 }
263 285 </script>
264 286 </body>
... ...
src/main/resources/templates/monitor/apilog/detail.html
... ... @@ -13,6 +13,9 @@
13 13 .green{
14 14 color:green;
15 15 }
  16 + .hideCopy{
  17 + display: none;
  18 + }
16 19 </style>
17 20 </head>
18 21 <body class="white-bg">
... ... @@ -28,7 +31,7 @@
28 31 </div>
29 32 <div class="">
30 33 <label class="col-sm-2 mylabel">请求方ip:</label>
31   - <label class="col-sm-10" th:text="${apiLog.getIp()}==null?'&nbsp;':${apiLog.getIp()} + '&nbsp;'"></label>
  34 + <label class="col-sm-10" th:text="${#strings.defaultString(apiLog.getIp(), '&nbsp;')} + '&nbsp;'"></label>
32 35 </div>
33 36 <div class="">
34 37 <label class="col-sm-2 mylabel">调用方向:</label>
... ... @@ -36,15 +39,15 @@
36 39 </div>
37 40 <div class="">
38 41 <label class="col-sm-2 mylabel">Method:</label>
39   - <label class="col-sm-10" th:text="${apiLog.getApiMethod()}"></label>
  42 + <label class="col-sm-10" th:text="${#strings.defaultString(apiLog.getApiMethod(),'&nbsp;')}"></label>
40 43 </div>
41 44 <div class="">
42 45 <label class="col-sm-2 mylabel">接口地址:</label>
43   - <label class="col-sm-10" th:text="${apiLog.getUrl()}"></label>
  46 + <label class="col-sm-10" th:text="${#strings.defaultString(apiLog.getUrl(), '&nbsp;')}"></label>
44 47 </div>
45 48 <div class="">
46 49 <label class="col-sm-2 mylabel">请求时间:</label>
47   - <label class="col-sm-10" th:text="${#dates.format(apiLog.requestTime, 'yyyy-MM-dd HH:mm:ss')}"></label>
  50 + <label class="col-sm-10" th:text="${#strings.defaultString(#dates.format(apiLog.requestTime, 'yyyy-MM-dd HH:mm:ss'), '&nbsp;')}"></label>
48 51 </div>
49 52 <!--<div class="">-->
50 53 <!--<label class="col-sm-2 mylabel">响应时间:</label>-->
... ... @@ -52,31 +55,36 @@
52 55 <!--</div>-->
53 56 <div class="" th:classappend="${apiLog.getDuration()}>=1000?'red'">
54 57 <label class="col-sm-2 mylabel">耗时:</label>
55   - <label class="col-sm-10" th:text="${apiLog.getDuration()} + ' 毫秒'"></label>
  58 + <label class="col-sm-10" th:text="${#strings.defaultString(apiLog.getDuration(), '&nbsp;')} + ' 毫秒'"></label>
56 59 </div>
57 60 <div class="" th:classappend="${apiLog.getHttpCode()}=='200'?'green':'red'">
58 61 <label class="col-sm-2 mylabel">HttpCode:</label>
59   - <label class="col-sm-10" th:text="${apiLog.getHttpCode()}==null?'&nbsp;':${apiLog.getHttpCode()}"></label>
  62 + <label class="col-sm-10" th:text="${#strings.defaultString(apiLog.getHttpCode(), '&nbsp;')}"></label>
60 63 </div>
61 64 <div class="" th:classappend="${apiLog.getRetCode()}=='200'?'green':'red'">
62 65 <label class="col-sm-2 mylabel">RetCode:</label>
63   - <label class="col-sm-10" th:text="${apiLog.getRetCode()}==null?'&nbsp;':${apiLog.getRetCode()}"></label>
  66 + <label class="col-sm-10" th:text="${#strings.defaultString(apiLog.getRetCode(), '&nbsp;')}"></label>
64 67 </div>
65 68 <div class="">
66   - <label class="col-sm-2 mylabel">请求头:</label>
67   - <div class="col-sm-10"><pre style="white-space: pre-wrap;" th:text="${apiLog.getRequestHeader()}"></pre></div>
  69 + <label class="col-sm-2 mylabel">请求头:
  70 + </label>
  71 + <div class="col-sm-9"><pre id="reqHeader" style="white-space: pre-wrap;" th:text="${apiLog.getRequestHeader()}"></pre></div>
  72 + <div class="col-sm-1 "><a class="btn btn-success btn-xs" th:classappend="${#strings.isEmpty(apiLog.getRequestHeader())}?' hideCopy':''" href="javacript:void(0);" onclick="copy('reqHeader')">复制</a></div>
68 73 </div>
69 74 <div class="">
70 75 <label class="col-sm-2 mylabel">响应头:</label>
71   - <div class="col-sm-10"><pre style="white-space: pre-wrap;" th:text="${apiLog.getResponseHeader()}"></pre></div>
  76 + <div class="col-sm-9"><pre id="respHeader" style="white-space: pre-wrap;" th:text="${apiLog.getResponseHeader()}"></pre></div>
  77 + <div class="col-sm-1 "><a class="btn btn-success btn-xs" th:classappend="${#strings.isEmpty(apiLog.getResponseHeader())}?' hideCopy':''" href="javacript:void(0);" onclick="copy('respHeader')">复制</a></div>
72 78 </div>
73 79 <div class="">
74 80 <label class="col-sm-2 mylabel">请求内容:</label>
75   - <div class="col-sm-10"><pre id="preReqBody" style="white-space: pre-wrap;" th:text="${apiLog.getRequestBody()}"></pre></div>
  81 + <div class="col-sm-9"><pre id="reqBody" style="white-space: pre-wrap;" th:text="${apiLog.getRequestBody()}"></pre></div>
  82 + <div class="col-sm-1 "><a class="btn btn-success btn-xs" th:classappend="${#strings.isEmpty(apiLog.getRequestBody())}?' hideCopy':''" href="javacript:void(0);" onclick="copy('reqBody')">复制</a></div>
76 83 </div>
77 84 <div class="">
78 85 <label class="col-sm-2 mylabel">响应内容:</label>
79   - <div class="col-sm-10"><pre id="preRespBody" style="white-space: pre-wrap;" th:text="${apiLog.getResponseBody()}"></pre></div>
  86 + <div class="col-sm-9"><pre id="respBody" style="white-space: pre-wrap;" th:text="${apiLog.getResponseBody()}"></pre></div>
  87 + <div class="col-sm-1 "><a class="btn btn-success btn-xs" th:classappend="${#strings.isEmpty(apiLog.getResponseBody())}?' hideCopy':''" href="javacript:void(0);" onclick="copy('respBody')">复制</a></div>
80 88 </div>
81 89 <!--<div class="">-->
82 90 <!--<label class="col-sm-2 mylabel">httpCode:</label>-->
... ... @@ -89,7 +97,8 @@
89 97 <!--</div>-->
90 98 <div class="" th:classappend="${apiLog.getException()}!=null?'red'">
91 99 <label class="col-sm-2 mylabel">异常信息:</label>
92   - <div class="col-sm-10"><pre style="white-space: pre-wrap;" th:text="${apiLog.getException()}"></pre></div>
  100 + <div class="col-sm-9"><pre id="exception" style="white-space: pre-wrap;" th:text="${apiLog.getException()}"></pre></div>
  101 + <div class="col-sm-1 "><a class="btn btn-success btn-xs" th:classappend="${#strings.isEmpty(apiLog.getException())}?' hideCopy':''" href="javacript:void(0);" onclick="copy('exception')">复制</a></div>
93 102 </div>
94 103 </div>
95 104 </div>
... ... @@ -108,8 +117,25 @@
108 117 }
109 118 }
110 119  
111   - parseJson(document.getElementById("preReqBody"))
112   - parseJson(document.getElementById("preRespBody"))
  120 + parseJson(document.getElementById("reqBody"))
  121 + parseJson(document.getElementById("respBody"))
  122 +
  123 + function copy(id) {
  124 + var obj = document.getElementById(id)
  125 + if(obj.innerHTML == "")
  126 + return;
  127 + let transfer = document.createElement('textarea');
  128 + document.body.appendChild(transfer);
  129 + transfer.value = obj.innerHTML;
  130 + // transfer.focus();
  131 + transfer.select();
  132 + if (document.execCommand('copy')) {
  133 + document.execCommand('copy');
  134 + }
  135 + transfer.blur();
  136 + document.body.removeChild(transfer);
  137 + $.modal.alertSuccess("复制成功");
  138 + }
113 139 </script>
114 140 </body>
115 141 </html>
116 142 \ No newline at end of file
... ...